refactor: collapse 9-level to 7-level ExposureLevel — eliminate degenerate Flat variants

The 4-branch DQN (direction x magnitude) had 3 degenerate variants
(Short25, Flat, Long25) that all mapped to 0.0 target exposure when
direction=Flat, causing 82% Flat collapse. Collapse these into a
single Flat variant, giving 7 levels (ShortSmall/Half/Full, Flat,
LongSmall/Half/Full) and 63 total factored actions (7x3x3).

- ExposureLevel enum: 9 variants -> 7 (add direction/magnitude/from_dir_mag)
- FactoredAction: 81 -> 63 total actions, from_index/to_index updated
- DQN epsilon-greedy: use from_dir_mag() instead of dir*3+mag indexing
- DQN config: num_actions default 9 -> 7
- PPO action space: 45 -> 63 actions, action masking updated
- Signal adapter CUDA kernel: 5-bin -> 7-bin exposure aggregation
- All tests updated for new variant names and index ranges

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
jgrusewski
2026-04-11 11:54:09 +02:00
parent 55be1776b5
commit 448b61d095
61 changed files with 737 additions and 710 deletions

View File

@@ -161,7 +161,7 @@ pub async fn load_models_for_backtest(specs: &[ModelSpec]) -> Result<(), MLError
"DQN" => {
let config = DQNConfig {
state_dim: 51,
num_actions: 45,
num_actions: 63,
hidden_dims: vec![128, 128],
..Default::default()
};
@@ -177,7 +177,7 @@ pub async fn load_models_for_backtest(specs: &[ModelSpec]) -> Result<(), MLError
"PPO" => {
let config = PPOConfig {
state_dim: 51,
num_actions: 45,
num_actions: 63,
policy_hidden_dims: vec![128, 64],
value_hidden_dims: vec![128, 64],
..Default::default()
@@ -217,7 +217,7 @@ mod tests {
fn test_dqn_config() -> DQNConfig {
DQNConfig {
state_dim: 51,
num_actions: 45,
num_actions: 63,
hidden_dims: vec![64, 64],
..Default::default()
}

View File

@@ -171,7 +171,7 @@ async fn test_replay_engine_streams_events() {
async fn test_model_loads_and_predicts() {
let config = DQNConfig {
state_dim: 51,
num_actions: 45,
num_actions: 63,
hidden_dims: vec![64, 64],
..Default::default()
};