Skip to content

MLA-SHARED-1: the four-family map earned at both banks — MLA absorbed, shared experts refused on economics - #364

Merged
chrishayuk merged 3 commits into
mainfrom
mla-shared-1
Sep 1, 2026
Merged

MLA-SHARED-1: the four-family map earned at both banks — MLA absorbed, shared experts refused on economics#364
chrishayuk merged 3 commits into
mainfrom
mla-shared-1

Conversation

@chrishayuk

@chrishayuk chrishayuk commented Aug 31, 2026

Copy link
Copy Markdown
Owner

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-v1 and 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

  • MLA encoding threading — the fourth verbatim application of the pattern:
    MlaDeviceWeights/DeviceAttn::Mla carry a projection encoding (four wide
    projections only; kv_a_norm stays f32, the latent cache always holds decoded
    values); all three MLA grouped dispatches plus the at-offset cache write select
    their kernel by encoding.
  • Shared experts needed zero kernel work — their dispatch has been
    encoding-aware since the expert rung; only the bytes were BF16.
  • The bench harness learned the same scopes — it timed KDA and the head but
    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.
  • The report carries the contract it is judged by — both the strict v3
    verdict and the balanced-v1 verdict travel in every report, so a claim of
    admissibility 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:

L23 5.75e-5  |  L26 1.24e-4  (plateau)
L19 8.43e-4  (the 15x jump)  |  L15 1.06e-3  |  L11 3.70e-3
all 7 MLA layers  2.61e-2  — 450x the L23 cell

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:

scope cost bytes saved cost per MB
MLA L23 5.75e-5 27.3 MB 2.1e-6
shared L25 1.240e-3 6.6 MB 1.9e-4

~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, no
failed criterion.

criterion limit three-family four-family budget
selection kl p99 3.5e-3 2.4006e-3 2.3791e-3 68.0 %
top-1 mass displaced max 0.12 9.415e-2 5.546e-2 46.2 %
top-10 mass p99 0.12 7.134e-2 6.465e-2 53.9 %
route mixture p99 / max 0.15 / 0.25 0.1258 / 0.1993 0.1248 / 0.1993 83.2 / 79.7 %
held-out kl p99 3.5e-3 2.6378e-3 2.6174e-3 74.8 %
top-1 mass displaced max 0.12 5.8313e-2 5.8313e-2 48.6 %
route mixture p99 / max 0.15 / 0.25 0.1262 / 0.2099 0.1257 / 0.2099 83.8 / 84.0 %

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.

session baseline candidate wall GPU ms/token GPU speedup
1 35.81 tok/s 40.79 tok/s 1.139x 26.87 → 23.43 1.147x
2 35.16 tok/s 40.52 tok/s 1.153x 26.97 → 23.56 1.145x

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:

signature reading
kl_p99 exactly 0.0, coverage exactly TOP_N/vocab the GPU completed command buffers without executing them
coverage far under the bank's floor, top10_mass_displaced p99 exactly 1.0 the instrument degraded PART WAY THROUGH a ~25 minute run

The CoveredMass criterion refused both — a run that could only "pass" by being
blind 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 the
2-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-vindex CI gates green, verified on an ISOLATED worktree holding HEAD
plus 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:

fmt · check --all-targets · check --examples · check --features gpu --all-targets
clippy --all-targets -D warnings · e0_generation_boundary (10)
cargo test -p larql-vindex (3418 lib + all integration binaries)
benches compile · gpu lib tests (3469 passed, 4 ignored)

Note for a follow-up, not fixed here: cargo clippy --features gpu — which CI does
NOT 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.

…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 chrishayuk changed the title MLA-SHARED-1 (draft): fourth family threaded, MLA scope chosen, shared rejected on economics — authority owed MLA-SHARED-1: the four-family map earned at both banks — MLA absorbed, shared experts refused on economics Aug 31, 2026
@chrishayuk
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
chrishayuk merged commit 8ac0b7a into main Sep 1, 2026
29 of 33 checks passed
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.
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