Repository navigation
dsv41 lookup: add TF_DSV41_COPY_DRAFTER ranked band matching, doubling and yield gating - #2638
Conversation
a531aa8 to
69c7d7a
Compare
|
@christopherowen, welcome, and thanks for a careful first PR. The exactness test against
Thanks again; happy to keep going once we know where the code comes from. |
…g and yield gating (ashhart#2638) Extends zig/src/families/deepseek_v41/draft/lookup.zig natively behind TF_DSV41_COPY_DRAFTER=1: - SuffixIndex.matchRanked and proposeRanked rank candidates within the highest matched confidence band by non-overlapping continuation length ((L - len) - end capped at the offer width), match length, and recency, stopping before the query suffix tail so near-tail matches cannot wrap into periodic self-repetition or shadow full-continuation matches in the same band. - Request.doublings grows the lookup offer width from 8 to 15 on full acceptance of a lookup round and resets to 0 on partial rejection or non-lookup rounds. - survivalYield and Planner.altYield gate lookup copy windows against the stream's expected neural draft yield. - Registers TF_DSV41_COPY_DRAFTER in platform/environment.zig, core/profile.zig, docs/environment.md, docs/profiles.md, and records spark-ds41f / vLLM suffix speculative decoding provenance in THIRD_PARTY_NOTICES.md.
69c7d7a to
173d4d5
Compare
|
Thanks for the detailed review, @ashhart — every point here is spot on. I have refactored the PR ( Here are the direct answers to each of your five points and what changed in 1. Provenance, Licensing, and Removing the Translated GPU-Kernel / Batch-Scheduler Structure
2. Native Integration into
|
|
@christopherowen @ashhart, some served numbers from Qwen3.8-27B on a GB10 that bear on the yield gate here. This is the existing core lookup ( Setup: one stream, 192 tokens. Agent class: 8 SWE-agent turns. Chat and code: 4 prompts each. Order A-B-B-A, page cache dropped. Token hashes at T=0 are identical across all arms. Cells are decode tok/s at T=0 / T=1.
No fixed match length is right for every class. A gate of the kind this PR adds, which copies only when the copy's expected yield beats the drafter's, targets exactly that trade. That is why we'd suggest it live in core We are running an offline replay on these prompts (T=0 reference, every proposer's offer at every position, simulated acceptance, priced with the measured verify costs). It includes this PR's ranked match, its 8-to-15 doubling and its yield gate. We'll post which rule wins per class once it is done. We can also run the served cells on a GB10 if that helps. |
|
@christopherowen, thank you for the quick and thorough rework. Folding the three ideas into the existing lookup plan behind one switch is the shape we hoped for, and thanks for being straightforward about where the first version came from.
Thanks again; this is close. |
|
Thanks @ashhart and @jschmied! Rebased onto
|
ec868fe to
38cfc67
Compare
…g and yield gating (ashhart#2638) Extends zig/src/families/deepseek_v41/draft/lookup.zig natively behind TF_DSV41_COPY_DRAFTER=1: - SuffixIndex.matchRanked and proposeRanked rank candidates within the highest matched confidence band by non-overlapping continuation length ((L - len) - end capped at the offer width), match length, and recency, stopping before the query suffix tail so near-tail matches cannot wrap into periodic self-repetition or shadow full-continuation matches in the same band. - Request.doublings grows the lookup offer width from 8 to 15 on full acceptance of a lookup round and resets to 0 on partial rejection or non-lookup rounds. - survivalYield and Planner.altYield gate lookup copy windows against the stream's expected neural draft yield. - Registers TF_DSV41_COPY_DRAFTER in platform/environment.zig, core/profile.zig, docs/environment.md, docs/profiles.md, and records spark-ds41f / vLLM suffix speculative decoding provenance in THIRD_PARTY_NOTICES.md.
|
@christopherowen thanks: the notice and the source comment are gone, the switch implies the plan and is refused with lookup off (with tests), the unused pieces are dropped, the Twin test now fails if no copy round fires, and the CHANGELOG line reads plainly. Two things:
Optional: the lookup-off refusal could name |
|
Updated in
|
…g and yield gating (ashhart#2638) Extends zig/src/families/deepseek_v41/draft/lookup.zig natively behind TF_DSV41_COPY_DRAFTER=1: - SuffixIndex.matchRanked and proposeRanked rank candidates within the highest matched confidence band by non-overlapping continuation length ((L - len) - end capped at the offer width), match length, and recency, stopping before the query suffix tail so near-tail matches cannot wrap into periodic self-repetition or shadow full-continuation matches in the same band. - Request.doublings grows the lookup offer width from 8 to 15 on full acceptance of a lookup round and resets to 0 on partial rejection or non-lookup rounds. - survivalYield and Planner.altYield gate lookup copy windows against the stream's expected neural draft yield. - Registers TF_DSV41_COPY_DRAFTER in platform/environment.zig, core/profile.zig, docs/environment.md, docs/profiles.md, and records spark-ds41f / vLLM suffix speculative decoding provenance in THIRD_PARTY_NOTICES.md.
a47f688 to
df9b2c6
Compare
|
@christopherowen thanks, the provenance line is clear, and the credits and description now read as ideas first tried elsewhere, which closes that point. The refusal now names both variables, with a test. What's left is the served cells. When you or @jschmied can run them on the head:
One optional tidy-up: the lookup-off rule is DeepSeek's own, but it now sits in |
|
@christopherowen @ashhart, sorry, I have to take back the served-cells offer for this PR: there is no DeepSeek-V4.1 checkpoint on our GB10, so we can't run the DSV41 cells. My offer was meant for the core lookup cells on Qwen, and I should have said so. The served cells will need someone with the model. What I promised in my earlier comment is the offline replay. It ran the PR's planner beside a neural drafter on Qwen3.8-27B + DSpine: our core
Copies alone (no drafter), agent: this PR's planner 19.5, core match 5 19.1. The replay's absolute drafter numbers don't match served ones, but its copy-rule deltas did: match 20 → 5 was +6 % simulated against +5 % served on agent, and −6 % against −6 % on chat. Served, match 12 against 20 was +4 to +9 % on agent, with chat and code within ±2.4 %. So on this target a shorter fixed match beats the priced planner. I'd expect the reason to be the drafter beside it: DSpine accepts long runs on its own, so a gate that defers to its yield gives up copies that would have landed. DeepSeek's DSpark may sit differently, which only the served DSV41 cells can show. If useful, I can rerun the replay against |
|
@christopherowen, thanks again. Nothing in the code is outstanding from our side: the provenance, the wiring, the refusals, the Twin test and the CHANGELOG line are all as we asked. With the switch unset, the lookup plan runs exactly as on main. @jschmied, thank you for the replay and for being clear about the checkpoint. Yes, please rerun it against What's left:
Still optional: moving the lookup-off rule from CI hasn't run on this head yet because the workflows need our approval; we'll start them. Once the served cells are in and CI is green, we'll take it through landing after the current release. |
|
@ashhart @christopherowen, here is the replay rerun at It is an offline replay on Qwen3.8-27B with DSpine or DFlash2 beside the lookup, not DeepSeek-V4.1. It uses the T=0 reference of each prompt (8 agent, 4 chat, 4 code), every proposer's offer at every position, and the verify costs we measured on a GB10. The planner model follows Simulated decode tok/s:
The oracle is a per-round greedy choice, not a strict bound; on code it sits below no copies. Copies only, with no drafter: this PR 19.5 / 15.4 / 12.2 (agent / chat / code), core match 5 19.1 / 14.9 / 12.0. The gate can't fire here, since What the yield gate itself does:
So on this target the geometric gate costs nothing on chat and code, where it barely fires. On agent it agrees with the pricing, and both give up the long copies that a fixed core match of 8 to 12 takes: 55.4 against 61.8. I'd still expect DSpark on DSV41 to sit differently, which only the served cells can show. Receipts: |
|
@christopherowen, thanks. Nothing in the code is outstanding: Two things are left before this can land:
Still optional: moving the lookup-off rule out of the shared
|
|
Pushed
|
|
Thanks @christopherowen. The description now says plainly what has and hasn't been measured, and the lookup-off rule lives in DeepSeek's own startup check with one shared helper and a test, so nothing in the code is outstanding. One thing is left: the served DeepSeek-V4.1 cells, now on
|
|
I found a ranked-copy coverage gap on To reproduce, let On M5 Max with Zig 0.17.0, Igor Lessio - AIFLOW LABS |
fc1bba6 to
6323319
Compare
|
Thanks @AIFlowML for the catch and minimal repro. Fixed in
|
6323319 to
c6f3b14
Compare
…g and yield gating (ashhart#2638) Extends zig/src/families/deepseek_v41/draft/lookup.zig natively behind TF_DSV41_COPY_DRAFTER=1: - SuffixIndex.matchRanked and proposeRanked rank candidates within the highest matched confidence band by non-overlapping continuation length ((L - len) - end capped at the offer width), match length, and recency, stopping before the query suffix tail so near-tail matches cannot wrap into periodic self-repetition or shadow full-continuation matches in the same band. - Request.doublings grows the lookup offer width from 8 to 15 on full acceptance of a lookup round and resets to 0 on partial rejection or non-lookup rounds. - survivalYield and Planner.altYield gate lookup copy windows against the stream's expected neural draft yield. - Registers TF_DSV41_COPY_DRAFTER in platform/environment.zig, core/profile.zig, docs/environment.md, docs/profiles.md, and records spark-ds41f / vLLM suffix speculative decoding provenance in THIRD_PARTY_NOTICES.md.
…g and yield gating (ashhart#2638) Extends zig/src/families/deepseek_v41/draft/lookup.zig natively behind TF_DSV41_COPY_DRAFTER=1: - SuffixIndex.matchRanked and proposeRanked rank candidates within the highest matched confidence band by non-overlapping continuation length ((L - len) - end capped at the offer width), match length, and recency, stopping before the query suffix tail so near-tail matches cannot wrap into periodic self-repetition or shadow full-continuation matches in the same band. - Request.doublings grows the lookup offer width from 8 to 15 on full acceptance of a lookup round and resets to 0 on partial rejection or non-lookup rounds. - survivalYield and Planner.altYield gate lookup copy windows against the stream's expected neural draft yield. - Registers TF_DSV41_COPY_DRAFTER in platform/environment.zig, core/profile.zig, docs/environment.md, docs/profiles.md, and records spark-ds41f / vLLM suffix speculative decoding provenance in THIRD_PARTY_NOTICES.md.
…move lookup-off check to env_validate
c6f3b14 to
f8e5ab7
Compare
…g and yield gating (#2638) Extends zig/src/families/deepseek_v41/draft/lookup.zig natively behind TF_DSV41_COPY_DRAFTER=1: - SuffixIndex.matchRanked and proposeRanked rank candidates within the highest matched confidence band by non-overlapping continuation length ((L - len) - end capped at the offer width), match length, and recency, stopping before the query suffix tail so near-tail matches cannot wrap into periodic self-repetition or shadow full-continuation matches in the same band. - Request.doublings grows the lookup offer width from 8 to 15 on full acceptance of a lookup round and resets to 0 on partial rejection or non-lookup rounds. - survivalYield and Planner.altYield gate lookup copy windows against the stream's expected neural draft yield. - Registers TF_DSV41_COPY_DRAFTER in platform/environment.zig, core/profile.zig, docs/environment.md, docs/profiles.md, and records spark-ds41f / vLLM suffix speculative decoding provenance in THIRD_PARTY_NOTICES.md.
|
Thank you @christopherowen. This is merged into main with your commits under your own name, so you're listed as a TensorFold contributor. It ships in the next release, credited to you in the changelog and the release notes. |
Summary
Extends DeepSeek-V4.1's priced lookup planner (
zig/src/families/deepseek_v41/draft/lookup.zig) with native continuation-ranked band matching, adaptive doubling (8 -> 15), and span-aware expected-yield gating (written directly against TensorFold'sSuffixIndex,Planner, anddepth.bestK, following ideas first tried inchristopherowen/spark-ds41f), gated behind the strict environment switchTF_DSV41_COPY_DRAFTER=1(default off;TF_DSV41_LOOKUP_PLAN=1behavior is unchanged when unset):Continuation-ranked band matching (
SuffixIndex.matchRanked/proposeRanked):>= min_match), ranks candidate occurrences by available non-overlapping continuation tokens up to the requested offer width (want), breaking ties by match length and then recency.t.len - m.len) or any image virtual token (>= vbase), preventing short near-tail matches from wrapping into self-repetition when an earlier occurrence in the same band has a full continuation.Adaptive doubling offer width (
8 -> 15):initial_offer = 8(doubled: bool = false).max_rows - 1 = 15(doubled = true) after a lookup round where all offered drafts are accepted (kept >= drafts), and resetsdoubled = falseon any partial rejection or non-lookup round.Span-aware pricing and expected-yield gating (
Planner.altYield,copy_span_base/copy_span_slope):len = 4..7,q = 0.45), keeps i.i.d. geometric survival (copy_yield ~ 0.45..0.82 < 1.0), gating off short cold matches on chat.b >= 1,len >= 8) whenq >= bands[1].prior(0.70) or on a cooldown re-probe (copy_probe_every = 2), prices per-step continuation survival asq_eff = 0.75 + 0.25 * max(q, bands[b].prior)(0.925 / 0.950 / 0.975for Bands 1/2/3, yielding5.76 / 6.40 / 7.16expected drafts atk = 8and10.2..12.4atk = 15). This preventsdepth.bestKandcopy_yield >= p.altYield(r)from rejecting 8–15 and 16–31 token agent/code copies alongside a 3–4 tok/round neural drafter (both on DeepSeek-V4.1's GB10calib-1bb.jsoncurve and in@jschmied's replay), while still dropping back toq(0.467, yield~0.86) immediately after a0-keep miss.Strict environment validation & profile registration:
TF_DSV41_COPY_DRAFTER(0or1) inzig/src/platform/environment.zig(.dsv41,.flag) andzig/src/core/profile.zig(.experimental,deepseek_v41on CUDA).lookup.Settings.checkCopyDrafter/lookupEnabledbetweenzig/src/families/deepseek_v41/draft/lookup.zigandzig/src/families/deepseek_v41/env_validate.zig(moving the family rule out ofplatform/environment.zig's genericrefusal), refusing witherror.InvalidEnvironment(namingTF_DSV41_COPY_DRAFTERandTF_DSV41_LOOKUP) whenTF_DSV41_LOOKUPis blank or off.Verification & Replay Measurements
What has been measured
draft/draft.zig(52/52 tests pass, including all 18 tests inlookup_test.zig):fixtures/lookup-golden.json) withcopy_drafter = false(100% unchanged).matchRanked/proposeRanked).8 -> 15) on DeepSeek-V4.1's TP=2 GB10 calibration curve (calib-1bb.jsonfromfixtures/calib-golden.json) alongside a 3-keep DSpark stream (altYield = 3.0), and reset (doubled = false) on partial rejection.copy_yieldvsPlanner.altYieldgating: blocks short cold Band-0 matches (len = 4..7), opens Band 1 (len = 8..15) alongside a 3-keep DSpark stream, gates off Band 1 after a0-keep miss, re-probes after the 1-skip cooldown (copy_probe_every = 2), and gates off cold Band 1 whenaltYieldexceedscopy_yield(kept = 6).lookup.Proposer+Lanes+Twinexact token-for-token parity againstTwin.serialunder both greedy (null) and stochastic (temperature = 0.85, top_p = 0.9, top_k = 4, seed = 42) sampling, asserting active copy trials and accepted copy drafts (copy_trials > 0andcopy_acc > 0).environment.zig(13/13),env_validate.zig(23/23),profile_test.zig(19/19),profile_line.zig(11/11), andpython3 tools/pr_check.py --pr 2638(0 error(s), 0 warning(s)).Planner+ TP=2 Measured Cost-Table (servedCosts/calib-1bb.json) Replay:TF_DSV41_LOOKUP_PLAN=1(copy_drafter = false)TF_DSV41_COPY_DRAFTER=1(copy_drafter = true)4.00tok/round,82.7tok/s4.00tok/round,82.7tok/s (0false-positive copy rounds)0.0%chat regression (short/miss bands gated off)2.65tok/round,55.1tok/s3.35tok/round,65.6tok/s (8 -> 15doubling + ranked match)@jschmied,#issuecomment-6764291262):50.9/41.5tok/s, eliminating the-6%chat regression frommin_match = 5), and identified that i.i.d. geometric decay (0.70^k/0.80^k) inbestKandcopy_yield >= altYieldturned down 65 of 73 agent matches in Bands 1–2 (8..31tokens), which is resolved infc1bba68eby pricing activeb >= 1(>= 8-token) span continuations withq_eff = 0.75 + 0.25 * max(q, bands[b].prior).What has not been measured yet
token_shaparity againstmainand"draft": false, solo and concurrent, and servedtok/round+ decodetok/son agent, code, and chat prompts): neither our accessible hosts nor@jschmied's GB10 hold a packed DeepSeek-V4.1.exl3checkpoint +TF_DSV41_ASSETSdirectory, so live serveddeepseek_v41GPU cells remain unmeasured pending a machine with that checkpoint loaded.