Skip to content

Commit 60aae9a

Browse files
danielhanchenvoid-mckenzieKareemMuslehCuppaXanaxIsaacBreen
authored
Qwen 3, Bug Fixes (#2445)
* bug fix #2008 (#2039) * fix (#2051) * Update loader.py * Update pyproject.toml * Update pyproject.toml * Update vision.py * more prints * Update loader.py * LoRA 16bit fix * Update vision.py * Update vision.py * Update _utils.py * Update vision.py * move forced float32 * Update _utils.py * Update _utils.py * Update _utils.py * Update _utils.py * move print * Update _utils.py * disable bfloat16 * Fix forced float32 * move float32 * Ensure trust_remote_code propegates down to unsloth_compile_transformers (#2075) * Update _utils.py * Show both `peft_error` and `autoconfig_error`, not just `autoconfig_error` (#2080) When loading a PEFT model fails, only the `autoconfig_error` is shown. Instead of the `peft_error`, which is what really matters when we're trying to load a PEFT adapter, the user will see something like this: ``` RuntimeError: Unrecognized model in my_model. Should have a `model_type` key in its config.json, or contain one of the following strings in its name: albert, align, altclip, ... ``` This PR just changes it so `autoconfig_error` and `peft_error` are both displayed. * fix error message (#2046) * Update vision.py * Update _utils.py * Update pyproject.toml * Update __init__.py * Update __init__.py * Update vision.py * Update vision.py * Update vision.py * Update vision.py * Update vision.py * Update vision.py * Update vision.py * Update vision.py * Update vision.py * Update rl_replacements.py * Update rl_replacements.py * Update rl_replacements.py * Update rl_replacements.py * Update vision.py * Update vision.py * Update vision.py * Update vision.py * Update vision.py * Update rl_replacements.py * Update vision.py * Update rl_replacements.py * Update vision.py * Update vision.py * Update vision.py * Update vision.py * Update vision.py * Update vision.py * Remove double generate patch * Update vision.py * Update vision.py * Update vision.py * Update vision.py * Update vision.py * Update mapper.py * Update vision.py * fix: config.torch_dtype in LlamaModel_fast_forward_inference (#2091) * fix: config.torch_dtype in LlamaModel_fast_forward_inference * Update llama.py * update for consistency --------- Co-authored-by: Daniel Han <[email protected]> * versioning * Update vision.py * Update vision.py * Update vision.py * Update vision.py * Update vision.py * Update vision.py * Update vision.py * Update vision.py * Update vision.py * Update vision.py * model_type_arch * Update vision.py * Update vision.py * Update vision.py * Update vision.py * Update vision.py * Update vision.py * Update loader.py * check * Update _utils.py * Update loader.py * Update loader.py * Remove prints * Update README.md typo * Update _utils.py * Update _utils.py * versioning * Update _utils.py * Update _utils.py * Update _utils.py * Update llama.py * Update llama.py * Update llama.py * Update llama.py * Update llama.py * Update llama.py * Update llama.py * Update llama.py * Update llama.py * Update llama.py * Update llama.py * Update llama.py * Update llama.py * Update llama.py * Update llama.py * Update llama.py * Update llama.py * Update llama.py * Update llama.py * Update llama.py * Update llama.py * Update llama.py * Update llama.py * Update llama.py * Update llama.py * Update vision.py * HF Transfer * fix(utils): add missing importlib import to fix NameError (#2134) This commit fixes a NameError that occurs when `importlib` is referenced in _utils.py without being imported, especially when UNSLOTH_USE_MODELSCOPE=1 is enabled. By adding the missing import statement, the code will no longer throw a NameError. * Add QLoRA Train and Merge16bit Test (#2130) * add reference and unsloth lora merging tests * add test / dataset printing to test scripts * allow running tests from repo root * add qlora test readme * more readme edits * ruff formatting * additional readme comments * forgot to add actual tests * add apache license * Update pyproject.toml * Update vision.py * Update vision.py * Update vision.py * Update vision.py * Update loader.py * Update loader.py * Revert * Update vision.py * Update vision.py * Update vision.py * Update vision.py * Update vision.py * Bug fix * Update mapper.py * check SDPA for Mistral 3, Pixtral * Update vision.py * Versioning * Update rl_replacements.py * Update README.md * add model registry * move hf hub utils to unsloth/utils * refactor global model info dicts to dataclasses * fix dataclass init * fix llama registration * remove deprecated key function * start registry reog * add llama vision * quant types -> Enum * remap literal quant types to QuantType Enum * add llama model registration * fix quant tag mapping * add qwen2.5 models to registry * add option to include original model in registry * handle quant types per model size * separate registration of base and instruct llama3.2 * add QwenQVQ to registry * add gemma3 to registry * add phi * add deepseek v3 * add deepseek r1 base * add deepseek r1 zero * add deepseek distill llama * add deepseek distill models * remove redundant code when constructing model names * add mistral small to registry * rename model registration methods * rename deepseek registration methods * refactor naming for mistral and phi * add global register models * refactor model registration tests for new registry apis * add model search method * remove deprecated registration api * add quant type test * add registry readme * make llama registration more specific * clear registry when executing individual model registration file * more registry readme updates * Update _auto_install.py * Llama4 * Update synthetic.py * Update synthetic.py * Update synthetic.py * Update synthetic.py * Update synthetic.py * Update synthetic.py * Update synthetic.py * Update synthetic.py * Update synthetic.py * Update synthetic.py * Update synthetic.py * Synthetic data * Update mapper.py * Xet and Synthetic * Update synthetic.py * Update loader.py * Update synthetic.py * Update synthetic.py * Update synthetic.py * Update synthetic.py * Update synthetic.py * Update synthetic.py * Update synthetic.py * Update synthetic.py * Update synthetic.py * Update synthetic.py * Update synthetic.py * Update synthetic.py * Update synthetic.py * Update synthetic.py * Update synthetic.py * Update synthetic.py * Update synthetic.py * Update synthetic.py * Update synthetic.py * Update synthetic.py * Update synthetic.py * Update synthetic.py * Update synthetic.py * Update synthetic.py * Update synthetic.py * Update synthetic.py * Update synthetic.py * Update pyproject.toml * Delete .gitignore --------- Co-authored-by: Mukkesh Ganesh <[email protected]> Co-authored-by: Kareem <[email protected]> Co-authored-by: Xander Hawthorne <[email protected]> Co-authored-by: Isaac Breen <[email protected]> Co-authored-by: lurf21 <[email protected]> Co-authored-by: Jack Shi Wei Lun <[email protected]> Co-authored-by: naliazheli <[email protected]> Co-authored-by: jeromeku <[email protected]> Co-authored-by: Michael Han <[email protected]>
1 parent 9625c42 commit 60aae9a

File tree

19 files changed

+1470
-225
lines changed

19 files changed

+1470
-225
lines changed

tests/__init__.py

Whitespace-only changes.

tests/test_model_registry.py

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
"""
2+
3+
Test model registration methods
4+
Checks that model registration methods work for respective models as well as all models
5+
The check is performed
6+
- by registering the models
7+
- checking that the instantiated models can be found on huggingface hub by querying for the model id
8+
9+
"""
10+
11+
from dataclasses import dataclass
12+
13+
import pytest
14+
from huggingface_hub import ModelInfo as HfModelInfo
15+
16+
from unsloth.registry import register_models, search_models
17+
from unsloth.registry._deepseek import register_deepseek_models
18+
from unsloth.registry._gemma import register_gemma_models
19+
from unsloth.registry._llama import register_llama_models
20+
from unsloth.registry._mistral import register_mistral_models
21+
from unsloth.registry._phi import register_phi_models
22+
from unsloth.registry._qwen import register_qwen_models
23+
from unsloth.registry.registry import MODEL_REGISTRY, QUANT_TAG_MAP, QuantType
24+
from unsloth.utils.hf_hub import get_model_info
25+
26+
MODEL_NAMES = [
27+
"llama",
28+
"qwen",
29+
"mistral",
30+
"phi",
31+
"gemma",
32+
"deepseek",
33+
]
34+
MODEL_REGISTRATION_METHODS = [
35+
register_llama_models,
36+
register_qwen_models,
37+
register_mistral_models,
38+
register_phi_models,
39+
register_gemma_models,
40+
register_deepseek_models,
41+
]
42+
43+
44+
@dataclass
45+
class ModelTestParam:
46+
name: str
47+
register_models: callable
48+
49+
50+
def _test_model_uploaded(model_ids: list[str]):
51+
missing_models = []
52+
for _id in model_ids:
53+
model_info: HfModelInfo = get_model_info(_id)
54+
if not model_info:
55+
missing_models.append(_id)
56+
57+
return missing_models
58+
59+
60+
TestParams = [
61+
ModelTestParam(name, models)
62+
for name, models in zip(MODEL_NAMES, MODEL_REGISTRATION_METHODS)
63+
]
64+
65+
66+
# Test that model registration methods register respective models
67+
@pytest.mark.parametrize("model_test_param", TestParams, ids=lambda param: param.name)
68+
def test_model_registration(model_test_param: ModelTestParam):
69+
MODEL_REGISTRY.clear()
70+
registration_method = model_test_param.register_models
71+
registration_method()
72+
registered_models = MODEL_REGISTRY.keys()
73+
missing_models = _test_model_uploaded(registered_models)
74+
assert not missing_models, (
75+
f"{model_test_param.name} missing following models: {missing_models}"
76+
)
77+
78+
79+
def test_all_model_registration():
80+
register_models()
81+
registered_models = MODEL_REGISTRY.keys()
82+
missing_models = _test_model_uploaded(registered_models)
83+
assert not missing_models, f"Missing following models: {missing_models}"
84+
85+
def test_quant_type():
86+
# Test that the quant_type is correctly set for model paths
87+
# NOTE: for models registered under org="unsloth" with QuantType.NONE aliases QuantType.UNSLOTH
88+
dynamic_quant_models = search_models(quant_types=[QuantType.UNSLOTH])
89+
assert all(m.quant_type == QuantType.UNSLOTH for m in dynamic_quant_models)
90+
quant_tag = QUANT_TAG_MAP[QuantType.UNSLOTH]
91+
assert all(quant_tag in m.model_path for m in dynamic_quant_models)

unsloth/_auto_install.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
v = V(torch.__version__)
1919
cuda = str(torch.version.cuda)
2020
is_ampere = torch.cuda.get_device_capability()[0] >= 8
21-
if cuda != "12.1" and cuda != "11.8" and cuda != "12.4" and cuda != "12.6": raise RuntimeError(f"CUDA = {cuda} not supported!")
21+
if cuda != "12.1" and cuda != "11.8" and cuda != "12.4" and cuda != "12.6" and cuda != "12.8": raise RuntimeError(f"CUDA = {cuda} not supported!")
2222
if v <= V('2.1.0'): raise RuntimeError(f"Torch = {v} too old!")
2323
elif v <= V('2.1.1'): x = 'cu{}{}-torch211'
2424
elif v <= V('2.1.2'): x = 'cu{}{}-torch212'
@@ -28,6 +28,7 @@
2828
elif v < V('2.5.1'): x = 'cu{}{}-torch250'
2929
elif v <= V('2.5.1'): x = 'cu{}{}-torch251'
3030
elif v < V('2.7.0'): x = 'cu{}{}-torch260'
31+
elif v < V('2.8.0'): x = 'cu{}{}-torch270'
3132
else: raise RuntimeError(f"Torch = {v} too new!")
3233
x = x.format(cuda.replace(".", ""), "-ampere" if is_ampere else "")
3334
print(f'pip install --upgrade pip && pip install "unsloth[{x}] @ git+https://github.com/unslothai/unsloth.git"')

0 commit comments

Comments
 (0)