Files
foxhunt/docs
jgrusewski 9f2d0fffb5 fix(sp21): T2.2 Phase 8.7 — default ISV buffer in evaluator (atomic)
v8 smoke (train-96wfk, commit 5694eb4df) eval pod crashed at the
same point as v7 with CUDA_ERROR_ILLEGAL_ADDRESS despite Phase 8.5's
set_branch_sizes fix. 15-minute runtime confirmed env_step decoder
no longer crashes (8.5 worked); a later kernel still OOBed.

Localization via local compute-sanitizer (RTX 3050 Ti):

  Updated gpu_backtest_validation.rs to mirror production eval-baseline
  (FEATURE_DIM=42, portfolio_dim=24, set_branch_sizes), reproducing the
  v8 crash in 1.66s locally.

  compute-sanitizer --tool=memcheck pinpointed:
    Invalid __global__ read of size 4 bytes
      at cost_net_sharpe_kernel+0x90
      by thread (32,0,0) in block (0,0,0)
      Access at 0x65c is out of bounds

  0x65c = 1628 bytes = float index 407 = OFI_IMPACT_LAMBDA_INDEX.
  Kernel reads isv[407]; isv pointer was 0 (null) because
  isv_signals_ptr defaults to 0 in constructor and set_isv_signals_ptr
  is only called by production training. Closure-path callers
  (eval-baseline) dereferenced null + slot×4 bytes.

Fix:

  Allocate zero-filled default_isv_buf of size ISV_TOTAL_DIM=536 f32
  in constructor. Wire isv_signals_ptr to its dev_ptr by default.
  Production training still overrides via set_isv_signals_ptr.

  Zero-init semantics:
    - isv[407]=0 → ofi_lambda=0 → c_ofi=0 in cost-net sharpe
      (degraded but valid; matches LobBar.ofi=0.0 placeholder)
    - Other slots default to 0 — Kelly health, controller anchors,
      etc. all see degraded-but-valid defaults

Test updates (consumer migration):
  - FEATURE_DIM 10 → 42 (production value; FEATURE_DIM < 32 makes
    gather kernel's `market_dim = feat_dim - SL_OFI_DIM (32)` negative
    → OOB; previous tests were already broken even before our changes)
  - portfolio_dim 3 → 24 (Phase 8.3+9 contract)
  - set_branch_sizes call added (Phase 8.5 contract)

Verification:
  cargo test -p ml --test gpu_backtest_validation \
    gpu_tests::test_always_long_on_uptrend --features cuda --release
    # PASSES

  compute-sanitizer --tool=memcheck <test_bin>
    # 0 CUDA errors across all 6 tests
    # (2 PnL-assertion test failures are pre-existing data-expectation
    #  issues with new FEATURE_DIM=42, not OOB bugs)

Pearls honoured:
  - feedback_no_hiding: null pointer surfaced via compute-sanitizer
    instead of silently crashing in production
  - feedback_no_partial_refactor: closure-path callers now have
    self-contained ISV setup matching training path; consumer
    migration (test FEATURE_DIM/portfolio_dim/set_branch_sizes)
    atomic with the producer-side default ISV alloc
  - pearl_no_deferrals_for_complementary_fixes: same SP cycle as
    8.3+9, 8.5 (the layer-by-layer eval rot peeling)

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-12 16:37:28 +02:00
..