Repository navigation
feat(steer): name the steering methods once, as SteerMethod - #22
Merged
Merged
Conversation
The three steering arithmetics had two spellings: `SteerSpec.method` said `additive`, the worker dict's `op` said `add`, and nothing but a runtime set-membership check told a caller which one it was speaking to. `steer_specs.SteerMethod` is now the one vocabulary -- a `StrEnum`, so a member compares equal to its spelling and a spec loaded from JSON needs no translation. - `SteerSpec.method` is typed `SteerMethod` and coerced in `__post_init__`, so an unknown name is refused at construction with the members listed, rather than at the first forward. - `steer_delta` and the worker's `_make_steer_modifier` dispatch by `match` on the enum, which pyright checks for exhaustiveness. - `steering_spec_to_worker_specs` emits the enum's values; the static tap's op set and the backend's static-write gate read from it (`STATIC_WRITE_OPS` is now public so the gate cannot restate the list). - `STEER_METHODS` stays, derived from the enum, for callers that listed the methods. The worker dict's `op="add"` is gone rather than aliased. Only `steering_spec_to_worker_specs` built those dicts, so nothing outside the package spoke it; a raw dict that still does is refused with the new spelling in the message. Verified on CPU (full fast suite) and on the vLLM worker on GPU (`-m gpu -k steer`, gpt2). Co-authored-by: Cursor <cursoragent@cursor.com>
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.
steer_specs.SteerMethod(StrEnum:additive,orthogonal,projection_cap) andsteer_method(), which refuses an unknown name and lists the members. Both exported frominterp_engine.SteerSpec.methodis typedSteerMethodand coerced in__post_init__; a string still works.steer_deltaand the worker's_make_steer_modifierdispatch withmatchon the enum.steering_spec_to_worker_specsemits the enum's values. The worker dict'sop="add"becomes"additive";"add"is refused.STATIC_WRITE_OPSis public;vllm_backend's static-write gate reads it instead of restating the list.STEER_METHODSstays, derived from the enum."add".Verified: full fast suite on CPU, and
-m gpu -k steeron the vLLM worker (gpt2).