[PR #2673] [CLOSED] native dense: upload the projection matrices from 8 threads through pinned staging (1.5 s -> 0.3 s) #4205

Closed
opened 2026-11-07 15:34:01 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Niko1221/Strata/pull/2673
Author: @page1
Created: 10/15/2026
Status: ❌ Closed

Base: main ← Head: feature/dense-upload-threads


📝 Commits (2)

  • ced2a40 native dense: upload the projection matrices from 8 threads through pinned staging (1.5 s -> 0.3 s)
  • 2f1603a native dense: 8 upload threads by default on Windows only; 1 (the serial copy) elsewhere

📊 Changes

1 file changed (+159 additions, -1 deletions)

View changed files

📝 src/core/native_dense.cpp (+159 -1)

📄 Description

Title

Issue: none

Summary

On Windows the shard mapping is not read ahead, so one synchronous cudaMemcpy per matrix took its page faults one at a time: 300 projection matrices, 2019 MiB, in 1.5 s. Now 8 threads copy them in 8 MiB pieces through pinned staging: 0.3 s. The GPU holds the same bytes (checksum below).

What changed

  • src/core/native_dense.cpp: the matrices are allocated as before, then copied in 8 MiB pieces by 8 threads. On Windows each thread reads its piece with ReadFile into a double-buffered pinned staging buffer and cudaMemcpyAsync on its own stream. Elsewhere, or if the file cannot be opened, a piece is copied from the mapping.
  • STRATA_DENSE_UPLOAD_THREADS=N sets the threads; 1 keeps the serial path.
  • STRATA_DENSE_CHECKSUM=1 hashes the matrices as the GPU holds them: e2a34e261e2077dd for both the threaded and the serial path (IQ3_S, 300 matrices, on v0.1.44.1).

Extra Notes

Measured on an RTX 3090 24 GB, Core Ultra 9 285K, 95 GB DDR5, WD SN8100, Windows 11 26300, IQ3_S at 262K context, against a source build of v0.1.44.1 (296b59d2) the same day. 6 + 6 server starts in a rotated order, /health polled every 0.25 s:

v0.1.44.1 this branch
projection matrices (the engine's own line) 1.5 s (every start) 0.3 s (every start)
server start to loaded, median (range) 17.82 s (16.91-18.23) 16.92 s (16.43-17.13)
decode at 1.7K / 61K tokens (3 + 3 starts) 89.2 / 85.4 tok/s 89.5 / 84.9 tok/s
prompt at 61K tokens 2718 tok/s 2699 tok/s

Built: CUDA 13.4 (sm_86) only. Not built for HIP or SYCL (no ROCm or oneAPI here), and the non-Windows path (from the mapping) was not run. native_dense.cpp is part of the HIP build, so it needs a HIP build check.

🤖 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/Niko1221/Strata/pull/2673 **Author:** [@page1](https://github.com/page1) **Created:** 10/15/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `feature/dense-upload-threads` --- ### 📝 Commits (2) - [`ced2a40`](https://github.com/Niko1221/Strata/commit/ced2a40695a64720987069ccd0c0371845249ffe) native dense: upload the projection matrices from 8 threads through pinned staging (1.5 s -> 0.3 s) - [`2f1603a`](https://github.com/Niko1221/Strata/commit/2f1603ae35050713d8fb01cafc9c8cb3e8d23ea1) native dense: 8 upload threads by default on Windows only; 1 (the serial copy) elsewhere ### 📊 Changes **1 file changed** (+159 additions, -1 deletions) <details> <summary>View changed files</summary> 📝 `src/core/native_dense.cpp` (+159 -1) </details> ### 📄 Description ## Title Issue: none ## Summary On Windows the shard mapping is not read ahead, so one synchronous `cudaMemcpy` per matrix took its page faults one at a time: 300 projection matrices, 2019 MiB, in 1.5 s. Now 8 threads copy them in 8 MiB pieces through pinned staging: 0.3 s. The GPU holds the same bytes (checksum below). ## What changed - `src/core/native_dense.cpp`: the matrices are allocated as before, then copied in 8 MiB pieces by 8 threads. On Windows each thread reads its piece with `ReadFile` into a double-buffered pinned staging buffer and `cudaMemcpyAsync` on its own stream. Elsewhere, or if the file cannot be opened, a piece is copied from the mapping. - `STRATA_DENSE_UPLOAD_THREADS=N` sets the threads; `1` keeps the serial path. - `STRATA_DENSE_CHECKSUM=1` hashes the matrices as the GPU holds them: `e2a34e261e2077dd` for both the threaded and the serial path (IQ3_S, 300 matrices, on v0.1.44.1). ## Extra Notes Measured on an RTX 3090 24 GB, Core Ultra 9 285K, 95 GB DDR5, WD SN8100, Windows 11 26300, IQ3_S at 262K context, against a source build of v0.1.44.1 (`296b59d2`) the same day. 6 + 6 server starts in a rotated order, `/health` polled every 0.25 s: | | v0.1.44.1 | this branch | |---|---|---| | projection matrices (the engine's own line) | 1.5 s (every start) | **0.3 s** (every start) | | server start to loaded, median (range) | 17.82 s (16.91-18.23) | 16.92 s (16.43-17.13) | | decode at 1.7K / 61K tokens (3 + 3 starts) | 89.2 / 85.4 tok/s | 89.5 / 84.9 tok/s | | prompt at 61K tokens | 2718 tok/s | 2699 tok/s | Built: CUDA 13.4 (sm_86) only. **Not built for HIP or SYCL** (no ROCm or oneAPI here), and the non-Windows path (from the mapping) was not run. `native_dense.cpp` is part of the HIP build, so it needs a HIP build check. 🤖 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-11-07 15:34:01 +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#4205
No description provided.