mirror of
https://github.com/mw00/project-maya.git
synced 2026-12-03 21:08:26 +07:00
[PR #377] [MERGED] ds4: flow - a TP member stages its own gate/up rows from a RAM copy #500
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#500
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/377
Author: @NenadSteric
Created: 10/22/2026
Status: ✅ Merged
Merged: 10/22/2026
Merged by: @mw00
Base:
main← Head:pr/ds4-flow-tp-ram-copy📝 Commits (1)
2b728d5ds4: flow - a TP member stages its own rows from a RAM copy📊 Changes
1 file changed (+14 additions, -5 deletions)
View changed files
📝
src/ds4/ds4_model.cu(+14 -5)📄 Description
Problem
With a tensor-parallel group, the flow on (
DS4_FLOW_TP=1) and the CPU lane's experts copied into RAM (--mmap-experts off), every member after the first computes its streamed experts with the first member's gate/up rows. The output stays plausible, so nothing looks broken - but the logits are wrong (KLD 0.32 against the non-flow path, top-1 agreement 85%).On main this needs a GGUF that can form a TP group (TP 2 with 32-value expert blocks; Maya's own 256-value quants cannot), so few setups reach it today. It matters once the flow is used with TP - which is worth doing, see Why it matters below.
Cause
A member reads only its share of each gate/up matrix. The file path applies the member's row offset when it reads (
mx_read_off), so the staging slot starts at the member's rows. The copy path stages the whole matrix, and the DMA then takesmx_read_lenbytes from the start of the slot - the first member's rows. Example with TP 2 (n_ff 2304, 1152 rows a member), member 1:The down matrix is staged whole on both paths and cut by the 2D copy, so it is right either way. Member 0's rows start at 0, which is why one member in the group is always right.
Fix
The copy path now stages the same rows the file path reads (
mx_read_off/mx_read_len), taking each NUMA part's share of that range when NH > 1, and the item counts the jobs it queued. A member's copy jobs only get smaller;jobs[6]still bounds them (at most NH a matrix).Why it matters: the flow makes TP prompt reading much faster
Without the flow, a TP group's chunked prompt path streams every CPU-lane expert of every layer for each chunk - on our machine about 60 GB, ~5 s per prompt, however short. The flow streams only the experts a chunk routes to. With this fix the flow is correct, and on 6x RTX 3090 / 256 GB RAM, DeepSeek V4.1 Flash 1017 Maya-S, TP 3 (a v1.1.20 build with this fix, the TP patches listed under Next and a P2P all-reduce of ours) it reads prompts much faster:
On v1.1.22 (same TP patches, plus the CPU-lane patch from Next) the agent-session replay takes 95 s with v1.1.22's copy-engine all-reduce and 98 s with
DS4_AR_DMA=0: the gain comes from the flow, not from the all-reduce.In full agent coding sessions (flow plus a small CPU-lane patch for prompts under 512 tokens) prompt reading went from 174 - 205 to 403 - 408 tok/s and a session's wall time from 23 - 25 to 11.5 - 14 minutes, with decode unchanged (90 - 94 tok/s).
Validation
Engine CLI logits of 1,024 fixed tokens on v1.1.22, compared with the non-flow chunked path (
DS4_CHUNK=256). Maya-S cannot form a TP group on main (TP 2 halves n_ff 2304 into rows that are not whole 256-value blocks; TP 3 does not divide the 64 heads), so this used main + a local uneven-head-split patch (not part of this PR) with even FFN shares, TP 3 over 6 GPUs:CI-equivalent: HIP name mapping passes; server tests 342 OK (10 skipped); tools tests 383 OK (28 skipped).
Not tested: HIP at runtime; NH = 2 (one NUMA node here - the part arithmetic is checked by reading only); a TP group on main without the head-split patch.
Next
Further PRs will follow, each opt-in with unchanged defaults:
--mmap-experts autofor GGUFs: it reads in place even when RAM holds every CPU-lane expert; copying them was +34% decode here.🤖 Generated with Claude Code
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.