Skip to content

Resolve Hub model commits through huggingface_hub, not config._commit_hash - #57

Merged
a9lim merged 3 commits into
mainfrom
fix/hub-commit-resolution
Oct 28, 2026
Merged

a9lim merged 3 commits into
mainfrom
fix/hub-commit-resolution

Conversation

@a9lim

@a9lim a9lim commented Oct 28, 2026 •

Copy link
Copy Markdown
Collaborator

What

Drowse now gets a Hub model's immutable commit from huggingface_hub (HfApi.resolve_revision) through one helper, core.model.resolve_model_revision. It no longer reads config._commit_hash, which transformers 5.18+ never sets.

Why

Transformers 5.18 drops _commit_hash when it builds a config. Every drowse reader of that attribute quietly lost the model's commit (verified with transformers 5.21.0 and huggingface_hub 1.33.0):

  • drowse lens fetch <model> neuronpedia (and workspace-r/workspace-j) failed for every model with ValueError: could not resolve immutable Hugging Face model revision for Qwen/Qwen3-8B.
  • _resolve_load_plan pinned nothing. _finalize_model therefore never stamped the live config, and a session would have rejected any fetched external J-lens binding as stale even after a successful fetch.
  • model_source_fingerprint returned None for every Hub model. That disabled the metadata-only preflights (lens fit / manifold fit no-op proofs) and the source-trusted cache path in loaded_model_fingerprint.

The fix:

  • resolve_model_revision(model_id) returns the commit: from the Hub when online, from the cached refs/ entry when offline, and None for a local directory. Hub errors propagate, so a gated or missing repo keeps huggingface_hub's own message.
  • The load plan resolves the commit first and also pins the probe config read. It fails open the way transformers' own resolver does.
  • model_source_fingerprint takes the plan's revision from the loader, or resolves it itself for a preflight. A preflight's recompute therefore matches the stamp again.
  • Lens fetch resolves the commit, then reads the dimension-check config pinned to it. _model_commit is gone.
  • The live config's _commit_hash is still the slot the identity checks read (_jlens_matches_loaded_model, capture fingerprints). Drowse's stamp now fills it on every load.
  • The PR declares huggingface-hub>=1.26, the first release with resolve_revision. The transformers>=5.10 floor only implies hub ≥1.5.

Test plan

  • ruff check . passes
  • pyright passes (0 errors; the one warning is the optional ripser import)
  • Non-GPU tests pass (pytest -q -m "not gpu"): 3951 passed, 33 skipped
  • GPU smoke tests: not run. The Mac was busy with other Qwen3-8B jobs, so this used a real CPU load_model of hf-internal-testing/tiny-random-LlamaForCausalLM instead (below)
  • Manually verified against: Qwen/Qwen3-8B (configs only) and the tiny Llama on CPU

New offline tests: test_neuronpedia_fetch_pins_the_resolved_model_commit runs the full fetch against a config with no _commit_hash. It fails on main with the reported ValueError and passes here. The resolver tests check .resolved against the requested ref (a ResolvedRevision stringifies to "main"), local directories, and fail-open behavior. The plan, stamp, and preflight tests cover the rest.

Manual checks, run on the real Hub:

  • drowse lens fetch Qwen/Qwen3-8B neuronpedia binds neuronpedia/jacobian-lens@e166deb5…, 35 layers, 461 prompts, and model_revision b968826d… (the Hub's current main). drowse lens show Qwen/Qwen3-8B reports it.
  • _resolve_load_plan("Qwen/Qwen3-8B") pins the same commit, and _jlens_matches_loaded_model accepts the fetched sidecar against the stamped config.
  • load_model on the tiny Llama stamps the resolved commit, and its _drowse_source_fingerprint equals the preflight recompute.
  • With HF_HUB_OFFLINE=1, the commit resolves from the cached ref.

CI fixes in this PR

Two CI failures here were already on main (its last run, 8114d796, failed too). They're fixed in their own commits:

  • typecheck: pandas 3.1 types df[label] as Series | DataFrame, so df[c].nunique(...) > 1 in drowse/notebook/plots.py typed as Series | bool. A cast to pd.Series states the actual type. tests/test_notebook.py passes.
  • webui-build (npm run check:hosted): the full-runtime evidence fixture was pinned to producedAt 2026-08-29. The producer rejects observer reports more than 30 days old against the real clock, so two tests in record-hosted-evidence.test.mjs have failed since 2026-09-28. The fixture is now minted a minute before the test. Locally, the file passes 19/19 and npm run check:hosted passes end to end. npm run build leaves drowse/web/dist unchanged. I didn't run test:hosted locally (Playwright browsers aren't installed on this Mac), so CI covers it.

Notes

  • Local lens fits made under transformers ≥5.18 before this fix recorded model_source_fingerprint: null. The lens fit no-op preflight can't prove those artifacts, so they re-fit once.
  • core/sae.py already resolved SAE repos via model_info(...).sha and is unaffected.

a9lim added 3 commits October 28, 2026 11:23
…_hash

Transformers 5.18 stopped setting config._commit_hash (configs drop it at
construction). Every drowse reader of that attribute silently lost the
model's immutable commit:

- `drowse lens fetch <model> neuronpedia|workspace-r|workspace-j` raised
  "could not resolve immutable Hugging Face model revision" for every model.
- The load plan pinned nothing, so _finalize_model never stamped the live
  config, and a session rejected every fetched external J-lens binding as
  stale.
- model_source_fingerprint returned None for every Hub model, which disabled
  the metadata-only preflights and the source-trusted cache path.

resolve_model_revision (core/model.py) is now the one source of the commit:
HfApi.resolve_revision online, the cached ref offline, None for a local
directory. The load plan resolves it first and pins the probe config read
too. The fingerprint takes the plan's revision, or resolves it for a
preflight. Lens fetch resolves the commit and then reads the dimension-check
config pinned to it. The live config's _commit_hash stays the slot that the
identity checks read, now filled by drowse's stamp on every load.

Declares huggingface-hub>=1.26, the first release with resolve_revision;
the transformers 5.10 floor only implies hub>=1.5.
pandas 3.1 annotates df[label] as Series | DataFrame, so
df[c].nunique(...) > 1 typed as Series | bool and pyright rejected the
conditional (CI typecheck). A string label selects a Series here; cast
says so.
validateFullRuntimeReport rejects observer reports older than 30 days
against the real clock, and the producer runs as a subprocess, so the
fixed 2026-08-29 fixture timestamp made both full-runtime benchmark tests
fail from 2026-09-28 on (webui-build, check:hosted). The fixture report
is now minted a minute before the test runs.
@a9lim
a9lim enabled auto-merge October 28, 2026 15:45
@a9lim
a9lim merged commit 6bfc804 into main Oct 28, 2026
20 of 21 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant