Repository navigation
Re-apply #4939: updated models template mappers - #4950
Conversation
There was a problem hiding this comment.
Code Review
This pull request adds support for several new models, including Gemma 4 (standard and thinking variants) and LFM 2/2.5, by updating model mappings, template configurations, and version requirements. A review comment suggests including the 4-bit quantized version of the Gemma 4 31B model in the Ollama template mappers to maintain consistency with other model groups.
| "unsloth/gemma-4-E4B-it", | ||
| "unsloth/gemma-4-E4B", | ||
| "unsloth/gemma-4-E4B-it-unsloth-bnb-4bit", | ||
| "unsloth/gemma-4-31B-it", |
There was a problem hiding this comment.
For consistency, unsloth/gemma-4-31B-it-unsloth-bnb-4bit should probably be included here. It's part of the gemma-4-thinking group in model_mappings.py, and its float counterpart unsloth/gemma-4-31B-it is already present.
| "unsloth/gemma-4-31B-it", | |
| "unsloth/gemma-4-31B-it", | |
| "unsloth/gemma-4-31B-it-unsloth-bnb-4bit", |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 30c9e7fd5b
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| "gemma4": ( | ||
| "unsloth/gemma-4-E2B-it", | ||
| "unsloth/gemma-4-E2B", | ||
| "unsloth/gemma-4-E2B-it-unsloth-bnb-4bit", |
There was a problem hiding this comment.
Keep Gemma-4 base IDs mapped to Ollama template
Replacing the base Gemma-4 IDs with only *-it-unsloth-bnb-4bit variants drops template detection for models like unsloth/gemma-4-E2B, ...-E4B, ...-31B, and ...-26B-A4B. create_ollama_modelfile() does an exact lookup in MODEL_TO_OLLAMA_TEMPLATE_MAPPER and returns None when a model ID is missing, so GGUF/Ollama exports for those still-supported base IDs now skip Modelfile generation and lose the prompt template wiring.
Useful? React with 👍 / 👎.
…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.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 864dab5ac0
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| "lfm-2.5": ( | ||
| "unsloth/LFM2.5-1.2B-Instruct", | ||
| "LiquidAI/LFM2.5-1.2B-Instruct", |
There was a problem hiding this comment.
Map LFM2.5 models to a defined chat template
Adding unsloth/LFM2.5-1.2B-Instruct under the new "lfm-2.5" template key makes Studio resolve that model to lfm-2.5, but unsloth.chat_templates.get_chat_template() only has lfm-2 and raises on unknown keys. In the chat-formatting path this means the Unsloth template application always fails for LFM2.5 and silently falls back, which can produce incorrect/empty formatted text when the tokenizer itself has no chat template. Please map this model to an existing template key or add an lfm-2.5 template alias in unsloth/chat_templates.py.
Useful? React with 👍 / 👎.
…plate files 1. Add missing gemma-4-31B-it-unsloth-bnb-4bit to Ollama gemma4 tuple 2. Remove redundant gemma-4-31B-it self-map from __INT_TO_FLOAT_MAPPER (bnb-4bit entry already covers FLOAT_TO_INT and MAP_TO_UNSLOTH_16bit) 3. Add CHAT_TEMPLATES["lfm-2.5"] alias to chat_templates.py (template key was mapped but never registered, causing silent fallback) 4. Widen lfm2.5-vl-450m to lfm2.5-vl in transformers 5.3.0 allowlist (covers future VL variants without false-positiving on text models)
…ai#4950 1. Include <|channel>thought\n<channel|> in gemma-4-thinking response marker, consistent with qwen3-thinking and glm patterns. The thinking template always injects channel tokens for model turns; marking them as structural avoids wasting training loss on fixed tokens. 2. Remove stale "Phi-3" comment from lfm-2 DEFAULT_SYSTEM_MESSAGE.
…emplate 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
…hinking response prefix for PR unslothai#4950 - Fix gemma4 Ollama template to map assistant role to model (was outputting <|turn>assistant instead of <|turn>model) - Restore dropped base model IDs (E2B, E4B, 31B, 26B-A4B) in Ollama template mapper to prevent export regression - Update gemma-4-thinking response prefix to include <|channel>thought<channel|> header, consistent with qwen3-thinking pattern - Remove redundant gemma-4-31B-it self-referencing entry from INT_TO_FLOAT_MAPPER (already covered by bnb-4bit entry) - Fix stale Phi-3 comment on lfm-2 system message line
…meter for PR unslothai#4950 - Gemma-4 has no native system role token; the HF chat template folds system messages into the first user turn. Hardcode <|turn>user for both user and system messages, matching the gemma3n Ollama template pattern. - Add PARAMETER stop "<turn|>" so Ollama halts generation at turn boundaries.
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.
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.
|
Auto-review verdict: Changes requested Reason: no verdict parsed; defaulting based on commit history |
These test_*.py files were added at the repo root rather than under tests/. Removing them from this PR; the production mapper changes remain.
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.
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.
|
I believe this causes a bug. with: i see editing in unsloth/models/loader_utils.py fixed it. this was the commit before this code was introduced |
|
@jonahsamost you need to update your installed version of studio. we just made a release and you need to update to that release or else your older version will pull the updated mapper file from the repo but not have the other necessary changes. or |
This re-applies template mapping changes for gemma4, lfm2.5 and lfm2
also adds lfm2.5 to transformers 5.3.0 white list