Skip to content

CUDA: every synchronous readback stages on integrated GPUs, as download does (#2102) - #2289

Open
ashhart wants to merge 2 commits into
mainfrom
lead/staged-copies
Open

ashhart wants to merge 2 commits into
mainfrom
lead/staged-copies

Conversation

@ashhart

@ashhart ashhart commented Nov 5, 2026

Copy link
Copy Markdown
Owner

Part of #2102. #2103 made DeviceBuffer.download stage through a per-thread pinned buffer on integrated GPUs such as the GB10, where a synchronous copy into pageable memory can miss pages. Discrete cards keep the direct copy.

This moves every other synchronous device-to-host copy on main onto the same path. There are 54, not the 18 we first counted: 27 in family code and developer tools, and 27 in device tests. Each destination is stack or allocator memory, so on a GB10 each had the exposure download had. They now go through cuda.memory.download, a borrowed device span handed to DeviceBuffer.download. The shared path keeps both driver calls it already had: the direct copy on discrete cards, and the copy into the pinned bounce on integrated ones. The attribute gate, the 4 MiB pieces, per-thread reuse and host accounting are as #2103 left them.

Bytes copied don't change. Each replaced call is checked against its original source address, destination and byte count. Host tests cover the routing on a fake driver, integrated against discrete.

Not run yet: any device. Our GB10 run against main comes before this lands. Large copies get slower on an idle GB10, as #2103's own table shows (212 µs instead of 85 µs at 4 MiB), so the run checks the families that copy most.

Refs #2102.

Route unowned spans through DeviceBuffer.download so integrated devices use
its pinned bounce and discrete devices retain their direct copy. Preserve
each caller's source, destination and byte count, including developer checks.

Release the current thread's bounce and device reading before its driver
closes. Exercise every changed copy expression on both fake device classes,
plus chunk offsets, tails and driver lifetime.
@ashhart

ashhart commented Nov 6, 2026

Copy link
Copy Markdown
Owner Author

GLM-5.3-Flash NVFP4 at TP=2 on two GB10s, main's merge base against this PR's tree (same patch as the current head), runs ordered base, new, new, base, --context 65536 --parallel 2, prompt cache off for the A/B:

Cell Base New against base
2K prompt 1,222.8 tok/s +31.5%
8K prompt 1,473.9 tok/s level (-0.0%)
32K prompt 1,477.1 tok/s level (-0.0%)
Chat, 1 stream 30.2 tok/s +0.2%
Chat, 2 streams 53.2 tok/s level
Code, 1 stream 55.5 tok/s +0.3%
Code, 2 streams 80.2 tok/s +0.1%

Tokens: 52 equal, 0 unequal, 0 unverified, and no cell had unequal streams. The six-turn chat with the default cache qualified on both binaries, thinking on and off, with the same cached_tokens on every turn. So nothing is slower and the 2K prompt is 31.5% faster. It goes back in the landing queue.

@ashhart

ashhart commented Nov 6, 2026

Copy link
Copy Markdown
Owner Author

/atc exchange f4207260c61d8a0241a6eb0acabf6abd4d14b77e7bec32c321178ddaef8a417e

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