feat(aprender-serve): SaveTensorStage gains MoeRouter + MoeFfnOut — M-MOE-SUB-1#1499
Merged
noahgift merged 1 commit intoMay 5, 2026
Merged
Conversation
c59abb0 to
264c22d
Compare
…-MOE-SUB-1 Per `contracts/trace-moe-gpu-sub-stages-v1.yaml` v1.0.0 (PR #1498), M-MOE-SUB-1 implementation: extend the parent SaveTensorStage enum with the 2 new mandatory MoE-GPU bisection variants. WHAT THIS PR ADDS: * `MoeRouter` — top-k expert weights post-softmax + renormalize, per-layer, captured AFTER FfnNorm and BEFORE per-expert SwiGLU. * `MoeFfnOut` — aggregated MoE FFN output Σ w_e * expert_out_e, per-layer, captured AFTER all per-expert computations. CHANGES: * `SaveTensorStage` enum: 2 new variants between `PostFfnResidual` and `FinalNorm`. * `ALL` array: 20 → 22 entries; new variants in canonical position. * `canonical_name()`: 2 new arms returning "moe_router" + "moe_ffn_out". * `FromStr::from_str()` lowercase match: 2 new accepted strings. * `is_per_layer_count_matches_contract` test: per_layer 18 → 20, total 20 → 22. * `canonical_names_match_contract_enumeration` test: expected[] grows to 22 with new entries in canonical order. * 5 new `falsify_moe_sub_001_*` tests: - `moe_router_round_trip` - `moe_ffn_out_round_trip` - `2_new_stages_in_canonical_order` (ALL position assertions) - `parse_list_accepts_2_new_stages_together` - `parse_list_accepts_full_moe_block_chain` (3-stage bisection chain `ffn_norm,moe_router,moe_ffn_out`) DISCHARGES: FALSIFY-MOE-SUB-001 (per contract). NOT DISCHARGED YET (separate follow-up scope per contract): * FALSIFY-MOE-SUB-002 (byte-identity preservation) — needs the instrumentation PR (M-MOE-SUB-2 + 3) that wires MoeRouter + MoeFfnOut capture into both forward bodies. * FALSIFY-MOE-SUB-003 (live bisection on lambda-vector RTX 4090). * FALSIFY-MOE-SUB-004 (fix PR cites bisected stage by name). VERIFICATION: cargo test -p aprender-serve --lib save_tensor_stage → 29 passed; 0 failed; 0 ignored rustfmt --check → exit 0 DEPENDS ON: PR #1498 (`trace-moe-gpu-sub-stages-v1` v1.0.0 contract scaffold) being on aprender main first. The contract pinned the new variants' names + semantics; this PR implements them. Refs: M-GPU-MOE-1.4 step (a) instrumentation, R10, qwen3-moe-forward-gpu-v1 v1.4.0, trace-moe-gpu-sub-stages-v1 v1.0.0, FALSIFY-MOE-SUB-001 (DISCHARGED). Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
264c22d to
e645913
Compare
4 tasks
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.
Summary
Per
trace-moe-gpu-sub-stages-v1.yamlv1.0.0 (PR #1498), implements M-MOE-SUB-1: extend the parentSaveTensorStageenum with the 2 new mandatory MoE-GPU bisection variants needed for M-GPU-MOE-1.4.Changes
SaveTensorStageenumMoeRouter+MoeFfnOutALLarraycanonical_name()moe_router,moe_ffn_out)FromStrparserfalsify_moe_sub_001_*testsDischarges
trace-moe-gpu-sub-stages-v1.yaml)NOT yet discharged (separate scope)
Verification
Stacks on
PR #1498 (
trace-moe-gpu-sub-stages-v1v1.0.0 contract scaffold).Test plan
🤖 Generated with Claude Code