cciwon-code-review-cli 2.0.1 → 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/bin/code-review.js +1 -1
- 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
package/bin/code-review.js
CHANGED
|
@@ -16,7 +16,7 @@ program
|
|
|
16
16
|
.version('1.0.0');
|
|
17
17
|
|
|
18
18
|
// 서버 URL 설정 (환경변수 또는 기본값)
|
|
19
|
-
const SERVER_URL = process.env.CODE_REVIEW_SERVER || 'http://
|
|
19
|
+
const SERVER_URL = process.env.CODE_REVIEW_SERVER || 'http://211.56.247.71:8000';
|
|
20
20
|
const client = new CodeReviewClient(SERVER_URL);
|
|
21
21
|
|
|
22
22
|
// ==========================================
|
package/lib/chat-mode.js
CHANGED
|
@@ -145,16 +145,21 @@ class ChatMode {
|
|
|
145
145
|
*/
|
|
146
146
|
async reviewFile(filePath) {
|
|
147
147
|
try {
|
|
148
|
+
console.log(chalk.bold(`\n=== ${filePath} ===\n`));
|
|
149
|
+
|
|
148
150
|
// 파일 내용 읽기
|
|
151
|
+
console.log(chalk.gray(`📖 파일 읽는 중...`));
|
|
149
152
|
const content = await this.fileReader.readFile(filePath);
|
|
153
|
+
console.log(chalk.gray(`✓ 파일 읽기 완료 (${content.length}자)`));
|
|
150
154
|
|
|
151
155
|
// 언어 감지
|
|
152
156
|
const language = this.detectLanguage(filePath);
|
|
153
|
-
|
|
154
|
-
console.log(chalk.bold(`\n=== ${filePath} ===\n`));
|
|
157
|
+
console.log(chalk.gray(`🔍 언어: ${language}`));
|
|
155
158
|
|
|
156
159
|
// 서버에 리뷰 요청
|
|
160
|
+
console.log(chalk.gray(`🚀 서버로 리뷰 요청 중...`));
|
|
157
161
|
const result = await this.client.reviewCode(content, language);
|
|
162
|
+
console.log(chalk.gray(`✓ 리뷰 완료\n`));
|
|
158
163
|
|
|
159
164
|
// 결과 출력
|
|
160
165
|
console.log(result.review);
|
package/package.json
CHANGED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,88 @@
|
|
|
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.aqlm 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.base_layer(x)
|
|
66
|
+
|
|
67
|
+
if self.disable_adapters:
|
|
68
|
+
return result
|
|
69
|
+
|
|
70
|
+
for active_adapter in self.active_adapters:
|
|
71
|
+
if active_adapter not in self.lora_A.keys():
|
|
72
|
+
continue
|
|
73
|
+
lora_A = self.lora_A[active_adapter]
|
|
74
|
+
lora_B = self.lora_B[active_adapter]
|
|
75
|
+
dropout = self.lora_dropout[active_adapter]
|
|
76
|
+
scaling = self.scaling[active_adapter]
|
|
77
|
+
|
|
78
|
+
requires_conversion = not torch.is_autocast_enabled()
|
|
79
|
+
if requires_conversion:
|
|
80
|
+
expected_dtype = result.dtype
|
|
81
|
+
x = self._cast_input_dtype(x, lora_A.weight.dtype)
|
|
82
|
+
|
|
83
|
+
output = lora_B(lora_A(dropout(x)))
|
|
84
|
+
if requires_conversion:
|
|
85
|
+
output = output.to(expected_dtype)
|
|
86
|
+
output = output * scaling
|
|
87
|
+
result += output
|
|
88
|
+
return result
|
|
@@ -0,0 +1,87 @@
|
|
|
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.awq 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
|
+
result = self.quant_linear_module(x)
|
|
65
|
+
|
|
66
|
+
if self.disable_adapters:
|
|
67
|
+
return result
|
|
68
|
+
|
|
69
|
+
for active_adapter in self.active_adapters:
|
|
70
|
+
if active_adapter not in self.lora_A.keys():
|
|
71
|
+
continue
|
|
72
|
+
lora_A = self.lora_A[active_adapter]
|
|
73
|
+
lora_B = self.lora_B[active_adapter]
|
|
74
|
+
dropout = self.lora_dropout[active_adapter]
|
|
75
|
+
scaling = self.scaling[active_adapter]
|
|
76
|
+
|
|
77
|
+
requires_conversion = not torch.is_autocast_enabled()
|
|
78
|
+
if requires_conversion:
|
|
79
|
+
expected_dtype = result.dtype
|
|
80
|
+
x = self._cast_input_dtype(x, lora_A.weight.dtype)
|
|
81
|
+
|
|
82
|
+
output = lora_B(lora_A(dropout(x)))
|
|
83
|
+
if requires_conversion:
|
|
84
|
+
output = output.to(expected_dtype)
|
|
85
|
+
output = output * scaling
|
|
86
|
+
result = result + output
|
|
87
|
+
return result
|
|
@@ -0,0 +1,117 @@
|
|
|
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, nn)
|
|
68
|
+
|
|
69
|
+
def forward(self, input: Tensor) -> Tensor:
|
|
70
|
+
self._check_input_dim(input)
|
|
71
|
+
|
|
72
|
+
# exponential_average_factor is set to self.momentum
|
|
73
|
+
# (when it is available) only so that it gets updated
|
|
74
|
+
# in ONNX graph when this node is exported to ONNX.
|
|
75
|
+
if self.momentum is None:
|
|
76
|
+
exponential_average_factor = 0.0
|
|
77
|
+
else:
|
|
78
|
+
exponential_average_factor = self.momentum
|
|
79
|
+
|
|
80
|
+
if self.training and self.track_running_stats:
|
|
81
|
+
# TODO: if statement only here to tell the jit to skip emitting this when it is None
|
|
82
|
+
if self.num_batches_tracked is not None: # type: ignore[has-type]
|
|
83
|
+
self.num_batches_tracked.add_(1) # type: ignore[has-type]
|
|
84
|
+
if self.momentum is None: # use cumulative moving average
|
|
85
|
+
exponential_average_factor = 1.0 / float(self.num_batches_tracked)
|
|
86
|
+
else: # use exponential moving average
|
|
87
|
+
exponential_average_factor = self.momentum
|
|
88
|
+
|
|
89
|
+
r"""
|
|
90
|
+
Decide whether the mini-batch stats should be used for normalization rather than the buffers.
|
|
91
|
+
Mini-batch stats are used in training mode, and in eval mode when buffers are None.
|
|
92
|
+
"""
|
|
93
|
+
if self.training:
|
|
94
|
+
bn_training = True
|
|
95
|
+
else:
|
|
96
|
+
bn_training = (self.running_mean is None) and (self.running_var is None)
|
|
97
|
+
|
|
98
|
+
r"""
|
|
99
|
+
Buffers are only updated if they are to be tracked and we are in training mode. Thus they only need to be
|
|
100
|
+
passed when the update should occur (i.e. in training mode when they are tracked), or when buffer stats are
|
|
101
|
+
used for normalization (i.e. in eval mode when buffers are not None).
|
|
102
|
+
"""
|
|
103
|
+
return F.batch_norm(
|
|
104
|
+
input,
|
|
105
|
+
# If buffers are not to be tracked, ensure that they won't be updated
|
|
106
|
+
(
|
|
107
|
+
self.running_mean
|
|
108
|
+
if not self.training or self.track_running_stats
|
|
109
|
+
else None
|
|
110
|
+
),
|
|
111
|
+
self.running_var if not self.training or self.track_running_stats else None,
|
|
112
|
+
self.weight,
|
|
113
|
+
self.bias,
|
|
114
|
+
bn_training,
|
|
115
|
+
exponential_average_factor,
|
|
116
|
+
self.eps,
|
|
117
|
+
).to(input.dtype).to(input.dtype)
|
|
@@ -0,0 +1,117 @@
|
|
|
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, nn)
|
|
68
|
+
|
|
69
|
+
def forward(self, input: Tensor) -> Tensor:
|
|
70
|
+
self._check_input_dim(input)
|
|
71
|
+
|
|
72
|
+
# exponential_average_factor is set to self.momentum
|
|
73
|
+
# (when it is available) only so that it gets updated
|
|
74
|
+
# in ONNX graph when this node is exported to ONNX.
|
|
75
|
+
if self.momentum is None:
|
|
76
|
+
exponential_average_factor = 0.0
|
|
77
|
+
else:
|
|
78
|
+
exponential_average_factor = self.momentum
|
|
79
|
+
|
|
80
|
+
if self.training and self.track_running_stats:
|
|
81
|
+
# TODO: if statement only here to tell the jit to skip emitting this when it is None
|
|
82
|
+
if self.num_batches_tracked is not None: # type: ignore[has-type]
|
|
83
|
+
self.num_batches_tracked.add_(1) # type: ignore[has-type]
|
|
84
|
+
if self.momentum is None: # use cumulative moving average
|
|
85
|
+
exponential_average_factor = 1.0 / float(self.num_batches_tracked)
|
|
86
|
+
else: # use exponential moving average
|
|
87
|
+
exponential_average_factor = self.momentum
|
|
88
|
+
|
|
89
|
+
r"""
|
|
90
|
+
Decide whether the mini-batch stats should be used for normalization rather than the buffers.
|
|
91
|
+
Mini-batch stats are used in training mode, and in eval mode when buffers are None.
|
|
92
|
+
"""
|
|
93
|
+
if self.training:
|
|
94
|
+
bn_training = True
|
|
95
|
+
else:
|
|
96
|
+
bn_training = (self.running_mean is None) and (self.running_var is None)
|
|
97
|
+
|
|
98
|
+
r"""
|
|
99
|
+
Buffers are only updated if they are to be tracked and we are in training mode. Thus they only need to be
|
|
100
|
+
passed when the update should occur (i.e. in training mode when they are tracked), or when buffer stats are
|
|
101
|
+
used for normalization (i.e. in eval mode when buffers are not None).
|
|
102
|
+
"""
|
|
103
|
+
return F.batch_norm(
|
|
104
|
+
input,
|
|
105
|
+
# If buffers are not to be tracked, ensure that they won't be updated
|
|
106
|
+
(
|
|
107
|
+
self.running_mean
|
|
108
|
+
if not self.training or self.track_running_stats
|
|
109
|
+
else None
|
|
110
|
+
),
|
|
111
|
+
self.running_var if not self.training or self.track_running_stats else None,
|
|
112
|
+
self.weight,
|
|
113
|
+
self.bias,
|
|
114
|
+
bn_training,
|
|
115
|
+
exponential_average_factor,
|
|
116
|
+
self.eps,
|
|
117
|
+
).to(input.dtype).to(input.dtype)
|
|
@@ -0,0 +1,117 @@
|
|
|
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, nn)
|
|
68
|
+
|
|
69
|
+
def forward(self, input: Tensor) -> Tensor:
|
|
70
|
+
self._check_input_dim(input)
|
|
71
|
+
|
|
72
|
+
# exponential_average_factor is set to self.momentum
|
|
73
|
+
# (when it is available) only so that it gets updated
|
|
74
|
+
# in ONNX graph when this node is exported to ONNX.
|
|
75
|
+
if self.momentum is None:
|
|
76
|
+
exponential_average_factor = 0.0
|
|
77
|
+
else:
|
|
78
|
+
exponential_average_factor = self.momentum
|
|
79
|
+
|
|
80
|
+
if self.training and self.track_running_stats:
|
|
81
|
+
# TODO: if statement only here to tell the jit to skip emitting this when it is None
|
|
82
|
+
if self.num_batches_tracked is not None: # type: ignore[has-type]
|
|
83
|
+
self.num_batches_tracked.add_(1) # type: ignore[has-type]
|
|
84
|
+
if self.momentum is None: # use cumulative moving average
|
|
85
|
+
exponential_average_factor = 1.0 / float(self.num_batches_tracked)
|
|
86
|
+
else: # use exponential moving average
|
|
87
|
+
exponential_average_factor = self.momentum
|
|
88
|
+
|
|
89
|
+
r"""
|
|
90
|
+
Decide whether the mini-batch stats should be used for normalization rather than the buffers.
|
|
91
|
+
Mini-batch stats are used in training mode, and in eval mode when buffers are None.
|
|
92
|
+
"""
|
|
93
|
+
if self.training:
|
|
94
|
+
bn_training = True
|
|
95
|
+
else:
|
|
96
|
+
bn_training = (self.running_mean is None) and (self.running_var is None)
|
|
97
|
+
|
|
98
|
+
r"""
|
|
99
|
+
Buffers are only updated if they are to be tracked and we are in training mode. Thus they only need to be
|
|
100
|
+
passed when the update should occur (i.e. in training mode when they are tracked), or when buffer stats are
|
|
101
|
+
used for normalization (i.e. in eval mode when buffers are not None).
|
|
102
|
+
"""
|
|
103
|
+
return F.batch_norm(
|
|
104
|
+
input,
|
|
105
|
+
# If buffers are not to be tracked, ensure that they won't be updated
|
|
106
|
+
(
|
|
107
|
+
self.running_mean
|
|
108
|
+
if not self.training or self.track_running_stats
|
|
109
|
+
else None
|
|
110
|
+
),
|
|
111
|
+
self.running_var if not self.training or self.track_running_stats else None,
|
|
112
|
+
self.weight,
|
|
113
|
+
self.bias,
|
|
114
|
+
bn_training,
|
|
115
|
+
exponential_average_factor,
|
|
116
|
+
self.eps,
|
|
117
|
+
).to(input.dtype).to(input.dtype)
|