unsloth/unsloth
Daniel Han ff23ce40b4
Fix review findings for chat-template repair (#5049) (#5056)
* Fix review findings for PR #49

1. Sandbox fallback Jinja env in _VariantTokenizerProxy.apply_chat_template
   (use SandboxedEnvironment, matching _derive_assistant_prefix_by_render)
2. Unwrap benign outer-If guards in _template_ends_with_toplevel_for so
   templates like {% if messages %}{% for ... %}{% endfor %}{% endif %}
   are still repairable (preserves Qwen3-Guard rejection via else-branch
   and add_generation_prompt-name checks)
3. Preserve raw name_or_path in _VariantTokenizerProxy._source_path so
   local-path detection works for dict/list variant tokenizers
4. Context-aware strict-mode messages: omit "will still load" and
   "Set UNSLOTH_STRICT_CHAT_TEMPLATE=1" when already raising

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2026-04-16 08:02:05 -07:00
..
dataprep Fix raw text paragraph break normalization (#4884) 2026-04-09 04:45:43 -07:00
kernels Add AMD ROCm/HIP support across installer and hardware detection (#4720) 2026-04-10 01:56:12 -07:00
models Restrict flash attn to <=256 head dim. Consolidate attn impl checks (#5051) 2026-04-16 09:00:17 -05:00
optimizers feat: Implement Q-GaLore optimizer and custom embedding learning rate… (#4511) 2026-03-25 01:03:10 -07:00
registry Revert "[pre-commit.ci] auto fixes from pre-commit.com hooks" 2025-12-01 07:24:58 -08:00
utils Add check to disable xformers on newer GPUs (#4342) 2026-03-16 22:42:38 -07:00
__init__.py Only run ldconfig CUDA-linking recovery when we have permission (#4930) 2026-04-09 00:07:25 -07:00
_auto_install.py Add PyTorch 2.10 and xformers 0.0.34 support (#3985) 2026-02-05 05:56:26 -08:00
chat_templates.py Re-apply #4939: updated models template mappers (#4950) 2026-04-15 07:52:12 -07:00
device_type.py Conditionally enable 4bit on CDNA for bitsandbytes>=v0.49.2 (#4161) 2026-03-07 01:33:40 -08:00
import_fixes.py Also patch accelerate's is_wandb_available for trl callbacks path (#4148) 2026-03-03 08:28:55 -08:00
ollama_template_mappers.py Re-apply #4939: updated models template mappers (#4950) 2026-04-15 07:52:12 -07:00
save.py fix(security): shell injection in GGML export conversion (#4768) 2026-04-02 00:10:43 -07:00
tokenizer_utils.py Fix review findings for chat-template repair (#5049) (#5056) 2026-04-16 08:02:05 -07:00
trainer.py feat: Implement Q-GaLore optimizer and custom embedding learning rate… (#4511) 2026-03-25 01:03:10 -07:00