mirror of
https://github.com/mw00/project-maya.git
synced 2026-12-03 21:08:26 +07:00
[PR #276] [CLOSED] DeepSeek-V4.1-Flash-1017: the 3.5-bit quant in the setup, strata-ds4 tensor parallel over 4 / 8 GPUs, its KV as packed FP4, expert cache swaps on threads, ./maya.sh --calibrate for --tp and the CPU threads #441
Labels
No labels
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
mw00/project-maya#441
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/mw00/project-maya/pull/276
Author: @needmorevram
Created: 10/19/2026
Status: ❌ Closed
Base:
main← Head:ds4-3.5bpw-tp-fp4kv📝 Commits (6)
36c7c09strata-ds4: tensor parallel over 4 or 8 GPUs (uneven 128-block splits, a reduce-scatter all-reduce), the drafter's markov steps over the head group, leaner decode kernels65cbce1strata-ds4 CLI: --ids @FILE, DS4_BENCH_REPEAT (warm passes), DS4_PROFILE (nsys capture of the decode alone)98fd0c5DeepSeek-V4.1-Flash-1017 at 3.5 bits in the setup, strata-ds4's KV as packed FP4, expert cache swaps on threadse4c92e4strata-ds4: the hand-offs of a window's packed index-key rows (68 bytes) in 4-byte units - a misaligned address with tensor parallel 2, their last bytes left out9150574./maya.sh --calibrate for DeepSeek-V4.1-Flash-1017: --tp and the CPU threads measured on this PC (tools/calibrate_ds4.py), an engine start each59b36f6strata-ds4: a group's heads on as many members as they split among evenly (--tp 6 and 7 start); the DeepSeek calibration leaves out a setting the engine does not run with📊 Changes
18 files changed (+2657 additions, -401 deletions)
View changed files
📝
docs/SETUP.md(+12 -6)📝
include/strata/kernels/exl3.hpp(+3 -0)📝
maya.py(+182 -46)📝
serve/gpu_map.py(+9 -4)📝
serve/test_dashboard.py(+12 -0)📝
serve/web/app.js(+6 -2)📝
src/ds4/ds4_kernels.cu(+469 -52)📝
src/ds4/ds4_kernels.cuh(+46 -10)📝
src/ds4/ds4_main.cpp(+101 -10)📝
src/ds4/ds4_model.cu(+617 -268)📝
src/ds4/ds4_model.hpp(+8 -0)📝
src/kernels/cuda/exl3.cu(+11 -0)➕
tests/ds4_kv_fp4_parity.cu(+267 -0)➕
tests/ds4_topk_order.cu(+59 -0)➕
tools/calibrate_ds4.py(+276 -0)➕
tools/ds4/download-3.5bpw.json(+239 -0)➕
tools/test_calibrate_ds4.py(+190 -0)📝
tools/test_setup_ds4.py(+150 -3)📄 Description
Follow-up to #271, DeepSeek only: LibertAIDAI's 3.5-bit quant in the setup, strata-ds4's tensor parallel over 4 or 8 GPUs, the compressed KV and index keys stored as packed FP4, and expert cache swaps on threads of their own. Outside
src/ds4the only engine code is a newx3::mv_colsthat only strata-ds4 calls; GLM's paths are unchanged.The setup: DeepSeek-V4.1-Flash-1017 at 3.5 bits
--model DeepSeek-V4.1-Flash-1017-3.5bpw, or the model menu's third row.tools/ds4/download-3.5bpw.jsonpins every file to revision04a492fcwith its size and sha256.<models>/<quant name>) and its own memory figure for the PC check. 3.5 bits needs about 280 GB of VRAM and RAM together, and below that the check warns as it does for 2.9 bits.ds4_link_engram): when they are missing in one quant's folder but whole in another's, they are hard-linked from it along with their sha256 record. That means no second 203 GB download and no second copy on the disk. If a hard link isn't possible (another drive), they are left to the download.docs/SETUP.mdcovers both quants.strata-ds4
36c7c091): FFN, shared-expert and head columns split in whole 128-blocks, as even as they go. Three members or more sum through a reduce-scatter + all-gather (FP16 by default,DS4_AR_F16=0for F32). On 8 GPUs at 5 tokens that took 156 µs before, now 66 µs in F32 and about 35 µs in FP16. On a head group of two or more, the drafter's markov bias runs across the members, which gives the same drafts and cuts drafting from 4.1 to 2.6 ms a round. Leaner decode kernels: router GEMV for a window in one launch, head rows in runs (x3::mv_cols), and one sampler launch for a verify window's greedy picks. The commit's speed figures were measured together with a fastermoe_win_groupkernel, which is left out of this PR because GLM's window path uses it too.--tpset to the GPU count, where its tightest member sets the experts' room). The heads go to as many members as they split among evenly (64 heads and 8 output groups: 9 → 8, 7 or 6 → 4, 5 → 4, 3 → 2), and the first members take only an FFN share. Before59b36f63, heads went to all members or all but one, so--tp 6and--tp 7did not start.Finish::pdst), a quarter of BF16's bytes plus a little.index_scoreandsparse_attnread them back bit for bit the BF16 rows.DS4_CACHE_THREADS, 4) and switched between windows. The swap rule's margin, bonus, decay and in-flight limit are settings (DS4_CACHE_*).DS4_PLACE_UNIFORMkeeps the even split.hc_mix+hc_splitrun on a second stream beside the attention and the MoE.--ppl FILE(one sequence per line, each scored in one forward),--ids @FILE,DS4_BENCH_REPEAT(warm passes) andDS4_PROFILE(an nsys capture of the decode alone).STATlines (the live expert tiers) every 8 tokens, and per-GPUVRAMlines beforeREADY, for the Monitor.The Monitor (strata-ds4 only)
VRAMline reports it asvision_own: the GPU map counts it as vision, not as "the rest"../maya.sh --calibratefor DeepSeek (9150574f,59b36f63)Until now
--calibrateskipped DeepSeek configs and went straight to loading the model. It now measures strata-ds4's--tpand its CPU threads on this PC (tools/calibrate_ds4.py). Each setting needs its own engine start, so each start gets a warm-up, the decode speed (the median of 2 prompt groups) and the read of a 16K-token prompt.--tp: every value that groups this PC's GPUs differently. That is 2, 4, 8 and 16 up to the longest run of equal GPUs, then that run's length, then all GPUs together (on 9 GPUs: 2, 4, 8, 9). The config's own value is measured first as the baseline.--tpwhose long prompt reads below 60% of the baseline's is not taken. A winner must beat the baseline by more than 5%, and one that wins by less than 15% is started again beside the baseline before it is kept.--tp, it tries 3/4 and then 1/2 of the engine's default (44 here), going on only while a step helps by more than 5%. This is skipped when VRAM holds every expert.failed, and the rest are still measured. The config's own--tpmust run, since it is the baseline.maya-ds4.jsonand~/.config/project-maya/calibration.json(keyed by the hardware), and a later setup applies it to flags the config does not already set. If the calibration fails, the config stays as it was.--speed-calibrationstill has nothing to compare for DeepSeek (no drafter choice).INFOline now reportscpu_threads.docs/SETUP.mddescribes it.Measured on 9 GPUs (RTX 3090 + 8x RTX 5060 Ti, 2x Xeon Gold 6152, 183 GB RAM), 3.5 bits, 262,144-token context:
--tp--tp 8won by 6.3%, which is under 15%, so both started once more.--tp 4came in at 55.4 (5% faster than its first start: starts of one setting vary that much, which is why a small win is confirmed) and--tp 8at 56.7. Over both starts that is 54.1 against 56.1 tok/s, +3.8%, under the 5% bar. At--tp 4, 33 CPU threads gave 53.9 tok/s, no gain over 44, so it stopped there. Result:--tp 4with the engine's 44 threads, 54.1 tok/s, which is what this PC's config already had. The whole run took about an hour:--tp 8loads in about 9.5 minutes, the others in about 5.(The machine went down once during
--tp 9's first load. Nothing was in the journal or the kernel log, no OOM and no Xid. The rerun went through, with the GPUs drawing at most 910 W in all. The--tp 9row and the steps after the sweep come from rerunning those starts with the tool's own functions.)6 or 7 equal GPUs (e.g. 7x RTX 3090: candidates 2, 4, 7) now work too (
59b36f63). On this PC--tp 7makes one group of seven RTX 5060 Ti, with parts 0-2 holding no heads:--tp 7--tp 4The greedy answer to "why is the sky blue" at
--tp 7is a correct explanation of Rayleigh scattering. The time estimates indocs/SETUP.mdand in the calibration's own message now say about an hour.Tests
strata-ds4builds from this branch on CUDA 13.4 (sm_86 + sm_120) with no warnings insrc/ds4.tools.test_setup_ds4(17 tests, with 5 new ones for the calibration's result in the config), the newtools.test_calibrate_ds4(17 tests, with stand-in engines: the candidates, the choice, the confirmation, the threads, the profile copies, and settings whose engine does not start) andserve.test_dashboard(22 tests, with a new one forvision_own) pass. The GLM calibration's and the server's tests still pass.tests/ds4_kv_fp4_parity.cu(packed FP4 rows against BF16: 0 of 768,000 / 1,536,000 values differ, andindex_score/sparse_attnmatch bit for bit; and the hand-offs below, 42 cases) andtests/ds4_topk_order.cu(top-k against a host reference with heavy ties, a single value everywhere, and n up to 200K, the same output twice) both pass. They build withnvccas their headers describe.e4c92e49): with--tp 2, the 3.5-bit model stopped within 2-5 decoded tokens, and the server's first long prompt stopped withcudaStreamSynchronize: misaligned address/streaming layer 0 expert 1 failed. A GPU core dump put it inxfer_put_kernel: the hand-offs of a window's new rows to the layers in other groups copied in 16-byte units, and a packed index-key row is 68 bytes (where the addresses did line up, a row's last bytes were left out). Each segment now goes in the widest unit its ends and size allow; the KV's 288-byte rows keep 16-byte units. One group of every GPU hands no rows off, which is why the earlier--tp 9runs never showed it.--tp 2and a 262,144-token context, this branch's engine: an 8,000-token prompt in windows of 16, then 256 tokens (DSpark 4.2 tokens a round, 69 tok/s); and the same prompt in one chunked pass (339 tok/s), then 128 tokens that carry on the prompt's text. Before the fix, both runs stopped after 2-5 tokens.🤖 Generated with Claude Code
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.