chore(ml): file-level allow(unsafe_code) on 12 CUDA-launch files
CUDA kernel launches via cudarc::launch_builder and MappedF32::new (cuMemHostAlloc DEVICEMAP FFI) inherently require unsafe blocks. The workspace-wide '-W unsafe-code' lint produced ~80 warnings across these files, all structurally identical. Match the established pattern from ml-backtesting/src/harness.rs and ml-backtesting/src/sim/mod.rs: single file-level allow with a comment explaining the rationale. Files: alpha_dqn_h600_smoke, alpha_baseline, cublaslt_debug, gpu_walk_forward, cuda_pipeline/mod, hyperopt adapters (mamba2, ppo), DQN smoke_tests (helpers, td_propagation), trainers/ppo, and two ml/tests files. Documented in dqn-wire-up-audit.md.
This commit is contained in:
@@ -1,3 +1,7 @@
|
||||
// CUDA kernel launches via cudarc + MappedF32::new (cuMemHostAlloc DEVICEMAP) require
|
||||
// unsafe FFI. Workspace -W unsafe-code is structural noise here. Same rationale as
|
||||
// ml-backtesting/src/harness.rs file-level allow.
|
||||
#![allow(unsafe_code)]
|
||||
//! Phase E.3 Task 23 — Composition backtest with cost sweep.
|
||||
//!
|
||||
//! Trains the Phase E execution-policy DQN (linear Q + Phase 1d.3
|
||||
|
||||
@@ -38,6 +38,12 @@
|
||||
//! --n-episodes 1000
|
||||
//! ```
|
||||
|
||||
// CUDA kernel launches via `cudarc::launch_builder.launch(...)` and
|
||||
// `MappedF32::new` (`cuMemHostAlloc(DEVICEMAP)` FFI) require `unsafe`. The
|
||||
// workspace-wide `-W unsafe-code` lint is therefore noise here. Same rationale
|
||||
// as `ml-backtesting/src/harness.rs` and `sim/mod.rs`'s file-level allows.
|
||||
#![allow(unsafe_code)]
|
||||
|
||||
use std::fs::File;
|
||||
use std::io::Write;
|
||||
use std::mem::MaybeUninit;
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
// CUDA kernel launches via cudarc + MappedF32::new (cuMemHostAlloc DEVICEMAP) require
|
||||
// unsafe FFI. Workspace -W unsafe-code is structural noise here. Same rationale as
|
||||
// ml-backtesting/src/harness.rs file-level allow.
|
||||
#![allow(unsafe_code)]
|
||||
//! Standalone cublasLtMatmul debug test.
|
||||
//! Tests the EXACT same API call that fails in the experience collector on H100.
|
||||
//! Run: SQLX_OFFLINE=true cargo test -p ml --lib -- cuda_pipeline::cublaslt_debug --nocapture
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
// CUDA kernel launches via cudarc + MappedF32::new (cuMemHostAlloc DEVICEMAP) require
|
||||
// unsafe FFI. Workspace -W unsafe-code is structural noise here. Same rationale as
|
||||
// ml-backtesting/src/harness.rs file-level allow.
|
||||
#![allow(unsafe_code)]
|
||||
//! GPU-resident walk-forward data manager.
|
||||
//!
|
||||
//! Uploads the ENTIRE dataset to GPU VRAM once, then provides per-fold
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
// CUDA kernel launches via cudarc + MappedF32::new (cuMemHostAlloc DEVICEMAP) require
|
||||
// unsafe FFI. Workspace -W unsafe-code is structural noise here. Same rationale as
|
||||
// ml-backtesting/src/harness.rs file-level allow.
|
||||
#![allow(unsafe_code)]
|
||||
//! GPU Pipeline: Pre-uploaded training data for DQN/PPO trainers.
|
||||
//!
|
||||
//! Eliminates per-bar heap allocations by uploading all training data
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
// CUDA kernel launches via cudarc + MappedF32::new (cuMemHostAlloc DEVICEMAP) require
|
||||
// unsafe FFI. Workspace -W unsafe-code is structural noise here. Same rationale as
|
||||
// ml-backtesting/src/harness.rs file-level allow.
|
||||
#![allow(unsafe_code)]
|
||||
//! MAMBA-2 Hyperparameter Optimization Adapter
|
||||
//!
|
||||
//! This module provides a production-ready adapter for optimizing MAMBA-2
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
// CUDA kernel launches via cudarc + MappedF32::new (cuMemHostAlloc DEVICEMAP) require
|
||||
// unsafe FFI. Workspace -W unsafe-code is structural noise here. Same rationale as
|
||||
// ml-backtesting/src/harness.rs file-level allow.
|
||||
#![allow(unsafe_code)]
|
||||
//! PPO Hyperparameter Optimization Adapter
|
||||
//!
|
||||
//! This module provides a production-ready adapter for optimizing PPO
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
// CUDA kernel launches via cudarc + MappedF32::new (cuMemHostAlloc DEVICEMAP) require
|
||||
// unsafe FFI. Workspace -W unsafe-code is structural noise here. Same rationale as
|
||||
// ml-backtesting/src/harness.rs file-level allow.
|
||||
#![allow(unsafe_code)]
|
||||
use crate::trainers::dqn::{DQNHyperparameters, DQNTrainer};
|
||||
use ml_core::device::MlDevice;
|
||||
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
// CUDA kernel launches via cudarc + MappedF32::new (cuMemHostAlloc DEVICEMAP) require
|
||||
// unsafe FFI. Workspace -W unsafe-code is structural noise here. Same rationale as
|
||||
// ml-backtesting/src/harness.rs file-level allow.
|
||||
#![allow(unsafe_code)]
|
||||
//! TD propagation diagnostic: does sparse-reward Q-learning actually learn?
|
||||
//!
|
||||
//! After Phase 2's reward-shaping purge, training reward is essentially pure
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
// CUDA kernel launches via cudarc + MappedF32::new (cuMemHostAlloc DEVICEMAP) require
|
||||
// unsafe FFI. Workspace -W unsafe-code is structural noise here. Same rationale as
|
||||
// ml-backtesting/src/harness.rs file-level allow.
|
||||
#![allow(unsafe_code)]
|
||||
//! PPO Trainer with gRPC Integration
|
||||
//!
|
||||
//! This module provides a production-ready PPO trainer that integrates with the ML Training Service
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
// CUDA kernel launches via cudarc + MappedF32::new (cuMemHostAlloc DEVICEMAP) require
|
||||
// unsafe FFI. Workspace -W unsafe-code is structural noise here. Same rationale as
|
||||
// ml-backtesting/src/harness.rs file-level allow.
|
||||
#![allow(unsafe_code)]
|
||||
//! Per-regime WR GPU oracle tests (audit follow-up 2026-05-09).
|
||||
//!
|
||||
//! Validates that `compute_backtest_metrics` correctly bucketises
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
// CUDA kernel launches via cudarc + MappedF32::new (cuMemHostAlloc DEVICEMAP) require
|
||||
// unsafe FFI. Workspace -W unsafe-code is structural noise here. Same rationale as
|
||||
// ml-backtesting/src/harness.rs file-level allow.
|
||||
#![allow(unsafe_code)]
|
||||
#![allow(
|
||||
clippy::assertions_on_constants,
|
||||
clippy::assertions_on_result_states,
|
||||
|
||||
@@ -18750,3 +18750,29 @@ failed because Q2-Q9 contain different `instrument_id`s than Q1 — see
|
||||
(`FrontMonth` once DQN training moves to multi-quarter walk-forward).
|
||||
|
||||
**Wire-up impact:** None (semantic preservation only).
|
||||
|
||||
## 2026-05-22 — chore(ml): file-level allow(unsafe_code) on CUDA-launch files
|
||||
|
||||
**Branch:** `ml-alpha-phase-a`. **Trigger:** CUDA kernel launches via
|
||||
`cudarc::launch_builder` and `MappedF32::new` (cuMemHostAlloc DEVICEMAP FFI)
|
||||
inherently require `unsafe` blocks. The workspace-wide `-W unsafe-code` lint
|
||||
flagged ~80 individual unsafe blocks across 12 files, all structurally
|
||||
identical (kernel launch must be unsafe). Established pattern is the
|
||||
file-level allow in `ml-backtesting/src/harness.rs` and
|
||||
`ml-backtesting/src/sim/mod.rs`.
|
||||
|
||||
**Change:** Added `#![allow(unsafe_code)]` at the top of 12 files with the
|
||||
same justification comment: `crates/ml/examples/alpha_dqn_h600_smoke.rs`,
|
||||
`crates/ml/examples/alpha_baseline.rs`,
|
||||
`crates/ml/src/cuda_pipeline/cublaslt_debug.rs`,
|
||||
`crates/ml/src/cuda_pipeline/gpu_walk_forward.rs`,
|
||||
`crates/ml/src/cuda_pipeline/mod.rs`,
|
||||
`crates/ml/src/hyperopt/adapters/mamba2.rs`,
|
||||
`crates/ml/src/hyperopt/adapters/ppo.rs`,
|
||||
`crates/ml/src/trainers/dqn/smoke_tests/helpers.rs`,
|
||||
`crates/ml/src/trainers/dqn/smoke_tests/td_propagation.rs`,
|
||||
`crates/ml/src/trainers/ppo.rs`,
|
||||
`crates/ml/tests/regime_wr_oracle_tests.rs`,
|
||||
`crates/ml/tests/smoke_test_real_data.rs`.
|
||||
|
||||
**Wire-up impact:** None (lint hygiene only — no semantic changes).
|
||||
|
||||
Reference in New Issue
Block a user