feat(reward-v7): update kernel signature — replace v6 penalty args with v7 CEA/order/risk args

Replace loss_aversion/beta_penalty/trade_clustering_penalty with cea_weight/
order_credit_weight/risk_efficiency_weight; remove regret_blend entirely.
Rust launch arg order matches CUDA parameter order exactly.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
jgrusewski
2026-04-07 20:14:44 +02:00
parent b615559507
commit 94e8e5bdc7
2 changed files with 11 additions and 11 deletions

View File

@@ -804,10 +804,12 @@ extern "C" __global__ void experience_action_select(
* 3. Computes target position = exposure_fraction * max_position.
* 4. Applies position adjustment delta with volatility-scaled tx cost.
* 5. Runs dynamic trailing stop (regime-adaptive).
* 6. Computes reward v6:
* 6. Computes reward v7:
* sparse = trade_return * patience_mult (at trade exit, primary signal)
* reward = sparse (Sparse Trade-Completion Only)
* if reward < 0: reward *= loss_aversion (prospect theory)
* + CEA bonus (counterfactual exposure advantage)
* + order_credit (microstructure credit for order type selection)
* + risk_efficiency (intra-trade risk-adjusted return bonus)
* 7. Writes (batch_states, action, reward, done) to output replay buffer.
* 8. Updates portfolio_states[0..19] in place.
* 9. Increments current_timesteps[i].
@@ -836,7 +838,7 @@ extern "C" __global__ void experience_env_step(
const float* __restrict__ batch_states, /* #30: f32 states from state_gather */
float max_position,
float tx_cost_multiplier,
float loss_aversion,
float cea_weight, /* v7: counterfactual exposure advantage weight */
const __nv_bfloat16* __restrict__ features,
int market_dim,
int L,
@@ -856,15 +858,14 @@ extern "C" __global__ void experience_env_step(
float margin_pct, /* e.g. 0.06 (6% initial margin) */
float dd_threshold, /* drawdown fraction before penalty (0.02 = 2%) */
float w_dd, /* drawdown penalty weight (1.0 = full) */
float beta_penalty, /* anti-correlation: penalize market-aligned returns (0.0 = off) */
float trade_clustering_penalty, /* #25 trade clustering: CV(inter-trade times) * weight (0=off) */
float order_credit_weight, /* v7: order type microstructure credit weight */
float risk_efficiency_weight, /* v7: intra-trade risk efficiency weight */
int mirror_active, /* #10 mirror universe: invert exposure actions */
/* #19 Position entropy: per-episode position visit histogram [N, 9].
* NULL = disabled. Incremented at each timestep. Entropy bonus computed
* at episode end (done=1) and added to final reward. */
float* __restrict__ position_histogram,
float position_entropy_weight, /* #19: reward += weight * H(histogram). 0=disabled. */
float regret_blend, /* #17: blend factor for counterfactual regret (0=pure PnL, 1=pure regret) */
/* #33 Per-episode saboteur params [N, 3]: (spread_mult, fill_prob, slippage_mult).
* NULL = disabled (use global scalars). When non-NULL, overrides
* spread_cost, fill_ioc_fill_prob, tx_cost_multiplier per episode. */

View File

@@ -1787,7 +1787,7 @@ impl GpuExperienceCollector {
// ── 5. Environment step (reward v5: trade-aware hybrid) ──────
// max_pos and min_hold_bars_i32 already defined above (action_select block)
let tx_cost = config.tx_cost_multiplier;
let rw_loss_av = config.loss_aversion;
let cea_w = config.cea_weight as f32;
let l_i32 = timesteps as i32;
// Task 8: current_t is now GPU-resident — pass device pointer
// instead of host scalar. step_counter_gpu[0] == t at this point.
@@ -1806,7 +1806,7 @@ impl GpuExperienceCollector {
.arg(&self.batch_states)
.arg(&max_pos)
.arg(&tx_cost)
.arg(&rw_loss_av)
.arg(&cea_w)
.arg(market_features_buf)
.arg(&md)
.arg(&l_i32)
@@ -1826,12 +1826,11 @@ impl GpuExperienceCollector {
.arg(&config.margin_pct) // initial margin fraction (e.g. 0.06 = 6%)
.arg(&config.dd_threshold) // drawdown threshold before penalty (0.02 = 2%)
.arg(&config.w_dd) // drawdown penalty weight
.arg(&config.beta_penalty) // anti-correlation beta penalty
.arg(&config.trade_clustering_penalty) // #25 trade clustering penalty
.arg(&(config.order_credit_weight as f32)) // v7: order microstructure credit
.arg(&(config.risk_efficiency_weight as f32)) // v7: risk efficiency bonus
.arg(&mirror_i32) // #10 mirror universe
.arg(&mut self.position_histogram) // #19 position entropy histogram
.arg(&config.position_entropy_weight) // #19 position entropy weight
.arg(&config.regret_blend) // #17 counterfactual regret
// #33 Per-episode saboteur params (0 = NULL = disabled)
.arg(&{
if self.saboteur_active {