- Reduce CI GPU test datasets 16x for walltime reduction - Reduce early-stop epochs 50→10, add --test-threads=1 - Serialize all GPU lib tests to prevent cuBLAS init race - Align state_dim to 16 for BF16 tensor core HMMA dispatch - BF16 precision tolerance in ml-dqn tests - Enable branching DQN + tracing subscriber in smoke tests - Prevent min_replay_size > buffer_size deadlock in early-stop tests - Prevent AutoReplaySizer from breaking gradient collapse warmup - Replace racy tokio::spawn checkpoint counter with AtomicUsize - Set warmup_steps=0 and max_training_steps_per_epoch=300 in early-stop tests - RealDataLoader respects TEST_DATA_DIR for CI PVC layout - Add collapse_warmup_capacity to gpu_smoketest DQNConfig - Drain CUDA context between test binaries - Detached HEAD checkout prevents local branch corruption - GPU pipeline tests: fix BF16 dtype and rank-1 squeeze assertions - OOD input handling tests use use_gpu: true Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
183 lines
5.5 KiB
Rust
183 lines
5.5 KiB
Rust
#![allow(
|
|
clippy::assertions_on_constants,
|
|
clippy::assertions_on_result_states,
|
|
clippy::clone_on_copy,
|
|
clippy::decimal_literal_representation,
|
|
clippy::doc_markdown,
|
|
clippy::empty_line_after_doc_comments,
|
|
clippy::field_reassign_with_default,
|
|
clippy::get_unwrap,
|
|
clippy::identity_op,
|
|
clippy::inconsistent_digit_grouping,
|
|
clippy::indexing_slicing,
|
|
clippy::integer_division,
|
|
clippy::len_zero,
|
|
clippy::let_underscore_must_use,
|
|
clippy::manual_div_ceil,
|
|
clippy::manual_let_else,
|
|
clippy::manual_range_contains,
|
|
clippy::modulo_arithmetic,
|
|
clippy::needless_range_loop,
|
|
clippy::non_ascii_literal,
|
|
clippy::redundant_clone,
|
|
clippy::shadow_reuse,
|
|
clippy::shadow_same,
|
|
clippy::shadow_unrelated,
|
|
clippy::single_match_else,
|
|
clippy::str_to_string,
|
|
clippy::string_slice,
|
|
clippy::tests_outside_test_module,
|
|
clippy::too_many_lines,
|
|
clippy::unnecessary_wraps,
|
|
clippy::unseparated_literal_suffix,
|
|
clippy::use_debug,
|
|
clippy::useless_vec,
|
|
clippy::wildcard_enum_match_arm,
|
|
clippy::else_if_without_else,
|
|
clippy::expect_used,
|
|
clippy::missing_const_for_fn,
|
|
clippy::similar_names,
|
|
clippy::type_complexity,
|
|
clippy::collapsible_else_if,
|
|
clippy::doc_lazy_continuation,
|
|
clippy::items_after_test_module,
|
|
clippy::map_clone,
|
|
clippy::multiple_unsafe_ops_per_block,
|
|
clippy::unwrap_or_default,
|
|
clippy::assign_op_pattern,
|
|
clippy::needless_borrow,
|
|
clippy::println_empty_string,
|
|
clippy::unnecessary_cast,
|
|
clippy::used_underscore_binding,
|
|
clippy::create_dir,
|
|
clippy::implicit_saturating_sub,
|
|
clippy::exit,
|
|
clippy::expect_fun_call,
|
|
clippy::too_many_arguments,
|
|
clippy::unnecessary_map_or,
|
|
clippy::unwrap_used,
|
|
dead_code,
|
|
unused_imports,
|
|
unused_variables,
|
|
clippy::cloned_ref_to_slice_refs,
|
|
clippy::neg_multiply,
|
|
clippy::while_let_loop,
|
|
clippy::bool_assert_comparison,
|
|
clippy::excessive_precision,
|
|
clippy::trivially_copy_pass_by_ref,
|
|
clippy::op_ref,
|
|
clippy::redundant_closure,
|
|
clippy::unnecessary_lazy_evaluations,
|
|
clippy::if_then_some_else_none,
|
|
clippy::unnecessary_to_owned,
|
|
clippy::single_component_path_imports,
|
|
)]
|
|
// ml/tests/action_loader_real_csv_test.rs
|
|
// Test loading the real DQN actions CSV file
|
|
|
|
use ml::backtesting::load_actions_from_csv;
|
|
use tracing::{info, warn};
|
|
|
|
#[test]
|
|
fn test_load_real_csv_file() {
|
|
// Test loading the real CSV file with 13,552 actions
|
|
let csv_path = "/tmp/dqn_actions_wave3.csv";
|
|
|
|
// Skip test if CSV file doesn't exist
|
|
if !std::path::Path::new(csv_path).exists() {
|
|
warn!(path = csv_path, "Skipping test: CSV file not found");
|
|
return;
|
|
}
|
|
|
|
let actions = load_actions_from_csv(csv_path).unwrap();
|
|
|
|
// Verify count (13,552 actions)
|
|
assert_eq!(actions.len(), 13_552, "Expected 13,552 actions from CSV");
|
|
|
|
// Verify first action
|
|
assert_eq!(actions[0].action, 2, "First action should be 2 (Hold)");
|
|
assert_eq!(actions[0].q_buy, -658.8440);
|
|
assert_eq!(actions[0].q_sell, 355.0268);
|
|
assert_eq!(actions[0].q_hold, 538.5875);
|
|
assert_eq!(actions[0].open, 5914.50);
|
|
assert_eq!(actions[0].high, 5914.75);
|
|
assert_eq!(actions[0].low, 5914.25);
|
|
assert_eq!(actions[0].close, 5914.25);
|
|
assert_eq!(actions[0].volume, 27);
|
|
|
|
// Verify all actions have valid bounds (0-2)
|
|
for (i, action) in actions.iter().enumerate() {
|
|
assert!(
|
|
action.action <= 2,
|
|
"Action {} at index {} exceeds bounds",
|
|
action.action,
|
|
i
|
|
);
|
|
}
|
|
|
|
// Verify all Q-values are finite
|
|
for (i, action) in actions.iter().enumerate() {
|
|
assert!(
|
|
action.q_buy.is_finite(),
|
|
"q_buy at index {} is not finite",
|
|
i
|
|
);
|
|
assert!(
|
|
action.q_sell.is_finite(),
|
|
"q_sell at index {} is not finite",
|
|
i
|
|
);
|
|
assert!(
|
|
action.q_hold.is_finite(),
|
|
"q_hold at index {} is not finite",
|
|
i
|
|
);
|
|
}
|
|
|
|
// Verify timestamp ordering (monotonically increasing)
|
|
for i in 1..actions.len() {
|
|
assert!(
|
|
actions[i].timestamp >= actions[i - 1].timestamp,
|
|
"Timestamp ordering violation at index {}: {} < {}",
|
|
i,
|
|
actions[i].timestamp,
|
|
actions[i - 1].timestamp
|
|
);
|
|
}
|
|
|
|
// Verify action distribution (sanity check)
|
|
let mut buy_count = 0;
|
|
let mut sell_count = 0;
|
|
let mut hold_count = 0;
|
|
for action in &actions {
|
|
match action.action {
|
|
0 => buy_count += 1,
|
|
1 => sell_count += 1,
|
|
2 => hold_count += 1,
|
|
_ => panic!("Invalid action: {}", action.action),
|
|
}
|
|
}
|
|
|
|
// Note: Buy count might be 0 for certain datasets (DQN-specific behavior)
|
|
assert_eq!(
|
|
buy_count + sell_count + hold_count,
|
|
13_552,
|
|
"Action counts must sum to total"
|
|
);
|
|
|
|
info!(
|
|
buy = buy_count,
|
|
buy_pct = 100.0 * buy_count as f64 / actions.len() as f64,
|
|
sell = sell_count,
|
|
sell_pct = 100.0 * sell_count as f64 / actions.len() as f64,
|
|
hold = hold_count,
|
|
hold_pct = 100.0 * hold_count as f64 / actions.len() as f64,
|
|
"Action distribution"
|
|
);
|
|
|
|
// Verify expected distribution for this specific CSV (no buy actions)
|
|
assert_eq!(buy_count, 0, "Expected 0 buy actions for this dataset");
|
|
assert_eq!(sell_count, 7_668, "Expected 7,668 sell actions");
|
|
assert_eq!(hold_count, 5_884, "Expected 5,884 hold actions");
|
|
}
|