Skip to content

feat(v1): carry paired routing weights in single-turn traces - #2568

Draft
faresobeid wants to merge 1 commit into
mainfrom
feat/total-router-recall-mvp
Draft

feat(v1): carry paired routing weights in single-turn traces#2568
faresobeid wants to merge 1 commit into
mainfrom
feat/total-router-recall-mvp

Conversation

@faresobeid

@faresobeid faresobeid commented Sep 9, 2026

Copy link
Copy Markdown
Collaborator

Summary

Add the verifier transport and trace layer for Total Router Recall (TRR): immutable paired expert IDs and captured FP32 coefficients, with token-row validity. Keep IDs-only routing supported.

  • Validate the versioned HTTP payload before graph mutation. Preserve coefficient bytes and expert-slot order.
  • Carry paired routing through graph node slices, branch concatenation, and raw-byte msgpack serialization.
  • Accept complete capture or one unforwarded final sampled token. Mark that terminal placeholder invalid with zero weights.
  • Reject full-coefficient delta capture, reused-prefix continuation, and shared-prefix forks. This MVP supports independent single-turn calls only.
  • Extend existing graph/trace tests. No standalone routing test suite is added.

Validation

Current-main CPU validation, using the prepared renderer companion source:

  • uv run pytest tests/v1/test_graph.py tests/v1/test_trace.py -o addopts= -q: 37 passed.
  • Audited standalone routing suite, copied unchanged to an ignored external QA location and not included in this PR: 89 passed.
  • Ruff lint/format, git diff --check, and uv run pre-commit run --all-files: passed.

A broader local-only contributor run was attempted before the final test fix: 79 passed, 15 failed, 1 collection error. Eleven failures and the collection error require omitted example/optional task packages. Four failures came from a new test fixture that dropped the transient routing field; the focused rerun above confirms its fix. The full suite is not claimed as passing.

The original audited implementation reported 111 verifier routing/graph/trace passes. That is prior evidence, not a result from this rebased branch. No live provider, sandbox, GPU, training, throughput, or numerical-equivalence result is claimed. Model expert-count validation remains the trainer loader's responsibility.

Companions

Related #2544 backfills IDs-only turn boundaries; #2408 handles opaque ID decoding. Neither adds coefficient transport or full-coefficient replay.

AI assistance

AI agents assisted with implementation, review, tests, and preparation of this draft.

Note

Add RoutingData carrier for paired routing weights in single-turn traces

  • Introduces an immutable RoutingData dataclass in routing.py carrying FP32 weights, expert IDs, and per-row validity, with wire encode/decode and model-dependent validation.
  • Updates graph.py _commit_turn to decode and validate full routing captures before mutation: rejects malformed coverage, unsupported reused-prefix/delta captures, and invalid message-span metadata; valid P+C-1 captures receive a synthetic invalid terminal row.
  • Changes MessageNode.routed_experts and Branch.routed_experts to accept either legacy ID arrays or RoutingData, enforcing single-sampled-node replay and sampled-terminal semantics for full mode while preserving legacy None behavior.
  • Adds HTTP/base64 and graph-wire decoders for legacy IDs-only and versioned full routing envelopes in routing.py; exports RoutingData from verifiers/v1/init.py and adds weight typing to types.py.
  • Risk: _commit_turn now rejects reused-prefix continuations when existing prefix nodes already carry full routing and rejects mixed full/legacy routing evidence in concatenate_routing; callers passing legacy ID arrays must still use supported uint8/uint16 dtypes.

Macroscope summarized 036c828.

Carry immutable expert IDs, FP32 coefficients and captured-row validity through
single-turn training traces. Validate full payloads before graph mutation and
reject unsupported continuation/fork cases without changing IDs-only replay.

Assisted-by: Prime Agent
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