MLA-SHARED-1: the four-family map earned at both banks — MLA absorbed, shared experts refused on economics - #364
Merged
Merged
Conversation
…urth encoding application, authority still owed
MlaDeviceWeights and DeviceAttn::Mla carry a projection encoding for
the four wide projections (kv_a_norm stays f32; the latent cache
always holds decoded values); all three MLA grouped dispatches and the
at-offset cache write select their kernel by encoding. Shared experts
needed no kernel work at all — their dispatch has been encoding-aware
since the expert rung; the probe gains the byte swap
(PhysicalStore::owned, region() now pub(crate)).
Probe scopes: LARQL_MLA_Q8_LAYER and LARQL_SHARED_Q8_LAYER beside the
KDA list, scope-aware attribution, per-scope labels. The measured
cells this enabled (reports in provenance): MLA depth curve L23
5.75e-5 / L26 1.24e-4 / L19 8.4e-4 / L15 1.06e-3 / L11 3.7e-3 / full
tower 2.6e-2 — late plateau, sharp interior cliff, the fourth family
to show the shape; shared experts REJECTED on bytes-per-behavioural-
cost (1.2e-3 for ~6.6 MB against MLA's 5.8e-5 for ~27 MB) — an
economic refusal, not a capability gap. Four-family diagnostic
(experts + KDA + head + MLA{23,26}): 2.476e-3, the MLA pair absorbed.
Also: the probe's null-partner stack (a third full stack, ~17 GB
wired, needed only for the null arm) is dropped before the long
measurement — holding it tipped the wired-collector wall mid-run at
four-family scale and produced two catalogued flat-instrument
signatures, both refused by the CoveredMass criterion.
Authority at 8192 on both banks and the benchmark are still owed for
this map — interrupted by machine handback; the guarded chain to
resume is recorded.
…bed, shared experts refused on economics
The fourth byte family is admitted and the fifth is declined, both
under one frozen behavioural contract. Five families make up the
decoder's BF16 read per token — routed experts 49.2%, KDA projections
25.2%, output head 12.6%, MLA projections 6.8%, shared experts 6.1%.
MLA showed the same shape the other three families showed: L23
5.75e-5 and L26 1.24e-4 on a plateau, a 15x jump to L19 8.43e-4, and
the full 7-layer tower at 2.61e-2 whose token-distance curve
ACCUMULATES where the late cells' does not. Scope by the jump rule:
MLA{23,26}, non-contiguous by design.
Shared experts are refused on bytes-per-behavioural-cost, not
capability — 1.9e-4 per MB against MLA's 2.1e-6, ~90x worse — even
though their dispatch has been encoding-aware since the expert rung
and the pair {24,25} composes sub-additively. The first refusal in
this programme that is an optimizer's judgement rather than an engine
limitation.
Authority at 8192 positions on the selection AND held-out banks under
kimi-logit-balanced-v1: PASS, no failed criterion. MLA{23,26} is
behaviourally ABSORBED — on the held-out bank top1_mass 5.8313e-2 and
route_max 0.2099 are identical to the three-family map to four
decimals, so the worst single overturn and the worst single routing
displacement are the same unchanged events after adding a family;
counts move at most 2%. The route budget is now the binding
constraint (83-84% of limit against KL's 68-75%): it is the only
criterion measuring a DISCRETE consequence, so it does not average
out over 8192 positions the way KL and mass displacement do.
Decode, two sessions, interleaved blocks, per-arm minimum: baseline
35.16-35.81 tok/s, candidate 40.52-40.79, GPU 26.87-26.97 -> 23.43-
23.56 ms/token = 1.146x. The prediction registered beforehand from
the byte ledger alone (957 MB of 5.985 GB removed, 16.0%) was
1.15-1.16x — accurate to ~1% but OPTIMISTIC: the GPU measure lands
just below the band. Conversion 0.79-0.80 of bytes to GPU time,
against a 1.190x pure-bandwidth roofline.
Harness: q2a_decode_bench could time KDA and the head but not MLA or
shared, so a four-family map was judgeable for quality and not for
speed; it now shares one scope-parsing surface with the quality probe,
and a head-only map no longer silently times two identical arms. Every
report carries the balanced-v1 verdict beside the strict v3 one, so a
claim of admissibility is not re-derived from the bank by hand.
Evidence in ~/chris-models/kimi-quality-bank-provenance/: three fresh
reports, both bench session logs, the guarded chain, and QUARANTINE.md
recording two flat-instrument signatures — uniform-flat (kl exactly
0.0, coverage exactly TOP_N/vocab) and mid-run partial collapse
(coverage far under the bank's floor, top10 p99 exactly 1.0). Both
were refused by CoveredMass. An up-front guard cannot protect a
25-minute run, so health is now checked after every stage.
Docs: docs/kimi-precision-topology.md gains the whole-decoder chapter.
chrishayuk
marked this pull request as ready for review
August 31, 2026 21:22
`use super::kimi_layer::ExpertEncoding;` was inserted above `use super::grouped_experts::…` when MLA learned its projection encoding, which rustfmt orders the other way. The larql-compute-metal format gate has been red on this branch since a477765: that session ran the larql-vindex gates for a larql-vindex change and did not run this crate's, and the flags differ per crate. Gates for larql-compute-metal, all green: fmt, clippy --all-targets --no-deps -D warnings, lib tests (519), integration tests.
chrishayuk
added a commit
that referenced
this pull request
Sep 1, 2026
A capture is process-wide, and its test assumed an exclusivity it never had: a sibling test projecting on another thread lands inside the capture window. Six calls recorded for five issued turned larql-vindex red on Windows at 8ac0b7a, after fourteen green runs on an identical image with an identical test count — neither #364 nor #371 changed anything that compiles on Windows. Calls are now selected by operand address (`WeightRows::primary_addr`), and the two tests that OPEN a capture share one lock rather than one each. `record` also probed the lock with `try_lock` and returned on contention, reasoning that a racing worker "would only ever be inside a projection this call already recorded". Nothing enforces that: `parallel6` exists to run six independent branches on separate pool workers, and those issue distinct projections. That path is LATENT, not live — parallel6 has no production call site and the MoE fan-out reaches `project_rows` directly rather than through `project` — so no shipped measurement is known to have lost a call. A recorder whose correctness rests on no caller ever fanning out is still the wrong shape. An AtomicBool now gates the idle path, cheaper than the lock probe it replaces, and the operand is built before the lock so the held section is one push. Reproduces locally: both capture tests fail together in parallel and pass under --test-threads=1.
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.
What
The fourth byte family joins the representation vocabulary, and the fifth is
refused on economics. MLA projections and shared-expert branches become
encodable scopes; the composed four-family map is judged at 8,192 positions on
both banks under
kimi-logit-balanced-v1and benchmarked.Five families make up the decoder's BF16 read per token — routed experts 49.2 %,
KDA projections 25.2 %, output head 12.6 %, MLA projections 6.8 %, shared
experts 6.1 %. Four are now admitted under one frozen contract.
The engine change
MlaDeviceWeights/DeviceAttn::Mlacarry a projection encoding (four wideprojections only;
kv_a_normstays f32, the latent cache always holds decodedvalues); all three MLA grouped dispatches plus the at-offset cache write select
their kernel by encoding.
encoding-aware since the expert rung; only the bytes were BF16.
could not see MLA or shared, so a four-family map could be judged for quality
and not for speed. It now shares one scope-parsing surface with the quality
probe, and a head-only map no longer silently times two identical arms.
v3verdict and the
balanced-v1verdict travel in every report, so a claim ofadmissibility no longer has to be re-derived from the bank by hand.
The measurement
MLA depth curve — the fourth family with the same shape every other family showed:
The tower's token-distance curve ACCUMULATES (2.6e-4 → 2.9e-3) where the late
cells' does not. Scope chosen by the jump rule: MLA{23,26}, non-contiguous
by design.
Shared experts refused on economics, not capability. Their dispatch has been
encoding-aware since the expert rung, so admitting them costs no kernel work:
~90x worse per byte. The pair {24,25} even composes sub-additively (1.09e-3 vs
1.24e-3 solo) and still loses. The first refusal in this programme that is an
optimizer's judgement rather than an engine limitation.
Authority — both banks, 8,192 positions,
kimi-logit-balanced-v1: PASS, nofailed criterion.
MLA{23,26} is behaviourally absorbed. On the held-out bank both max
statistics are IDENTICAL to the three-family map to four decimals — the worst
single overturn and the worst single routing displacement in 8,192 positions are
the same events, unchanged, after adding a family. Counts move ≤ 2 %. On the
selection bank the worst top-1 severity fell 0.094 → 0.055 while the flip count
went 130 → 129: one position reshuffling, not an improvement, and not claimed as
one.
The route budget is the binding constraint (83-84 % of limit against KL's
68-75 %). It is the only criterion measuring a discrete consequence — which
experts got selected — so it does not average out over 8,192 positions the way
KL and mass displacement do.
Decode — the cost model scored against the machine. Prediction registered
BEFORE the run from the byte ledger alone: 957 MB of the 5.985 GB per-token BF16
read removed (16.0 %), predicted 1.15-1.16x.
Measured 1.146x GPU, 1.139-1.153x wall. The prediction was accurate to ~1 %
but on the optimistic side — the GPU measure sits just below the band, not
inside it. Score the GPU column: it is stable to 0.05 ms across blocks while
wall carries 1-6.6 ms/token of intermittent non-GPU overhead. Conversion:
16.0 % of bytes removed → 12.7 % of GPU time removed, 0.79-0.80, against a
1.190x pure-bandwidth roofline.
Instrument hazards catalogued
Two flat-instrument episodes were diagnosed and are frozen as evidence under
kimi-quality-bank-provenance/QUARANTINE.md:kl_p99exactly 0.0, coverage exactlyTOP_N/vocabtop10_mass_displacedp99 exactly 1.0The
CoveredMasscriterion refused both — a run that could only "pass" by beingblind is exactly what it exists to catch. Root cause: the probe held a third
full stack (
null_partner, ~17 GB of wired attention banks) needed only by the2-minute null arm through the entire measurement. It is now dropped immediately
after the null arm, and the authority chain checks instrument health after
EVERY stage rather than only up front.
Gates
All
larql-vindexCI gates green, verified on an ISOLATED worktree holding HEADplus only this diff — the shared worktree currently carries another in-flight
change whose modules are not yet declared, so a gate run there would not have
been attributable:
Note for a follow-up, not fixed here:
cargo clippy --features gpu— which CI doesNOT run — reports 4 pre-existing errors in
kimi_moe_metal/grouped/represent/.GPU-gated test code is currently unlinted by CI. A fifth, in the file this PR
touches (a condition duplicated with
is_empty()), is fixed.What this opens
Four byte families admissible under one frozen contract; the fifth declined on
bytes-per-behavioural-cost. Q8_0 was the INSTRUMENT that mapped the topology,
not the destination — every family showed the same late-plateau / interior-cliff
shape, which is what makes a search tractable. The manual phase ends here.
BALANCED-SEARCH-2 optimizes codec choice under the vector of behavioural
constraints, not a scalar bytes-per-KL, with the full-bank composed gate
authoritative.