support loading fit checkpoints in JacobianLens.load() - #1574
support loading fit checkpoints in JacobianLens.load()#1574priyanka25aug wants to merge 4 commits into
Conversation
|
Hi @jlarson4 — all format, type, docstring, and benchmark checks are passing. The remaining long-running jobs (compatibility across Python 3.10/3.11/3.12 and full coverage) are still in progress but looking clean so far. Would you mind taking a look when you get a chance? Happy to make any changes based on your feedback. |
jlarson4
left a comment
There was a problem hiding this comment.
Hi @priyanka25aug! Thanks for taking this on. Checkpoint import is a genuinely useful capability, and the conversion math, artifact-path safety, and merge sentinel are all done right.
A couple comments below that we should address before merging
…, fix tuned-lens note - Remove "target_layer" from _FIT_RESERVED_KEYS so it survives checkpoint conversion and validate_model() can refuse non-final-target lenses - Add test_load_checkpoint_mirrors_fit_payload_schema: fixture matches the exact keys fit() produces so format drift causes a test failure - Fix tuned-lens note: it is the Jacobian artifact format that has no bias slot, not the tuned-lens format; tuned-lens translators are affine (weight + bias)
|
@jlarson4 All four of your review comments have been addressed in
|
Real checkpoint writers (reference package) store the prompt count as n_done, not n_prompts. Prefer n_done with n_prompts as fallback so genuine checkpoints are not rejected with n_prompts=0. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01NiwNUm3YFj9yAuSBuGDnd8
7aec2e7 to
8eda574
Compare
|
@priyanka25aug There is a CI failure that needs it be addressed still it looks like. The failure is an indicator of the remaining bug. If the intent was a TransformerLens checkpoint format rather than the reference one, say so and we'll take the other fork: that would mean teaching Suggested order:
|
What this does
Extends
JacobianLens.load()to accept fit checkpoints (files saved by the fitting pipeline with ajacobian_sumkey) in addition to the existing artifact format (files with aJkey).The conversion lives in a new
_from_checkpoint_payload()classmethod:n_promptsto recover the per-prompt meanmodel_name,model_revision,corpus) from the flat payload namespace intometadatatransformer_lens_fit,transformer_lens_version,model_system, etc.) so they don't leak into the converted lensweights_only=Truereload, recording their names and shapes indropped_fieldsfor transparencyconverted_from: "jacobian_lens_checkpoint"somerge()naturally refuses to mix converted and natively TL-fitted lenses (provenance keys differ)Raises
ValueErrorwith a clear message if the file has neither key, or ifn_prompts <= 0. Tuned-lens support deferred.Files changed
transformer_lens/tools/analysis/jacobian_lens.py— new_FIT_RESERVED_KEYSand_CHECKPOINT_FLAT_PROVENANCEfrozensets; updatedload(); new_from_checkpoint_payload()tests/unit/tools/test_jacobian_lens_import.py— unit tests on synthetic fixtures covering artifact regression, checkpoint round-trip, dtype preservation,n_prompts=0guard, tensor field dropping, fit-key stripping, and merge provenance rejection; no model/oracle dependencydocs/source/content/jacobian_lens_fitting.md— "Importing an existing lens" section addedType of change
Checklist
Testing