Files
ml/hanzo-ml/tests/rocm_kernels_compile.rs
zeekayandHanzo Dev 3cfd155734 rocm: the fused GDN scan includes the HIP runtime; every kernel source is compile-checked
gdn.hip named threadIdx without including hip_runtime.h, so hipcc refused it
at the first forward that reached the scan. A kernel is compiled from source at
first use; the new test compiles every shipped source for the box's GPU.
hanzo-rocm-kernels 0.11.40, hanzo-ml 0.11.101; 0.11.39 and 0.11.100 are yanked.

Co-authored-by: Hanzo Dev <[email protected]>
2026-09-17 19:17:38 -07:00

43 lines
1.5 KiB
Rust

//! Every ROCm kernel source the crate ships compiles for this GPU. The kernels are compiled from
//! source at first use, so a source that hipcc rejects fails at the first forward that needs it,
//! not at build time; this is the build-time check.
#![cfg(feature = "rocm")]
use hanzo_rocm_kernels::kernel::KernelSource;
fn compiles<K: KernelSource>() {
let dir = std::env::temp_dir();
let src = dir.join(format!("hanzo_{}_compile_check.hip", K::NAME));
let out = dir.join(format!("hanzo_{}_compile_check.hsaco", K::NAME));
std::fs::write(&src, K::CODE).unwrap();
let arch = std::env::var("HANZO_ROCM_ARCH").unwrap_or_else(|_| "gfx1151".into());
let status = std::process::Command::new("hipcc")
.args(["--genco", "-O1", &format!("--offload-arch={arch}"), "-o"])
.arg(&out)
.arg(&src)
.status()
.expect("hipcc on PATH");
assert!(status.success(), "{} does not compile", K::NAME);
}
#[test]
fn every_kernel_source_compiles() {
use hanzo_rocm_kernels::kernel::*;
compiles::<BinaryKernel>();
compiles::<UnaryKernel>();
compiles::<AffineKernel>();
compiles::<FillKernel>();
compiles::<ReduceKernel>();
compiles::<ConvKernel>();
compiles::<IndexingKernel>();
compiles::<CastKernel>();
compiles::<TernaryKernel>();
compiles::<SortKernel>();
compiles::<QuantKernel>();
compiles::<RopeKernel>();
compiles::<FlashKernel>();
compiles::<DslRmsNormKernel>();
compiles::<DslAddRmsNormKernel>();
compiles::<GdnKernel>();
}