Skip to content

Preserve per-call expert routing on shared prompt prefixes - #3326

Draft
KyleWong288 wants to merge 2 commits into
mainfrom
feat/per-call-router-replay
Draft

KyleWong288 wants to merge 2 commits into
mainfrom
feat/per-call-router-replay

Conversation

@KyleWong288

@KyleWong288 KyleWong288 commented Dec 2, 2026 •

Copy link
Copy Markdown
Member

When vLLM recomputes part of a shared prompt, two responses can see the same token IDs but yield different MoE routed experts. When paired with R3, the trainer may accidentally use the wrong routed experts.

The fix yields a 62% reduction in mismatch_kl on a 25M token test.

The trainer consumes these routing histories in Prime-RL #4904.

Note

Preserve per-call expert routing on shared prompt prefixes

  • When a call reuses a prompt prefix, its routes may differ from the routes stored on earlier prefix nodes. Now prefix routes are kept as-is, and differences from the current call are stored on the response node as routing_override plus routing_offset (see _record_prefix_routes and _attribute_routed_experts in graph.py).
  • TrainClient.get_response in train.py now always requests routed-expert history from offset zero, and response_from_generate rejects payloads that do not start at zero or do not cover the full call.
  • Branch.routed_experts, Branch.node_routed_experts, and Branch.routing_segments in trace.py expose the combined branch routes, first-producer routes, and routing segments.
  • routing_override and routing_offset are treated as training-array fields in delta.py and excluded from disk serialization.
  • Behavioral Change: prior prefix nodes keep their original routes instead of being overwritten with the latest call's routes; tests in test_graph.py are updated for this.

Macroscope summarized 45be0c4. (Automatic summaries will resume when PR exits draft mode or review begins).

This branch has not been deployed

No deployments
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