fix: zen precommit — 2 criticals + 3 lows resolved
CRITICAL: ISV+plan heads wired into submit_forward_ops_main (training). CRITICAL: backtest single-step 3-branch→4-branch action encoding. LOW: Remove dead bar_start_ns/bar_duration_ns from MicrostructureState. LOW: Pre-allocated eps_host_buf replaces Vec allocation in hot path. LOW: training_sharpe + val_loss added to metrics additional_metrics. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -684,11 +684,8 @@ const fn safe_clip(value: f64, min: f64, max: f64) -> f64 {
|
|||||||
/// | 18 | OFI Acceleration |
|
/// | 18 | OFI Acceleration |
|
||||||
/// | 19 | Toxicity Gradient |
|
/// | 19 | Toxicity Gradient |
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
#[allow(dead_code)]
|
|
||||||
pub struct MicrostructureState {
|
pub struct MicrostructureState {
|
||||||
// --- bar timing ---
|
/// Bar midpoint for intra-bar momentum half-split (used by update_snapshot).
|
||||||
bar_start_ns: u64,
|
|
||||||
bar_duration_ns: u64,
|
|
||||||
bar_mid_ns: u64,
|
bar_mid_ns: u64,
|
||||||
|
|
||||||
// --- [8] OFI Trajectory: online linear regression of OFI_L1 over time ---
|
// --- [8] OFI Trajectory: online linear regression of OFI_L1 over time ---
|
||||||
@@ -758,8 +755,6 @@ impl MicrostructureState {
|
|||||||
/// Create a new state for a bar starting at `bar_start_ns` with given duration.
|
/// Create a new state for a bar starting at `bar_start_ns` with given duration.
|
||||||
pub fn new(bar_start_ns: u64, bar_duration_ns: u64) -> Self {
|
pub fn new(bar_start_ns: u64, bar_duration_ns: u64) -> Self {
|
||||||
Self {
|
Self {
|
||||||
bar_start_ns,
|
|
||||||
bar_duration_ns,
|
|
||||||
bar_mid_ns: bar_start_ns + bar_duration_ns / 2,
|
bar_mid_ns: bar_start_ns + bar_duration_ns / 2,
|
||||||
|
|
||||||
ofi_linreg_n: 0.0,
|
ofi_linreg_n: 0.0,
|
||||||
|
|||||||
@@ -46,6 +46,8 @@ pub struct GpuActionSelector {
|
|||||||
/// Per-sample epsilon buffer for branching kernel: [max_batch_size] on GPU.
|
/// Per-sample epsilon buffer for branching kernel: [max_batch_size] on GPU.
|
||||||
/// Filled with uniform epsilon before each branching launch.
|
/// Filled with uniform epsilon before each branching launch.
|
||||||
epsilon_buf: CudaSlice<f32>,
|
epsilon_buf: CudaSlice<f32>,
|
||||||
|
/// Pre-allocated host buffer for epsilon fill — avoids Vec allocation in hot path.
|
||||||
|
eps_host_buf: Vec<f32>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl GpuActionSelector {
|
impl GpuActionSelector {
|
||||||
@@ -71,6 +73,7 @@ impl GpuActionSelector {
|
|||||||
bonus_exposure_ptr: 0, bonus_order_ptr: 0, bonus_urgency_ptr: 0,
|
bonus_exposure_ptr: 0, bonus_order_ptr: 0, bonus_urgency_ptr: 0,
|
||||||
bonus_exposure_buf: None, bonus_order_buf: None, bonus_urgency_buf: None,
|
bonus_exposure_buf: None, bonus_order_buf: None, bonus_urgency_buf: None,
|
||||||
epsilon_buf,
|
epsilon_buf,
|
||||||
|
eps_host_buf: vec![0.0_f32; max_batch_size],
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -151,8 +154,9 @@ impl GpuActionSelector {
|
|||||||
if batch_size > self.max_batch_size { return Err(MLError::ModelError(format!("batch_size {} exceeds max {}", batch_size, self.max_batch_size))); }
|
if batch_size > self.max_batch_size { return Err(MLError::ModelError(format!("batch_size {} exceeds max {}", batch_size, self.max_batch_size))); }
|
||||||
// Fill per-sample epsilon buffer with uniform value (kernel reads per_sample_epsilon[idx])
|
// Fill per-sample epsilon buffer with uniform value (kernel reads per_sample_epsilon[idx])
|
||||||
// Slice to batch_size to match eps_host length (epsilon_buf allocated for max_batch_size)
|
// Slice to batch_size to match eps_host length (epsilon_buf allocated for max_batch_size)
|
||||||
let eps_host = vec![epsilon; batch_size];
|
// Fill pre-allocated host buffer (no heap allocation in hot path)
|
||||||
self.stream.memcpy_htod(&eps_host, &mut self.epsilon_buf.slice_mut(..batch_size))
|
self.eps_host_buf[..batch_size].fill(epsilon);
|
||||||
|
self.stream.memcpy_htod(&self.eps_host_buf[..batch_size], &mut self.epsilon_buf.slice_mut(..batch_size))
|
||||||
.map_err(|e| MLError::ModelError(format!("upload epsilon_buf: {e}")))?;
|
.map_err(|e| MLError::ModelError(format!("upload epsilon_buf: {e}")))?;
|
||||||
let config = launch_config_1d(batch_size);
|
let config = launch_config_1d(batch_size);
|
||||||
let bs_i32 = batch_size as i32;
|
let bs_i32 = batch_size as i32;
|
||||||
|
|||||||
4742
pal_precommit.changeset
Normal file
4742
pal_precommit.changeset
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user