[PR #512] [CLOSED] DeepSeek decode: four exact trims, checked at load (MAYA_DS4_DECODE_TRIM) #568

Closed
opened 2026-10-29 21:26:59 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/mw00/project-maya/pull/512
Author: @pepuscz
Created: 10/26/2026
Status: ❌ Closed

Base: main ← Head: pr/ds4-up-b-decode-trim


📝 Commits (9)

  • 001d578 ds4: DS4_HC_FUSE - a decoded token's hc_split and hc_pre_norm in one launch, the attention input rounded there
  • fddc0f2 ds4: DS4_ROUTE_FUSE - a decoded token's router stage on the lead in two launches instead of four
  • 8e9e97b ds4: DS4_ROUTE_FUSE - nothing published after a launch that did not go in; one eligibility check before any enqueue
  • 4b335ff ds4: DS4_HC_FUSE=2 - the HC split + norm fuse for a decode window's rows too (parked, not built)
  • aced0d1 ds4: DS4_HC_FUSE=2 - the FFN's split rounds its input too, for the shared expert's w1 / w3
  • ed02cf0 ds4: DS4_ROUTE_FUSE=2 - the fused router stage for a decode window's rows too
  • aab71b9 docs: DeepSeek's fused decode launches - MAYA_DS4_HC_FUSE and MAYA_DS4_ROUTE_FUSE
  • bcd24b2 ds4: DS4_DECODE_TRIM - the decode's last four small trims, each exact and checked at load
  • 28e66e7 docs: DeepSeek's decode trims - MAYA_DS4_DECODE_TRIM

📊 Changes

6 files changed (+1763 additions, -54 deletions)

View changed files

📝 docs/SETTINGS.md (+27 -0)
📝 src/ds4/ds4_gguf.cu (+18 -2)
📝 src/ds4/ds4_gguf.cuh (+14 -0)
📝 src/ds4/ds4_kernels.cu (+355 -0)
📝 src/ds4/ds4_kernels.cuh (+69 -0)
📝 src/ds4/ds4_model.cu (+1280 -52)

📄 Description

Part of #510 (PR B of 9: A, B, C, C2, D, E, F, G, H). Stacked on #511: until that merges, this PR also shows its commits; this PR's own are the last ones listed. Glad to rebase as main moves.

What. After A, four small costs remain in a decode step: two int8 rounding launches, the verify window's compressor snapshot (four runtime copies), and the drafter's hand-offs between cards through pinned memory and events.

Change. MAYA_DS4_DECODE_TRIM=<bits> (unset / 0: as before):

  • 1: the shared expert's swiglu rounds its output to int8 where it is made, and s2's GEMV takes it as is (one launch less a layer);
  • 2: q's low-rank norm rounds its stored values the same way for wq_b's GEMV (one launch less a layer);
  • 4: the window's compressor snapshot and a ratio-1 layer's latent copy as one kernel each (copy_regions) instead of runtime copies;
  • 8: the drafter's hand-offs between its devices by xfer_put / xfer_get through each device's host-mapped rows and a flag, as the pipeline's groups hand theirs.

Exact, checked at load. trim_q8_check (bits 1 / 2: the first and last layer of every device, 1 and kWin rows, random and edge inputs, every int8 row, scale and GEMV output byte for byte against the old path) and trim_copy_check (bit 4: copy_regions against the runtime copies; bit 8: every ordered device pair's round trip).

Tested on one box, 2x RX 7900 XTX (gfx1100) + Radeon 8060S (gfx1151), HIP: this PR's head builds on its own (each PR of the series was built in order), and the full series passed its load checks and --bench (numbers in #510). Not built or run on CUDA.

🤖 Generated with Claude Code


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/mw00/project-maya/pull/512 **Author:** [@pepuscz](https://github.com/pepuscz) **Created:** 10/26/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `pr/ds4-up-b-decode-trim` --- ### 📝 Commits (9) - [`001d578`](https://github.com/mw00/project-maya/commit/001d5788f3522fc3004501924b9d525c30cc3b71) ds4: DS4_HC_FUSE - a decoded token's hc_split and hc_pre_norm in one launch, the attention input rounded there - [`fddc0f2`](https://github.com/mw00/project-maya/commit/fddc0f2d09cf35307e77ad96270a3d28377771c3) ds4: DS4_ROUTE_FUSE - a decoded token's router stage on the lead in two launches instead of four - [`8e9e97b`](https://github.com/mw00/project-maya/commit/8e9e97bb15180a14d759c1bdf06054c30a7c3739) ds4: DS4_ROUTE_FUSE - nothing published after a launch that did not go in; one eligibility check before any enqueue - [`4b335ff`](https://github.com/mw00/project-maya/commit/4b335ff17822727dd49af950ed243b2202f280b8) ds4: DS4_HC_FUSE=2 - the HC split + norm fuse for a decode window's rows too (parked, not built) - [`aced0d1`](https://github.com/mw00/project-maya/commit/aced0d160799bfae3445968ac098a849936d894a) ds4: DS4_HC_FUSE=2 - the FFN's split rounds its input too, for the shared expert's w1 / w3 - [`ed02cf0`](https://github.com/mw00/project-maya/commit/ed02cf0032f5512e15b535ff7f9461cfd008f7df) ds4: DS4_ROUTE_FUSE=2 - the fused router stage for a decode window's rows too - [`aab71b9`](https://github.com/mw00/project-maya/commit/aab71b989fb3ab9def238c841134fef3434db64c) docs: DeepSeek's fused decode launches - MAYA_DS4_HC_FUSE and MAYA_DS4_ROUTE_FUSE - [`bcd24b2`](https://github.com/mw00/project-maya/commit/bcd24b2f567e93eeaae618be11236c34a71182b8) ds4: DS4_DECODE_TRIM - the decode's last four small trims, each exact and checked at load - [`28e66e7`](https://github.com/mw00/project-maya/commit/28e66e7bc02de3b5866abbcb9f9bee2e7f452ed0) docs: DeepSeek's decode trims - MAYA_DS4_DECODE_TRIM ### 📊 Changes **6 files changed** (+1763 additions, -54 deletions) <details> <summary>View changed files</summary> 📝 `docs/SETTINGS.md` (+27 -0) 📝 `src/ds4/ds4_gguf.cu` (+18 -2) 📝 `src/ds4/ds4_gguf.cuh` (+14 -0) 📝 `src/ds4/ds4_kernels.cu` (+355 -0) 📝 `src/ds4/ds4_kernels.cuh` (+69 -0) 📝 `src/ds4/ds4_model.cu` (+1280 -52) </details> ### 📄 Description Part of #510 (PR B of 9: A, B, C, C2, D, E, F, G, H). **Stacked on #511**: until that merges, this PR also shows its commits; this PR's own are the last ones listed. Glad to rebase as `main` moves. **What.** After A, four small costs remain in a decode step: two int8 rounding launches, the verify window's compressor snapshot (four runtime copies), and the drafter's hand-offs between cards through pinned memory and events. **Change.** `MAYA_DS4_DECODE_TRIM=<bits>` (unset / `0`: as before): - `1`: the shared expert's swiglu rounds its output to int8 where it is made, and s2's GEMV takes it as is (one launch less a layer); - `2`: q's low-rank norm rounds its stored values the same way for wq_b's GEMV (one launch less a layer); - `4`: the window's compressor snapshot and a ratio-1 layer's latent copy as one kernel each (`copy_regions`) instead of runtime copies; - `8`: the drafter's hand-offs between its devices by `xfer_put` / `xfer_get` through each device's host-mapped rows and a flag, as the pipeline's groups hand theirs. **Exact, checked at load.** `trim_q8_check` (bits 1 / 2: the first and last layer of every device, 1 and kWin rows, random and edge inputs, every int8 row, scale and GEMV output byte for byte against the old path) and `trim_copy_check` (bit 4: `copy_regions` against the runtime copies; bit 8: every ordered device pair's round trip). **Tested** on one box, 2x RX 7900 XTX (gfx1100) + Radeon 8060S (gfx1151), HIP: this PR's head builds on its own (each PR of the series was built in order), and the full series passed its load checks and `--bench` (numbers in #510). Not built or run on CUDA. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-29 21:26:59 +07:00
Sign in to join this conversation.
No labels
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
mw00/project-maya#568
No description provided.