Module arch_preflight

Module arch_preflight 

Source
Expand description

2026-09-25: Refuse a GPU whose compute capability cannot run the kernels’ architecture, before MetraleCudaBackend::new loads any module, with an error that names both ([metrale_core::arch::ArchMismatch]); also warn when the device’s SM count differs from the target’s sm_count.

The rule is [metrale_core::arch::ptx_arch_runs_on_device]; the preflight’s device queries are addressed by ordinal (cuDeviceGet), not by the calling thread’s current context (see device_compute_capability_of).

Owner: gpu-runtime (CUDA backend). Invariants:

  • preflight_device_arch_with returns Ok without a device query when the target records no architecture.
  • An SM-count mismatch or an unanswered SM-count query never fails the preflight.

Functions§

check_arch
2026-09-25: The verdict, without touching a GPU: Ok(line to log), or the [metrale_core::arch::ArchMismatch] as the error. Testable with no CUDA.
check_sm_count
2026-09-25: Compare the device’s SM count with the target’s kernels/<hw>/HARDWARE.toml [hardware] sm_count: None when they are equal, otherwise a warning naming both numbers and the file. The caller logs it and carries on (preflight_device_arch_with).
device_compute_capability
2026-09-25: (major, minor) compute capability of the device of the calling thread’s current context; fails without one. --check-kernels calls it after the backend is built (kernel_gate.rs current_device_cc). The preflight uses device_compute_capability_of instead.
device_compute_capability_of
2026-09-25: (major, minor) compute capability of GPU ordinal, with no current context needed on the calling thread.
device_sm_count_of
2026-09-25: Streaming multiprocessors on GPU ordinal, addressed by ordinal like device_compute_capability_of. Fails when the query fails or the count is <= 0.
preflight_arch
2026-09-25: The architecture string the preflight judges: the target’s ptx_arch ([hardware].arch verbatim, e.g. sm_90a), not target.arch, which has the a/f suffix stripped. The suffix decides which devices the PTX runs on: plain sm_90 passes on CC 10.0 and 12.1, sm_90a does not (ptx_arch_runs_on_device).
preflight_device_arch
2026-09-25: Fail if kernels built for compiled_arch cannot run on GPU ordinal. Call it before MetraleCudaBackend::new, which loads the modules (init_gpu_backend does, through kernel_gate::gate_device_arch).