Repository navigation
fix(calibrate): a Hugging Face snapshot is recorded as its repo id and commit - #71
Merged
Merged
Conversation
Reviewer's GuideThis PR fixes calibration metadata to record Hugging Face cache snapshots using the same repo ID and commit identity that basal-serve uses, while retaining existing behavior for repo IDs, plain directories, and URL-only flows. It updates both calibration execution paths, adds strict-calibration regression coverage, and documents the change. Sequence diagram for calibration model identity recordingsequenceDiagram
participant Calibrate as basal-calibrate
participant Resolve as resolve
participant Identity as model_identity
participant File as Calibration file
participant Server as basal-serve
Calibrate->>Resolve: resolve(a.model, a.revision, metadata_only=True)
Resolve-->>Calibrate: model metadata
Calibrate->>Identity: model_identity(a.model, metadata)
Identity-->>Calibrate: repo_id, revision
Calibrate->>File: write fitted_on.model and fitted_on.revision
Server->>File: load calibration
Server->>Identity: model_identity(served_model, server_metadata)
Identity-->>Server: repo_id, revision
Server-->>File: strict calibration matches
File-Level Changes
Assessment against linked issues
Possibly linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey - I've found 1 issue
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location path="basal/calibrate.py" line_range="1367" />
<code_context>
baseline, base_file = compared(srv.md, srv.kind, a.calibration, quant, orders, a.no_calibration, preset,
a.layout)
- model, revision = a.model, model_identity(a.model, srv.md)[1]
+ model, revision = model_identity(a.model, srv.md)
engine = mode + (f" --quant {a.quant}" if a.quant else "") + (f" --gguf {Path(a.gguf).name}" if a.gguf else "") \
+ (f" --vllm-preset {preset}" if preset not in (None, "default") else "")
</code_context>
<issue_to_address>
**Calibration docs promise original path**
When `--model` points to a Hugging Face cache snapshot directory, `model_identity` stores the repo id instead of the supplied snapshot path, contradicting the guide and leaving users or consumers that rely on the documented `fitted_on.model` value with a different identity than promised.
Update the calibration guide to explain that snapshot paths are recorded as their repo id and commit.
Also at `basal/calibrate.py:1348`.
</issue_to_address>
Owner
|
Thank you, Paweł! Planned for basal 2.5: we are merging it into the 2.5 release branch now, after our checks (full CPU suite, your tests, serving code unchanged). The PR will close when 2.5 is published on main. |
rkinas
added a commit
that referenced
this pull request
Nov 2, 2026
… version CONTRIBUTING.md credits the 2.5 pull requests as the release notes' community line lists them (Paweł Kiszczak #52, #62, #64, #66, #68, #71, #73, #75; Marcin Brzeżański #56; Grzegorz Brzezinka #76, #78) and adds Dariusz Koryto (#53, #58, #59, #60 and #55); the README's list names him too. docs/changes/README.md and the changelog.py help use 2.5.1, the next release, as the example.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #70
What
basal-calibraterecords the model asmodel_identity(--model, md)— the pair it already used forfitted_on.revision— instead of the--modelargument as given: a Hugging Face cache snapshot directory becomes its repo id and commit, as basal-serve'scalibration_mismatchnames the served model. Both the in-process path and--urlwith--model(basal/calibrate.py).docs/WHATS_NEW.md: a bullet under# Unreleased.Why
A file fitted on
--model <cache>/models--Remek--x/snapshots/<commit>recorded the path; basal-serve serving that snapshot warned that it was fitted on another model (the last path segment is the commit, not the name) and refused it under--strict-calibration.Compatibility
Repo ids resolve to the same snapshot and were already recorded as the repo id; plain directories and
--urlwithout--modelare recorded exactly as before (model_identityreturns the name as given and no revision). Only snapshot paths change, from the path to<org>/<name>+revision.Tests run
tests/test_calibrate.py::test_a_cache_snapshot_is_recorded_as_its_repo_id_and_commit(snapshot and plain directory; the snapshot case fails without the fix:fitted_on.modelwas the path) — the written file is then loaded byServerwith--strict-calibration, no mismatch.--mode mps):basal-calibrate basal/examples/questions.jsonl --model <HF cache>/models--Remek--basal-2.0-mini/snapshots/cb81b32…writesfitted_on.model = "Remek/basal-2.0-mini",revision = "cb81b32…";Server(--name Remek/basal-2.0-mini --model <snapshot> --calibration FILE --strict-calibration)loads it,cal_mismatchNone.uv run --no-sync pytest -q -x— 763 passed, 53 skipped, 1 warning.uvx [email protected] check --select E9,F63,F7,F82 --target-version py310 .— only the existingF821 Undefined name kposin untouchedbasal/gemma4.py:471.Summary by Sourcery
Fix calibration model identity recording so Hugging Face cache snapshots are accepted by strict serving checks.
Bug Fixes:
Documentation:
Tests: