Skip to content

Opt-in exact verify mode for speculative batches (COLI_EXACT_VERIFY=1) - #1395

Open
rybruscoe wants to merge 1 commit into
JustVugg:devfrom
rybruscoe:exact-verify-689
Open

rybruscoe wants to merge 1 commit into
JustVugg:devfrom
rybruscoe:exact-verify-689

Conversation

@rybruscoe

Copy link
Copy Markdown

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 separate if; the else is 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 in TEST_BINS), the two gated branches in c/colibri.c, four lines in the Makefile.

Token-exact check. glm_tiny oracle, decode mode, DRAFT=4, 5 runs each:

matching tokens tok/s (median of 5)
DRAFT=4 20/20 9090
DRAFT=4 COLI_EXACT_VERIFY=1 20/20 5657

Measured 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-c passes; 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.

…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.
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