Conversation
…JustVugg#689) During draft+verify forwards (g_spec_live) the CPU MLA-absorb attention core accumulates its score dot and context dot exactly: integer products binned by exponent, folded into one wide integer, rounded once (exact_dot.h). No summation order, SIMD width or contraction flag can change the bits, so a verify row decides near-ties the same way on every host. Off by default; the default paths are untouched (the exact branch is a separate if, the else is the original code). Not applied on the tq1/g_tq/g_kv8 context paths. Unit test: c/tests/test_exact_dot.c (registered in TEST_BINS): exact vs long-double reference, near-tie rounding, subnormals, NaN/inf propagation; cost 2.5 ns/elem exact vs 0.38 naive at -O3. glm_tiny oracle (decode, DRAFT=4, 5 runs each): token-exact 20/20 with and without the gate; median 9090 tok/s -> 5657 tok/s with COLI_EXACT_VERIFY=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.
Follow-up to #689. Opt-in, env-gated, verify batches only, default paths untouched.
What it does. With
COLI_EXACT_VERIFY=1, during draft+verify forwards (g_spec_live) the CPU MLA-absorb attention core accumulates its two dots (q.k score and p.v context) exactly: every product is formed from the integer mantissas, binned by exponent, folded into one wide integer and rounded once. Summation order, SIMD width and contraction flags can't change the bits, so a verify row decides a near-tie the same way on every host. Off by default, and the exact branch is a separateif; theelseis the existing code, so the default build path doesn't move. The tq1 / TQ / kv8 context paths are left alone.Files.
c/exact_dot.h(the accumulator, header-only, needs__int128),c/tests/test_exact_dot.c(registered inTEST_BINS), the two gated branches inc/colibri.c, four lines in the Makefile.Token-exact check. glm_tiny oracle, decode mode,
DRAFT=4, 5 runs each:DRAFT=4DRAFT=4 COLI_EXACT_VERIFY=1Measured on a box that was also running a training job, so the absolute tok/s wobble run to run; the ratio (about 0.6x) is the number to read. Same tokens either way on this oracle, which is what you'd expect: the exact path only changes bits on near-ties, and the tiny model doesn't produce one in 20 tokens. The number I don't have is a flip caught on the big model at n=64; I don't have the hardware to run GLM-5.2 here, so that check is yours if you want it.
Cost. The tiny model is the worst case for the tok/s hit, since attention is most of its forward; on a real MoE the expert matvecs dominate and the gated dots are a small slice. On the dot itself it's about 7x the float loop at -O3 (2.5 ns/elem vs 0.38, from the unit test).
make test-cpasses; no new warnings.Unit test covers: exact vs long-double reference, near-tie rounding (nearest-even), subnormals, cancellation, NaN/inf propagation matching the float classification.
Happy to move the gate name or narrow the scope further if you'd rather.