mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-03 19:03:30 +07:00
[PR #3416] [Engine] Preserve target probabilities in gated MTP #4627
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#4627
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/3416
Author: @KeyanHu-git
Created: 10/20/2026
Status: 🔄 Open
Base:
main← Head:codex/2591-v021-validated📝 Commits (6)
470d558fix: preserve target probabilities in gated MTP on 0.25469c3efix: apply in-request draft costs only after their counters commite19ea23docs: make delayed draft feedback measurements reproducible093e987docs: keep each benchmark request on one record lined7d4319merge main while preserving gated window preparation and progress reportingea1aab8bench: record uninstrumented paired comparison on current main📊 Changes
60 files changed (+18774 additions, -126 deletions)
View changed files
📝
CMakeLists.txt(+30 -0)➕
bench/results/2026-10-20-gated-mtp-v021/README.md(+44 -0)➕
bench/results/2026-10-20-gated-mtp-v021/code-manifest.json(+31 -0)➕
bench/results/2026-10-20-gated-mtp-v021/contracts.json(+87 -0)➕
bench/results/2026-10-20-gated-mtp-v021/cuda-host-tests.txt(+31 -0)➕
bench/results/2026-10-20-gated-mtp-v021/default-control.json(+26 -0)➕
bench/results/2026-10-20-gated-mtp-v021/final-verification.json(+180 -0)➕
bench/results/2026-10-20-gated-mtp-v021/manifest.json(+290 -0)➕
bench/results/2026-10-20-gated-mtp-v021/plot.py(+25 -0)➕
bench/results/2026-10-20-gated-mtp-v021/singleton.json(+342 -0)➕
bench/results/2026-10-20-gated-mtp-v021/sycl-host-tests.txt(+32 -0)➕
bench/results/2026-10-20-gated-mtp-v021/target-agreement.png(+0 -0)➕
bench/results/2026-10-20-gated-mtp-v021/token12.json(+1115 -0)➕
bench/results/2026-10-22-gated-mtp-cost-delay/README.md(+33 -0)➕
bench/results/2026-10-22-gated-mtp-cost-delay/delay-measurements.json(+700 -0)➕
bench/results/2026-10-22-gated-mtp-cost-delay/final-measurements.json(+443 -0)➕
bench/results/2026-10-22-gated-mtp-cost-delay/flow.png(+0 -0)➕
bench/results/2026-10-22-gated-mtp-cost-delay/recompute.py(+25 -0)➕
bench/results/2026-10-22-gated-mtp-cost-delay/speed.png(+0 -0)➕
bench/results/2026-10-22-gated-mtp-cost-delay/summary.json(+156 -0)...and 40 more files
📄 Description
Released in 0.2.7; AMD validation
Niko ported this work into 0.2.7 with authorship preserved. I tested release
5e8a4ccaon a Ryzen 5 7600X and RX 7900 XTX with Coder IQ1_M. The HIP build, proposal/admission and draft-policy tests, eight CPU arithmetic configurations, and GPU proposal parity passed.Performance of the fix: same-mode comparison on 0.2.2
The direct before/after comparison used probabilistic pick sampling in both builds: original
011c9e60versus the fix atd7d43198. Across 48 requests in 24 randomized pairs with diagnostics off, English point estimates were −0.24% and −0.25% at temperatures 0.6 and 1.0. Repetition was +2.64% and −1.90%, respectively. All four 95% intervals include zero: these measurements establish neither a consistent speedup/slowdown nor performance equivalence. Full measurements and reproduction details.Release runtime validation: different-mode comparison on 0.2.7
The table below compares default drafting with opt-in probabilistic drafting. Its +8.96% English result is a difference between modes on this workload, not an estimate of the speedup caused by the fix.
A randomized paired run compared the same release binary with
STRATA_SPEC_PROB=0(default) andSTRATA_SPEC_PROB=1(repaired pick mode), with identical model, cache and sampling settings. Four paired blocks covered English and repetition at temperatures 0.6 and 1.0, for 32 measured requests of 256 tokens. Timing and tracing diagnostics were off;--lookup-chain 0 --adapt-swaps 0 --pcie-frac 0kept the repaired path eligible.Changes are geometric means of paired throughput ratios between the two complete modes. They are retained as release observations and are not attributed to the fix. No new language-model accuracy score is claimed.
The first run hit a Windows result-file replacement error after 31 requests. I retained those records and reran the entire final paired block with its original order and seeds, saving immutable snapshots. The table uses the first three complete blocks plus the replacement fourth block. Total measurement time including recovery was about 11 minutes.
Release configuration
The tested opt-in path uses one RX 7900 XTX with serial generation,
STRATA_SPEC_PROB=1,STRATA_SPEC_PROB_GATE=pick, and--lookup-chain 0 --adapt-swaps 0 --pcie-frac 0. In 0.2.7, unsupported combinations warn and fall back to the older acceptance rule. The recorded runs were checked for that fallback warning at startup and after warmup; none occurred.A follow-up run on October 28 completed four more 256-token requests (English and repetition at temperatures 0.6 and 1.0) in 70 seconds with the repaired mode enabled. The complete log contained no fallback warning. These requests are a separate runtime check and are not included in the paired speed table.
The material below records the original PR and earlier-version experiments. The release validation above is the current hardware result.
Original proposal and historical validation (0.2.1–0.2.2)
Problem and result
With
STRATA_SPEC_PROB=1, the confidence gate filters a token drawn from q, but the original verifier uses the unfiltered q. Treating a failed gate as a plain target sample then changes the output distribution. For example, withp=(0.5,0.5),q=(0.875,0.125)and threshold0.5, the original rule emits(0.5625,0.4375)instead of(0.5,0.5).This PR accounts for the gate in the proposal distribution, preserves the target's singleton CPU arithmetic across speculative window sizes, and lets the draft policy learn within a request without immediately feeding speculative timing back into reused random counters.
Related discussion
Refs #2028; continues #2591, originally ported to v0.2.1 (
90767252, engine 0.1.46). Thanks to KarlGrier for the report and derivation. This replacement follows the intake bot's guidance after GitHub rejected reopening #2591.Approach
Proposal and verification. Keep q's mass on eligible tokens without renormalizing it; call this measure μ. A filtered draw becomes NULL. Accept an offered token D with
min(1,p(D)/μ(D)); rejection and NULL sample the normalized positive part ofp−μ. A position with no attempted proposal remains a plain target sample. CLI and serial serve use the same packet builder.Target arithmetic. CPU expert dispatch keeps the singleton arithmetic order when verifying multiple rows. It retains shared weight decoding where the result is unchanged, including Trellis/Hadamard handling and cold-read jobs. ARM retains its native arithmetic path.
Policy feedback. Freezing the entire request's policy avoids immediate feedback from speculative draws, but also freezes its cost estimates. In the diagnostic workload, the frozen version chose mean lookup windows of 5.87 for the first repeat request and 3.38 for the second. The submitted policy updates committed acceptance/probe counts immediately and delays round costs until all random counters they depend on are behind the committed position. Its mean windows were 4.31 and 4.05.
A cost observation includes both the verified window and the next MTP draft. With starting position p, window length T, a accepted drafts and MTP bound S, it is held through
max(p+T−1, p+a+1+S)and applied only after the committed position passes that boundary. Applying a held cost does not count the same probe twice. This dependency boundary is central to the sampling argument.Validation
Historical PR code revision:
d7d43198, merged with main011c9e60(0.2.2 / engine 0.1.47). The subsequent benchmark-only commit adds the raw uninstrumented comparison below.Passed:
d7d43198, full CUDA (sm_120), Windows HIP (gfx1100), SYCL and Metal builds passed. The local policy test passed all 25 assertions. The Windows contract run passed packet, pick-law and top-law checks, all eight arithmetic configurations, and HIP proposal parity (432 rows).5469c3e0, independently rebuilt and ran the policy test on macOS: all 25 assertions passed, including delayed publication and probe accounting. The Windows experiment records report passingdraft_policy_test,gated_proposal_test(266 checks), and spec-admission default/pick/top tests.470d558b, CUDA, HIP, SYCL and Metal engine builds passed. The arithmetic test performed 4,866,048 finite bitwise comparisons in each of eight Windows configurations; HIP proposal parity covered 432 rows with zero oracle mismatches.Historical uninstrumented comparison on 0.2.2
U is unmodified main
011c9e60; A is this PR's final delayed-feedback implementation atd7d43198. This A label differs from the frozen-policy arm in the older diagnostic data. Both use Coder IQ1_M on Windows / RX 7900 XTX, a 10 GiB resident budget, identical expert/KV allocation, and the same probabilistic pick gate. Diagnostic switches were off. Engine order and workload order were randomized; seeds and inputs were paired. Every measured request produced 256 tokens.Six complete blocks, 48 requests, 843.76 seconds; all completed pairs are included. English point estimates are near zero; repeated-text results change sign between temperatures. These intervals do not establish equivalence or a stable speedup. All request timings, outputs, binary hashes, exact inputs and analysis script.
Earlier diagnostic rounds used
STRATA_DECODE_TIMING=1and informed the window-selection investigation. Their 336 request records and original revision labels remain in the diagnostic archive.Failed: The uninstrumented runner hit a Windows
PermissionErrorreplacing its result file after the final measured request. Its final handler retained all 48 request records and 24 pairs; two further planned blocks did not run. An independent post-run check confirmed that all test engines had exited and port 8080 was absent, as it was before the run. The archived runner status remains failed.An earlier diagnostic attempt exhausted Windows commit headroom and lost the intended RAM residency budget. It was stopped before a complete cross-arm block; the completed final round was run separately with residency checks.
Not run: CUDA/SYCL/Metal model execution; a new full GSM8K evaluation. The earlier synthetic distribution-test claims have not been independently reproduced in this review; statistical agreement alone is not a proof of the feedback rule.
Limits
The repaired proposal path supports serial generation on one CUDA/HIP device, with lookup-chain, adaptive swaps and PCIe sharing off. The historical PR rejected unsupported combinations. Release 0.2.7 instead warns and falls back to the older acceptance rule; the release validation above uses an eligible configuration. Default exact-match drafting remains the default; explicit
topgating remains available.The numerical fixture checks target probabilities at the first divergence; it does not measure aggregate model quality or explain the entire later reasoning trajectory. Fixed lookup T=5 was faster on the tested repeat workload (C/T5: −9.55%, interval [−12.58, −6.51]); that result identifies remaining window-selection work without changing the default in this PR.
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.