feat(cuda): report device identity and compiled architecture - #30
Open
NicolasRouquette wants to merge 1 commit into
Open
feat(cuda): report device identity and compiled architecture#30NicolasRouquette wants to merge 1 commit into
NicolasRouquette wants to merge 1 commit into
Conversation
NicolasRouquette
force-pushed
the
cuda-device-identity
branch
3 times, most recently
from
August 26, 2026 23:38
4d00f0c to
c30b1ef
Compare
A benchmark or a sizing decision that cannot name the device it ran on produces a number that cannot be filed beside another one. The allocator snapshot already answers how much device memory there is; nothing answered which device, and nothing answered which architectures the binary actually holds native code for. Adds `Buffer.deviceInfo : IO (Option DeviceInfo)` over `cudaGetDeviceProperties` — name, index, compute capability, SM count, core and memory clocks, bus width, total memory, driver and runtime versions — plus `peakBandwidthGBs`, so a row reporting achieved GB/s can be read as a fraction of the roofline without the reader looking the card up. Adds `Buffer.compiledArchList`, the binary's own `__CUDA_ARCH_LIST__`, and `DeviceInfo.runsNatively`. A binary compiled for one architecture still runs on a newer device through PTX JIT, silently turning a benchmark into a measurement of the fallback; the pair of facts makes that visible, and `DeviceInfo.format` prints it as a warning when they disagree. Properties are queried once under `pthread_once` and cached. In the CPU stub, and in a CUDA build on a host where no device answers, the name is empty and `deviceInfo` is `none` — so a caller prints one line under either flavour and reads the absence off the fields rather than off its own build flavour. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
NicolasRouquette
force-pushed
the
cuda-device-identity
branch
from
August 28, 2026 15:56
c30b1ef to
34006aa
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
A benchmark or a sizing decision that cannot name the device it ran on produces a number that cannot be filed beside another one.
Buffer.allocatorStatsalready answers how much device memory there is; nothing answered which device, and nothing answered which architectures the binary actually holds native code for.The second gap is the one that bites quietly. Device code is compiled for an architecture, and with no
-archthe toolkit applies its own default. A binary built that way still runs on a newer GPU — through forward PTX JIT — so nothing fails and nothing warns. The timings are then of JIT-generated code for an architecture the compiler was never told about, which is a different measurement from the one a reader will assume.What
Buffer.deviceInfo : IO (Option DeviceInfo)overcudaGetDeviceProperties: name, index, compute capability, SM count, core and memory clocks, memory bus width, total memory, driver and runtime versions.DeviceInfo.peakBandwidthGBs, so a row reporting achieved GB/s can be read as a fraction of the roofline without the reader looking the card up.Buffer.compiledArchList— the binary's own__CUDA_ARCH_LIST__("860","750,860") — andDeviceInfo.runsNatively.DeviceInfo.formatprints the mismatch as a warning:That line is not hypothetical — it is the first thing the check reported on the machine it was written on.
Shape of the change
Properties are queried once under
pthread_onceand cached;cudaGetDevicePropertiesis comparatively expensive and its answer cannot change for a device index.In the CPU stub, and in a CUDA build on a host where no device answers, the name is empty and every scalar is
0, sodeviceInforeturnsnone. A caller therefore prints one line under either build flavour and reads the absence off the fields rather than off its own build flavour.Additions only — 4 files, no existing declaration or symbol changed. The stub carries the matching definitions so the parity build keeps linking.
Testing
Built and run both flavours on an RTX A4500 (sm_86, CUDA 12.6, driver 13.0):
deviceInforeturnsnone, the caller's line reads as absence.-arch: reports the device correctly and flagscompiled for 520, NOT sm_86.TORCHLEAN_CUDA_ARCH=sm_86: warning gone, reads[compiled for 860].Measured cost of the JIT for the workload in hand: none (24.47 ms against 23.29 ms, within run-to-run scatter). The point is that it was not knowable before.
🤖 Generated with Claude Code