Repository navigation
feat(gpu,arch,spec,quant): DFlash Q4_0, FlashCascade, SenseNova-Loop mHC, external draft models, q4/q2 KV, RDNA3.5 WMMA & AVX-512 - #50
Closed
ybenyedder wants to merge 863 commits into
Conversation
The low 4 bits of a Q3_K sub-block scale come from byte is & 7, shifted by 4 when is >= 8. It was a select between two byte loads; now it is one load and a shift. Integer only, so the output is the same bit for bit (perplexity logprobs of Qwen3-30B-A3B UD-Q2_K_XL at 4096 tokens). RTX 3060, Qwen3-30B-A3B UD-Q2_K_XL decode at 512 tokens of context, --mtp 0: 105.6 -> 108.0 tok/s. Prefill is unchanged. The same change in the Vulkan shader made no difference, so it is not ported.
The two half-float scales at the end of a Q2_K block (rows are 4-aligned) come from one 4-byte load instead of two 2-byte loads, as Q4_K already does. The values are the same, so the output is unchanged bit for bit (perplexity logprobs of Qwen3-30B-A3B UD-Q2_K_XL at 4096 tokens). RTX 3060, Qwen3-30B-A3B UD-Q2_K_XL decode at 512 tokens of context: moe_gemv_q2_k median 36.1 -> 35.3 us, decode 107.9 -> 108.5 tok/s.
The rotation angle is a double, and the 3060 runs double math at 1/64 rate. sincos shares the argument reduction of sin and cos and gives the same values, so the output is unchanged bit for bit (perplexity logprobs of Qwen3-4B Q4_K_M and Qwen3-30B-A3B UD-Q2_K_XL at 4096 tokens). rms_norm_rope median on Qwen3-30B-A3B decode: 8.0 -> 7.5 us per layer. Most of what is left is the double pow of the frequency, which a float version shows to be about 5 us per layer; a table of the frequencies made on the GPU before the decode graph is captured would remove it.
rms_norm_rope computed base^(-2i / n_rot) with an f64 pow per element, which consumer cards run at 1/64 rate. A rope_freq kernel now writes the same values once per (base, n_rot) and the kernel reads them. A graph captured before the table exists computes them itself, and the next call captures again with the table. Output is the same bit for bit. RTX 3060, 512 tokens of context: Qwen3-30B-A3B UD-Q2_K_XL 109.0 to 111.3 tok/s, Qwen3-4B Q4_K_M 93.2 to 94.3 tok/s.
Signed-off-by: bettercallcaleb <121191527+bettercallcaleb@users.noreply.github.com>
Signed-off-by: bettercallcaleb <121191527+bettercallcaleb@users.noreply.github.com>
…gguf-shards-model-list fix(serve): hide incomplete GGUF shard sets from model list
# Conflicts: # tests/serve.rs
…memory gemmi_dp asks for 49168 bytes of Workgroup storage with SHARED_TABLES (the xq/wq double buffers plus the three spec-constant-sized IQ table arrays), 16 over maxComputeSharedMemorySize (49152) on sm_70. The NVIDIA driver does not drop the unused table arrays there, so the first chunked prefill dies with Xid 13 (SKEDCHECK18_L1_CONFIG_TOO_SMALL) and a lost logical device. Read the tables from the buffer in the non-cooperative-matrix path instead; load_tables() becomes a no-op when SHARED_TABLES is not defined. Verified on a Tesla V100-SXM2-32GB: Qwen3.6-35B-A3B UD-Q2_K_XL on Vulkan, 4K prefill 1424 tok/s, decode 109 tok/s.
Plan for the fork: keep Vulkan as the working backend on Volta, then port the CUDA kernels (ldmatrix, mma.m16n8k16, cp.async, warp reduce, int8 tensor cores) behind __CUDA_ARCH__ guards. Results file records the baseline measured on the V100-SXM2-32GB.
AGENTS.md is the contract: fork rules, branch model, build/test commands, environment (V100 sm_70, driver 580, CUDA 12.x, Vulkan without cooperative matrix) and the non-negotiable constraints. docs/agents/WORKFLOW.md defines the three-step protocol: the analyst opens the issue with the task contract, the developer implements it on a task branch and opens a PR, the reviewer verifies against the issue and merges or sends it back. Labels step:* drive the state. .opencode/agents/ adds the coordinator (no code, orchestration only) and the three subagents with their permissions. .github adds the issue and PR templates.
The fork has its own issue tracker; gh without --repo can resolve to the upstream remote. Document the explicit --repo target and the fact that gh repo set-default is already configured.
New sessions in the fork start as the coordinator, which cannot edit files: the analysis/development/review work is done by the three subagents.
All agent-facing documents, prompts and artifacts are English-only from now on. Add the planner subagent (Step 0): it decomposes the request into milestones and tasks and writes the living docs/ROADMAP.md, which the coordinator keeps updated. AGENTS.md and the workflow document the new step, the roadmap artifact and the English-only rule.
Produced by the planner from the fork request: goals/non-goals, hard constraints, status legend, milestone exit criteria, task tables with IDs, scope, files, size, dependencies, acceptance criteria and empty issue/PR columns for traceability, plus critical path and risks. The coordinator owns this document: it updates statuses and issue/PR links after every verified merge. It supersedes the earlier Italian plan, which is removed, and the informal issue #1.
Project 'RustingStrata V100' (5) is linked to the repository with a Roadmap table and a Board view. Fields: Milestone group (M0-M4), Task ID, Size, Depends on and an extended Status. 36 draft items mirror the tasks; repository milestones M0-M4 are created for the real issues. The sync protocol when an issue is opened is documented.
Upstreaming is deferred and not part of the plan for now. Drop the three upstream tasks (sync job, audit, open PRs), renumber the remaining M4 tasks (documentation -> M4-T4, release -> M4-T5), and update M4 title, exit criteria, dependencies, critical path and the non-goals. The GitHub project and repository milestone #5 are updated to match.
* feat(vulkan): account Workgroup shared memory and refuse oversized pipelines Walk the committed SPIR-V, keep the Workgroup OpVariables and evaluate their OpTypeArray lengths with the pipeline's specialization map (constants 0..n-1 plus 15 = kv_q8), failing with the opcode on anything unsupported. Vk::new queries maxComputeSharedMemorySize and logs it on the device line; Vk::pipeline compares every new pipeline with it and refuses with the kernel, spec, bytes needed and limit before creating anything (the driver used to accept it and fault at dispatch, Xid 13 on Volta). STRATA_VK_SMEM_LIMIT overrides the reported limit so the refusal can be tested without a doctored shader. * feat(vulkan): preflight the model's pipelines before weights are uploaded gpu_weight_types derives the weight types a GPU load leaves for the kernels: upload_type applies Backend::upload's F16 -> F32 and Q4_0/Q5_0 -> Q8_0 rewrites (experts are copied raw), and the load_part gate (cpu_only, f32_up) is shared rather than duplicated. Vk::preflight walks the (kernel, spec) pairs each type reaches, mirroring gemm_raw's COOP split, NT and wpb, and checks them through the same accounting Vk::pipeline uses: SPIR-V and spec arithmetic only, no pipeline, model buffer or dispatch. Engine::runner runs it after the backend is opened and before GpuModel::load_split, so a refusal precedes every weight upload. The Backend trait gets a no-op default for backends without Workgroup shared memory. * feat(cli): add strata check for the Vulkan shared-memory preflight strata check --model --backend vulkan --device runs the preflight without loading the model: it lists every checked (kernel, specialization) pair, the shared-memory limit and the wall-clock cost, and exits non-zero on overflow. The GPU-free tests assert the measured sizes of the committed SPIR-V (gemmi_dp: 49152 bytes with Q2_K, 40960 with IQ3_S; the COOP gemmi: 49168) and the refusal text (kernel, spec, bytes, limit), which Vk::pipeline raises before it creates anything. The reference-model preflight test skips cleanly without the model or a Vulkan device.
* test: select test backends with STRATA_TEST_BACKENDS A comma-separated allow-list lets the Vulkan suites run on this box while the CUDA backend still panics on NVRTC sm_70. Filtered backends are reported as SKIP: <name> (filtered) and never opened. * test(kernels): synthesize finite blocks for every GgmlType random_tensor now writes d / dmin / m and the IQ1_M packed scale at the offsets each dequantizer reads, for all 23 types, and asserts every produced f32 is finite. Adds a GPU-free generator test. * test(vulkan): add the per-type GGUF matrix Exercise dequant, GEMV/GEMV-N/GEMV-Q, MoE GEMV, dense and tiled GEMM for all 23 GgmlType variants with synthetic raw blocks, and print one MATRIX line per type. Vk::max_shared_bytes exposes the per-type shared-memory footprint checked by the existing preflight accounting. * fix(test): match the Vulkan f16 conversion in GEMM references On the NVIDIA Volta driver the shader's OpFConvert (packFloat2x16) truncates toward zero, while CUDA's __float2half rounds to nearest even. References for the f16 GEMM path now use the conversion the running backend performs; otherwise a 1-ulp input difference reads as a kernel error. No shader or numerics change. * docs: record the M0-T5 Vulkan GGUF type matrix Append the 23-row per-type matrix, both strata check results, both end-to-end generations, the informational bench and the no-Xid statement for the V100 Vulkan window.
int_dot had no IQ4_NL entry, so routed experts stored as IQ4_NL (the ffn_down_exps of OrcaRouter Qwen3.8-Flash-Next-Uncensored IQ3_XXS) fell back to f32 row dequantization in the CPU expert worker. Add dot_iq4nl against the Q8_K activations like dot_iq4xs: 18-byte blocks, eight per Q8_K block. The AVX2 version looks up KVALUES_IQ4NL with pshufb and handles two blocks per step plus an odd tail. int_dots_match_dequant covers it at 672 values (21 blocks, odd tail). RTX 3060 + Ryzen 7 5800XT, 8K prompt: CPU worker 75.6 -> 15.9 ms/token, decode 10.9 -> 31.6 tok/s.
…duct, MTP for Flash-Next and layer splits - chat page: MCP tools from an mcp.json file (serve --mcp), per-tool switches, confirm step before each call (RustingStudio#18) - cpu_moe: integer IQ4_NL dot product, scalar and AVX2 (RustingStudio#47) - experts: a long prompt no longer freezes the placement for the reply (RustingStudio#44) - mtp: draft head for Qwen3.8-Flash-Next on the GPU (--mtp-model), drafts with a multi-GPU layer split (RustingStudio#38) - vision: faster CPU encoder, image prompts prefill on the GPU with M-RoPE - startup warning when the binary has no AVX2 but the CPU does (RustingStudio#44) - cuda: size_t pointer offsets in moe_combine, STRATA_NVRTC_OPTS (RustingStudio#34) - docs: LORA.md rewritten for users (RustingStudio#15)
ybenyedder
force-pushed
the
upstream/kv-q4-thinking-budget-tq1
branch
from
November 17, 2026 22:59
a7819cd to
4bb0d52
Compare
ybenyedder
force-pushed
the
upstream/kv-q4-thinking-budget-tq1
branch
2 times, most recently
from
November 18, 2026 09:43
358773f to
b32e064
Compare
Member
|
Hi Hi, tysm for contribute, I am reviewing this PR and will merge if everything is fine |
ybenyedder
force-pushed
the
upstream/kv-q4-thinking-budget-tq1
branch
from
November 18, 2026 11:31
b32e064 to
f339543
Compare
ybenyedder
force-pushed
the
upstream/kv-q4-thinking-budget-tq1
branch
2 times, most recently
from
November 18, 2026 12:55
2b33e38 to
f133c75
Compare
Member
|
@ybenyedder I see you still working, can you just request review when you finish |
ybenyedder
force-pushed
the
upstream/kv-q4-thinking-budget-tq1
branch
from
November 18, 2026 13:31
f133c75 to
803c93d
Compare
…va-Loop mHC, external draft models, q4/q2 KV, RDNA3.5 WMMA & AVX-512
ybenyedder
force-pushed
the
upstream/kv-q4-thinking-budget-tq1
branch
from
November 18, 2026 16:55
803c93d to
3f3446d
Compare
Vasyl-Trefilov
added a commit
that referenced
this pull request
Nov 18, 2026
Co-authored-by: Andrew Pavlov <100561417+andrew-pavlov-ua@users.noreply.github.com>
Member
|
oh hell, I am so sorry, I did it by accident, I will reopen it, I am so sorry. |
Member
|
@ybenyedder GitHub won't let me reopen this: I rewrote main's history, so your branch and main no longer share any commits. Your PR is one commit on top of the old 1.2.5 commit b29ab99. Could you rebase it onto the new main (git rebase --onto /main b29ab99) and open a new PR that links back here? There is one conflict, in src/vulkan/mod.rs. Sorry for the trouble, I am really sorry. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
src/config.rs,src/gguf.rs,src/gpu_model.rs,src/gpu_model/prefill.rs,src/main.rs,src/model.rs,src/ops.rs): auto-converts HF DFlash safetensors +config.jsoninto nativeQ4_0(223.1 MiB, default) orQ8_0(391.1 MiB) GGUF, extracts concatenated post-layer target hidden states acrossprefill_chunk/forward, caches persistent DFlash KV across turns, supports lossless greedy (gemv_rows_n143K shortlist) & Leviathan residual rejection sampling (draft_dist/accept_dist), includes Adaptive Block Controller{8, 12, 16}, and integrates FlashCascade (--spec-type suffix,ngram-simple,ngram-cachewith DFlash).moe_gemv_q, unrolledgemv_f, & strided DeltaNet rollback (src/vulkan/shaders/{moe_gemv_q.comp,gemv_f.comp,deltanet.comp},src/backend.rs,src/vulkan/{mod.rs,preflight.rs},src/gpu_model.rs): specializesMAX_NM{1,4,8,17}+ dedicatednm <= 4fast path eliminating register/scratch spills (Scratch size 0), addsgemv_rows_n/upload_raw, and strides DeltaNet state snapshots (SNAP_STRIDE = 4+ exact 0..3 token GPU replay on rollback, saving-738 MBVRAM &-51%DeltaNet kernel time).16x16x16INT8 coopmat (gemmi_16/gemmi_s_16), 2 GiB expert pools,--kv q4/--kv q2, & Zen 5 AVX-512 VNNI+VBMI: unlocks100%fast-path GPU expert residency (10240/10240on 27 GiB unified APU), 256K–1M KV context,--thinking-budget,--short, DeltaNet GEMV dedup, exact MTP shortlist, and AVX-512Q8_0/Q4_*/Q5_*/IQ4_*/TQ1_0/IQ1_S/IQ2_XXS/IQ3_Skernels.Verification (AMD Ryzen AI 9 HX 470 + Radeon 890M
gfx1150)./tools/gen_spirv.sh && cargo test --release --lib --bins --tests: all 20 release test suites pass (0 failures, 0 warnings), verified both onfork/mainand the squashed PR branch onorigin/main(b29ab99).STRATA_VK_STATS=1:Spilled SGPRs 0, Spilled VGPRs 0, Scratch size 0on allmoe_gemv_q,gemv_f, anddeltanetpipelines.--temp 0parity vs--mtp 0: 100% SHA-256 bit-identical outputs verified across Rust SPSC (-n 256:13.83 -> 24.49 tok/s), Math--thinking-budget 512(14.23 -> 30.89 tok/s), accented French prose (14.12 -> 26.86 tok/s), and FlashCascade contextual refactoring (14.18 -> 43.36 tok/s,72.3%acceptance).bench --gpu --backend vulkan --kv q4 --chunk 512 --tg 256: 14.2 tok/s (--mtp 0) -> 58.5–65.5 tok/s (DFlash Q4_0, 90.4%) -> 66.3–78.6 tok/s (+ FlashCascade).Wave 4 — Community Architectures & Speculative Decoding (
sensenova_loop, External Draft Models & Looped DFlash)sensenova_loop(SenseNova-Loop-9B) Architecture:phys_layermapping virtual layers28..52to physicalblk.4..27.*) with zero duplicate VRAM allocation viaArc-backedGpuTensorcloning while maintaining independent KV and DeltaNet states across all 56 virtual layers.mHC) with 20-step log-space Sinkhorn-Knopp doubly-stochastic stream mixing (mhc.streams = 2 | 4,mhc.layer_kindsenter/carry/leave phases) across CPU (src/model.rs), Vulkan (hc_mix.comp,hc_write.comp), and CUDA (kernels.cu).--draft-model <standalone-model.gguf>):nvidia/Qwen3.5-4B-Qwen3.8-27B-Draft,Qwen3.5-0.8B,Qwen3-0.6B) to act as an external speculative drafter (ext_draftinGpuModel) sharing the same GPU device (Backend::share), with cross-turn KV/DeltaNet state reuse (ext_draft_sync_prompt),FlashCascade(hybrid_spec_step) integration, and lossless greedy (--temp 0) / Leviathan rejection sampling (--temp > 0).STRATA_DFLASH_STEPS=2..4):Wave 5 — Register-Zero Vulkan Decode Attention, Reduced-Spill
HD=256Prefill & ChunkedmHCPrefillattn_decode(src/vulkan/shaders/attn_decode.comp+attn_decode.spv):kr/vrregister live ranges do not overlap, achievingSpilled VGPRs 0, Scratch size 0(Subgroups per SIMD 16) underSTRATA_VK_STATS=1across all tested spec widths ([0,2,..],[0,4,..],[0,8,..]).HD>128attn_prefill(src/vulkan/shaders/attn_prefill.glsl+attn_prefill_{64,128,256}.spv):ri/ciinto 2-registerr_pack/c_packbitfields, streams K/V forHD > 128, and addssubgroupMemoryBarrierShared()every 2 tiles, cuttingattn_prefill_256spills from127(Scratch size 16384,Latency 340146) to81(Scratch size 10496,Latency 197502).sensenova_loop(src/gpu_model.rs,src/gpu_model/prefill.rs,src/model.rs,src/main.rs):prefill_chunkformhc_streams > 0models using non-aliasing stream scratch (hg/mix/mopasttotal), dense WMMA projections (gemm_densewhencols % 64 == 0), andmhc_loadbatch sizing (chunk.min(ctx).max(TMAX)).sensenova_loopsummary reporting tochecksubcommand and validates 4-token chunked prefill (chunk=64,short=2), GPU decode, and CPU parity (max_err <= 0.0080,< 1e-2tolerance).cargo test --release --lib --bins --tests: 20 test binaries run (261 passed; 0 failed; 6 ignoredbench/external-model tests),0compiler warnings.Wave 6 — Speculative rollback / kernel cleanups (measured neutral)
Vk::dtodskips the per-copy barrier insidebatch;deltanetsupportso == 0(state-only replay);moe_down_combinehoistsxq/xd/sxfornsb == 2(0 spills, 16 subgroups/SIMD); DeltaNet rollback runs as a graph;dflash_commit_forwardbatches its 6 layers;FlashCascadecan splice an n-gram prefix (order >= 6) into DFlash drafts.high,--temp 0 -n 256(Wave 327ed6dbvs this branch, 2 runs each): decode speed is the same within noise (rust 18.9 vs 18.9-19.0, math 41.3-42.4 vs 41.5-42.1, french 17.0-17.2 vs 17.1-17.2, ctx 50.2-50.3 vs 50.3-50.5 tok/s) and the draft acceptance is identical (174/701, 240/408, 163/791, 241/351). Outputs are byte-identical to a no-draft run (SHA-256 equal on all 4 prompts, baseline 14.1-14.2 tok/s). So Wave 6 is lossless but gives no measurable speedup; an earlier +14.7% figure compared different prompts and is retracted.