mirror of
https://github.com/unslothai/unsloth
synced 2026-04-21 13:37:39 +00:00
* Reapply "updated models template mappers. added lfm2.5vl450m to transformers 5…" (#4945)
This reverts commit 33503ea248.
* Add missing gemma-4-31B-it bnb-4bit mapper entry and LFM2.5 upstream namespace for PR #4950
- Add unsloth/gemma-4-31B-it-unsloth-bnb-4bit to __INT_TO_FLOAT_MAPPER so
the int-to-float resolution works for this model (already listed in
TEMPLATE_TO_MODEL_MAPPER but had no mapper entry).
- Add LiquidAI/LFM2.5-1.2B-Instruct to lfm-2.5 TEMPLATE_TO_MODEL_MAPPER
entry so the canonical upstream namespace is mapped consistently with lfm-2.
* Add missing gemma-4-31B-it bnb-4bit Ollama mapping and lfm-2.5 chat template alias
- Add unsloth/gemma-4-31B-it-unsloth-bnb-4bit to OLLAMA_TEMPLATE_TO_MODEL_MAPPER
so Ollama export works for this model (E2B-it and E4B-it bnb-4bit variants were
already present, 31B-it was inconsistently omitted)
- Register CHAT_TEMPLATES["lfm-2.5"] as alias of the lfm-2 template to prevent
KeyError when Studio resolves LFM2.5 models through MODEL_TO_TEMPLATE_MAPPER
* Add missing LFM2 bnb-4bit INT_TO_FLOAT_MAPPER entry
unsloth/LFM2-1.2B-unsloth-bnb-4bit is referenced in model_mappings.py
but had no mapper.py entry, so model resolution would fail when users
load that variant with load_in_4bit=False or when the float name is
used with load_in_4bit=True.
* Fix review findings for PR #16
1. ollama_template_mappers.py: Restore dropped Gemma-4 base model IDs
(E2B, E4B, 31B, 26B-A4B) and add missing google/ upstream IDs to
the gemma4 Ollama mapper for consistency with other gemma entries.
2. mapper.py: Remove self-mapping non-bnb-4bit entries from
__INT_TO_FLOAT_MAPPER that were polluting FLOAT_TO_INT_MAPPER with
lowercase 16-bit names, causing load_in_4bit=True to return bad
model names. Add direct MAP_TO_UNSLOTH_16bit entries to preserve
the google->unsloth 16-bit redirects.
3. mapper.py: Add LFM2.5 MAP_TO_UNSLOTH_16bit redirect so
LiquidAI/LFM2.5-1.2B-Instruct resolves to its unsloth mirror.
* Add review tests for PR #4950
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* Remove top-level test files
These test_*.py files were added at the repo root rather than under tests/.
Removing them from this PR; the production mapper changes remain.
* Add gemma-4-26B-A4B-it mapping
Adds unsloth/gemma-4-26B-A4B-it to __INT_TO_FLOAT_MAPPER as a 2-tuple so
google/gemma-4-26B-A4B-it routes to unsloth/gemma-4-26B-A4B-it across
INT_TO_FLOAT_MAPPER, FLOAT_TO_INT_MAPPER, and MAP_TO_UNSLOTH_16bit.
The 26B-A4B (MoE) model has no bnb-4bit variant, so the key uses the
plain unsloth name rather than the -unsloth-bnb-4bit suffix.
Removes the now-redundant standalone _add_with_lower call for the -it
variant; the 16bit mapping is registered via the dict loop.
* Add unsloth-bnb-4bit mappings for gemma-4 base (non-it) models
Adds E2B, E4B, 31B base unsloth-bnb-4bit entries to __INT_TO_FLOAT_MAPPER.
The 26B-A4B (MoE) base has no bnb-4bit variant on HF, so it stays on the
standalone _add_with_lower line for the 16bit-only routing.
Removes the redundant _add_with_lower lines for E2B, E4B, 31B base since
the dict loop now registers the same google->unsloth route through the
2-tuple entries, plus full FLOAT_TO_INT and INT_TO_FLOAT coverage.
---------
Co-authored-by: Daniel Han <danielhanchen@gmail.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
This commit is contained in:
parent
7c5464ad71
commit
800ddc95f8
5 changed files with 82 additions and 0 deletions
|
|
@ -215,6 +215,21 @@ TEMPLATE_TO_MODEL_MAPPER = {
|
|||
"google/gemma-3n-E2B-it",
|
||||
"unsloth/gemma-3n-E2B-it-unsloth-bnb-4bit",
|
||||
),
|
||||
"gemma-4": (
|
||||
"unsloth/gemma-4-E2B-it",
|
||||
"google/gemma-4-E2B-it",
|
||||
"unsloth/gemma-4-E4B-it",
|
||||
"google/gemma-4-E4B-it",
|
||||
"unsloth/gemma-4-E2B-it-unsloth-bnb-4bit",
|
||||
"unsloth/gemma-4-E4B-it-unsloth-bnb-4bit",
|
||||
),
|
||||
"gemma-4-thinking": (
|
||||
"unsloth/gemma-4-26B-A4B-it",
|
||||
"google/gemma-4-26B-A4B-it",
|
||||
"unsloth/gemma-4-31B-it",
|
||||
"unsloth/gemma-4-31B-it-unsloth-bnb-4bit",
|
||||
"google/gemma-4-31B-it",
|
||||
),
|
||||
"qwen2.5": (
|
||||
"unsloth/Qwen2.5-0.5B-Instruct-unsloth-bnb-4bit",
|
||||
"unsloth/Qwen2.5-0.5B-Instruct",
|
||||
|
|
@ -399,6 +414,15 @@ TEMPLATE_TO_MODEL_MAPPER = {
|
|||
"THUDM/GLM-4.7-Flash",
|
||||
"unsloth/GLM-4.7-Flash-bnb-4bit",
|
||||
),
|
||||
"lfm-2": (
|
||||
"unsloth/LFM2-1.2B",
|
||||
"LiquidAI/LFM2-1.2B",
|
||||
"unsloth/LFM2-1.2B-unsloth-bnb-4bit",
|
||||
),
|
||||
"lfm-2.5": (
|
||||
"unsloth/LFM2.5-1.2B-Instruct",
|
||||
"LiquidAI/LFM2.5-1.2B-Instruct",
|
||||
),
|
||||
}
|
||||
|
||||
MODEL_TO_TEMPLATE_MAPPER = {}
|
||||
|
|
@ -414,6 +438,14 @@ for key, values in TEMPLATE_TO_MODEL_MAPPER.items():
|
|||
|
||||
|
||||
TEMPLATE_TO_RESPONSES_MAPPER = {
|
||||
"gemma-4-thinking": {
|
||||
"instruction": "<|turn>user\n",
|
||||
"response": "<|turn>model\n",
|
||||
},
|
||||
"gemma-4": {
|
||||
"instruction": "<|turn>user\n",
|
||||
"response": "<|turn>model\n",
|
||||
},
|
||||
"gemma-3": {
|
||||
"instruction": "<start_of_turn>user\n",
|
||||
"response": "<start_of_turn>model\n",
|
||||
|
|
@ -514,6 +546,10 @@ TEMPLATE_TO_RESPONSES_MAPPER = {
|
|||
"instruction": "<|im_start|>user\n",
|
||||
"response": "<|im_start|>assistant\n",
|
||||
},
|
||||
"lfm-2.5": {
|
||||
"instruction": "<|im_start|>user\n",
|
||||
"response": "<|im_start|>assistant\n",
|
||||
},
|
||||
"starling": {
|
||||
"instruction": "GPT4 Correct User: ",
|
||||
"response": "GPT4 Correct Assistant: ",
|
||||
|
|
|
|||
|
|
@ -52,6 +52,7 @@ TRANSFORMERS_5_MODEL_SUBSTRINGS: tuple[str, ...] = (
|
|||
"qwen3.5", # Qwen3.5 family (35B-A3B, etc.)
|
||||
"qwen3-next", # Qwen3-Next and variants
|
||||
"tiny_qwen3_moe", # imdatta0/tiny_qwen3_moe_2.8B_0.7B
|
||||
"lfm2.5-vl-450m", # LiquidAI/LFM2.5-VL-450M
|
||||
)
|
||||
|
||||
# Lowercase substrings for models that require transformers 5.5.0 (checked first).
|
||||
|
|
|
|||
|
|
@ -1716,6 +1716,8 @@ liquid_lfm2_template = \
|
|||
liquid_lfm2_template_eos_token = "<|im_end|>"
|
||||
CHAT_TEMPLATES["lfm-2"] = (liquid_lfm2_template, liquid_lfm2_template_eos_token, False, None)
|
||||
DEFAULT_SYSTEM_MESSAGE["lfm-2"] = None # No system message in Phi-3
|
||||
CHAT_TEMPLATES["lfm-2.5"] = (liquid_lfm2_template, liquid_lfm2_template_eos_token, False, None)
|
||||
DEFAULT_SYSTEM_MESSAGE["lfm-2.5"] = None
|
||||
|
||||
|
||||
# =========================================== Starling-LM
|
||||
|
|
|
|||
|
|
@ -22,6 +22,39 @@ __all__ = [
|
|||
|
||||
__INT_TO_FLOAT_MAPPER = \
|
||||
{
|
||||
"unsloth/gemma-4-E2B-it-unsloth-bnb-4bit" : (
|
||||
"unsloth/gemma-4-E2B-it",
|
||||
"google/gemma-4-E2B-it",
|
||||
),
|
||||
"unsloth/gemma-4-E4B-it-unsloth-bnb-4bit" : (
|
||||
"unsloth/gemma-4-E4B-it",
|
||||
"google/gemma-4-E4B-it",
|
||||
),
|
||||
"unsloth/gemma-4-31B-it-unsloth-bnb-4bit" : (
|
||||
"unsloth/gemma-4-31B-it",
|
||||
"google/gemma-4-31B-it",
|
||||
),
|
||||
"unsloth/gemma-4-26B-A4B-it" : (
|
||||
"unsloth/gemma-4-26B-A4B-it",
|
||||
"google/gemma-4-26B-A4B-it",
|
||||
),
|
||||
"unsloth/gemma-4-E2B-unsloth-bnb-4bit" : (
|
||||
"unsloth/gemma-4-E2B",
|
||||
"google/gemma-4-E2B",
|
||||
),
|
||||
"unsloth/gemma-4-E4B-unsloth-bnb-4bit" : (
|
||||
"unsloth/gemma-4-E4B",
|
||||
"google/gemma-4-E4B",
|
||||
),
|
||||
"unsloth/gemma-4-31B-unsloth-bnb-4bit" : (
|
||||
"unsloth/gemma-4-31B",
|
||||
"google/gemma-4-31B",
|
||||
),
|
||||
"unsloth/LFM2-1.2B-unsloth-bnb-4bit" : (
|
||||
"unsloth/LFM2-1.2B",
|
||||
"LiquidAI/LFM2-1.2B",
|
||||
),
|
||||
|
||||
"unsloth/mistral-7b-bnb-4bit" : (
|
||||
"unsloth/mistral-7b",
|
||||
"mistralai/Mistral-7B-v0.1",
|
||||
|
|
@ -1428,3 +1461,6 @@ for key, values in __INT_TO_FLOAT_MAPPER.items():
|
|||
|
||||
for value in values:
|
||||
FLOAT_TO_INT_MAPPER[value.lower()] = lowered_key
|
||||
|
||||
_add_with_lower(MAP_TO_UNSLOTH_16bit, "google/gemma-4-26B-A4B", "unsloth/gemma-4-26B-A4B")
|
||||
_add_with_lower(MAP_TO_UNSLOTH_16bit, "LiquidAI/LFM2.5-1.2B-Instruct", "unsloth/LFM2.5-1.2B-Instruct")
|
||||
|
|
|
|||
|
|
@ -1978,12 +1978,19 @@ OLLAMA_TEMPLATE_TO_MODEL_MAPPER = {
|
|||
),
|
||||
"gemma4": (
|
||||
"unsloth/gemma-4-E2B-it",
|
||||
"unsloth/gemma-4-E2B-it-unsloth-bnb-4bit",
|
||||
"google/gemma-4-E2B-it",
|
||||
"unsloth/gemma-4-E2B",
|
||||
"unsloth/gemma-4-E4B-it",
|
||||
"unsloth/gemma-4-E4B-it-unsloth-bnb-4bit",
|
||||
"google/gemma-4-E4B-it",
|
||||
"unsloth/gemma-4-E4B",
|
||||
"unsloth/gemma-4-31B-it",
|
||||
"unsloth/gemma-4-31B-it-unsloth-bnb-4bit",
|
||||
"google/gemma-4-31B-it",
|
||||
"unsloth/gemma-4-31B",
|
||||
"unsloth/gemma-4-26B-A4B-it",
|
||||
"google/gemma-4-26B-A4B-it",
|
||||
"unsloth/gemma-4-26B-A4B",
|
||||
),
|
||||
"gemma3n": (
|
||||
|
|
|
|||
Loading…
Reference in a new issue