Skip to content

feat(steer): name the steering methods once, as SteerMethod - #22

Merged
hijohnnylin merged 1 commit into
mainfrom
steer-method-enum
Sep 18, 2026
Merged

hijohnnylin merged 1 commit into
mainfrom
steer-method-enum

Conversation

@hijohnnylin

Copy link
Copy Markdown
Contributor
  • Add steer_specs.SteerMethod (StrEnum: additive, orthogonal, projection_cap) and steer_method(), which refuses an unknown name and lists the members. Both exported from interp_engine.
  • SteerSpec.method is typed SteerMethod and coerced in __post_init__; a string still works.
  • steer_delta and the worker's _make_steer_modifier dispatch with match on the enum.
  • steering_spec_to_worker_specs emits the enum's values. The worker dict's op="add" becomes "additive"; "add" is refused.
  • STATIC_WRITE_OPS is public; vllm_backend's static-write gate reads it instead of restating the list.
  • STEER_METHODS stays, derived from the enum.
  • Tests updated; new tests for construction-time refusal, string-to-enum coercion, worker/eager spelling parity, and refusal of "add".

Verified: full fast suite on CPU, and -m gpu -k steer on the vLLM worker (gpt2).

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>
@hijohnnylin
hijohnnylin merged commit b9b440e into main Sep 18, 2026
8 checks passed
@hijohnnylin
hijohnnylin deleted the steer-method-enum branch September 18, 2026 04:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant