feat(patch): multi-hook sweeps + source-run lifecycle#237
Merged
RhizoNymph merged 3 commits intoJul 5, 2026
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.
Stacked on #235 (base
feat/patch-sweep-spans).Adds first-class multi-hook activation-patching sweeps and a source-run lifecycle so one-call sweeps stop leaking (and polluting the LRU with) fresh uuid runs.
Multi-hook sweeps
hooks: list[str] | NoneonPatchSweepRequest. When given (non-empty, each injectable — validated, 400 otherwise) the(layers x positions)grid runs at every hook;hookswins over the singlehookfield. The corrupt baseline and noise floor are computed once and shared across hooks; only patched cells fan out per hook.hook_grids: list[HookGrid](one{hook, grid, argmax}per hook). Top-levelgrid/hook/argmaxmirror the first hook, so single-hook clients keep working;positions/layers/clean/corrupt/noise_floor/alignment/skippedstay shared (skipped cells carry theirhook).hooks=["post_block"]matcheshook="post_block"bar the extrahook_gridsentry.sweep_layers_positions(..., server_side=True, hooks=[..])returnsdict[str, SweepResult]keyed by hook; passinghookson the per-cell path raisesValueError.Hook-complete auto-capture
_auto_capture_cleannow taps all three injectable hooks (pre_attn,post_attn,post_block) at the swept layers in one forward, so a kept auto-captured run is reusable for hook-comparison follow-up sweeps at a different hook.Source-run lifecycle
keep_source: bool = Falseretains it; a pre-existing run is never dropped. Drop failures are log-warn.DELETE /v1/patch_source/{run_id}->collective_rpc("drop_patch_source_run")(new gpu_worker RPC mirroringlease_patch_source_runs), unioned across ranks: 200{"dropped": true}or 404. An explicit owner drop succeeds even if the run is leased (storedrop_runclears the lease); LRU eviction still never touches a leased run._PatchSourceCacheso a dropped run is not reported as still-existing (which would skip auto-capture and 400 the next sweep).PatchStudy.drop_runwired to the DELETE route (returnsbool); one-callkeep_sourcepassthrough.Conflicts
Expected merge conflicts with sibling branch
feat/patch-sweep-stream(SSE streaming) inapi_router.py's fan-out section,protocol.py, anddocs/features/activation_patching.md.