[PR #285] [CLOSED] Start: read the expert arena unbuffered (the GGUF too, fixes #230), register it while it loads, on its own thread #2549

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

📋 Pull Request Information

Original PR: https://github.com/Niko1221/Strata/pull/285
Author: @sergqwer
Created: 9/30/2026
Status: ❌ Closed

Base: main ← Head: pr/faster-start


📝 Commits (1)

  • 119b7c7 Start: read the expert arena unbuffered, register it while it loads, on its own thread

📊 Changes

6 files changed (+387 additions, -53 deletions)

View changed files

📝 include/strata/core/pinned.hpp (+18 -0)
📝 include/strata/prefill/gemm.hpp (+4 -0)
📝 src/core/expert_source.cpp (+165 -5)
📝 src/core/pinned.cu (+100 -0)
📝 src/prefill/gemm.cu (+32 -2)
📝 src/program/generate.cpp (+68 -46)

📄 Description

Summary

The expert arena's load was the start's long pole. It was a buffered read, then one CUDA registration of the whole
arena; registering 63 GiB of 4 KiB pages alone took 6.6 s. This PR changes four things:

  • Unbuffered reads.
    • A pack's experts.bin is read with FILE_FLAG_NO_BUFFERING straight into the arena (16 readers, 8 MiB each).
    • The GGUF branch too: this fixes #230. Setup's default native pack has no experts.bin, and its GGUF branch
      read through MSVC's std::ifstream in 4095-byte pieces: 0.02 GiB/s, 42 minutes in #230. Each chunk's 4 KiB-aligned
      window is now read unbuffered into an aligned buffer and scattered into the blobs. Off Windows the old reader
      stays.
  • Registration while loading. The arena is reserved first, and a thread registers its per-layer slices ahead of
    the readers (PinnedArena::Deferred + register_slices). A reader waits for its slice: writing pages while
    cudaHostRegister runs on them corrupted the arena under WDDM, even on large pages.
  • In parallel. The arena loads on its own thread while the main thread loads the dense weights, the PLE table,
    the MTP drafter and the native head.
  • cuBLAS early. gemm_prewarm() creates the handle and runs its first GEMM off the critical path.

Measured

Measured on current main (0.1.29, d6708a4) with ISTA-DASLab's IQ2_XS, RTX 5090 32 GB, Ryzen 9 9950X3D, 128 GB DDR5, Windows 11. KL is first-token KL divergence (STRATA_DUMP_FIRST_LOGITS, #276); two runs of main itself differ by 0 on 5 of 6 short prompts and by 0.00013 on the sixth. IQ2_XS without experts.bin (setup's default pack), a 1K-token prompt and 64 tokens:

arena read start to exit
main (buffered, the file already in the OS cache) 33 GiB at 6.8 GiB/s 17.5 s
this PR (unbuffered from the NVMe) 33 GiB in 7.7 s, registration alongside 11.7 s

main had the advantage of the OS file cache here (128 GB of RAM). The 0.02 GiB/s of #230 appears on a cold start,
or when RAM is too small to cache the shards; the unbuffered reader does not depend on either. A pack with
experts.bin (fork, PCIe 5 drive, 63 GiB): 11.8 GiB/s instead of 3.3, first token after ~8 s instead of ~10.

Correctness

STRATA_VERIFY_ARENA=1 prints a checksum of the loaded arena. The unbuffered GGUF loader and the buffered one give
the same checksum (5217dac097a1751f), and the generated tokens are unchanged.

Switch

STRATA_BUFFERED_LOAD=1 keeps the old loaders.

🤖 Generated with Claude Code

https://claude.ai/code/session_01VZy1yKaDDiA8a7svdwaHio


🔄 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/285 **Author:** [@sergqwer](https://github.com/sergqwer) **Created:** 9/30/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `pr/faster-start` --- ### 📝 Commits (1) - [`119b7c7`](https://github.com/Niko1221/Strata/commit/119b7c73f69b3db8edec1d6123af0470b204931f) Start: read the expert arena unbuffered, register it while it loads, on its own thread ### 📊 Changes **6 files changed** (+387 additions, -53 deletions) <details> <summary>View changed files</summary> 📝 `include/strata/core/pinned.hpp` (+18 -0) 📝 `include/strata/prefill/gemm.hpp` (+4 -0) 📝 `src/core/expert_source.cpp` (+165 -5) 📝 `src/core/pinned.cu` (+100 -0) 📝 `src/prefill/gemm.cu` (+32 -2) 📝 `src/program/generate.cpp` (+68 -46) </details> ### 📄 Description ## Summary The expert arena's load was the start's long pole. It was a buffered read, then one CUDA registration of the whole arena; registering 63 GiB of 4 KiB pages alone took 6.6 s. This PR changes four things: - **Unbuffered reads.** - A pack's `experts.bin` is read with `FILE_FLAG_NO_BUFFERING` straight into the arena (16 readers, 8 MiB each). - **The GGUF branch too: this fixes #230.** Setup's default native pack has no `experts.bin`, and its GGUF branch read through MSVC's `std::ifstream` in 4095-byte pieces: 0.02 GiB/s, 42 minutes in #230. Each chunk's 4 KiB-aligned window is now read unbuffered into an aligned buffer and scattered into the blobs. Off Windows the old reader stays. - **Registration while loading.** The arena is reserved first, and a thread registers its per-layer slices ahead of the readers (`PinnedArena::Deferred` + `register_slices`). A reader waits for its slice: writing pages while `cudaHostRegister` runs on them corrupted the arena under WDDM, even on large pages. - **In parallel.** The arena loads on its own thread while the main thread loads the dense weights, the PLE table, the MTP drafter and the native head. - **cuBLAS early.** `gemm_prewarm()` creates the handle and runs its first GEMM off the critical path. ## Measured Measured on current main (0.1.29, d6708a4) with ISTA-DASLab's IQ2_XS, RTX 5090 32 GB, Ryzen 9 9950X3D, 128 GB DDR5, Windows 11. KL is first-token KL divergence (`STRATA_DUMP_FIRST_LOGITS`, #276); two runs of main itself differ by 0 on 5 of 6 short prompts and by 0.00013 on the sixth. IQ2_XS without `experts.bin` (setup's default pack), a 1K-token prompt and 64 tokens: | | arena read | start to exit | | --- | ---: | ---: | | main (buffered, the file already in the OS cache) | 33 GiB at 6.8 GiB/s | 17.5 s | | this PR (unbuffered from the NVMe) | 33 GiB in 7.7 s, registration alongside | 11.7 s | main had the advantage of the OS file cache here (128 GB of RAM). The 0.02 GiB/s of #230 appears on a cold start, or when RAM is too small to cache the shards; the unbuffered reader does not depend on either. A pack with `experts.bin` (fork, PCIe 5 drive, 63 GiB): 11.8 GiB/s instead of 3.3, first token after ~8 s instead of ~10. ## Correctness `STRATA_VERIFY_ARENA=1` prints a checksum of the loaded arena. The unbuffered GGUF loader and the buffered one give the same checksum (`5217dac097a1751f`), and the generated tokens are unchanged. ## Switch `STRATA_BUFFERED_LOAD=1` keeps the old loaders. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01VZy1yKaDDiA8a7svdwaHio --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-04 02:01:14 +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#2549
No description provided.