spec(sp20): reserve 10 ISV slots [510..520) for WR-first reward optimization
This commit is contained in:
@@ -2585,7 +2585,7 @@ const ISV_NETWORK_DIM: usize = 23;
|
||||
/// (and the C-side mirrors in `state_layout.cuh`). Bump this constant in the
|
||||
/// SAME commit that adds the new range, and update `layout_fingerprint_seed`
|
||||
/// to register the new slot names.
|
||||
pub(crate) const ISV_TOTAL_DIM: usize = 510;
|
||||
pub(crate) const ISV_TOTAL_DIM: usize = 520; // was 510, SP20 added 10 slots [510..520)
|
||||
/// Legacy alias preserved for call sites that haven't been audited for the
|
||||
/// network-vs-total split. New code should pick `ISV_NETWORK_DIM` (for weight
|
||||
/// tensor sizing) or `ISV_TOTAL_DIM` (for the broadcast bus buffer).
|
||||
@@ -3701,7 +3701,17 @@ const fn layout_fingerprint_seed() -> &'static [u8] {
|
||||
SLOT_507_REWARD_HORIZON_WEIGHT_1BAR=507;\
|
||||
SLOT_508_REWARD_HORIZON_WEIGHT_5BAR=508;\
|
||||
SLOT_509_REWARD_HORIZON_WEIGHT_30BAR=509;\
|
||||
ISV_TOTAL_DIM=510;\
|
||||
SLOT_510_LOSS_CAP=510;\
|
||||
SLOT_511_ALPHA_EMA=511;\
|
||||
SLOT_512_WR_EMA=512;\
|
||||
SLOT_513_HOLD_COST_SCALE=513;\
|
||||
SLOT_514_TARGET_HOLD_PCT=514;\
|
||||
SLOT_515_HOLD_PCT_EMA=515;\
|
||||
SLOT_516_HOLD_REWARD_EMA=516;\
|
||||
SLOT_517_N_STEP=517;\
|
||||
SLOT_518_AUX_CONF_THRESHOLD=518;\
|
||||
SLOT_519_AUX_GATE_TEMP=519;\
|
||||
ISV_TOTAL_DIM=520;\
|
||||
SP19_PRODUCER_HARDCODED_HORIZON_BLEND=sp19_path_b;\
|
||||
SP14_C_AUX_TRUNK_CONTROL_PLANE=sp14_c_phase_1;\
|
||||
ALPHA_MACHINERY_DELETED=sp14_c_phase_1;\
|
||||
|
||||
@@ -863,6 +863,66 @@ pub const SENTINEL_REWARD_HORIZON_WEIGHT_DEFAULT: f32 = 0.333_333_343_f32; // 1.
|
||||
pub const SP19_REWARD_HORIZON_SLOT_BASE: usize = 507;
|
||||
pub const SP19_REWARD_HORIZON_SLOT_END: usize = 510;
|
||||
|
||||
// SP20 — WR-first reward + multi-horizon label utilization (2026-05-09)
|
||||
//
|
||||
// Slots 510-519 reserved for SP20 components per spec
|
||||
// docs/superpowers/specs/2026-05-09-sp19-20-wr-first-design.md.
|
||||
//
|
||||
// All slots are produced by sp20_emas_compute_kernel,
|
||||
// sp20_controllers_compute_kernel, or sp20_stats_compute_kernel
|
||||
// per Component 5 of the spec.
|
||||
|
||||
/// Adaptive loss cap for Component 1 reward kernel.
|
||||
/// Value: -1.0 - clamp((wr_ema - 0.50) / 0.05, 0, 1) — ranges [-1, -2].
|
||||
/// Producer: sp20_controllers_compute_kernel.
|
||||
pub const LOSS_CAP_INDEX: usize = 510;
|
||||
|
||||
/// Wiener-α EMA over alpha (= R_event - hold_baseline) at trade-close events.
|
||||
/// Used by Component 1 to center R_used = alpha - alpha_ema.
|
||||
/// Producer: sp20_emas_compute_kernel.
|
||||
pub const ALPHA_EMA_INDEX: usize = 511;
|
||||
|
||||
/// Per-trade win-rate EMA. Wiener-α floor 0.4.
|
||||
/// Drives LOSS_CAP_INDEX adaptive ramp.
|
||||
/// Producer: sp20_emas_compute_kernel.
|
||||
pub const WR_EMA_INDEX: usize = 512;
|
||||
|
||||
/// Adaptive Hold opp-cost magnitude (Component 2 controller output).
|
||||
/// Bounded [0.01, 0.5]. Two-sided controller from hold_pct_ema vs target.
|
||||
/// Producer: sp20_controllers_compute_kernel.
|
||||
pub const HOLD_COST_SCALE_INDEX: usize = 513;
|
||||
|
||||
/// Target Hold% derived from aux confidence distribution.
|
||||
/// Value: clamp(0.8 - aux_conf_p50_ema * 1.5, 0.1, 0.8).
|
||||
/// Producer: sp20_controllers_compute_kernel.
|
||||
pub const TARGET_HOLD_PCT_INDEX: usize = 514;
|
||||
|
||||
/// Wiener-α EMA of (action == Hold) indicator. Drives HOLD_COST_SCALE controller.
|
||||
/// Producer: sp20_emas_compute_kernel.
|
||||
pub const HOLD_PCT_EMA_INDEX: usize = 515;
|
||||
|
||||
/// Long-run mean of per-bar Hold reward (R_per_bar = -aux_conf * cost_scale).
|
||||
/// Updated only on Hold-state bars. Used to center Hold reward for Q-target
|
||||
/// scale comparability with trade reward.
|
||||
/// Producer: sp20_emas_compute_kernel.
|
||||
pub const HOLD_REWARD_EMA_INDEX: usize = 516;
|
||||
|
||||
/// Adaptive n-step credit distribution width.
|
||||
/// Value: clamp(round(trade_duration_ema), 1, 30).
|
||||
/// Producer: sp20_controllers_compute_kernel.
|
||||
pub const N_STEP_INDEX: usize = 517;
|
||||
|
||||
/// Aux→Q gate threshold. Value: clamp(aux_dir_acc_ema - 0.50, 0.01, 0.20).
|
||||
/// Producer: sp20_controllers_compute_kernel.
|
||||
pub const AUX_CONF_THRESHOLD_INDEX: usize = 518;
|
||||
|
||||
/// Aux→Q gate temperature. Value: aux_conf_std_ema (with floor).
|
||||
/// Producer: sp20_controllers_compute_kernel.
|
||||
pub const AUX_GATE_TEMP_INDEX: usize = 519;
|
||||
|
||||
pub const SP20_ISV_SLOT_BASE: usize = 510;
|
||||
pub const SP20_ISV_SLOT_END: usize = 520;
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
@@ -1327,4 +1387,20 @@ mod tests {
|
||||
SP19_REWARD_HORIZON_SLOT_END, ISV_TOTAL_DIM,
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn sp20_isv_slots_reserved_510_to_520() {
|
||||
use crate::cuda_pipeline::gpu_dqn_trainer::ISV_TOTAL_DIM;
|
||||
assert_eq!(ISV_TOTAL_DIM, 520);
|
||||
assert_eq!(LOSS_CAP_INDEX, 510);
|
||||
assert_eq!(ALPHA_EMA_INDEX, 511);
|
||||
assert_eq!(WR_EMA_INDEX, 512);
|
||||
assert_eq!(HOLD_COST_SCALE_INDEX, 513);
|
||||
assert_eq!(TARGET_HOLD_PCT_INDEX, 514);
|
||||
assert_eq!(HOLD_PCT_EMA_INDEX, 515);
|
||||
assert_eq!(HOLD_REWARD_EMA_INDEX, 516);
|
||||
assert_eq!(N_STEP_INDEX, 517);
|
||||
assert_eq!(AUX_CONF_THRESHOLD_INDEX, 518);
|
||||
assert_eq!(AUX_GATE_TEMP_INDEX, 519);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user