refactor: eliminate GpuVarStore — DuelingWeightSet is zero-copy pointer view into params_buf

DuelingWeightSet and BranchingWeightSet fields changed from owned
CudaSlice<f32> to raw u64 device pointers + usize element counts.
This enables zero-copy views directly into the flat params_buf for
the training hot path (no D2D copies, no shadow allocations).

Key changes:
- Weight sets store u64 + usize pairs instead of CudaSlice<f32>
- from_flat_buffer() creates zero-copy views into params_buf
- from_slices() creates pointer views from owned CudaSlice allocations
- DuelingWeightBacking/BranchingWeightBacking hold owned CudaSlice
  arrays for callers that need independent allocations (experience
  collector, ensemble heads, tests)
- flatten/unflatten become no-ops when weight sets point into params_buf
- extract functions return (Backing, WeightSet) tuples
- KernelWeightPack::build() uses u64 fields directly (no raw_device_ptr)
- All sync functions updated for pointer-based signatures
- Ensemble clone functions return backing + pointer view pairs
- gradient_budget tests updated (7/7 pass)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
jgrusewski
2026-04-11 14:02:55 +02:00
parent a662e54e86
commit 1c3eb3e331
8 changed files with 693 additions and 502 deletions

View File

@@ -1197,15 +1197,19 @@ fn evaluate_dqn_fold_gpu(
dueling_config.advantage_hidden_dim,
);
let weights = extract_dueling_weights(dqn.get_q_network_vars(), &stream)
let (_d_backing, weights) = extract_dueling_weights(dqn.get_q_network_vars(), &stream)
.with_context(|| format!("extract_dueling_weights failed for fold {}", fold))?;
// Extract branching weights if branching DQN is active
use ml::cuda_pipeline::gpu_weights::extract_branching_weights;
let branching_weights = dqn.branching_q_network.as_ref()
let branching_result = dqn.branching_q_network.as_ref()
.map(|br| extract_branching_weights(br.vars(), &stream))
.transpose()
.with_context(|| format!("extract_branching_weights failed for fold {}", fold))?;
let (_b_backing, branching_weights) = match branching_result {
Some((b, w)) => (Some(b), Some(w)),
None => (None, None),
};
let dqn_cfg = ml::cuda_pipeline::gpu_backtest_evaluator::DqnBacktestConfig::from_network_dims(network_dims);