WIP(bf16): atomic BF16 conversion — 36/37 CUDA kernels, all Rust types

CUDA kernels: 36 of 37 compiled with __nv_bfloat16* (dt_kernels.cu remaining)
Rust types: ALL CudaSlice<f32> → CudaSlice<half::bf16> across ml + ml-core
Build: all kernels now compiled with common_device_functions.cuh (BF16 helpers)
BF16 math wrappers: bf16_sqrt, bf16_log, bf16_exp, bf16_pow, bf16_fabs, bf16_fmax,
  bf16_fmin, bf16_cos, bf16_zero, bf16_one, bf16(), atomicAddBF16

NOT YET COMPILING — ml-core boundary errors (Vec<f32> → Vec<half::bf16>)
and dt_kernels.cu float*__nv_bfloat16 ambiguity remain.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
jgrusewski
2026-03-27 23:00:45 +01:00
parent 406fb44a3f
commit a797e61d96
81 changed files with 1776 additions and 1675 deletions

View File

@@ -87,7 +87,7 @@ fn test_per_sample_latency() -> anyhow::Result<()> {
let next_states = stream.clone_htod(&host_states).map_err(|e| anyhow::anyhow!("{e}"))?;
let actions = stream.alloc_zeros::<u32>(batch_insert).map_err(|e| anyhow::anyhow!("{e}"))?;
let rewards = stream.clone_htod(&host_rewards).map_err(|e| anyhow::anyhow!("{e}"))?;
let dones = stream.alloc_zeros::<f32>(batch_insert).map_err(|e| anyhow::anyhow!("{e}"))?;
let dones = stream.alloc_zeros::<half::bf16>(batch_insert).map_err(|e| anyhow::anyhow!("{e}"))?;
buf.insert_batch(&states, &next_states, &actions, &rewards, &dones, batch_insert)?;
}
assert_eq!(buf.len(), fill_count);