Skip to content

Pinned staging pool: 4 GiB cache, classes up to 1 GiB, LRU eviction - #47

Open
AdvaitTahilyani wants to merge 7 commits into
scale/29-matvec-host-copyfrom
scale/30-pinned-pool
Open

AdvaitTahilyani wants to merge 7 commits into
scale/29-matvec-host-copyfrom
scale/30-pinned-pool

Conversation

@AdvaitTahilyani

@AdvaitTahilyani AdvaitTahilyani commented Nov 26, 2026 •

Copy link
Copy Markdown

Three small changes to the pinned host pool used for staged GPU messages (cross-host, or same-host without CUDA IPC). Split out of the zero-copy work in #48 because they help the existing marshalled path on their own.

1. Cache up to 4 GiB of blocks by default (was 512 MB, CNUM_GPU_STAGE_MB). An operation whose staged messages in flight exceed the cap pays a cudaMallocHost and a cudaFreeHost for every block past it (~35 ms per 64 MB block). einsum -n 800 on 4 GPUs with CNUM_GPU_IPC=0 stages 4.7 GiB per iteration: 140 s of a 300 s run per process went to cudaMallocHost, and it took over 1.6 s per iteration against 0.63 s with a large cap. On 4 nodes × 4 GPUs the same program took 110.5 s with the old cap and 84.5 s with the new default (one run each).

2. Size classes up to 1 GiB (was 256 MB). A staged message of 256 MB to 1 GiB (ct_msg_max_bytes) got no pinned block and fell to CkDeviceBuffer, which blocks the PE for about a second per GiB. One message at a time between 2 processes on 2 nodes, ofi (GiB/s):

message before (scale-int defaults) after (1 + 2, marshalled path)
64 MB 1.96 1.98
256 MB 0.93 2.02
512 MB 0.27 2.23
1 GiB 0.27 2.24

3. Evict the least recently used size classes when the cache is full. A block freed into a full cache used to be unpinned itself while the cache kept blocks of sizes nothing used any more, so a program that moved to another message size after filling the cache (an einsum phase leaves 4 GiB of 64 MB blocks) pinned and unpinned a block per message. Measured with #48's zero-copy path (both sides hold pinned blocks): an n=12000 transpose after an einsum phase took 842–900 ms without the eviction, 40–68 ms with it.

The "after" numbers come from the zero-copy build run with CNUM_GPU_ZC=0, which is this pool with the old marshalled path; all on the older integration tree scale-int, not on this stack head.

Validated. nc and GPU (netlrts-cuda) builds; GPU runs: covered by the validation of the top of this stack (#48), whose CNUM_GPU_IPC=0 run goes through this pool for every cross-process message.

Known limits.

  • Power-of-two classes: a 600 MB message pins 1 GiB.
  • The cap bounds only cached blocks; blocks in flight are not bounded. With 4 processes per node up to 16 GiB of host memory per node can stay pinned in the cache.
  • Payloads over 1 GiB still have no pinned block (they go as fragments through one 64 MB pinned chunk).

🤖 Generated with Claude Code

AdvaitTahilyani and others added 4 commits November 24, 2026 22:58
CNUM_GPU_STAGE_MB capped the pinned host blocks kept for reuse at 512 MB.
An operation whose staged messages in flight exceed the cap pays a
cudaMallocHost and a cudaFreeHost for every block past it (~35 ms per
64 MB block). einsum -n 800 on 4 GPUs with CUDA IPC off stages 4.7 GiB
per iteration: 140 s of a 300 s run per process went to cudaMallocHost,
and the run took over 1.6 s per iteration against 0.63 s with a large
cap. On 16 GPUs (4 nodes) the same program took 84.5 s with the new
default and 110.5 s with the old cap, one run each.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The pool's largest class was 256 MB, so a staged message of 256 MB to
1 GiB (ct_msg_max_bytes) got no pinned block and went through
CkDeviceBuffer, which blocks the PE for about a second per GiB. Across
two nodes a single 512 MB or 1 GiB message ran at 0.27 GiB/s; with
classes up to 1 GiB and the marshalled staged path it runs at
2.2 GiB/s.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A block freed into a full cache was unpinned itself, while the cache kept
blocks of sizes nothing used any more. A program that moved on to another
message size after filling the cache (an einsum phase leaves 4 GiB of
64 MB blocks) then paid a cudaMallocHost and a cudaFreeHost per message.
A freed block now evicts cached blocks of the size classes allocated the
longest ago. Measured with the zero-copy staged path (where both sides
hold pinned blocks): an n=12000 transpose after an einsum phase took
842-900 ms without the eviction and 40-68 ms with it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant