cciwon-code-review-cli 2.0.2 → 2.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/chat-mode.js +7 -2
- package/package.json +1 -1
- package/unsloth_compiled_cache/.locks/.lock.AqlmLoraLinear_peft_forward.py +0 -0
- package/unsloth_compiled_cache/.locks/.lock.AwqLoraLinear_peft_forward.py +0 -0
- package/unsloth_compiled_cache/.locks/.lock.BatchNorm1d.py +0 -0
- package/unsloth_compiled_cache/.locks/.lock.BatchNorm2d.py +0 -0
- package/unsloth_compiled_cache/.locks/.lock.BatchNorm3d.py +0 -0
- package/unsloth_compiled_cache/.locks/.lock.Conv1d.py +0 -0
- package/unsloth_compiled_cache/.locks/.lock.Conv2d.py +0 -0
- package/unsloth_compiled_cache/.locks/.lock.Conv3d.py +0 -0
- package/unsloth_compiled_cache/.locks/.lock.ConvTranspose1d.py +0 -0
- package/unsloth_compiled_cache/.locks/.lock.ConvTranspose2d.py +0 -0
- package/unsloth_compiled_cache/.locks/.lock.ConvTranspose3d.py +0 -0
- package/unsloth_compiled_cache/.locks/.lock.GPTQLoraLinear_peft_forward.py +0 -0
- package/unsloth_compiled_cache/.locks/.lock.GroupNorm.py +0 -0
- package/unsloth_compiled_cache/.locks/.lock.LayerNorm.py +0 -0
- package/unsloth_compiled_cache/.locks/.lock.Linear4bit_peft_forward.py +0 -0
- package/unsloth_compiled_cache/.locks/.lock.Linear8bitLt_peft_forward.py +0 -0
- package/unsloth_compiled_cache/.locks/.lock.Linear_peft_forward.py +0 -0
- package/unsloth_compiled_cache/.locks/.lock.LoraParallelLinear_peft_forward.py +0 -0
- package/unsloth_compiled_cache/.locks/.lock.RMSNorm.py +0 -0
- package/unsloth_compiled_cache/.locks/.lock.UnslothBCOTrainer.py +0 -0
- package/unsloth_compiled_cache/.locks/.lock.UnslothCPOTrainer.py +0 -0
- package/unsloth_compiled_cache/.locks/.lock.UnslothDPOTrainer.py +0 -0
- package/unsloth_compiled_cache/.locks/.lock.UnslothGKDTrainer.py +0 -0
- package/unsloth_compiled_cache/.locks/.lock.UnslothGRPOTrainer.py +0 -0
- package/unsloth_compiled_cache/.locks/.lock.UnslothKTOTrainer.py +0 -0
- package/unsloth_compiled_cache/.locks/.lock.UnslothNashMDTrainer.py +0 -0
- package/unsloth_compiled_cache/.locks/.lock.UnslothORPOTrainer.py +0 -0
- package/unsloth_compiled_cache/.locks/.lock.UnslothOnlineDPOTrainer.py +0 -0
- package/unsloth_compiled_cache/.locks/.lock.UnslothPPOTrainer.py +0 -0
- package/unsloth_compiled_cache/.locks/.lock.UnslothPRMTrainer.py +0 -0
- package/unsloth_compiled_cache/.locks/.lock.UnslothRLOOTrainer.py +0 -0
- package/unsloth_compiled_cache/.locks/.lock.UnslothRewardTrainer.py +0 -0
- package/unsloth_compiled_cache/.locks/.lock.UnslothSFTTrainer.py +0 -0
- package/unsloth_compiled_cache/.locks/.lock.UnslothXPOTrainer.py +0 -0
- package/unsloth_compiled_cache/.locks/.lock.unsloth_compiled_module_qwen3_moe.py +0 -0
- package/unsloth_compiled_cache/.locks/.lock.unsloth_compiled_module_siglip.py +0 -0
- package/unsloth_compiled_cache/AqlmLoraLinear_peft_forward.py +88 -0
- package/unsloth_compiled_cache/AwqLoraLinear_peft_forward.py +87 -0
- package/unsloth_compiled_cache/BatchNorm1d.py +117 -0
- package/unsloth_compiled_cache/BatchNorm2d.py +117 -0
- package/unsloth_compiled_cache/BatchNorm3d.py +117 -0
- package/unsloth_compiled_cache/Conv1d.py +70 -0
- package/unsloth_compiled_cache/Conv2d.py +70 -0
- package/unsloth_compiled_cache/Conv3d.py +70 -0
- package/unsloth_compiled_cache/ConvTranspose1d.py +97 -0
- package/unsloth_compiled_cache/ConvTranspose2d.py +106 -0
- package/unsloth_compiled_cache/ConvTranspose3d.py +98 -0
- package/unsloth_compiled_cache/GPTQLoraLinear_peft_forward.py +95 -0
- package/unsloth_compiled_cache/GroupNorm.py +70 -0
- package/unsloth_compiled_cache/LayerNorm.py +72 -0
- package/unsloth_compiled_cache/Linear4bit_peft_forward.py +115 -0
- package/unsloth_compiled_cache/Linear8bitLt_peft_forward.py +113 -0
- package/unsloth_compiled_cache/Linear_peft_forward.py +104 -0
- package/unsloth_compiled_cache/LoraParallelLinear_peft_forward.py +91 -0
- package/unsloth_compiled_cache/RMSNorm.py +73 -0
- package/unsloth_compiled_cache/UnslothBCOTrainer.py +2026 -0
- package/unsloth_compiled_cache/UnslothCPOTrainer.py +1806 -0
- package/unsloth_compiled_cache/UnslothDPOTrainer.py +2750 -0
- package/unsloth_compiled_cache/UnslothGKDTrainer.py +1157 -0
- package/unsloth_compiled_cache/UnslothGRPOTrainer.py +3607 -0
- package/unsloth_compiled_cache/UnslothKTOTrainer.py +2220 -0
- package/unsloth_compiled_cache/UnslothNashMDTrainer.py +1210 -0
- package/unsloth_compiled_cache/UnslothORPOTrainer.py +1730 -0
- package/unsloth_compiled_cache/UnslothOnlineDPOTrainer.py +2313 -0
- package/unsloth_compiled_cache/UnslothPPOTrainer.py +1504 -0
- package/unsloth_compiled_cache/UnslothPRMTrainer.py +979 -0
- package/unsloth_compiled_cache/UnslothRLOOTrainer.py +2674 -0
- package/unsloth_compiled_cache/UnslothRewardTrainer.py +1197 -0
- package/unsloth_compiled_cache/UnslothSFTTrainer.py +1416 -0
- package/unsloth_compiled_cache/UnslothXPOTrainer.py +1255 -0
- package/unsloth_compiled_cache/__pycache__/AqlmLoraLinear_peft_forward.cpython-312.pyc +0 -0
- package/unsloth_compiled_cache/__pycache__/AwqLoraLinear_peft_forward.cpython-312.pyc +0 -0
- package/unsloth_compiled_cache/__pycache__/BatchNorm1d.cpython-312.pyc +0 -0
- package/unsloth_compiled_cache/__pycache__/BatchNorm2d.cpython-312.pyc +0 -0
- package/unsloth_compiled_cache/__pycache__/BatchNorm3d.cpython-312.pyc +0 -0
- package/unsloth_compiled_cache/__pycache__/Conv1d.cpython-312.pyc +0 -0
- package/unsloth_compiled_cache/__pycache__/Conv2d.cpython-312.pyc +0 -0
- package/unsloth_compiled_cache/__pycache__/Conv3d.cpython-312.pyc +0 -0
- package/unsloth_compiled_cache/__pycache__/ConvTranspose1d.cpython-312.pyc +0 -0
- package/unsloth_compiled_cache/__pycache__/ConvTranspose2d.cpython-312.pyc +0 -0
- package/unsloth_compiled_cache/__pycache__/ConvTranspose3d.cpython-312.pyc +0 -0
- package/unsloth_compiled_cache/__pycache__/GPTQLoraLinear_peft_forward.cpython-312.pyc +0 -0
- package/unsloth_compiled_cache/__pycache__/GroupNorm.cpython-312.pyc +0 -0
- package/unsloth_compiled_cache/__pycache__/LayerNorm.cpython-312.pyc +0 -0
- package/unsloth_compiled_cache/__pycache__/Linear4bit_peft_forward.cpython-312.pyc +0 -0
- package/unsloth_compiled_cache/__pycache__/Linear8bitLt_peft_forward.cpython-312.pyc +0 -0
- package/unsloth_compiled_cache/__pycache__/Linear_peft_forward.cpython-312.pyc +0 -0
- package/unsloth_compiled_cache/__pycache__/LoraParallelLinear_peft_forward.cpython-312.pyc +0 -0
- package/unsloth_compiled_cache/__pycache__/RMSNorm.cpython-312.pyc +0 -0
- package/unsloth_compiled_cache/__pycache__/UnslothBCOTrainer.cpython-312.pyc +0 -0
- package/unsloth_compiled_cache/__pycache__/UnslothCPOTrainer.cpython-312.pyc +0 -0
- package/unsloth_compiled_cache/__pycache__/UnslothDPOTrainer.cpython-312.pyc +0 -0
- package/unsloth_compiled_cache/__pycache__/UnslothGKDTrainer.cpython-312.pyc +0 -0
- package/unsloth_compiled_cache/__pycache__/UnslothGRPOTrainer.cpython-312.pyc +0 -0
- package/unsloth_compiled_cache/__pycache__/UnslothKTOTrainer.cpython-312.pyc +0 -0
- package/unsloth_compiled_cache/__pycache__/UnslothNashMDTrainer.cpython-312.pyc +0 -0
- package/unsloth_compiled_cache/__pycache__/UnslothORPOTrainer.cpython-312.pyc +0 -0
- package/unsloth_compiled_cache/__pycache__/UnslothOnlineDPOTrainer.cpython-312.pyc +0 -0
- package/unsloth_compiled_cache/__pycache__/UnslothPPOTrainer.cpython-312.pyc +0 -0
- package/unsloth_compiled_cache/__pycache__/UnslothPRMTrainer.cpython-312.pyc +0 -0
- package/unsloth_compiled_cache/__pycache__/UnslothRLOOTrainer.cpython-312.pyc +0 -0
- package/unsloth_compiled_cache/__pycache__/UnslothRewardTrainer.cpython-312.pyc +0 -0
- package/unsloth_compiled_cache/__pycache__/UnslothSFTTrainer.cpython-312.pyc +0 -0
- package/unsloth_compiled_cache/__pycache__/UnslothXPOTrainer.cpython-312.pyc +0 -0
- package/unsloth_compiled_cache/__pycache__/unsloth_compiled_module_qwen3_moe.cpython-312.pyc +0 -0
- package/unsloth_compiled_cache/__pycache__/unsloth_compiled_module_siglip.cpython-312.pyc +0 -0
- package/unsloth_compiled_cache/unsloth_compiled_module_qwen3_moe.py +726 -0
- package/unsloth_compiled_cache/unsloth_compiled_module_siglip.py +534 -0
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
"""
|
|
2
|
+
2025.12.6
|
|
3
|
+
2025.12.7
|
|
4
|
+
4.57.1
|
|
5
|
+
0.24.0
|
|
6
|
+
__UNSLOTH_VERSIONING__
|
|
7
|
+
"""
|
|
8
|
+
|
|
9
|
+
# Unsloth auto generated code
|
|
10
|
+
# Copyright 2023-present Daniel Han-Chen, Michael Han-Chen & the Unsloth team. All rights reserved.
|
|
11
|
+
#
|
|
12
|
+
# This program is free software: you can redistribute it and/or modify
|
|
13
|
+
# it under the terms of the GNU Lesser General Public License as published by
|
|
14
|
+
# the Free Software Foundation, either version 3 of the License, or
|
|
15
|
+
# (at your option) any later version.
|
|
16
|
+
#
|
|
17
|
+
# This program is distributed in the hope that it will be useful,
|
|
18
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
19
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
20
|
+
# GNU General Public License for more details.
|
|
21
|
+
#
|
|
22
|
+
# You should have received a copy of the GNU Lesser General Public License
|
|
23
|
+
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
import os
|
|
27
|
+
import torch
|
|
28
|
+
import importlib.util
|
|
29
|
+
import math
|
|
30
|
+
if importlib.util.find_spec("unsloth_studio") is None:
|
|
31
|
+
UNSLOTH_STUDIO_ENABLED = False
|
|
32
|
+
else:
|
|
33
|
+
UNSLOTH_STUDIO_ENABLED = os.environ.get("UNSLOTH_STUDIO_DISABLED", "0") == "0"
|
|
34
|
+
pass
|
|
35
|
+
from typing import Any, List, Optional, Tuple, Union, Dict, Set, Callable
|
|
36
|
+
import math
|
|
37
|
+
|
|
38
|
+
UNSLOTH_ENABLE_LOGGING = os.environ.get("UNSLOTH_ENABLE_LOGGING", "0") == "1"
|
|
39
|
+
UNSLOTH_ENABLE_CCE = os.environ.get("UNSLOTH_ENABLE_CCE", "1") == "1"
|
|
40
|
+
UNSLOTH_COMPILE_DISABLE = os.environ.get("UNSLOTH_COMPILE_DISABLE", "0") in ("1", "partial",)
|
|
41
|
+
|
|
42
|
+
import logging
|
|
43
|
+
logger_compiler = logging.getLogger(__name__)
|
|
44
|
+
if UNSLOTH_ENABLE_LOGGING:
|
|
45
|
+
logger_compiler.setLevel(logging.DEBUG)
|
|
46
|
+
|
|
47
|
+
global INFERENCE_RUNS
|
|
48
|
+
INFERENCE_RUNS = 0
|
|
49
|
+
|
|
50
|
+
try:
|
|
51
|
+
import torch._dynamo.eval_frame as torch_dynamo_eval_frame
|
|
52
|
+
torch_dynamo_eval_frame._stance.stance
|
|
53
|
+
torch_compiler_set_stance = torch.compiler.set_stance
|
|
54
|
+
except:
|
|
55
|
+
torch_dynamo_eval_frame = None
|
|
56
|
+
torch_compiler_set_stance = None
|
|
57
|
+
pass
|
|
58
|
+
|
|
59
|
+
from unsloth_zoo import DEVICE_TYPE_TORCH, DEVICE_COUNT
|
|
60
|
+
|
|
61
|
+
torch_compile_options = {'epilogue_fusion': True, 'max_autotune': False, 'shape_padding': True, 'trace.enabled': False, 'triton.cudagraphs': False, 'debug': False, 'dce': True, 'memory_planning': True, 'coordinate_descent_tuning': False, 'trace.graph_diagram': False, 'compile_threads': 32, 'group_fusion': True, 'disable_progress': True, 'verbose_progress': False, 'triton.multi_kernel': 0, 'triton.use_block_ptr': False, 'triton.enable_persistent_tma_matmul': True, 'triton.autotune_at_compile_time': False, 'triton.cooperative_reductions': False, 'cuda.compile_opt_level': '-O2', 'cuda.enable_cuda_lto': True, 'combo_kernels': False, 'benchmark_combo_kernel': True, 'combo_kernel_foreach_dynamic_shapes': True}
|
|
62
|
+
from torch import Tensor
|
|
63
|
+
import torch
|
|
64
|
+
import torch.nn as nn
|
|
65
|
+
from torch.nn import functional as F
|
|
66
|
+
from typing import Any, List, Optional, Tuple, Union, Dict, Set, Callable
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
def forward(self, input: Tensor) -> Tensor:
|
|
70
|
+
return self._conv_forward(input, self.weight, self.bias).to(input.dtype).to(input.dtype)
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
"""
|
|
2
|
+
2025.12.6
|
|
3
|
+
2025.12.7
|
|
4
|
+
4.57.1
|
|
5
|
+
0.24.0
|
|
6
|
+
__UNSLOTH_VERSIONING__
|
|
7
|
+
"""
|
|
8
|
+
|
|
9
|
+
# Unsloth auto generated code
|
|
10
|
+
# Copyright 2023-present Daniel Han-Chen, Michael Han-Chen & the Unsloth team. All rights reserved.
|
|
11
|
+
#
|
|
12
|
+
# This program is free software: you can redistribute it and/or modify
|
|
13
|
+
# it under the terms of the GNU Lesser General Public License as published by
|
|
14
|
+
# the Free Software Foundation, either version 3 of the License, or
|
|
15
|
+
# (at your option) any later version.
|
|
16
|
+
#
|
|
17
|
+
# This program is distributed in the hope that it will be useful,
|
|
18
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
19
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
20
|
+
# GNU General Public License for more details.
|
|
21
|
+
#
|
|
22
|
+
# You should have received a copy of the GNU Lesser General Public License
|
|
23
|
+
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
import os
|
|
27
|
+
import torch
|
|
28
|
+
import importlib.util
|
|
29
|
+
import math
|
|
30
|
+
if importlib.util.find_spec("unsloth_studio") is None:
|
|
31
|
+
UNSLOTH_STUDIO_ENABLED = False
|
|
32
|
+
else:
|
|
33
|
+
UNSLOTH_STUDIO_ENABLED = os.environ.get("UNSLOTH_STUDIO_DISABLED", "0") == "0"
|
|
34
|
+
pass
|
|
35
|
+
from typing import Any, List, Optional, Tuple, Union, Dict, Set, Callable
|
|
36
|
+
import math
|
|
37
|
+
|
|
38
|
+
UNSLOTH_ENABLE_LOGGING = os.environ.get("UNSLOTH_ENABLE_LOGGING", "0") == "1"
|
|
39
|
+
UNSLOTH_ENABLE_CCE = os.environ.get("UNSLOTH_ENABLE_CCE", "1") == "1"
|
|
40
|
+
UNSLOTH_COMPILE_DISABLE = os.environ.get("UNSLOTH_COMPILE_DISABLE", "0") in ("1", "partial",)
|
|
41
|
+
|
|
42
|
+
import logging
|
|
43
|
+
logger_compiler = logging.getLogger(__name__)
|
|
44
|
+
if UNSLOTH_ENABLE_LOGGING:
|
|
45
|
+
logger_compiler.setLevel(logging.DEBUG)
|
|
46
|
+
|
|
47
|
+
global INFERENCE_RUNS
|
|
48
|
+
INFERENCE_RUNS = 0
|
|
49
|
+
|
|
50
|
+
try:
|
|
51
|
+
import torch._dynamo.eval_frame as torch_dynamo_eval_frame
|
|
52
|
+
torch_dynamo_eval_frame._stance.stance
|
|
53
|
+
torch_compiler_set_stance = torch.compiler.set_stance
|
|
54
|
+
except:
|
|
55
|
+
torch_dynamo_eval_frame = None
|
|
56
|
+
torch_compiler_set_stance = None
|
|
57
|
+
pass
|
|
58
|
+
|
|
59
|
+
from unsloth_zoo import DEVICE_TYPE_TORCH, DEVICE_COUNT
|
|
60
|
+
|
|
61
|
+
torch_compile_options = {'epilogue_fusion': True, 'max_autotune': False, 'shape_padding': True, 'trace.enabled': False, 'triton.cudagraphs': False, 'debug': False, 'dce': True, 'memory_planning': True, 'coordinate_descent_tuning': False, 'trace.graph_diagram': False, 'compile_threads': 32, 'group_fusion': True, 'disable_progress': True, 'verbose_progress': False, 'triton.multi_kernel': 0, 'triton.use_block_ptr': False, 'triton.enable_persistent_tma_matmul': True, 'triton.autotune_at_compile_time': False, 'triton.cooperative_reductions': False, 'cuda.compile_opt_level': '-O2', 'cuda.enable_cuda_lto': True, 'combo_kernels': False, 'benchmark_combo_kernel': True, 'combo_kernel_foreach_dynamic_shapes': True}
|
|
62
|
+
from torch import Tensor
|
|
63
|
+
import torch
|
|
64
|
+
import torch.nn as nn
|
|
65
|
+
from torch.nn import functional as F
|
|
66
|
+
from typing import Any, List, Optional, Tuple, Union, Dict, Set, Callable
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
def forward(self, input: Tensor) -> Tensor:
|
|
70
|
+
return self._conv_forward(input, self.weight, self.bias).to(input.dtype).to(input.dtype)
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
"""
|
|
2
|
+
2025.12.6
|
|
3
|
+
2025.12.7
|
|
4
|
+
4.57.1
|
|
5
|
+
0.24.0
|
|
6
|
+
__UNSLOTH_VERSIONING__
|
|
7
|
+
"""
|
|
8
|
+
|
|
9
|
+
# Unsloth auto generated code
|
|
10
|
+
# Copyright 2023-present Daniel Han-Chen, Michael Han-Chen & the Unsloth team. All rights reserved.
|
|
11
|
+
#
|
|
12
|
+
# This program is free software: you can redistribute it and/or modify
|
|
13
|
+
# it under the terms of the GNU Lesser General Public License as published by
|
|
14
|
+
# the Free Software Foundation, either version 3 of the License, or
|
|
15
|
+
# (at your option) any later version.
|
|
16
|
+
#
|
|
17
|
+
# This program is distributed in the hope that it will be useful,
|
|
18
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
19
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
20
|
+
# GNU General Public License for more details.
|
|
21
|
+
#
|
|
22
|
+
# You should have received a copy of the GNU Lesser General Public License
|
|
23
|
+
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
import os
|
|
27
|
+
import torch
|
|
28
|
+
import importlib.util
|
|
29
|
+
import math
|
|
30
|
+
if importlib.util.find_spec("unsloth_studio") is None:
|
|
31
|
+
UNSLOTH_STUDIO_ENABLED = False
|
|
32
|
+
else:
|
|
33
|
+
UNSLOTH_STUDIO_ENABLED = os.environ.get("UNSLOTH_STUDIO_DISABLED", "0") == "0"
|
|
34
|
+
pass
|
|
35
|
+
from typing import Any, List, Optional, Tuple, Union, Dict, Set, Callable
|
|
36
|
+
import math
|
|
37
|
+
|
|
38
|
+
UNSLOTH_ENABLE_LOGGING = os.environ.get("UNSLOTH_ENABLE_LOGGING", "0") == "1"
|
|
39
|
+
UNSLOTH_ENABLE_CCE = os.environ.get("UNSLOTH_ENABLE_CCE", "1") == "1"
|
|
40
|
+
UNSLOTH_COMPILE_DISABLE = os.environ.get("UNSLOTH_COMPILE_DISABLE", "0") in ("1", "partial",)
|
|
41
|
+
|
|
42
|
+
import logging
|
|
43
|
+
logger_compiler = logging.getLogger(__name__)
|
|
44
|
+
if UNSLOTH_ENABLE_LOGGING:
|
|
45
|
+
logger_compiler.setLevel(logging.DEBUG)
|
|
46
|
+
|
|
47
|
+
global INFERENCE_RUNS
|
|
48
|
+
INFERENCE_RUNS = 0
|
|
49
|
+
|
|
50
|
+
try:
|
|
51
|
+
import torch._dynamo.eval_frame as torch_dynamo_eval_frame
|
|
52
|
+
torch_dynamo_eval_frame._stance.stance
|
|
53
|
+
torch_compiler_set_stance = torch.compiler.set_stance
|
|
54
|
+
except:
|
|
55
|
+
torch_dynamo_eval_frame = None
|
|
56
|
+
torch_compiler_set_stance = None
|
|
57
|
+
pass
|
|
58
|
+
|
|
59
|
+
from unsloth_zoo import DEVICE_TYPE_TORCH, DEVICE_COUNT
|
|
60
|
+
|
|
61
|
+
torch_compile_options = {'epilogue_fusion': True, 'max_autotune': False, 'shape_padding': True, 'trace.enabled': False, 'triton.cudagraphs': False, 'debug': False, 'dce': True, 'memory_planning': True, 'coordinate_descent_tuning': False, 'trace.graph_diagram': False, 'compile_threads': 32, 'group_fusion': True, 'disable_progress': True, 'verbose_progress': False, 'triton.multi_kernel': 0, 'triton.use_block_ptr': False, 'triton.enable_persistent_tma_matmul': True, 'triton.autotune_at_compile_time': False, 'triton.cooperative_reductions': False, 'cuda.compile_opt_level': '-O2', 'cuda.enable_cuda_lto': True, 'combo_kernels': False, 'benchmark_combo_kernel': True, 'combo_kernel_foreach_dynamic_shapes': True}
|
|
62
|
+
from torch import Tensor
|
|
63
|
+
import torch
|
|
64
|
+
import torch.nn as nn
|
|
65
|
+
from torch.nn import functional as F
|
|
66
|
+
from typing import Any, List, Optional, Tuple, Union, Dict, Set, Callable
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
def forward(self, input: Tensor) -> Tensor:
|
|
70
|
+
return self._conv_forward(input, self.weight, self.bias).to(input.dtype).to(input.dtype)
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
"""
|
|
2
|
+
2025.12.6
|
|
3
|
+
2025.12.7
|
|
4
|
+
4.57.1
|
|
5
|
+
0.24.0
|
|
6
|
+
__UNSLOTH_VERSIONING__
|
|
7
|
+
"""
|
|
8
|
+
|
|
9
|
+
# Unsloth auto generated code
|
|
10
|
+
# Copyright 2023-present Daniel Han-Chen, Michael Han-Chen & the Unsloth team. All rights reserved.
|
|
11
|
+
#
|
|
12
|
+
# This program is free software: you can redistribute it and/or modify
|
|
13
|
+
# it under the terms of the GNU Lesser General Public License as published by
|
|
14
|
+
# the Free Software Foundation, either version 3 of the License, or
|
|
15
|
+
# (at your option) any later version.
|
|
16
|
+
#
|
|
17
|
+
# This program is distributed in the hope that it will be useful,
|
|
18
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
19
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
20
|
+
# GNU General Public License for more details.
|
|
21
|
+
#
|
|
22
|
+
# You should have received a copy of the GNU Lesser General Public License
|
|
23
|
+
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
import os
|
|
27
|
+
import torch
|
|
28
|
+
import importlib.util
|
|
29
|
+
import math
|
|
30
|
+
if importlib.util.find_spec("unsloth_studio") is None:
|
|
31
|
+
UNSLOTH_STUDIO_ENABLED = False
|
|
32
|
+
else:
|
|
33
|
+
UNSLOTH_STUDIO_ENABLED = os.environ.get("UNSLOTH_STUDIO_DISABLED", "0") == "0"
|
|
34
|
+
pass
|
|
35
|
+
from typing import Any, List, Optional, Tuple, Union, Dict, Set, Callable
|
|
36
|
+
import math
|
|
37
|
+
|
|
38
|
+
UNSLOTH_ENABLE_LOGGING = os.environ.get("UNSLOTH_ENABLE_LOGGING", "0") == "1"
|
|
39
|
+
UNSLOTH_ENABLE_CCE = os.environ.get("UNSLOTH_ENABLE_CCE", "1") == "1"
|
|
40
|
+
UNSLOTH_COMPILE_DISABLE = os.environ.get("UNSLOTH_COMPILE_DISABLE", "0") in ("1", "partial",)
|
|
41
|
+
|
|
42
|
+
import logging
|
|
43
|
+
logger_compiler = logging.getLogger(__name__)
|
|
44
|
+
if UNSLOTH_ENABLE_LOGGING:
|
|
45
|
+
logger_compiler.setLevel(logging.DEBUG)
|
|
46
|
+
|
|
47
|
+
global INFERENCE_RUNS
|
|
48
|
+
INFERENCE_RUNS = 0
|
|
49
|
+
|
|
50
|
+
try:
|
|
51
|
+
import torch._dynamo.eval_frame as torch_dynamo_eval_frame
|
|
52
|
+
torch_dynamo_eval_frame._stance.stance
|
|
53
|
+
torch_compiler_set_stance = torch.compiler.set_stance
|
|
54
|
+
except:
|
|
55
|
+
torch_dynamo_eval_frame = None
|
|
56
|
+
torch_compiler_set_stance = None
|
|
57
|
+
pass
|
|
58
|
+
|
|
59
|
+
from unsloth_zoo import DEVICE_TYPE_TORCH, DEVICE_COUNT
|
|
60
|
+
|
|
61
|
+
torch_compile_options = {'epilogue_fusion': True, 'max_autotune': False, 'shape_padding': True, 'trace.enabled': False, 'triton.cudagraphs': False, 'debug': False, 'dce': True, 'memory_planning': True, 'coordinate_descent_tuning': False, 'trace.graph_diagram': False, 'compile_threads': 32, 'group_fusion': True, 'disable_progress': True, 'verbose_progress': False, 'triton.multi_kernel': 0, 'triton.use_block_ptr': False, 'triton.enable_persistent_tma_matmul': True, 'triton.autotune_at_compile_time': False, 'triton.cooperative_reductions': False, 'cuda.compile_opt_level': '-O2', 'cuda.enable_cuda_lto': True, 'combo_kernels': False, 'benchmark_combo_kernel': True, 'combo_kernel_foreach_dynamic_shapes': True}
|
|
62
|
+
from torch import Tensor
|
|
63
|
+
import torch
|
|
64
|
+
import torch.nn as nn
|
|
65
|
+
from torch.nn import functional as F
|
|
66
|
+
from typing import Any, List, Optional, Tuple, Union, Dict, Set, Callable
|
|
67
|
+
from transformers.models.qwen3_moe.modeling_qwen3_moe import (F, Optional, nn)
|
|
68
|
+
|
|
69
|
+
def forward(self, input: Tensor, output_size: Optional[list[int]] = None) -> Tensor:
|
|
70
|
+
if self.padding_mode != "zeros":
|
|
71
|
+
raise ValueError(
|
|
72
|
+
"Only `zeros` padding mode is supported for ConvTranspose1d"
|
|
73
|
+
)
|
|
74
|
+
|
|
75
|
+
assert isinstance(self.padding, tuple)
|
|
76
|
+
# One cannot replace List by Tuple or Sequence in "_output_padding" because
|
|
77
|
+
# TorchScript does not support `Sequence[T]` or `Tuple[T, ...]`.
|
|
78
|
+
num_spatial_dims = 1
|
|
79
|
+
output_padding = self._output_padding(
|
|
80
|
+
input,
|
|
81
|
+
output_size,
|
|
82
|
+
self.stride, # type: ignore[arg-type]
|
|
83
|
+
self.padding, # type: ignore[arg-type]
|
|
84
|
+
self.kernel_size, # type: ignore[arg-type]
|
|
85
|
+
num_spatial_dims,
|
|
86
|
+
self.dilation, # type: ignore[arg-type]
|
|
87
|
+
)
|
|
88
|
+
return F.conv_transpose1d(
|
|
89
|
+
input,
|
|
90
|
+
self.weight,
|
|
91
|
+
self.bias,
|
|
92
|
+
self.stride,
|
|
93
|
+
self.padding,
|
|
94
|
+
output_padding,
|
|
95
|
+
self.groups,
|
|
96
|
+
self.dilation,
|
|
97
|
+
).to(input.dtype).to(input.dtype)
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
"""
|
|
2
|
+
2025.12.6
|
|
3
|
+
2025.12.7
|
|
4
|
+
4.57.1
|
|
5
|
+
0.24.0
|
|
6
|
+
__UNSLOTH_VERSIONING__
|
|
7
|
+
"""
|
|
8
|
+
|
|
9
|
+
# Unsloth auto generated code
|
|
10
|
+
# Copyright 2023-present Daniel Han-Chen, Michael Han-Chen & the Unsloth team. All rights reserved.
|
|
11
|
+
#
|
|
12
|
+
# This program is free software: you can redistribute it and/or modify
|
|
13
|
+
# it under the terms of the GNU Lesser General Public License as published by
|
|
14
|
+
# the Free Software Foundation, either version 3 of the License, or
|
|
15
|
+
# (at your option) any later version.
|
|
16
|
+
#
|
|
17
|
+
# This program is distributed in the hope that it will be useful,
|
|
18
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
19
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
20
|
+
# GNU General Public License for more details.
|
|
21
|
+
#
|
|
22
|
+
# You should have received a copy of the GNU Lesser General Public License
|
|
23
|
+
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
import os
|
|
27
|
+
import torch
|
|
28
|
+
import importlib.util
|
|
29
|
+
import math
|
|
30
|
+
if importlib.util.find_spec("unsloth_studio") is None:
|
|
31
|
+
UNSLOTH_STUDIO_ENABLED = False
|
|
32
|
+
else:
|
|
33
|
+
UNSLOTH_STUDIO_ENABLED = os.environ.get("UNSLOTH_STUDIO_DISABLED", "0") == "0"
|
|
34
|
+
pass
|
|
35
|
+
from typing import Any, List, Optional, Tuple, Union, Dict, Set, Callable
|
|
36
|
+
import math
|
|
37
|
+
|
|
38
|
+
UNSLOTH_ENABLE_LOGGING = os.environ.get("UNSLOTH_ENABLE_LOGGING", "0") == "1"
|
|
39
|
+
UNSLOTH_ENABLE_CCE = os.environ.get("UNSLOTH_ENABLE_CCE", "1") == "1"
|
|
40
|
+
UNSLOTH_COMPILE_DISABLE = os.environ.get("UNSLOTH_COMPILE_DISABLE", "0") in ("1", "partial",)
|
|
41
|
+
|
|
42
|
+
import logging
|
|
43
|
+
logger_compiler = logging.getLogger(__name__)
|
|
44
|
+
if UNSLOTH_ENABLE_LOGGING:
|
|
45
|
+
logger_compiler.setLevel(logging.DEBUG)
|
|
46
|
+
|
|
47
|
+
global INFERENCE_RUNS
|
|
48
|
+
INFERENCE_RUNS = 0
|
|
49
|
+
|
|
50
|
+
try:
|
|
51
|
+
import torch._dynamo.eval_frame as torch_dynamo_eval_frame
|
|
52
|
+
torch_dynamo_eval_frame._stance.stance
|
|
53
|
+
torch_compiler_set_stance = torch.compiler.set_stance
|
|
54
|
+
except:
|
|
55
|
+
torch_dynamo_eval_frame = None
|
|
56
|
+
torch_compiler_set_stance = None
|
|
57
|
+
pass
|
|
58
|
+
|
|
59
|
+
from unsloth_zoo import DEVICE_TYPE_TORCH, DEVICE_COUNT
|
|
60
|
+
|
|
61
|
+
torch_compile_options = {'epilogue_fusion': True, 'max_autotune': False, 'shape_padding': True, 'trace.enabled': False, 'triton.cudagraphs': False, 'debug': False, 'dce': True, 'memory_planning': True, 'coordinate_descent_tuning': False, 'trace.graph_diagram': False, 'compile_threads': 32, 'group_fusion': True, 'disable_progress': True, 'verbose_progress': False, 'triton.multi_kernel': 0, 'triton.use_block_ptr': False, 'triton.enable_persistent_tma_matmul': True, 'triton.autotune_at_compile_time': False, 'triton.cooperative_reductions': False, 'cuda.compile_opt_level': '-O2', 'cuda.enable_cuda_lto': True, 'combo_kernels': False, 'benchmark_combo_kernel': True, 'combo_kernel_foreach_dynamic_shapes': True}
|
|
62
|
+
from torch import Tensor
|
|
63
|
+
import torch
|
|
64
|
+
import torch.nn as nn
|
|
65
|
+
from torch.nn import functional as F
|
|
66
|
+
from typing import Any, List, Optional, Tuple, Union, Dict, Set, Callable
|
|
67
|
+
from transformers.models.qwen3_moe.modeling_qwen3_moe import (F, Optional, nn)
|
|
68
|
+
|
|
69
|
+
def forward(self, input: Tensor, output_size: Optional[list[int]] = None) -> Tensor:
|
|
70
|
+
"""
|
|
71
|
+
Performs the forward pass.
|
|
72
|
+
|
|
73
|
+
Attributes:
|
|
74
|
+
input (Tensor): The input tensor.
|
|
75
|
+
output_size (list[int], optional): A list of integers representing
|
|
76
|
+
the size of the output tensor. Default is None.
|
|
77
|
+
"""
|
|
78
|
+
if self.padding_mode != "zeros":
|
|
79
|
+
raise ValueError(
|
|
80
|
+
"Only `zeros` padding mode is supported for ConvTranspose2d"
|
|
81
|
+
)
|
|
82
|
+
|
|
83
|
+
assert isinstance(self.padding, tuple)
|
|
84
|
+
# One cannot replace List by Tuple or Sequence in "_output_padding" because
|
|
85
|
+
# TorchScript does not support `Sequence[T]` or `Tuple[T, ...]`.
|
|
86
|
+
num_spatial_dims = 2
|
|
87
|
+
output_padding = self._output_padding(
|
|
88
|
+
input,
|
|
89
|
+
output_size,
|
|
90
|
+
self.stride, # type: ignore[arg-type]
|
|
91
|
+
self.padding, # type: ignore[arg-type]
|
|
92
|
+
self.kernel_size, # type: ignore[arg-type]
|
|
93
|
+
num_spatial_dims,
|
|
94
|
+
self.dilation, # type: ignore[arg-type]
|
|
95
|
+
)
|
|
96
|
+
|
|
97
|
+
return F.conv_transpose2d(
|
|
98
|
+
input,
|
|
99
|
+
self.weight,
|
|
100
|
+
self.bias,
|
|
101
|
+
self.stride,
|
|
102
|
+
self.padding,
|
|
103
|
+
output_padding,
|
|
104
|
+
self.groups,
|
|
105
|
+
self.dilation,
|
|
106
|
+
).to(input.dtype).to(input.dtype)
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
"""
|
|
2
|
+
2025.12.6
|
|
3
|
+
2025.12.7
|
|
4
|
+
4.57.1
|
|
5
|
+
0.24.0
|
|
6
|
+
__UNSLOTH_VERSIONING__
|
|
7
|
+
"""
|
|
8
|
+
|
|
9
|
+
# Unsloth auto generated code
|
|
10
|
+
# Copyright 2023-present Daniel Han-Chen, Michael Han-Chen & the Unsloth team. All rights reserved.
|
|
11
|
+
#
|
|
12
|
+
# This program is free software: you can redistribute it and/or modify
|
|
13
|
+
# it under the terms of the GNU Lesser General Public License as published by
|
|
14
|
+
# the Free Software Foundation, either version 3 of the License, or
|
|
15
|
+
# (at your option) any later version.
|
|
16
|
+
#
|
|
17
|
+
# This program is distributed in the hope that it will be useful,
|
|
18
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
19
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
20
|
+
# GNU General Public License for more details.
|
|
21
|
+
#
|
|
22
|
+
# You should have received a copy of the GNU Lesser General Public License
|
|
23
|
+
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
import os
|
|
27
|
+
import torch
|
|
28
|
+
import importlib.util
|
|
29
|
+
import math
|
|
30
|
+
if importlib.util.find_spec("unsloth_studio") is None:
|
|
31
|
+
UNSLOTH_STUDIO_ENABLED = False
|
|
32
|
+
else:
|
|
33
|
+
UNSLOTH_STUDIO_ENABLED = os.environ.get("UNSLOTH_STUDIO_DISABLED", "0") == "0"
|
|
34
|
+
pass
|
|
35
|
+
from typing import Any, List, Optional, Tuple, Union, Dict, Set, Callable
|
|
36
|
+
import math
|
|
37
|
+
|
|
38
|
+
UNSLOTH_ENABLE_LOGGING = os.environ.get("UNSLOTH_ENABLE_LOGGING", "0") == "1"
|
|
39
|
+
UNSLOTH_ENABLE_CCE = os.environ.get("UNSLOTH_ENABLE_CCE", "1") == "1"
|
|
40
|
+
UNSLOTH_COMPILE_DISABLE = os.environ.get("UNSLOTH_COMPILE_DISABLE", "0") in ("1", "partial",)
|
|
41
|
+
|
|
42
|
+
import logging
|
|
43
|
+
logger_compiler = logging.getLogger(__name__)
|
|
44
|
+
if UNSLOTH_ENABLE_LOGGING:
|
|
45
|
+
logger_compiler.setLevel(logging.DEBUG)
|
|
46
|
+
|
|
47
|
+
global INFERENCE_RUNS
|
|
48
|
+
INFERENCE_RUNS = 0
|
|
49
|
+
|
|
50
|
+
try:
|
|
51
|
+
import torch._dynamo.eval_frame as torch_dynamo_eval_frame
|
|
52
|
+
torch_dynamo_eval_frame._stance.stance
|
|
53
|
+
torch_compiler_set_stance = torch.compiler.set_stance
|
|
54
|
+
except:
|
|
55
|
+
torch_dynamo_eval_frame = None
|
|
56
|
+
torch_compiler_set_stance = None
|
|
57
|
+
pass
|
|
58
|
+
|
|
59
|
+
from unsloth_zoo import DEVICE_TYPE_TORCH, DEVICE_COUNT
|
|
60
|
+
|
|
61
|
+
torch_compile_options = {'epilogue_fusion': True, 'max_autotune': False, 'shape_padding': True, 'trace.enabled': False, 'triton.cudagraphs': False, 'debug': False, 'dce': True, 'memory_planning': True, 'coordinate_descent_tuning': False, 'trace.graph_diagram': False, 'compile_threads': 32, 'group_fusion': True, 'disable_progress': True, 'verbose_progress': False, 'triton.multi_kernel': 0, 'triton.use_block_ptr': False, 'triton.enable_persistent_tma_matmul': True, 'triton.autotune_at_compile_time': False, 'triton.cooperative_reductions': False, 'cuda.compile_opt_level': '-O2', 'cuda.enable_cuda_lto': True, 'combo_kernels': False, 'benchmark_combo_kernel': True, 'combo_kernel_foreach_dynamic_shapes': True}
|
|
62
|
+
from torch import Tensor
|
|
63
|
+
import torch
|
|
64
|
+
import torch.nn as nn
|
|
65
|
+
from torch.nn import functional as F
|
|
66
|
+
from typing import Any, List, Optional, Tuple, Union, Dict, Set, Callable
|
|
67
|
+
from transformers.models.qwen3_moe.modeling_qwen3_moe import (F, Optional, nn)
|
|
68
|
+
|
|
69
|
+
def forward(self, input: Tensor, output_size: Optional[list[int]] = None) -> Tensor:
|
|
70
|
+
if self.padding_mode != "zeros":
|
|
71
|
+
raise ValueError(
|
|
72
|
+
"Only `zeros` padding mode is supported for ConvTranspose3d"
|
|
73
|
+
)
|
|
74
|
+
|
|
75
|
+
assert isinstance(self.padding, tuple)
|
|
76
|
+
# One cannot replace List by Tuple or Sequence in "_output_padding" because
|
|
77
|
+
# TorchScript does not support `Sequence[T]` or `Tuple[T, ...]`.
|
|
78
|
+
num_spatial_dims = 3
|
|
79
|
+
output_padding = self._output_padding(
|
|
80
|
+
input,
|
|
81
|
+
output_size,
|
|
82
|
+
self.stride, # type: ignore[arg-type]
|
|
83
|
+
self.padding, # type: ignore[arg-type]
|
|
84
|
+
self.kernel_size, # type: ignore[arg-type]
|
|
85
|
+
num_spatial_dims,
|
|
86
|
+
self.dilation, # type: ignore[arg-type]
|
|
87
|
+
)
|
|
88
|
+
|
|
89
|
+
return F.conv_transpose3d(
|
|
90
|
+
input,
|
|
91
|
+
self.weight,
|
|
92
|
+
self.bias,
|
|
93
|
+
self.stride,
|
|
94
|
+
self.padding,
|
|
95
|
+
output_padding,
|
|
96
|
+
self.groups,
|
|
97
|
+
self.dilation,
|
|
98
|
+
).to(input.dtype).to(input.dtype)
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
"""
|
|
2
|
+
2025.12.6
|
|
3
|
+
2025.12.7
|
|
4
|
+
4.57.1
|
|
5
|
+
0.24.0
|
|
6
|
+
__UNSLOTH_VERSIONING__
|
|
7
|
+
"""
|
|
8
|
+
|
|
9
|
+
# Unsloth auto generated code
|
|
10
|
+
# Copyright 2023-present Daniel Han-Chen, Michael Han-Chen & the Unsloth team. All rights reserved.
|
|
11
|
+
#
|
|
12
|
+
# This program is free software: you can redistribute it and/or modify
|
|
13
|
+
# it under the terms of the GNU Lesser General Public License as published by
|
|
14
|
+
# the Free Software Foundation, either version 3 of the License, or
|
|
15
|
+
# (at your option) any later version.
|
|
16
|
+
#
|
|
17
|
+
# This program is distributed in the hope that it will be useful,
|
|
18
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
19
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
20
|
+
# GNU General Public License for more details.
|
|
21
|
+
#
|
|
22
|
+
# You should have received a copy of the GNU Lesser General Public License
|
|
23
|
+
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
torch_compile_options = {'epilogue_fusion': True, 'max_autotune': False, 'shape_padding': True, 'trace.enabled': False, 'triton.cudagraphs': False, 'debug': False, 'dce': True, 'memory_planning': True, 'coordinate_descent_tuning': False, 'trace.graph_diagram': False, 'compile_threads': 32, 'group_fusion': True, 'disable_progress': True, 'verbose_progress': False, 'triton.multi_kernel': 0, 'triton.use_block_ptr': False, 'triton.enable_persistent_tma_matmul': True, 'triton.autotune_at_compile_time': False, 'triton.cooperative_reductions': False, 'cuda.compile_opt_level': '-O2', 'cuda.enable_cuda_lto': True, 'combo_kernels': False, 'benchmark_combo_kernel': True, 'combo_kernel_foreach_dynamic_shapes': True}
|
|
27
|
+
from torch import Tensor
|
|
28
|
+
import torch
|
|
29
|
+
import torch.nn as nn
|
|
30
|
+
from torch.nn import functional as F
|
|
31
|
+
from typing import Any, List, Optional, Tuple, Union, Dict, Set, Callable
|
|
32
|
+
from peft.tuners.lora.gptq import (torch)
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
torch_addmm = torch.addmm
|
|
36
|
+
torch_add = torch.add
|
|
37
|
+
# @torch.compile(fullgraph = False, dynamic = True, options = torch_compile_options)
|
|
38
|
+
def lora_forward(result, lora_A, lora_B, dropout, x, scaling):
|
|
39
|
+
# Use result.dtype (bfloat16 from base layer) since x may have been cast to float32
|
|
40
|
+
# by _cast_input_dtype when autocast is disabled
|
|
41
|
+
target_dtype = result.dtype
|
|
42
|
+
xA = dropout(x).to(target_dtype) @ lora_A.weight.to(target_dtype).t()
|
|
43
|
+
# output = result + scaling * xA @ lora_B.weight.t()
|
|
44
|
+
shape = result.shape
|
|
45
|
+
output = torch_addmm(
|
|
46
|
+
result.view(-1, shape[-1]),
|
|
47
|
+
xA.view(-1, xA.shape[-1]),
|
|
48
|
+
lora_B.weight.to(target_dtype).t(),
|
|
49
|
+
alpha = scaling,
|
|
50
|
+
beta = 1,
|
|
51
|
+
).view(shape)
|
|
52
|
+
|
|
53
|
+
bias = lora_B.bias
|
|
54
|
+
if bias is not None:
|
|
55
|
+
output = torch_add(
|
|
56
|
+
output,
|
|
57
|
+
bias.to(target_dtype),
|
|
58
|
+
alpha = scaling,
|
|
59
|
+
)
|
|
60
|
+
return output
|
|
61
|
+
pass
|
|
62
|
+
|
|
63
|
+
def unsloth_forward(self, x: torch.Tensor):
|
|
64
|
+
# note: logic differs from default Linear because merging is not supported
|
|
65
|
+
result = self.quant_linear_module(x)
|
|
66
|
+
|
|
67
|
+
if self.disable_adapters:
|
|
68
|
+
return result
|
|
69
|
+
|
|
70
|
+
lora_A_keys = self.lora_A.keys()
|
|
71
|
+
|
|
72
|
+
for active_adapter in self.active_adapters:
|
|
73
|
+
if active_adapter not in lora_A_keys:
|
|
74
|
+
continue
|
|
75
|
+
torch_result_dtype = result.dtype
|
|
76
|
+
|
|
77
|
+
lora_A = self.lora_A[active_adapter]
|
|
78
|
+
lora_B = self.lora_B[active_adapter]
|
|
79
|
+
dropout = self.lora_dropout[active_adapter]
|
|
80
|
+
scaling = self.scaling[active_adapter]
|
|
81
|
+
|
|
82
|
+
if not torch.is_autocast_enabled(): result, x = result.to(lora_A.weight.dtype), x.to(lora_A.weight.dtype)
|
|
83
|
+
|
|
84
|
+
if active_adapter not in self.lora_variant: # vanilla LoRA
|
|
85
|
+
return lora_forward(result, lora_A, lora_B, dropout, x, scaling)
|
|
86
|
+
else:
|
|
87
|
+
result = self.lora_variant[active_adapter].forward(
|
|
88
|
+
self,
|
|
89
|
+
active_adapter=active_adapter,
|
|
90
|
+
x=x,
|
|
91
|
+
result=result,
|
|
92
|
+
)
|
|
93
|
+
|
|
94
|
+
result = result.to(torch_result_dtype)
|
|
95
|
+
return result
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
"""
|
|
2
|
+
2025.12.6
|
|
3
|
+
2025.12.7
|
|
4
|
+
4.57.1
|
|
5
|
+
0.24.0
|
|
6
|
+
__UNSLOTH_VERSIONING__
|
|
7
|
+
"""
|
|
8
|
+
|
|
9
|
+
# Unsloth auto generated code
|
|
10
|
+
# Copyright 2023-present Daniel Han-Chen, Michael Han-Chen & the Unsloth team. All rights reserved.
|
|
11
|
+
#
|
|
12
|
+
# This program is free software: you can redistribute it and/or modify
|
|
13
|
+
# it under the terms of the GNU Lesser General Public License as published by
|
|
14
|
+
# the Free Software Foundation, either version 3 of the License, or
|
|
15
|
+
# (at your option) any later version.
|
|
16
|
+
#
|
|
17
|
+
# This program is distributed in the hope that it will be useful,
|
|
18
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
19
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
20
|
+
# GNU General Public License for more details.
|
|
21
|
+
#
|
|
22
|
+
# You should have received a copy of the GNU Lesser General Public License
|
|
23
|
+
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
import os
|
|
27
|
+
import torch
|
|
28
|
+
import importlib.util
|
|
29
|
+
import math
|
|
30
|
+
if importlib.util.find_spec("unsloth_studio") is None:
|
|
31
|
+
UNSLOTH_STUDIO_ENABLED = False
|
|
32
|
+
else:
|
|
33
|
+
UNSLOTH_STUDIO_ENABLED = os.environ.get("UNSLOTH_STUDIO_DISABLED", "0") == "0"
|
|
34
|
+
pass
|
|
35
|
+
from typing import Any, List, Optional, Tuple, Union, Dict, Set, Callable
|
|
36
|
+
import math
|
|
37
|
+
|
|
38
|
+
UNSLOTH_ENABLE_LOGGING = os.environ.get("UNSLOTH_ENABLE_LOGGING", "0") == "1"
|
|
39
|
+
UNSLOTH_ENABLE_CCE = os.environ.get("UNSLOTH_ENABLE_CCE", "1") == "1"
|
|
40
|
+
UNSLOTH_COMPILE_DISABLE = os.environ.get("UNSLOTH_COMPILE_DISABLE", "0") in ("1", "partial",)
|
|
41
|
+
|
|
42
|
+
import logging
|
|
43
|
+
logger_compiler = logging.getLogger(__name__)
|
|
44
|
+
if UNSLOTH_ENABLE_LOGGING:
|
|
45
|
+
logger_compiler.setLevel(logging.DEBUG)
|
|
46
|
+
|
|
47
|
+
global INFERENCE_RUNS
|
|
48
|
+
INFERENCE_RUNS = 0
|
|
49
|
+
|
|
50
|
+
try:
|
|
51
|
+
import torch._dynamo.eval_frame as torch_dynamo_eval_frame
|
|
52
|
+
torch_dynamo_eval_frame._stance.stance
|
|
53
|
+
torch_compiler_set_stance = torch.compiler.set_stance
|
|
54
|
+
except:
|
|
55
|
+
torch_dynamo_eval_frame = None
|
|
56
|
+
torch_compiler_set_stance = None
|
|
57
|
+
pass
|
|
58
|
+
|
|
59
|
+
from unsloth_zoo import DEVICE_TYPE_TORCH, DEVICE_COUNT
|
|
60
|
+
|
|
61
|
+
torch_compile_options = {'epilogue_fusion': True, 'max_autotune': False, 'shape_padding': True, 'trace.enabled': False, 'triton.cudagraphs': False, 'debug': False, 'dce': True, 'memory_planning': True, 'coordinate_descent_tuning': False, 'trace.graph_diagram': False, 'compile_threads': 32, 'group_fusion': True, 'disable_progress': True, 'verbose_progress': False, 'triton.multi_kernel': 0, 'triton.use_block_ptr': False, 'triton.enable_persistent_tma_matmul': True, 'triton.autotune_at_compile_time': False, 'triton.cooperative_reductions': False, 'cuda.compile_opt_level': '-O2', 'cuda.enable_cuda_lto': True, 'combo_kernels': False, 'benchmark_combo_kernel': True, 'combo_kernel_foreach_dynamic_shapes': True}
|
|
62
|
+
from torch import Tensor
|
|
63
|
+
import torch
|
|
64
|
+
import torch.nn as nn
|
|
65
|
+
from torch.nn import functional as F
|
|
66
|
+
from typing import Any, List, Optional, Tuple, Union, Dict, Set, Callable
|
|
67
|
+
from transformers.models.qwen3_moe.modeling_qwen3_moe import (F)
|
|
68
|
+
|
|
69
|
+
def forward(self, input: Tensor) -> Tensor:
|
|
70
|
+
return F.group_norm(input, self.num_groups, self.weight, self.bias, self.eps).to(input.dtype).to(input.dtype)
|