mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-03 19:03:30 +07:00
[PR #5357] [Engine] DeepSeek: accept an MXFP4 down beside a low-bit gate / up (Unsloth UD-Q2_K_XL) #5401
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#5401
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/5357
Author: @R-Okauchi
Created: 11/5/2026
Status: 🔄 Open
Base:
main← Head:dsv41-mxfp4-down📝 Commits (1)
47cdfc5DeepSeek engine: a low-bit layer's down may be MXFP4📊 Changes
7 files changed (+98 additions, -40 deletions)
View changed files
📝
src/dsv41/ds4_gg_cpu.cpp(+4 -2)📝
src/dsv41/ds4_gguf.cu(+2 -2)📝
src/dsv41/ds4_gguf.cuh(+3 -2)📝
src/dsv41/ds4_iq.cu(+27 -3)📝
src/dsv41/ds4_iq.cuh(+5 -1)📝
src/dsv41/ds4_model.cu(+7 -2)📝
tests/dsv41/iq_expert_test.cpp(+50 -28)📄 Description
Problem and result
Unsloth's dynamic quants of DeepSeek-V4.1-Flash-1017 keep DeepSeek's own MXFP4 for the down matrices of some layers
beside low-bit gate and up. In UD-Q2_K_XL, layers 0-1 are IQ2_XS / IQ2_XS / MXFP4 and layers 15-19 IQ2_S / IQ2_S / MXFP4.
strata-dsv41 0.1.57 (v0.2.11; main has the same engine code) refuses such a pack at load:
With this change it loads and serves that pack on CUDA. For the types the engine already took, the kernels give the
same bits as main's (Validation).
Related discussion
None. It is a focused fix: no default changes, and nothing changes for a pack the engine already loads.
Approach
The low-bit kernels already decode MXFP4 blocks (
decode_b, which the light sets use), so what was missing is the downrole taking MXFP4 where a backend has it:
ds4_iq.cu: the down role's token, window and prompt-set kernels take MXFP4 (DS4_IQ_SWITCH_DOWN).deq8gets theMXFP4 branch the prompt tiles need; an MXFP4 block there fell through to Q3_K's.
block_values/block_bytes/nameknow MXFP4.supported_down()names the down types the low-bit path takes: not MXFP4 on Metal, whose sets haveno MXFP4 down, so Metal refuses such a pack as before.
ds4_gguf.cu:iq_argstakes asupported_down()down.ds4_gg_cpu.cpp: the CPU lane computes such a down with ggml-cpu's MXFP4 x Q8_0 dot. An all-MXFP4 layer keepscpu_experts_mx.ds4_model.cu: the load check lets an MXFP4 down beside a low-bit gate / up through wheresupported_down()does. AnMXFP4 gate or up still needs the whole layer in MXFP4.
tests/dsv41/iq_expert_test.cpp:--down Tgives the down matrices a type of their own. The gate / up data andinputs stay those of the run without it, so its gate / up checks must give the same numbers.
Validation
Every run is of this branch's tree, built with CUDA 13.0 unless noted.
Passed:
ds4_iq_test, RTX 4070 Ti (sm_89, x86-64), main's and this branch's built the same way: main's--dump, then thisbranch's
--cmpagainst it:bit-compare vs golden: 84 buffers, 0 differ -> IDENTICAL, ALL OK. This branch's--type 16,17,22,18,21,23,29 --down 39: ALL OK. Its 21 gate / up checks give the default run's numbers exactly, andthe MXFP4 down's worst errors are 5.7e-08 on the token path (tol 1e-06), 1.8e-03 in the prompt sets (tol 3e-03) and
8.0e-08 on the CPU lane (tol 1e-05).
ds4_iq_test, DGX Spark (GB10, sm_121; the CPU lane on aarch64), built withspark/build_engine.sh's flags and thetests on: main's
--dump, then this branch's--cmp:bit-compare vs golden: 84 buffers, 0 differ -> IDENTICAL, ALL OK.--type 16,17,22,18,21,23,29 --down 39: ALL OK, the 21 gate / up checks the default run's numbers exactly, the MXFP4down's worst errors 5.7e-08 on the token path, 1.8e-03 in the prompt sets and 6.0e-08 on the CPU lane (ggml-cpu on
aarch64).
A real UD pack, x86-64:
pack_gguf.pywith the plain recipe on AtomicChat's build of UD-Q2_K_XL (layer for layerthe same expert types as Unsloth's), all its shards but the Engram table's. That one is Q5_K, which the Engram reader
does not take (MXFP8, Q6_K, IQ4_NL), so
--engramnames the IQ4_NL table the ISTA-DAS sets share. 47,284 tensors:MXFP4 16.8 GB, IQ3_XXS 86.7 GB, IQ2_XXS 33.9 GB, IQ2_S 29.0 GB, IQ3_S 19.5 GB, IQ2_XS 5.2 GB. The engine (built for
sm_120 with
packaging/build_dsv41_cuda.sh's flags) on 2 x RTX PRO 5000 Blackwell 48 GB with 125 GiB of RAM loads it:6,515 experts on the cards, 8,845 on the CPU lane, a 94.8 GB RAM store. With
DS4_STREAM=1 DS4_LANE_CHECK=1the twonew formats go through both lanes at load like the others:
The spread is the same for every format: the two lanes round the activations differently with
DS4_IQ_Q8Koff.Through
serve/server.py: chat, a tool call at every reasoning effort, and a replayed tool turn answered correctly.Builds:
strata-dsv41for sm_121 (aarch64,spark/build_engine.sh's configuration) and sm_120 (x86-64);ds4_iq_testfor sm_89 / sm_120 / sm_121; HIP, ROCm 7.2.4, gfx1151 / gfx1201(
tools/dsv41/build_hip_linux.sh strata-dsv41 ds4_iq_test); Metal (strata_ds4, macOS 26.4, metal-cpp 26 andllama.cpp 3cf03257 as in
metal-build.yml); the CPU-onlyds4_gg_bench(-DSTRATA_BUILD_DSV41=ONwith no GPUbackend, macOS arm64). No new warnings: where I built main the same way (sm_121, the sm_89 / sm_120 tests, HIP,
Metal), the touched files give main's warnings, the same ones; on sm_120 they give the two that main has in
ds4_model.cu(lines 102 and 106) and nothing else; the CPU-only build gives none.Failed: none observed.
Not run:
supported_down()keeps such a pack refused, as before.covers the other low-bit types with an MXFP4 down.
moves from run to run (9,621-9,674 of 15,360 experts in VRAM over four runs with
--no-expert-cache, main'sincluded), so two runs of the same build already write different tokens. The kernel test's bit-for-bit
comparison above stands in for it.
Limits
above, about 22 GB of them came from a SATA SSD and it decoded at about 13 tok/s (the ISTA-DAS IQ2_XS set: 70).
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.