[PR #807] [CLOSED] cuda: opt-in batched expert uploads to reduce host submission overhead #2839

Closed
opened 2026-11-04 02:03:30 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Niko1221/Strata/pull/807
Author: @midhatn
Created: 10/4/2026
Status: ❌ Closed

Base: main ← Head: codex/batched-dma-submission


📝 Commits (1)

  • 7d6f942 cuda: add opt-in batched expert upload submission

📊 Changes

5 files changed (+301 additions, -1 deletions)

View changed files

📝 CMakeLists.txt (+10 -0)
➕ docs/BATCHED_DMA.md (+114 -0)
➕ include/strata/core/dma_batch.hpp (+53 -0)
📝 src/core/verify.cpp (+17 -1)
➕ tests/core/dma_batch_parity.cu (+107 -0)

📄 Description

The verifier's DMA path currently submits one copy per expert. This adds an opt-in cudaMemcpyBatchAsync path for independent pinned expert uploads on CUDA 13+, using the existing copy stream and readiness callback.

The useful result is lower host submission overhead. It is not a demonstrated model-speed improvement, so this is a draft and the default stays off.

On Windows with a Ryzen 9 7940HS, RTX 4070 Laptop 8 GB and 64 GB DDR5-5600, 16 registered-host uploads of 2 MiB each measured:

Path Median submission wall time Median total transfer time
Individual copies 0.0936 ms 2.5589 ms
Batched copies 0.0162 ms 2.5248 ms

That is 82.7% lower submission latency but only 1.3% lower total transfer latency. A separate repetition using QueryThreadCycleTime found about 84.9% fewer submitting-thread cycles. These are separate measurements; neither means an equivalent reduction in whole-model CPU usage or task time.

STRATA_DMA_BATCH=1 enables batching with --pcie-mode dma. Mode 2 additionally requests CUDA 13.4's overlap-with-compute hint. Older CUDA and HIP builds retain individual copies, as do single uploads and groups larger than 128. The normal kernel-upload path is unchanged. Registered Windows host pointers are resolved to device-visible aliases, and submission errors fail the engine rather than releasing consumers with stale weights.

Validation:

  • CUDA 13.4 and 13.0 batch paths, plus the CUDA 12.6 fallback: 63 byte-parity/event-order cases for each of cudaMallocHost and Windows VirtualAlloc + cudaHostRegister, 378 cases in total. The CMake test targets also pass.
  • The isolated patch on v0.1.39 passed 53 recorded model requests plus an HTTP smoke check: high reasoning, Swift 1.5 IQ3_XXS, 64K allocated context, MTP 5, tools, prompt reuse, a 57,750-token prompt with auxiliary-call restoration, and CPU vision.
  • A-B-B-A coding runs passed independent checks but had different reasoning lengths and draft acceptance. They did not establish better time to a verified answer. The table and settings are in docs/BATCHED_DMA.md.
  • Linux and HIP runtime testing remains outstanding. The older-CUDA fallback was tested on Windows, not HIP.

The design reference is NVIDIA NCCL's independent-copy batching, using the CUDA batch-copy contract. The helper and tests are new; no NCCL source was transplanted. No other experimental Strata PR is included.


🔄 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/Niko1221/Strata/pull/807 **Author:** [@midhatn](https://github.com/midhatn) **Created:** 10/4/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `codex/batched-dma-submission` --- ### 📝 Commits (1) - [`7d6f942`](https://github.com/Niko1221/Strata/commit/7d6f94248512c79faea8eb697db3e06cb9a6df97) cuda: add opt-in batched expert upload submission ### 📊 Changes **5 files changed** (+301 additions, -1 deletions) <details> <summary>View changed files</summary> 📝 `CMakeLists.txt` (+10 -0) ➕ `docs/BATCHED_DMA.md` (+114 -0) ➕ `include/strata/core/dma_batch.hpp` (+53 -0) 📝 `src/core/verify.cpp` (+17 -1) ➕ `tests/core/dma_batch_parity.cu` (+107 -0) </details> ### 📄 Description The verifier's DMA path currently submits one copy per expert. This adds an opt-in `cudaMemcpyBatchAsync` path for independent pinned expert uploads on CUDA 13+, using the existing copy stream and readiness callback. The useful result is lower host submission overhead. It is **not a demonstrated model-speed improvement**, so this is a draft and the default stays off. On Windows with a Ryzen 9 7940HS, RTX 4070 Laptop 8 GB and 64 GB DDR5-5600, 16 registered-host uploads of 2 MiB each measured: | Path | Median submission wall time | Median total transfer time | | --- | ---: | ---: | | Individual copies | 0.0936 ms | 2.5589 ms | | Batched copies | 0.0162 ms | 2.5248 ms | That is 82.7% lower submission latency but only 1.3% lower total transfer latency. A separate repetition using `QueryThreadCycleTime` found about 84.9% fewer submitting-thread cycles. These are separate measurements; neither means an equivalent reduction in whole-model CPU usage or task time. `STRATA_DMA_BATCH=1` enables batching with `--pcie-mode dma`. Mode `2` additionally requests CUDA 13.4's overlap-with-compute hint. Older CUDA and HIP builds retain individual copies, as do single uploads and groups larger than 128. The normal kernel-upload path is unchanged. Registered Windows host pointers are resolved to device-visible aliases, and submission errors fail the engine rather than releasing consumers with stale weights. Validation: - CUDA 13.4 and 13.0 batch paths, plus the CUDA 12.6 fallback: 63 byte-parity/event-order cases for each of `cudaMallocHost` and Windows `VirtualAlloc` + `cudaHostRegister`, 378 cases in total. The CMake test targets also pass. - The isolated patch on v0.1.39 passed 53 recorded model requests plus an HTTP smoke check: high reasoning, Swift 1.5 IQ3_XXS, 64K allocated context, MTP 5, tools, prompt reuse, a 57,750-token prompt with auxiliary-call restoration, and CPU vision. - A-B-B-A coding runs passed independent checks but had different reasoning lengths and draft acceptance. They did not establish better time to a verified answer. The table and settings are in `docs/BATCHED_DMA.md`. - Linux and HIP runtime testing remains outstanding. The older-CUDA fallback was tested on Windows, not HIP. The design reference is [NVIDIA NCCL's independent-copy batching](https://github.com/NVIDIA/nccl/blob/12df1a11afad322be5a204a2db890161cbf8131d/src/ce_coll.cc), using the [CUDA batch-copy contract](https://docs.nvidia.com/cuda/cuda-runtime-api/cuda_runtime_api/group__CUDART__MEMORY.html). The helper and tests are new; no NCCL source was transplanted. No other experimental Strata PR is included. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-04 02:03:30 +07:00
Sign in to join this conversation.
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
Niko1221/Strata#2839
No description provided.