mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-03 19:03:30 +07:00
[PR #1281] [CLOSED] sampler: coupled drafts with Gumbel-max picks (STRATA_SPEC_GUMBEL=1, opt-in): +7 points draft acceptance, +9% output at temperature 1.0 on Strix Halo #3356
Labels
No labels
needs-format
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Niko1221/Strata#3356
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/Niko1221/Strata/pull/1281
Author: @routhjim
Created: 10/6/2026
Status: ❌ Closed
Base:
main← Head:gumbel-coupled📝 Commits (3)
0b597a7sampler: Gumbel-max coupled drafts (STRATA_SPEC_GUMBEL=1, opt-in)3787d0cdocs: coupled drafts with Gumbel-max picks (STRATA_SPEC_GUMBEL), measured on Strix Halo6c5715ddocs: the coupled-draft measurement is the single-request path; --batch slot drafters do not couple (#1281 review)📊 Changes
5 files changed (+183 additions, -17 deletions)
View changed files
📝
docs/DETAILS.md(+16 -0)📝
include/strata/core/coupled_draft.hpp(+5 -0)📝
include/strata/kernels/sampler.hpp(+1 -0)📝
src/kernels/cuda/sampler.cu(+60 -15)📝
src/kernels/sampler_parity.cpp(+101 -2)📄 Description
Under sampling,
STRATA_SPEC_COUPLED=1makes the draft layer sample its guess with the target's chain and the target's Philox draw. Both sides then pick by walking one uniform over their own candidates sorted by probability. When the draft's top_k / top_p list differs from the target's by even one token, every later interval shifts, and the two picks land on different tokens even where the distributions mostly agree.This PR adds an opt-in Gumbel-max pick that does not have that problem. With
STRATA_SPEC_GUMBEL=1both the target and the coupled draft pick argmax_i p_i / E_i, where E_i ~ Exp(1) comes from a hash of (seed, counter, token id). That is exactly argmax(log p_i + Gumbel_i), so it is still an exact sample of p. A token gets the same noise in the draft's draw and in the target's, whichever other tokens survived either cut, so the two agree on the tokens they share. Verification is still exact-match against the target's pick: the text is a sample from the same distribution as before, and only the number of accepted drafts changes.What changes
src/kernels/cuda/sampler.cu:gumbel_exp(seed, counter, token)(splitmix64 to Exp(1)).sampler_kernelandsampled_tail_warp, which serves the split, one-block and coupled-draft paths.sub_to_id, so the draft-vocab subset does not break the coupling.include/strata/kernels/sampler.hpp:SamplerParams::gumbel. It sits in the struct's existing padding, sosizeofis unchanged (64 bytes).STRATA_SPEC_GUMBEL=1is read once on the host.sample_tokensapplies it to the target's pick, andcoupled_stage_kernelwrites it into the drafter's device copy of the params, so the captured round graphs see it.sampler_parity: three new checks, run on all three sampled paths by the existing ctest entries:docs/DETAILS.mdnext to the other opt-in switches, and a note ininclude/strata/core/coupled_draft.hpp.Measured on a Ryzen AI Max+ 395 (Radeon 8060S, gfx1151, 128 GB, Linux 7.2, ROCm 7.14.1, the iGPU alone).
82f46a8plus this PR, built perdocs/STRIX_HALO.mdwith the section-4 defaults andSTRATA_PF_FUSED_KQ=1, Unsloth UD-Q4_K_XL,--mmap-experts --expert-cache auto --spec 4 --mtp mtp/rt --lookup-chain 3 --kv int8(the base model's draft layer, Q2_0 experts)./metricstotals around each request; timings fromSTRATA_DECODE_TIMING=1.STRATA_SPEC_COUPLEDoff (default)STRATA_SPEC_COUPLED=1 STRATA_SPEC_GUMBEL=1A window costs the same: drafting by sampling adds about 0.3 ms of 64. The gain is entirely more tokens per verify window. ± is the standard error over the requests.
Output stays an exact sample: with the switches on, three seeds give three different texts, and the same seed twice gives the same text.
Not tested:
--batch-mtpslot drafters;STRATA_SPEC_COUPLED=1on its own with this draft layer: on this box with a different draft head it measured slightly below the default (one arm, within noise), so it is not claimed either way.Measured with the help of Claude (Anthropic).
🤖 Generated with Claude Code
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.