round 22 track b: router + glue #
delivered #
patch: /tmp/sol_r22_router_glue/sol_r22_router_glue.patch
sha256: 87651f461c679bb12d1decbe0f954172d04cda6ca3730f50fcbae6cc59fd3ef4
only metal/kernels/glue.metal changes. tracked vendor sources were not edited. git -C vendor/strata apply --check exits 0. baseline vendor head: 296b59d2f73c8f04a805df29c2fa97655adace78; baseline actual kernel snapshots are in /tmp/sol_r22_router_glue/baseline/ (the checkout may contain prior changes, so snapshots, not head alone, define this experiment).
swiglu_prep moves scale tables to program-scope constants and replaces its 16-float threadgroup array/barrier with same-order shuffle sums. lane 0 still adds even indices and odd indices separately, then adds the two results. all threads execute the shuffle, outside the lane-0 output branch. production dispatch uses 16 threads, entirely within one simdgroup. pipeline-reported static threadgroup memory changes 64 -> 0 bytes; source has one -> zero threadgroup barriers. maximum threads remains 1024. no interface/layout or host dispatch changes.
no measured latency win established. the parent explicitly requested retaining this resource-only reduction after seeing initial results. it is not an end-to-end throughput claim.
rejected hypotheses #
- full
route_bodyunrolling plus constant-index winner invalidation: byte-identical, but consistently slower. confirmed paired median regressions are below. reverted completely, including the entry barrier guard. - router entry barrier guard alone: +0.3% to +3.8% paired median latency across both formats/windows, not a win. not retained.
- combine
n_embd == 2560constant-division fast path: approximately -1.2% to -0.3%, below the predeclared 3% significance threshold. not retained. - combine simd-broadcast plan entries and shared sigmoid: +6.2%, +2.2%, +2.6%, and +0.7% for ntok 1/2/4/8, respectively. not retained. this candidate was only evaluated for width 2560, where groups do not cross token boundaries; it was not generalized to arbitrary widths.
no disassembly/register-count evidence was collected. increased register pressure / occupancy loss is a plausible explanation for the unroll regression, not a proven compiler diagnosis. source unrolling does not establish zero stack traffic or prove the original array spilled.
correctness #
fuse_parity: exit 0, 5.664s, all pass. includes bf16/f32 router logits/ids/w/plan bitwise checks for ntok 1..8 and repeated counter reset; fused norm/combine regressions also pass.route_parity: exit 0, 2.180s; 200 k=512 and 200 k=256/moce windows, zero mismatches. this existing cpu-reference test uses a floating-weight tolerance, not memcmp; it is supplementary, not the byte-parity evidence.- custom paired harness: full output-buffer
memcmp, sentinel-filled padding, 8 trials per kernel/window; ntok 1/2/4/8. every comparison passed for logits, ids, w, plan, xp and bo. counter reset also checked. trial zero deliberately produces exact tied router logits; later trials vary activations. router trials alternate 256/512 experts, with/without moce and draft scaling, random-like fixed residency; rejected full unroll additionally passes rank-1 scale 2 specialization. - delivered source rechecked for router_route_30/router_route_0/moe_combine_sh (
delivered_*.log, unchanged kernels) and swiglu (production*.log, changed kernel). swiglu tests the actual width 640,a.n_tok=8plane stride, and dispatched windows 1/2/4/8; unused rows remain sentinel-filled and match too. early exploratory swiglu runs used width 2560 and are not the production-shape evidence.
stock fuse compilation exceeded two original 4.9s deadlines. after explicit parent authorization for a 20s fuse timeout, its next run passed in 5.664s. all custom benchmark invocations stayed below 5s. no full model, no port 8080 interaction, no subagents.
paired gpu timings #
apple m5; runtime safe math; release appleclang 21.0.0.21000327. same process/library/inputs, separate outputs. final protocol: 0.10s alternating-kernel warmup, ten pairs of 256 dispatches, alternating which side runs first. table reports median baseline/candidate microseconds and median paired percentage (not ratio of medians). clocks/shared-gpu noise are visible in exploratory logs; unchanged combine control differs by about 1%, so changes near that scale are not credible wins.
production swiglu, three independent short invocations/window, 30 pairs pooled:
| kernel | ntok | base us | candidate us | paired change |
|---|---|---|---|---|
swiglu_prep |
1 | 1.898 | 1.882 | -0.94% |
swiglu_prep |
2 | 1.957 | 2.020 | +0.79% |
swiglu_prep |
4 | 2.519 | 2.583 | +1.14% |
swiglu_prep |
8 | 3.742 | 3.776 | +1.19% |
rejected full-unroll router, default k=512/no moce timed path (the parity trials still cover moce):
| kernel | ntok | base us | candidate us | paired change |
|---|---|---|---|---|
router_route_30 |
1 | 42.309 | 43.717 | +9.86% |
router_route_30 |
2 | 42.039 | 50.012 | +16.05% |
router_route_30 |
4 | 49.476 | 54.251 | +10.32% |
router_route_30 |
8 | 93.427 | 103.733 | +9.35% |
router_route_0 |
1 | 65.351 | 71.745 | +10.63% |
router_route_0 |
2 | 77.906 | 90.182 | +13.80% |
router_route_0 |
4 | 81.686 | 87.506 | +6.23% |
router_route_0 |
8 | 89.646 | 82.581 | +7.30% |
unchanged combine control, delivered source:
| kernel | ntok | base us | candidate us | paired change |
|---|---|---|---|---|
moe_combine_sh |
1 | 9.784 | 9.888 | -0.05% |
moe_combine_sh |
2 | 4.078 | 3.927 | -6.02% |
moe_combine_sh |
4 | 1.892 | 1.893 | -1.64% |
moe_combine_sh |
8 | 7.574 | 7.638 | +0.37% |
reproduction / artifacts #
all experimental sources, baseline snapshots, failed attempts and logs: /tmp/sol_r22_router_glue/; source hashes: source_sha256.json. plan.md records the predeclared threshold. ab.metal is the delivered baseline+candidate library; ab_full_unroll.metal, ab_barrier_only.metal, ab_combine_broadcast.metal retain rejected libraries. ab_initial.cpp, ab_v2.cpp, ab_full_confirmation.cpp preserve earlier evaluators; ab.cpp is the delivered evaluator.
cmake -S metal -B build -G Ninja -DCMAKE_BUILD_TYPE=Release
cmake --build build --target fuse_parity route_parity -j 4
# commands above run in /tmp/sol_r22_router_glue/strata
c++ -std=c++20 -O2 -I/tmp/sol_r22_router_glue/strata/metal/src /tmp/sol_r22_router_glue/ab.cpp /tmp/sol_r22_router_glue/strata/build/libmtl_rt.a -framework Metal -framework Foundation -o /tmp/sol_r22_router_glue/ab
/tmp/sol_r22_router_glue/ab swiglu_prep 1
# repeat ntok 2/4/8; other kernels: router_route_30, router_route_0, moe_combine_sh
/tmp/sol_r22_router_glue/strata/build/fuse_parity
/tmp/sol_r22_router_glue/strata/build/route_parity
git -C vendor/strata apply --check /tmp/sol_r22_router_glue/sol_r22_router_glue.patch
current Window::comb_push is at 1083–1091, not the brief's stale 1015–1045 range; no host changes were needed. final image review completed for the entire diff and surrounding glue code; scale-table placement and shuffle idiom match neighboring gr.metal.