Commit Graph
2041 Commits
Author SHA1 Message Date
Niko1221 29d55bd718 DFlash2 batch slots: deferred context when a round has no spare window row (taps parked on the host, replayed on catch-up), draft graphs of all slots launched then finished together, ring log merged 2026-11-02 05:40:37 +01:00
Niko1221 2f608aac30 Merge f-0291-df2-ring (DFlash2 ring log) into f-0291-df2-mgpu; copy_state_from carries the lineage log 2026-11-02 05:32:32 +01:00
Niko1221 72cf167e3b DFlash2 ring log: update the last window's rows when a request ends, quiet small gaps, copy_log_state_from, stats env
A request that ends on EOS or max_new skips the draft that would have made the last accepted window's context rows, so every turn left a hole of a + 1
positions (5 a turn, accumulating) that a later turn resuming after it found blank and the log could not rebuild. The serve loop now updates those rows
(one synchronous context update, ~0.4 ms) before it finishes the request: a four-turn agent loop plus a parked return now rebuilds with 0 rows missing.
The cold line prints only when 64 or more rows of the window are missing. copy_log_state_from(src) moves a lineage's log, tag shadow and epoch with a request
between two drafters (solo <-> a --parallel slot). STRATA_DF2_RING_STATS=1 prints the live log, the stash and each rebuild per request.
2026-11-02 04:18:30 +01:00
Niko1221 96f5227763 DFlash2 ring log: rebuild the draft ring's window from logged context rows after a restore, a rewind or a repeated prefix
The draft ring has 2,064 slots (position mod 2064). A request that resumes below the highest position written (a repeated or rewound prefix, a
parked conversation brought back) found the part of its first draft's window [n - 2047, resume) overwritten by later positions or never written,
and the drafter drafted poorly until it refilled: on an RTX PRO 6000 with the prompt cache on, DFlash2 alone was +14% over MTP on cold and live
turns but +3% on restored prompts and -2% on an exact repeat (acceptance 0.63 and 0.59 against 0.79 and 0.70 with the cache off). The repeat case
printed no warning at all, because the token history was equal.

The K/V of the five layers is a function of one row per position, the quantized hidden_norm output (2560 int8 codes and 80 block scales, 2.9 KB;
the K/V is 40 KB and the taps 51 KB). Every context update now copies that row into a chunked, copy-on-write host log of the lineage (a
pinned staging copy inside the captured graph, moved to the log after the stream sync). begin_request rebuilds, with the same kernels on the
same bytes, every slot of the window below `resume` whose tag does not match (a host shadow of the tags says which): the rebuilt K/V is bitwise
the original update's (dflash2_ring_test: rewind, parked, branch, evicted; 578 rows in 4.0 ms, a whole window of 2042 rows in 12.7 ms).
A lineage replaced by another is moved, not copied, into a stash (STRATA_DF2_LOG_MIB, default 256, oldest evicted); a request whose prefix matches a
stashed lineage swaps it back in; a rewind or branch keeps the old branch as a copy-on-write stash entry. STRATA_DF2_RING_LOG=0 restores the old
behaviour. Rows never logged are reported (cold) instead of silently blank.
2026-11-02 03:55:35 +01:00
Niko1221 6de7c8e315 DFlash2: the MTP chain's cost window and q lists apply only to candidates the MTP drew
With DFlash2 as the drafter the MTP stays loaded as the fallback (use_mtp stays true), and three decisions tested use_mtp where they meant
"the MTP chain drew this round's candidates":
- STRATA_SPEC_COST=1 (a GB10 default): T = clamp(chain_rows, 1, S_mtp), but chain_rows is only written by the MTP chain callback, so with DFlash2
  and no --draft-conf the window stayed at one row (CLI and serve; code_py 175 vs 258 tok/s on an RTX PRO 6000, serve 166-230 vs 283-397).
- STRATA_SPEC_PROB=1, sampled requests: ver.set_spec_q(mtp.spec_q()) judged DFlash2's deterministic candidates against the MTP's stale q lists
  (CLI: 107 of 137 windows), and serve's gated path was not declined for DFlash2.
- the lookup choice read mtp.prob() for the same reason.
spec/window_rule.hpp holds the window rule and the q rule, both loops call it. The default path is unchanged: window_rule_test compares the new
rule with a copy of the old code over 9216 inputs (only the DFlash2 + cost rule + no --draft-conf cases differ). The CLI stats also print the
window histogram for any rule that sets the width and, when STRATA_SPEC_PROB judged windows, their count and source.
2026-11-02 03:36:50 +01:00
Niko1221 cd9c7e7b57 Merge branch 'f-0291-df2-mem' into f-0291-df2-mgpu 2026-11-02 01:09:03 +01:00
Niko1221 96f0307aa0 --draft dflash2 without the MTP layer: refuse a missing draft vocabulary file instead of running the drafter's head over the whole vocabulary 2026-11-02 01:06:15 +01:00
Niko1221 f70368b996 DFlash2 on a layer split and in batch slots: stage-wise taps gathered onto the drafter's card (cross-device events), per-stage prompt taps, per-slot drafters sharing the pack and head, spare-row slot windows, solo<->slot ring handoff 2026-11-02 00:59:54 +01:00
Niko1221 962816b409 Merge branch 'f-0291-df2-mem' into f-0291-df2-mgpu 2026-11-02 00:32:35 +01:00
Niko1221 5a048c6c09 --draft dflash2 loads no MTP layer unless --draft-fallback mtp is given (the DFlash2 and the MTP layer are never loaded together by default); --draft auto still loads both 2026-11-02 00:32:01 +01:00
Niko1221 7dea06f75d Merge f-0291-df2-nv-a (DFlash2 source ownership) into f-0291-df2-mgpu; the window rule reads draft_on for min-p so DFlash2 alone keeps --spec-min-p 2026-11-02 00:30:10 +01:00
Niko1221 09c407d8f4 DFlash2: --draft-fallback none (no MTP layer loaded, DFlash2 the only drafter, an error at start if it cannot run) and the DFlash2 draft head shared with the MTP's byte-identical subset (STRATA_DF2_SHARE_HEAD_OFF=1 keeps its own copy)
Per-run source choice, no mid-run fallback. With the MTP loaded the DFlash2 gathered a second copy of the 106299-row draft head (212.9 MiB on Flash-Next); it now uses the MTP's when the type, the vocabulary ids and the layout match, and the expert cache is sized without the copy. The cache sizing also prices the DFlash2 head from the vocabulary file when there is no MTP.
2026-11-01 23:51:17 +01:00
Niko1221 34c0ab47b2 DFlash2: the MTP chain's cost window and q lists apply only to candidates the MTP drew
With DFlash2 as the drafter the MTP stays loaded as the fallback (use_mtp stays true), and three decisions tested use_mtp where they meant
"the MTP chain drew this round's candidates":
- STRATA_SPEC_COST=1 (a GB10 default): T = clamp(chain_rows, 1, S_mtp), but chain_rows is only written by the MTP chain callback, so with DFlash2
  and no --draft-conf the window stayed at one row (CLI and serve; code_py 175 vs 258 tok/s on an RTX PRO 6000, serve 166-230 vs 283-397).
- STRATA_SPEC_PROB=1, sampled requests: ver.set_spec_q(mtp.spec_q()) judged DFlash2's deterministic candidates against the MTP's stale q lists
  (CLI: 107 of 137 windows), and serve's gated path was not declined for DFlash2.
- the lookup choice read mtp.prob() for the same reason.
spec/window_rule.hpp holds the window rule and the q rule, both loops call it. The default path is unchanged: window_rule_test compares the new
rule with a copy of the old code over 9216 inputs (only the DFlash2 + cost rule + no --draft-conf cases differ). The CLI stats also print the
window histogram for any rule that sets the width and, when STRATA_SPEC_PROB judged windows, their count and source.
2026-11-01 23:41:43 +01:00
Niko1221 93970e0a27 DFlash2 Q4_0 GEMM default: two warps a block, two rows a warp (variant 17); one warp a row (28) is best on a 188-SM card but 10-35% slower than 17 on l620's 110 SMs 2026-11-01 20:29:47 +01:00
Niko1221 4019121f24 DFlash2 Q4_0 GEMM: more rows-a-warp variants; default one warp a row (bench: down 18.7->10.3 us, fc 29.3->16.4, akp 8.2->4.1, o 12.4->8.2, qkv 11.9->9.5; 184/184 bitwise) 2026-11-01 19:28:37 +01:00
Niko1221 f5e2e7a86e comment 2026-11-01 19:24:07 +01:00
Niko1221 0c09456693 DFlash2 Q4_0 GEMM: default rows-a-warp table (bitwise: gemm bench 128/128 on srv118; down 18.7->12.2 us, o 12.4->8.2, fc 29.4->18.4, akp 8.2->4.1) 2026-11-01 19:24:02 +01:00
Niko1221 d97d130902 DFlash2 Q4_0 GEMM: rows-a-warp variants (gemm4_rows_kernel, bitwise the same results), STRATA_DF2_GEMM4, gemm bench q4 mode (auto table still the old kernel until measured) 2026-11-01 17:54:08 +01:00
Niko1221 31f0e8647c generate.cpp: fix the merged ERR line 2026-11-01 17:49:41 +01:00
Niko1221 32c37513e7 Merge f-0291-df2-option (Q4_0 drafter pack as shipped) into f-0291-df2-more 2026-11-01 17:47:30 +01:00
Niko1221 a84eebb513 Remove STRATA_DF2_COUPLED (coupled sampled picks): at a fixed 8-row window it does not raise acceptance (tokens per round -1.7% short / -0.4% long, first-draft match 0.616 vs 0.629; draft temperature 0.6 / 1.5 / 2.5: 2.885 / 2.728 / 2.559 vs 2.868 tokens per round plain), the selector's argmax is the better draft 2026-11-01 15:02:51 +01:00
Niko1221 4deb89ef72 Revert "HC read v3 up kernel, ANOTHER SUMMATION ORDER (STRATA_GR_V3_PF bit 9, off by default, owner-approved item 10): a row per quarter warp, four rows side by side; gr_v3_screen reports its difference from the plain read"
This reverts commit ddd88c9f85.
2026-11-01 15:00:47 +01:00
Niko1221 ddd88c9f85 HC read v3 up kernel, ANOTHER SUMMATION ORDER (STRATA_GR_V3_PF bit 9, off by default, owner-approved item 10): a row per quarter warp, four rows side by side; gr_v3_screen reports its difference from the plain read 2026-11-01 14:29:22 +01:00
Niko1221 0e8e4d4c61 HC read v3: drop the up-kernel register blocking (slower: up 9.2 -> 10.6 us at T1, 18.8 -> 23.9 us at T8); the down kernel's register blocking stays: bit 7 = 2 rows a warp for windows of 5+ rows, bit 8 = 4 rows (bitwise; down 16.1/16.2/17.6/19.5 -> 13.3/14.1/14.7/15.6 us at T5-8) 2026-11-01 14:26:53 +01:00
Niko1221 f8f4da07df gr_v3_screen: room for 16 variants 2026-11-01 14:20:52 +01:00
Niko1221 4ab81c7968 HC read v3 down kernel: register-blocked dot phase for 2 / 4 rows a warp (STRATA_GR_V3_PF bits 7 / 8, any window size; same dots, same order) 2026-11-01 14:07:07 +01:00
Niko1221 686c0d42c7 HC read v3 up kernel: register-blocked dot phase (STRATA_GR_V3_PF bit 6, token loop outside the row loop, same dots in the same order); gr_v3_screen compares it bitwise 2026-11-01 14:05:41 +01:00
Niko1221 3b1d9ae360 DF2-MORE: serve STRATA_SPEC_TRACE (per round window, accepted, selector probabilities, drafts, lookup draft, committed tokens; bench only) and STRATA_DF2_COUPLED, the selector's picks drawn with the target's Philox uniform for sampled requests (opt-in, verify unchanged) 2026-11-01 13:32:20 +01:00
Niko1221 75d7427789 Revert the T=5 HC down variant choice: in the engine the T5 step stays (hc down 0.77-0.79 ms either way, wall 16.17 against 16.14 ms), the cold screen's 0.7 us did not carry over 2026-11-01 12:01:48 +01:00
Niko1221 ab583b6ad5 dflash2 GEMM kernels: pick the matrix of a warp's rows with constant indices (the by-value Df2Segs no longer lives in local memory: STACK 104 -> 0 in cuobjdump for every gemm4/gemm8/gemm_rows instantiation) 2026-11-01 11:40:39 +01:00
Niko1221 7d4feb2e8a HC read at T=5: the down kernel takes two rows a warp instead of the batched-staging variant (screen: 15.5 against 16.2 us, bitwise the same dots); mmvq_il_parity gets the 106,299-row draft head case 2026-11-01 11:38:10 +01:00
Niko1221 424a2af019 Int3 fix (belongs to f-0291-amd-q b9e3e2b86): prefill.cpp's no-fused stub block lacks fused::gfx12_iq2s_default, so a HIP build without STRATA_PREFILL_MMQ (every Windows HIP build that does not pass it) fails to link; release builds pass MMQ=ON and were not affected 2026-11-01 10:48:56 +01:00
Niko1221 7a87440629 DFlash2: drop the 128-thread QK tile (bitwise but 18% slower than the 64-thread tile in the bench) 2026-11-01 10:45:26 +01:00
Niko1221 2b32d0ff0b Int3 merge f-042-maya-rc (690f8b234): DS4_BORROW off by default on Metal 2026-11-01 10:44:03 +01:00
Niko1221 690f8b234a dsv41 Metal: the prompt path does not lend the experts' room by default (DS4_BORROW defaults off on Metal)
M5 Max, DeepSeek 2.25 bpw, 3 interleaved pairs: with the lent room a 639-token prompt took 6.2-7.6 s against 4.1 s with DS4_BORROW=0 (same bytes
read, the compute waited for reads equally long), 8K prompts -3.9%, 32K -20% (borrow also selects the 32,768 chunk); and the engine died
("mtl: wrap 7763574784 failed", exit 4) in 8 of 9 runs of a mixed 165/600-token/8K sequence that the build with DS4_BORROW=0 finished 3 of 3.
Only Metal changes (one_gpu_or is under STRATA_METAL); CUDA and HIP keep devs.size() == 1. DS4_BORROW=1 turns it back on.
2026-11-01 10:42:29 +01:00
Niko1221 9df71d5980 DFlash2: opt-in Q4_0 drafter pack (from 15165e170): dtype q4_0, tools/dflash2_pack.py --q4_0, nibble-packed tiled weights, gemm4_kernel, df2_q4_tile at load, CPU parity test dflash2_q4_parity 2026-11-01 10:20:59 +01:00
Niko1221 d7e50a515b DFlash2 drafter (bitwise): draft head through the interleaved Q5_K kernel, drafts only to the widest window - 1, R-split Q8 GEMM by matrix size, one rope table launch with precomputed inverse frequencies, selector projection beside the head, 128-thread QK tile variant (bench) and bench harnesses that check bitwise equality 2026-11-01 10:20:18 +01:00
Niko1221 0d2ee8defe Int3 fix (test programs only; four were already broken on MSVC in v0.2.9, gr_v3_screen is new): setenv / unsetenv / __builtin_popcount shims so a Windows build with tests ON compiles 2026-11-01 10:05:00 +01:00
Niko1221 3410d5520d Int3 merge f-042-maya-rc (8e8e3cafa): Metal DeepSeek router NaN guard, dense Q4_K dequantizer
# Conflicts:
#	src/dsv41/ds4_gguf.cu
2026-11-01 09:50:55 +01:00
Niko1221 8e8e3cafad dsv41 Metal: router NaN guard in the MSL route kernels, and a dense Q4_K dequantizer; tests for both
Router: ds4_route and ds4_route_publish left an all-NaN gate row's pick at 0x7fffffff and read sc[0x7fffffff] (threadgroup memory) and
vram[0x7fffffff]; the test process dies with SIGBUS on the old kernel. ds4_route_fallback_pick takes the lowest expert not picked yet
(the CUDA/HIP guard's rule) and raises a flag in a buffer of the Metal host; router_nonfinite_take synchronises and reads it
(metal_host::router_bad_take), so ds4_main ends the request with the error it already has. The warning names the GPU on Metal; the
CUDA/HIP text is unchanged. Test: metal/tests/ds4_route_guard_parity.cpp (finite, all NaN, +-inf, half NaN, fewer than k finite).

Dense Q4_K: ds4_gguf.cu rows() sends a dense matrix of a type metal_host::dequant_rows does not know to iq::dequant_rows, whose CUDA
launch has no Metal dispatch and aborts the engine. ds4_dq_q4k (ggml's dequantize_row_q4_K, the Q5_K kernel without the fifth bit) is
added; any other dense type now fails with a plain message naming it. Test: metal/tests/ds4_dq_parity.cpp (Q4_K, Q5_K, Q6_K, Q8_0, BF16
against ref_quant, padded row stride).
2026-11-01 09:49:17 +01:00
Niko1221 02c367d5ce gfx12: fused IQ2_S / IQ4_XS gate/up kernels ON by default (STRATA_PF_FUSED_IQ2S=0 or STRATA_PF_FUSED=0 turn them off); the CPU share limit on gfx12 follows to 1,536 (owner 11-01) 2026-11-01 09:48:15 +01:00
Niko1221 cc703b5e48 #4040 --lookup-max-t 12 by default (serve, 8-row CUDA build, one GPU, no batch/DFlash2/layer split/chain); --lookup-max-t 0 or STRATA_LOOKUP_MAX_T=0 turns it off (owner 11-01) 2026-11-01 09:48:05 +01:00
Niko1221 daed630ed5 ISTA-DAS in the last user-facing lines: the setup --check list and the own-files message print the set's label (ids unchanged); comments 2026-11-01 09:38:03 +01:00
Niko1221 c24a6836aa Int3 merge f-0291-pr-amd (c31f1fa31) 2026-11-01 09:37:11 +01:00
Niko1221 6360274c8d Int3 merge f-0291-df2-spark (15165e170) 2026-11-01 09:37:10 +01:00
Niko1221 de856c7b8c Int3 merge f-0291-bw-next (4c5a55491); generate.cpp: req_df2 and draft_long both kept 2026-11-01 09:37:10 +01:00
Niko1221 ea9a58d8a9 Int3 merge f-0291-bw-df2serve (eeb21d0e4); generate.cpp: draft_df2 and draft_long both kept 2026-11-01 09:36:57 +01:00
Niko1221 0e2f24b6ad Int3 merge f-042-strix-pf (2970fe74a) 2026-11-01 09:36:39 +01:00
Niko1221 af1cfe99cb Int3 merge f-0291-pr-nv (5e46c3415) 2026-11-01 09:36:38 +01:00
Niko1221 5e46c34159 DGX Spark: STRATA_SIDE_MIXER=2 is one of the sm_121 defaults (docs: five speed defaults)
Port of pull request 4737 by InB4DevOps (commit c14ee15d9 on v0.2.8). The mixer's input-only QSA/GDN work runs on graph branches; scheduling only, no arithmetic change.
STRATA_SM121_PERF=0, STRATA_DEFAULTS=026 or STRATA_SIDE_MIXER=0 turn it off. Measured here on a Spark, IQ3_S, greedy: ids identical 48 of 48; alone +1.0..+2.9% per class, with mode 8 +3.6% pooled.
Not yet measured at parallel 4.
2026-11-01 06:06:57 +01:00