Gradient Interpretability Toolkit (gradient recording, GFC operator, GSAE) - #119
Open
emirhanboge wants to merge 6 commits into
Open
Gradient Interpretability Toolkit (gradient recording, GFC operator, GSAE)#119emirhanboge wants to merge 6 commits into
emirhanboge wants to merge 6 commits into
Conversation
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.
Summary 📝
Adds a gradient-side capability to murano. Every existing capture path answers what a model represents; this answers what training would move. It records the gradient of the completion log-likelihood with respect to the residual stream on a frozen checkpoint, builds a cross-layer map of where that gradient travels between two layers, and trains a sparse dictionary over the recorded gradients so the directions of the training signal can be read and compared across checkpoints.
Three new step modules, one new
MuranoModelmethod, save/load for the three new artifacts, tests, and one runnable notebook. No new dependencies, andpyproject.tomlis untouched.Details
MuranoModel.grad_forward— the graph-preserving counterpart offorward_logits. The proxy capture paths all detach, so gradient-based steps need a forward whose activations stay attached to the autograd graph. It runs the base module natively with plain forward hooks on the requested decoder layers, the same raw-module seam the generation interventions already use, and returns the block outputs undetached.murano.steps.gradients—RolloutBatchholds a fixed rollout corpus (token ids plus the prompt boundary, with optional rewards and GRPO group ids).LoadRolloutsandRecordGradientsteacher-force a frozen checkpoint through those ids and write aGradientStore. Rollouts are processed one at a time rather than in padded batches, because padding would put the completion window at a different sequence offset per row.murano.steps.gfc—GFCOperatorreads the gradient at a source layer, projects it ontokorthonormal directions fixed by a seed before any checkpoint is loaded, and transports each direction's seed field back to an earlier target layer with one batched vector-Jacobian product.gradient_off=Trueholds every read strength at 1 so the operator reads the frozen transport alone.pairing_overlapcompares two operators after removing the rank-one marginal background, andpermutation_floormeasures the chance level of that comparison.murano.steps.gsae— a TopK sparse autoencoder over the recorded gradients. The existing SAE path loads pre-trained dictionaries and none exist for gradients, so this ships the minimal trainer the feature census needs: one dictionary fit once over pooled inputs from several checkpoints, decoder rows renormalised after every step, and dead features re-initialised from reconstruction residuals between epochs.murano.io— save and load for all three artifacts, registered with the existing artifact serializer registry so they persist from a pipeline run like every other store.notebooks/applications/gradient_interpretability.ipynb— runs the whole flow on a tiny model, following the shared template thattests/test_notebook_structure.pyenforces. Wired into the docs generators.Checks