fix(ml): suppress unsafe-code warning on startup env::set_var calls

CUBLAS_WORKSPACE_CONFIG and NVIDIA_TF32_OVERRIDE are set once at
startup before any threads or CUDA work begins. The unsafe block is
correct but triggers -W unsafe-code. Adding #[allow(unsafe_code)] at
the call site silences the warning while keeping the safety comment.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
jgrusewski
2026-03-12 08:46:17 +01:00
parent ad2a9662ca
commit bf9a739908
2 changed files with 2 additions and 0 deletions

View File

@@ -413,6 +413,7 @@ fn main() -> Result<()> {
// Pre-allocate CUBLAS workspace for deterministic + faster tensor core ops.
// Enable TF32 for all FP32 matmuls — ~8x throughput on H100 tensor cores.
// SAFETY: called once at startup before any multi-threading or CUDA work begins.
#[allow(unsafe_code)]
unsafe {
std::env::set_var("CUBLAS_WORKSPACE_CONFIG", ":4096:8");
std::env::set_var("NVIDIA_TF32_OVERRIDE", "1");

View File

@@ -1042,6 +1042,7 @@ fn main() -> Result<()> {
// Pre-allocate CUBLAS workspace for deterministic + faster tensor core ops.
// Enable TF32 for all FP32 matmuls — ~8x throughput on H100 tensor cores.
// SAFETY: called once at startup before any multi-threading or CUDA work begins.
#[allow(unsafe_code)]
unsafe {
std::env::set_var("CUBLAS_WORKSPACE_CONFIG", ":4096:8");
std::env::set_var("NVIDIA_TF32_OVERRIDE", "1");