Repository navigation
Point the Apertus mapper rows at the Instruct repo, not the base one - #9311
vineethsaivs wants to merge 1 commit into
Conversation
Slot 1 of an __INT_TO_FLOAT_MAPPER entry names the upstream repo the unsloth
build mirrors, and mapper.py turns it into two lookups:
FLOAT_TO_INT_MAPPER[upstream] -> the 4bit key
MAP_TO_UNSLOTH_16bit[upstream] -> slot 0
Both Apertus rows put the BASE repo there:
"unsloth/Apertus-8B-Instruct-2509-unsloth-bnb-4bit" : (
"unsloth/Apertus-8B-Instruct-2509",
"swiss-ai/Apertus-8B-2509", # the pretrained base
...
so FastLanguageModel.from_pretrained("swiss-ai/Apertus-8B-2509") resolves to
unsloth/Apertus-8B-Instruct-2509 (or its 4bit build) and silently loads instruct
weights for someone who asked for the base model, while
swiss-ai/Apertus-8B-Instruct-2509 itself matches nothing and misses the unsloth
build entirely. Same for the 70B pair.
swiss-ai ships chat_template.jinja only in the -Instruct repos, and the unsloth
mirrors carry that template inline, so the mirrors are of the Instruct models.
The base repo landed in slot 1 because an instruct model's `base_model` card tag
names the pretrained base, which reads like the upstream name.
Add tests/test_mapper_instruct_drift.py, an ast check in the same shape as
test_mapper_no_duplicate_keys.py, asserting no entry crosses the instruct/base
line in either direction. The whole table has no other crossing.
|
Closing this: it duplicates my own earlier PR #7339, which has been open on the same two mapper rows since 2026-07-22, and #7339 is the better change. I found the drift by scanning #7339 handles the 70B row correctly and this one does not. @oobabooga pointed out on that PR that I did see that 401 while checking which repo was which today and read it as a gated repo rather than an absent one. It was the more important of the two facts. The one thing here that #7339 does not have is |
Motivation
Slot 1 of an
__INT_TO_FLOAT_MAPPERentry names the upstream repo the unsloth build mirrors, andmapper.pyturns it into two lookups:Both Apertus rows put the pretrained base repo there:
So
__get_model_nameresolves the base repo to the instruct build, and the instruct repo to nothing at all. Built straight frommapper.pyonmain:Two consequences, both silent:
FastLanguageModel.from_pretrained("swiss-ai/Apertus-8B-2509")loads instruct weights, complete with a chat template, for someone who asked for the base model to continue-pretrain or fine-tune from scratch.swiss-ai/Apertus-8B-Instruct-2509matches nothing and downloads the upstream repo, missing the unsloth build entirely.Which repo is which
swiss-aishipschat_template.jinjaonly in the-Instructrepos:chat_template.jinjaswiss-ai/Apertus-8B-Instruct-2509swiss-ai/Apertus-8B-2509swiss-ai/Apertus-70B-Instruct-2509swiss-ai/Apertus-70B-2509and
unsloth/Apertus-8B-Instruct-2509carries that template inline intokenizer_config.json, so the unsloth mirrors are of the Instruct models.The base repo most likely landed in slot 1 because an instruct model's HuggingFace
base_modelcard tag names the pretrained base:swiss-ai/Apertus-8B-Instruct-2509itself declaresbase_model: ['swiss-ai/Apertus-8B-2509'], which reads like the upstream name when filling the row in.Fix
Two lines: slot 1 becomes
swiss-ai/Apertus-{8B,70B}-Instruct-2509. After it:Nonefor the base repos is correct: there is no unsloth Apertus base build, so those fall through to the ordinary HuggingFace path instead of being handed the wrong weights.Tests
tests/test_mapper_instruct_drift.py, anastcheck in the same shape as the existingtest_mapper_no_duplicate_keys.py, so it needs no imports and no network. It asserts no entry crosses the instruct/base line in either direction.test_base_entries_do_not_point_at_an_instruct_repois the other direction and passes onmaintoo, so it is a control rather than a second bug report: the rest of the table has no crossing either way, which is why the guard can be strict.The mapper suite around it, same environment:
The 4 are the same
test_new_mapper_fetched_fp8.pyfailures on both sides, pre-existing in my environment and untouched here; the delta is exactly the 2 tests added.ruff checkpasses on the new file, andscripts/run_ruff_format.pyleaves it unchanged on a second pass.mapper.pyis in ruff'sextend-excludeand in the kwarg hook's exclude, so its two edited lines are not formatter-affected.