mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-03 19:03:30 +07:00
[PR #2591] [CLOSED] [Engine] Preserve target probabilities in gated MTP #4152
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#4152
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/2591
Author: @KeyanHu-git
Created: 10/15/2026
Status: ❌ Closed
Base:
main← Head:fix/2028-probability-gate📝 Commits (2)
6318dd0spec: account for gated MTP proposals during verification611db6bdocs: illustrate gated MTP sampling and validation📊 Changes
45 files changed (+7325 additions, -124 deletions)
View changed files
📝
CMakeLists.txt(+30 -0)➕
bench/results/2026-10-18-gated-mtp/ANALYSIS-PROTOCOL.md(+7 -0)➕
bench/results/2026-10-18-gated-mtp/README.md(+84 -0)➕
bench/results/2026-10-18-gated-mtp/analyze.py(+305 -0)➕
bench/results/2026-10-18-gated-mtp/diagnostics/token12-counterfactuals.json(+315 -0)➕
bench/results/2026-10-18-gated-mtp/diagnostics/token12-trace.json(+1113 -0)➕
bench/results/2026-10-18-gated-mtp/diagnostics/token12.md(+39 -0)➕
bench/results/2026-10-18-gated-mtp/figures/plot-data.json(+35 -0)➕
bench/results/2026-10-18-gated-mtp/figures/proposal-flow.png(+0 -0)➕
bench/results/2026-10-18-gated-mtp/figures/render.py(+99 -0)➕
bench/results/2026-10-18-gated-mtp/figures/throughput.png(+0 -0)➕
bench/results/2026-10-18-gated-mtp/gsm8k-partial.json(+38 -0)➕
bench/results/2026-10-18-gated-mtp/manifest.json(+1607 -0)➕
bench/results/2026-10-18-gated-mtp/measurements.json(+2098 -0)➕
bench/results/2026-10-18-gated-mtp/model-assets.json(+108 -0)➕
bench/results/2026-10-18-gated-mtp/pairs.csv(+101 -0)📝
docs/DETAILS.md(+12 -1)📝
include/strata/core/expert_source.hpp(+1 -1)➕
include/strata/core/gated_proposal.hpp(+128 -0)📝
include/strata/core/mtp.hpp(+7 -2)...and 25 more files
📄 Description
Problem and result
With
STRATA_SPEC_PROB=1, the confidence gate selects drafts using the probability of the token it just drew. The original verifier still uses the unfiltered q, and a failed gate becomes a plain target sample. This biases the output toward the draft head's preferred tokens.This patch keeps the confidence gate and accounts for the missing proposal mass explicitly. It also keeps CPU expert arithmetic independent of how many tokens share a speculative window, so the verifier samples the singleton target distribution.
For
p=(0.5,0.5),q=(0.875,0.125)and threshold0.5, the original gate emits(0.5625,0.4375); the repaired gate emits(0.5,0.5).Related discussion
Refs #2028. Thanks to KarlGrier for the report and derivation. This updates the existing #2591 implementation to v0.2.1 (
90767252, engine 0.1.46) following the tracker reset.Approach
The proposal packet retains q on admitted tokens without renormalizing it; call this measure μ. A failed draw becomes an explicit NULL row. Offered tokens use
min(1,p(D)/μ(D)); rejection and NULL sample the normalized positive part ofp−μ. A row with no attempted proposal remains an ordinary bonus sample.CLI and serial serve share the packet builder. Attempt counts and context limits are decided at the producer boundary. Suffix eligibility uses committed context and request-fixed policy statistics. CPU dispatch preserves singleton arithmetic while retaining shared weight decoding where it gives the same result.
The 0.2 port preserves Trellis/Hadamard handling, per-job expert layouts and cold-read batching. Both ready and cold-read job submissions carry the arithmetic mode. ARM builds retain their native singleton arithmetic rather than referencing x86 kernels. Default exact-match drafting remains the default; explicit
topgating remains available.Validation
Passed:
gated_proposal_test: 266 checks, including macOS ASAN/UBSAN.spec_admission_testandSTRATA_SPEC_PROB_GATE=top spec_admission_test top: 900 Top cases and 2,700 μ-packet cases per configuration, with the original biased rule as a negative control.HIP_VISIBLE_DEVICES=1 STRATA_OLD_SAMPLER=0 STRATA_SAMPLER_ONE_BLOCK=0 spec_proposal_parity: 432 rows, zero mismatches against an independent CPU oracle on RX 7900 XTX.native_arithmetic_parity: 4,866,048 finite bitwise comparisons in each of eight Windows configurations, including Trellis formats and Hadamard-folded inputs.strata --version(0.1.46-metal).Prompt, seeds, binary/library hashes, per-position distributions and figure source. The six-run numerical probe generated 72 tokens in 115.47 seconds. Singleton controls advance one token at a time; they do not re-prefill the whole prefix.
Failed: No remaining failure in the checks listed above. During preparation, the Metal link exposed two x86-only references; architecture-specific dispatch fixes them. An initial GPU test selected the integrated GPU; the reported run explicitly selects the RX 7900 XTX. These failed setup attempts are retained in the local experiment record.
Not run: CUDA, SYCL and Metal model execution; a new full GSM8K evaluation; a 0.2.1 throughput benchmark.
Limits
The repaired proposal path supports serial generation on one CUDA/HIP device, with lookup-chain, adaptive swaps and PCIe sharing off. Unsupported combinations report an error. SYCL and Metal compile but do not execute this proposal path.
The numerical fixture resolves the earlier token-12 target-probability discrepancy. It does not establish an aggregate model-quality score or explain the later long reasoning trajectory. The previous 100-pair speed measurements remain results for the older engine, not 0.2.1 performance claims.
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.