mirror of
https://github.com/mw00/project-maya.git
synced 2026-12-03 21:08:26 +07:00
[PR #344] [MERGED] DeepSeek-V4.1 tensor parallel on 9 GPUs: prompts ~1.9x and answers ~1.55x faster at --tp 8 than main, the same perplexity (all-reduces off the SMs, the prompt skip on several GPUs, the expert cache's recent slots); ./maya.sh --calibr… #477
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#477
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/344
Author: @needmorevram
Created: 10/21/2026
Status: ✅ Merged
Merged: 10/22/2026
Merged by: @mw00
Base:
main← Head:ds4-perf📝 Commits (2)
67f69d1maya-ds4: tensor parallel on several GPUs (ds4-perf, rebased on v1.1.21)0fe616amaya-ds4: the review's build fixes; one GPU's decode on HIP as main's; --tp 1 keeps prompt chunks📊 Changes
23 files changed (+3437 additions, -171 deletions)
View changed files
📝
CMakeLists.txt(+3 -2)📝
docs/SETUP.md(+5 -1)📝
maya.py(+80 -9)📝
serve/gpu_map.py(+15 -7)📝
serve/test_dashboard.py(+24 -0)📝
serve/web/app.css(+5 -3)📝
serve/web/app.js(+6 -1)➕
src/ds4/ds4_host_ar.cpp(+85 -0)📝
src/ds4/ds4_kernels.cu(+904 -18)📝
src/ds4/ds4_kernels.cuh(+81 -7)📝
src/ds4/ds4_main.cpp(+105 -8)📝
src/ds4/ds4_model.cu(+958 -104)📝
src/ds4/ds4_model.hpp(+2 -1)📝
src/kernels/cuda/glm_fast.cu(+5 -2)➕
tests/ds4_allreduce_dma.cu(+141 -0)➕
tests/ds4_ar_latency.cu(+75 -0)➕
tests/ds4_index_score_tc.cu(+143 -0)➕
tests/ds4_topk_order.cu(+97 -0)➕
tools/calibrate_ds4_tp.py(+276 -0)📝
tools/ds4/pack.py(+63 -5)...and 3 more files
📄 Description
DeepSeek-V4.1-Flash-1017 with tensor parallel on several GPUs. This is the part of #276 that main doesn't have yet, rebased on main v1.1.21 (one commit, plus one for the review's fixes). At
--tp 8(3.5 bits) it reads long prompts about 1.9x faster than main v1.1.20 and answers about 1.55x faster, with the same perplexity.Results
One PC with 9 GPUs, each on PCIe 3.0 x8, and 2 NUMA nodes. LibertAIDAI's 3.5-bit EXL3 quant at
--tp 8 --prefill-chunk 2048. Measured on the v1.1.20 merge, before the rebase; the one-GPU decode path after the review's fixes is in the comments.The serve bench runs through the server's protocol, sampling at temperature 1.0 with DSpark on. It reads 2 fresh ~16K-token prompts and writes 12 chat answers of 256 tokens. Perplexity uses
--pplover 23 sequences of 2048 tokens (WikiText-2, this repo's code, its docs).The three perplexities are within 0.15% of each other. Single sequences move by about 0.4% in both directions, mostly from main's F32 router flipping borderline expert picks.
What it adds
maya-ds4: tensor parallel
allreduce_dma), in pieces with the copies on a stream of their own.HostReducer), its rows pinned on each GPU's NUMA node. Settings:DS4_AR_HOST,DS4_AR_HOST_THREADS,DS4_AR_HOST_PIECES;DS4_AR_DMA=0turns both off.ar_rs16_kernel, bit for bit (tests/ds4_allreduce_dma.cu). The loads are HIP-safe, and the host rows build on Windows too.DS4_AR_OVERLAP, on).MAYA_DS4_PROMPT_SKIP(layers 20-39 run over the prompt's tail only) required every layer on one GPU.--tp 8).DS4_EG_SHARE=0gives every GPU its own reads, as main does.chunk_default).maya-ds4: the expert cache and placement
DS4_RECENT, 32 a layer where prompts stream the experts):DS4_RECENT_FILLS,DS4_RECENT_NEED,DS4_RECENT_WIN.DS4_CHECK_SWAPSchecks each fill against the model file.DS4_COPY_IDLE, on). Over a GPU's PCIe link they slowed a window's all-reduces about 6x.tab_set): swaps and recent slots, instead of one 8-byte copy each.DS4_PLACE_UNIFORMgives main's even split.maya-ds4: decode and kernels
TopkScratch): the same picks in the same order, with a long row's passes spread over blocks (164 -> 78 µs at 64K positions). Checked bytests/ds4_topk_order.cu;DS4_TOPK_CHECKchecks it live.comp_restore_batch).markov_pickreads the members' slots in parallel.moe_combineleaves early for a token with no rows in the set.moe_win_groupreads its plan with every thread (GLM's kernel too: the same result).DS4_INDEX_TC=1).tests/ds4_index_score_tc.cugives the same masks and the same top 512 as the CUDA cores;DS4_INDEX_CHECKchecks it live.maya-ds4: CLI and diagnostics
--ppl FILE: one line is a sequence (BOS + text), scored in one full-sequence forward.--ids @FILE(no argv limit for long prompts).DS4_BENCH_REPEAT(warm passes in one load).DS4_PROFILE/DS4_PROFILE_PROMPT: an nsys capture of the decode, or of the prompt, alone.DS4_DUMP_LAST,DS4_CPU_STATS,DS4_ROUTE_TRACE.CUBLAS_WORKSPACE_CONFIG), so a long prompt's logits are the same from one start to the next.Monitor
serve/gpu_map.py,app.js,app.css,test_dashboard.py).Setup and tools
./maya.sh --calibrateon a DeepSeek config (tools/calibrate_ds4_tp.py):--tpthat groups the GPUs differently, and with fewer CPU threads, one engine start each.calibration.jsonfor this PC and quant, and a setup again reuses it.tools/calibrate_ds4.py, unchanged).tools/ds4/pack.py:chat_template.jinja(a port of DeepSeek'sencoding.py); this directory's copy is used only for a repo without one.exl3_k_map.jsonis checked against every EXL3 matrix's trellis (codebook mul1, K from its shape).Where main had its own version
dspark_cum), the chunk path's checkpoints, and Stop.--prefill-keep,DS4_DRAFT_SAMPLE,DS4_DRAFT_COST,DS4_AR_DEFER,DS4_CHUNK_FIRSTandDS4_EG_URING. Main covers each of them, or they weren't wins.Exactness
ar_rs16does, the top-k picks the same rows in the same order, the Engram rows are the same bytes, and the prompt skip is main's exact rule.DS4_INDEX_TC.Tests
ds4_gguf_test: ALL OK.tests/ds4_topk_order,ds4_allreduce_dma(4 and 8 members) andds4_index_score_tc: PASS.tools/test_ds4_pack,test_calibrate_ds4_tpandtest_setup_ds4pass.test_responses_schema,test_hip_archs(nocmakeon PATH),test_iq_pack./sys) are guarded.🤖 Generated with Claude Code
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.