b70-optimization-lab

Q6_K M=6 fused DFlash top-1 production record

Date: 2026-07-13

Outcome

The guarded Q6_K DFlash decoder LM-head fusion produced a confirmed strict single-B70 record. It computes only decoder rows 1 through 5, reduces them to five greedy token IDs on device, and avoids materializing/copying five full 248,320-token logit rows.

The confirmed BMG AOT result was:

The first strict candidate also passed at 47.114289 tok/s. The exact AOT control, changing only GGML_SYCL_XE2_Q6_M6_TOP1=0, measured 44.220504 tok/s. The confirmation is therefore 8.14% faster than the exact control and 8.05% faster than the previous matching 44.255388 tok/s LocalMaxxing record.

Why this was slow

Native DFlash decodes a six-row noise block, but row 0 is not sampled. The old path still projected all six rows through the Q6_K output weight, wrote full logits, ran a separate argmax, copied results across the host boundary, and constructed ordinary sampler candidates. Cycle timing put the ordinary warm width-6 draft block near 8.42-8.54 ms.

The production fusion expands the Q6_K output tensor once into signed int8 quants, int8 subscales, and fp16 superblock scales. A five-row kernel then quantizes the useful activations, reuses each weight slice across all rows, and performs lowest-token-ID top-1 reduction without writing logits. Warm A/B/A/B timing reduced the width-6 draft block to 7.18-7.20 ms, a 14.7-15.7% cycle-boundary reduction. Warm fixed-prompt throughput moved from 75.88/76.30 control to 77.74/77.81 tok/s candidate.

Exactness and safety contracts

The optimized matcher is default-off and requires all of the following:

The compact host boundary is enabled only for native DFlash with one sequence, n_max=5, n_min=0, p_min=0, and the fixed raw-argmax sampler semantics. Non-matching graphs execute the ordinary path. A successful fused dispatch marks the ordinary argmax skipped only after the fused enqueue succeeds.

An independent safety audit found three pre-promotion gaps. They were fixed before AOT promotion:

  1. The rows1..5 view now must have the matched argmax as its only consumer.
  2. A failed compact read rolls back the just-decoded noise block, permanently disables compact mode, and explicitly reruns the ordinary-logits graph. Rollback/retry failure throws instead of reading absent logits.
  3. Generic SYCL argmax and the fused reducer now use the same lowest-token-ID finite-tie contract. Synthetic oracles cover full-vocabulary zero ties and crossing ties 1/256, 255/256, and 0/248319.

The diagnostic forced-read-failure run completed without a missing-logits access and retained the deterministic hash 2a931ff83e89f577315a59bef7cdf6938145f3eceb3c9996d78b065bcc17bd71 and acceptance 49/63, mean draft length 4.50.

Production fixture and comparator

The real six-row normalized DFlash activation fixture is:

The five exact production token IDs are 12305, 198, 727, 369, 36951. The final comparator passed those rows, the actual sampler IDs, the full finite tie oracle, and the stride-crossing tie oracle. Its last short run measured a 2450.10 us fused boundary and passed the <2.5 ms micro gate.

Memory and startup

The expanded output pack is retained in addition to raw Q6_K:

This pack currently improves decode but costs startup work. Persisting it as a trusted native artifact is the next iteration-speed improvement.

Strict run identity

Artifacts

The patch snapshot was extracted from a shared dirty protected worktree using Q6/DFlash/argmax-specific hunks. Review it against the recorded source commit and active worktree before applying it elsewhere.