Repository navigation
fix(bridge): route legacy TL-format repos from boot_transformers to boot_tl_legacy - #2029
Conversation
…oot_tl_legacy NeelNanda/*, ArthurConmy/* and Baidicoot/* repos (and aliases like gelu-1l, solu-1l) have no HF model_type, so boot_transformers failed in AutoConfig. Hand them to boot_tl_legacy with a warning pointing at the direct call, forward device/dtype/tokenizer/checkpoint args, and raise on HF loading options boot_tl_legacy can't honor. A pre-loaded hf_model skips the routing. Closes TransformerLensOrg#2025 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
jlarson4
left a comment
There was a problem hiding this comment.
Thanks for putting this together @pablocs116, just a couple small notes, and a small bug I did not think about when reviewing your original proposal. Take a look and let me know what you think.
| ) | ||
| model_name = official_name | ||
| # A pre-loaded hf_model is HF-format by construction, whatever its repo name. | ||
| if hf_model is None and model_name.startswith(TL_LEGACY_PREFIXES): |
There was a problem hiding this comment.
Something not previously taken into account: these namespaces also host regular HF-format models, e.g. Baidicoot/Llama-3-8B-Instruct-LAT. Those load through boot_transformers, but with this change would fail with KeyError: 'd_model'. Can we route on something narrower than the namespace?
| device="cpu", | ||
| dtype=torch.float16, | ||
| tokenizer=tokenizer, | ||
| checkpoint_index=3, |
There was a problem hiding this comment.
Every case here leaves checkpoint_value as None, so the tests still pass if the routing stops forwarding it. Could one case pass a real value?
The NeelNanda/, ArthurConmy/ and Baidicoot/ namespaces also host HF-format models (e.g. Baidicoot/Llama-3-8B-Instruct-LAT), which prefix routing sent to boot_tl_legacy and broke with KeyError: 'd_model'. Route on an explicit TL_LEGACY_MODEL_NAMES list instead, kept in sync with OFFICIAL_MODEL_NAMES by a test. Also cover checkpoint_value forwarding with a real value. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Thanks @jlarson4, good catch on the namespace. Routing now uses an exact list, If you'd rather not keep a list in code, the alternative is to sniff the repo's |
|
Looks good, thank you for making those adjustments! I am fine with keeping the list in code, it is a static list that is not like to ever change, shouldn't be a big deal. |
Closes #2025
Problem
TransformerBridge.boot_transformerscouldn't load legacy TransformerLens-format repos (NeelNanda/*,ArthurConmy/*,Baidicoot/*), even though they and their aliases (gelu-1l,solu-1l,attn-only-2l, ...) are in the model registry. The alias resolved to the repo ID, and thenAutoConfigfailed withUnrecognized model ... Should have a model_type key.boot_tl_legacyloads these repos, but nothing pointed to it.Fix
In
sources/transformers/source.py::boot, after alias resolution, a name underTL_LEGACY_PREFIXESis handed toboot_tl_legacy:TransformerBridge.boot_tl_legacy('<repo>')call to use instead.device,dtype(None→ float32, the same as a freshboot_transformersload),tokenizer,checkpoint_index/checkpoint_value.ValueErrornamingboot_tl_legacyand the offending arguments, instead of being silently dropped:hf_config_overrides,load_weights=False,model_class,n_ctx,revision,code_revision,device_map,n_devices,max_memory,offload_folder.trust_remote_codeis ignored, since.pthrepos run no remote code.hf_model=skips the routing. A pre-loaded model is HF-format whatever its repo name, sobootkeeps reading its config as before.Docs: the
model_namedocstring andmigrating_to_v4.mdnow describe the routing and recommend callingboot_tl_legacydirectly.Tests
tests/unit/model_bridge/test_boot_tl_legacy_routing.py(new, mocked, no network, 15 tests): alias and repo ID both route, with the warning; supported options are forwarded; each unsupported option raises without loading; HF-format names andhf_model=aren't routed.tests/integration/model_bridge/test_tl_legacy_loader.py:boot_transformers("solu-1l")gives logits identical toboot_tl_legacy("NeelNanda/SoLU_1L512W_C4_Code").ValueError, and the unit tests error.Ran locally (CPU, Linux/WSL2):
test_tl_legacy_loader.py: 24 passedtests/unit/model_bridge/test_boot_*.py+tests/unit/model_bridge/sources: 144 passed, 2 skipped (optionalinspect_ainot installed)make format,uv run mypy .: cleanDownstream: SAELens works around this today (decoderesearch/SAELens#789) and can drop that once this ships.
🤖 Generated with Claude Code