Commit Graph

384 Commits

Author SHA1 Message Date
jgrusewski
d0b70b6c8a spec: OOS Performance Enhancement — 8 components for closing val/OOS gap
1. CVaR objective (risk-sensitive Bellman target, adaptive α)
2. Adaptive DSR (training Sharpe EMA drives w_dsr weight)
3. Ensemble heads (3 heads, epistemic uncertainty for exploration)
4. Mamba2 temporal scan (K=8 bar context, O(K) selective scan)
5. Multi-horizon prediction (1/5/20 bar value heads, regime-blended)
6. Adaptive atom positions (learned C51 spacing via softmax — NOVEL)
7. Regime-conditioned branch gating (ADX/CUSUM → branch importance — NOVEL)

Designed from live H100 analysis: val_Sharpe=45 but training_Sharpe=-1..+1.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-15 18:44:18 +02:00
jgrusewski
76b1655e07 spec: Component 13 + full train-vpb4w results + backtracking bug analysis
train-vpb4w results:
- Peak val_Sharpe=54.59 (2.3× baseline), plateau at 51.11 from epoch 23
- Backtracking NEVER triggered despite 6 frozen epochs — detection bug
- Root cause: only checks Q-gap freeze, not val_Sharpe freeze
- avg_grad=10 constant but weights frozen — Adam momentum cancellation

Component 13: val_Sharpe freeze detection as second backtracking trigger.
Adds |val_sharpe - prev| < 0.01 check alongside Q-gap velocity check.
Adds diagnostic logging for plateau detection progress.

Full metrics table and findings documented for next iteration.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-15 08:52:17 +02:00
jgrusewski
ed3504bd45 spec: add Components 10-12 from live H100 plateau analysis
Observed train-vpb4w freeze at epoch 23 (val_Sharpe=51.11):
- avg_grad=10.0 (nonzero!) but Q-stats FROZEN for 4+ epochs
- Root cause: Adam momentum converged to fixed point, not zero gradient

Component 10: Targeted Adam momentum reset for branch weights only
(indices 8-41). Lighter than full rewind, preserves trunk convergence.

Component 11: Q-gap target attractor for spread gradient. Amplifies
spread when Q-gap is below target, reduces when above. Prevents
spread from being too weak at high Q-gap levels.

Component 12: Cosine LR schedule with warm restarts (T=20 epochs).
LR decay prevents overshoot, restart jumps break fixed points.
Half-momentum at restart preserves gradient direction.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-15 08:46:21 +02:00
jgrusewski
f14440be55 plan: add Tasks 10-11 — Q-mean centering + atom entropy recovery (execute first)
Task 10: q_mean_reduce + q_mean_subtract two-phase kernel. Zero params.
Fixes Q-mean drift 0→+0.47 from bootstrapping bias.

Task 11: Adaptive entropy_coeff based on utilization_ema. Zero params.
Fixes atom utilization collapse 100%→20%.

Execution order: 10, 11, then 1-9.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-15 08:40:09 +02:00
jgrusewski
5b895f9347 spec: add Components 8+9 — Q-mean drift correction + atom utilization recovery
Observed in train-vpb4w (live H100 run):
- Q-mean drifts 0→+0.47 over 18 epochs (bootstrapping bias)
- Atom utilization drops 100%→20% (distributional collapse)
- val_Sharpe peaks 54.59 then decays to 31.52

Component 8: Mean-center Q-values before action selection pipeline.
Zero params, preserves ranking, prevents drift accumulation.

Component 9: Adaptive atom entropy regularization. Ramps entropy_coeff
when utilization drops below 50%. Uses existing c51_grad_kernel param.

Both are zero-param fixes moved to top of implementation order.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-15 08:37:49 +02:00
jgrusewski
d5e270e18b fix: Components 2+5 fully GPU — zero CPU compute, zero copies
xLSTM: qlstm_step kernel reads q_stats_buf directly on device, updates
C matrix on device, writes context[8] to device buffer. qlstm_train_step
runs SGD on device. No DtoH readback.

RK4 ODE: liquid_tau_rk4_step kernel reads per_branch_q_gap_ema (device),
context (device), writes liquid_mod (device). No pinned memory — plain
CudaSlice. Replaces CPU update_liquid_tau entirely.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-15 08:35:40 +02:00
jgrusewski
fcf34ac5c8 plan: Supervised Architecture Transfer — 9 tasks, 7 components
Task 1: 7 CUDA kernels (quantile, graph, KAN, diffusion, OFI concat)
Task 2: Quantile Q-select (replaces epsilon-greedy, zero params)
Task 3: Graph message passing (4 directed edges, 60 params)
Task 4: KAN spline gates (replaces sigmoid, 9,216 params)
Task 5: Diffusion Q-refinement (3-step denoise, 2,772 params)
Task 6: TLOB microstructure injection (widen order/urgency FC)
Task 7: xLSTM temporal context (CPU matrix memory, 528 params)
Task 8: RK4 adaptive ODE (replaces Euler in liquid tau)
Task 9: Build verification + smoke tests

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-15 08:29:51 +02:00
jgrusewski
9c4c97cf8d spec: Supervised Architecture Transfer — 7 concepts from KAN/xLSTM/Diffusion/TGNN/Liquid/TFT/TLOB
1. KAN spline activations → adaptive branch gates (learnable activation shape)
2. xLSTM matrix memory → temporal Q-value context (trajectory pattern detection)
3. Diffusion denoising → iterative Q-refinement (uncertainty-conditioned)
4. TGNN gating → cross-branch graph message passing (structural coordination)
5. Liquid RK4 ODE → higher-order training dynamics (adaptive Euler/RK4)
6. TFT quantile outputs → uncertainty-driven exploration (replaces epsilon-greedy)
7. TLOB MBP-10 → direct microstructure injection to order/urgency branches

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-15 08:19:18 +02:00
jgrusewski
d5414bec25 spec: Component 6 early termination — PLATEAU_EXHAUSTED after 12 attempts
3 rewinds × 4 routes = 12 max attempts. Failed = improvement rate below
threshold over 10 epochs. On exhaustion: save best model, exit cleanly,
log "structural change needed". Saves ~3 hours H100 vs frozen training.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-14 23:46:27 +02:00
jgrusewski
f5985cff14 spec: add Component 6 — Trajectory Backtracking (single GPU)
Checkpoint ring buffer ranked by improvement rate, plateau detection
via liquid tau velocity, informed perturbation cycle (Adam reset,
shrink-perturb, temp boost, LR×2), depth-limited rewind. ~150 lines
in training_loop.rs, zero CUDA changes. Recovers from plateaus that
prevention mechanisms (spread gradient, liquid tau) fail to avoid.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-14 23:38:05 +02:00
jgrusewski
cc232f644d plan: Cross-Pollinated Branch Intelligence — 9 tasks, 64 steps
Task 1: Dead code cleanup (11 items across 6 files)
Task 2: 6 CUDA kernels (VSN, GLU, Q-attention, selectivity)
Task 3: Weight layout 26→42 + separate buffers + liquid_mod pinned
Task 4: VSN + GLU forward integration
Task 5: VSN + GLU backward integration
Task 6: Cross-branch Q attention (624 params, 2-head on 12 Q-values)
Task 7: Liquid tau per-branch dynamics (replaces spread_velocity)
Task 8: Mamba-2 selective replay (learned PER curriculum)
Task 9: Build verification + smoke tests

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-14 23:26:13 +02:00
jgrusewski
0cfb2c7786 fix: 6 concerns in Cross-Pollinated Branch Intelligence spec
1. Variable Selection: static → input-dependent bottleneck (true TFT VSN)
2. Q Attention: add direct gradient via Expected SARSA target integration
3. Liquid Tau: modulates IQL scales via separate liquid_mod[4] buffer
4. Selectivity: per_sample_loss proxy (per-sample grad norms infeasible at 32GB)
5. GLU gate: zero-init W_gate/b_gate → sigmoid(0)=0.5 (stable start)
6. Weight layout: updated for 8 VSN bottleneck matrices (indices 26-33)

NUM_WEIGHT_TENSORS: 26 → 42. Total new params: ~297K.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-14 23:14:41 +02:00
jgrusewski
8a9424b6eb spec: Cross-Pollinated Branch Intelligence — 5-component unified design
Combines TFT Variable Selection, GLU Gating, Cross-Branch Q Attention,
Liquid adaptive tau, and Mamba-2 Selective Replay into unified branch
architecture. Plus 11-item dead code cleanup.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-14 23:06:18 +02:00
jgrusewski
f49ae6858e fix: Layer 3 plan — add Q_dir normalization by delta_z
Raw E[Q] ~ 0.1 while h_s2 ~ 1.0 post-ReLU. Without normalization,
Q_dir columns learn 10x slower. Dividing by delta_z scales to ~1-10.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-14 22:30:29 +02:00
jgrusewski
8d2ed799e6 plan: direction-conditioned magnitude head (Layer 3) — 7 tasks
Tasks: CUDA kernel, param widening, forward conditioning, backward split,
zero-init, experience collector, H100 integration test.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-14 22:19:41 +02:00
jgrusewski
234870d966 spec: direction-conditioned magnitude head (Layer 3)
Magnitude FC input changes from h_s2[B, SH2] to [h_s2; Q_dir][B, SH2+3].
Direction E[Q] values (3 scalars per sample) are computed from branch 0
logits and concatenated. w_b1fc grows by 3*adv_h parameters (768 for AH=256).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-14 22:14:49 +02:00
jgrusewski
e9e4bd54ac plan: Adaptive Training Dynamics Layers 1+2 implementation plan
Task 1: Reward rank normalization kernel (SNR amplification)
Task 2: Q-gap momentum for spread gradient (plateau modulation)
Task 3: H100 integration test (50 epochs, compare to train-w6qfd)

Layers 3+4 (dir→mag conditioning, variance sizing) deferred to
separate plan after L1+L2 validation.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-14 21:42:57 +02:00
jgrusewski
a5945db538 spec: Adaptive Training Dynamics v2 — 4-layer design for breaking Sharpe plateau
Layer 1: Rank-preserving signed reward standardization (SNR 0.001→0.5)
Layer 2: Temporal Q-gap momentum (spread modulation at plateaus)
Layer 3: Direction-conditioned magnitude (dir Q-values → mag head input)
Layer 4: Distributional variance position sizing (Kelly from C51 atoms)

Based on train-w6qfd results: val_Sharpe=21-25 sustained, Q-gap=0.138
growing. Builds on 32 fixes from this session. Implementation order:
1→2→4→3 (signal → momentum → variance → architecture).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-14 21:40:03 +02:00
jgrusewski
33b03a86a6 docs: IQL H100 hardening spec — drift readiness, p5 floor, buffer-relative staleness
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-13 20:13:39 +02:00
jgrusewski
f0cda76229 docs: IQL full integration implementation plan — 9 tasks
6 new CUDA kernels, C51/grad/epsilon kernel mods, dual-tau IQL,
v_range dead code deletion, per-sample everything.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-13 14:56:27 +02:00
jgrusewski
d0227e78bb docs: fix 6 issues in IQL integration spec from code review
- Fix staleness: buffer_write_pos is host-side, pass as scalar (not in GpuBatch)
- Fix epsilon: branching_action_select takes 3 scalar epsilons, not 1
- Fix dead code list: add GpuExperienceCollector::v_range_ptr, FusedTrainingCtx wrappers, training_loop callers
- Fix step 0: seed per_sample_support with [-1, 1] default at construction
- Fix entropy: delete ent_scale conditionals, branch_scales subsumes them
- Fix non-graph c51 launches: 4 sites in gpu_dqn_trainer.rs need per_sample_support

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-13 14:51:30 +02:00
jgrusewski
b593f038f7 docs: IQL full integration design spec — 5 components
Covers: PER advantage-weighted staleness, per-sample C51 atom
support centered on V(s), per-branch advantage decomposition,
dual-tau expectile gap exploration, and v_range dead code removal.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-13 14:45:26 +02:00
jgrusewski
6621177f78 docs: implementation plan for single shared cuBLAS handle
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-13 11:32:23 +02:00
jgrusewski
44b07d1022 docs: spec for single shared cuBLAS handle refactor
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-13 11:29:05 +02:00
jgrusewski
0f5b2b07b0 docs: spec for deterministic eval via training graph replay
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-13 09:26:14 +02:00
jgrusewski
1f6a8436d3 feat: v9 Differential Sharpe Ratio reward — optimize for consistency, not PnL
Fundamental shift: reward optimizes Sharpe ratio contribution per trade
instead of directional PnL magnitude. Targets Sharpe 5+ via many small
consistent gains (spread capture, execution quality) instead of few
large directional bets.

DSR implementation (Moody & Saffell, 2001):
- Per-episode EMA statistics in portfolio state slots [3]-[5]
- DSR = (B*R - 0.5*A*R²) / (B - A²)^1.5 at trade completion
- 10-trade warmup, clamped [-5, +5]
- w_dsr=5.0 (primary reward signal)

Reward hierarchy restructured:
- DSR: 5.0 (NEW — primary, rewards Sharpe consistency)
- Directional PnL: 2.0 (was 10.0 — demoted to secondary)
- Order credit: 1.0 (was 0.1 — spread capture amplified 10×)
- Urgency credit: 0.5 (was 0.1 — fill quality amplified 5×)
- Inventory penalty: -0.005×|pos|/max_pos per bar (NEW)
- Dense micro-reward: 0.0 (removed — noisy direction signal)

Expected: WinRate increases (many small spread captures), per-trade
variance decreases, Sharpe rises from consistency not prediction.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-12 14:33:56 +02:00
jgrusewski
eb7139c436 feat: adaptive C51 v_range — Q-values 0.008→0.525 (65× improvement)
Fundamental fix: C51 atom spacing (dz=0.6) was larger than the Q-value
range (0.02), making the distributional loss unable to resolve rewards.
The network was blind to its own learning signal.

Adaptive v_range via device buffer (same pattern as tau_buf):
- v_range_buf[2] on GPU, all C51/MSE/CQL/expected_q kernels read via
  pointer (graph captures stable address, reads value at replay time)
- Cold start: v_range=±1.0 → dz=2/51=0.039 → 25× atom resolution
- Monotonic expansion based on Q-stats every 50 training steps
- Never shrinks (avoids invalidating Bellman targets in replay buffer)

Kernel changes (5 files):
- c51_loss_kernel.cu, mse_loss_kernel.cu, mse_grad_kernel.cu,
  cql_grad_kernel.cu, compute_expected_q: scalar v_min/v_max → pointer

Also fixed:
- PopArt warmup 100→1 (start normalizing from step 1)
- PopArt variance floor 0.0001→1e-8 (allow sigma < 0.01)
- Backtest evaluator: allocate own v_range_buf for compute_expected_q
- num_atoms 51→52 in all TOMLs (TF32 4-element alignment)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-12 07:58:02 +02:00
jgrusewski
ad5c2b7ded refactor: exp collector zero-copy — direct pointer into trainer params_buf
Dead code sweep (167 lines deleted):
- online_params_flat (synced but never read by forward)
- online_params_f32 (never synced, always zeros — ROOT CAUSE of garbage Q-values)
- DuelingWeightSet/BranchingWeightSet/CuriosityWeightSet/RmsNormWeightSet fields
- sync_weights_flat, sync_weights_f32, flatten_online_weights methods
- sync_gpu_weights epoch-boundary DtoD copy

Zero-copy replacement:
- trainer_params_ptr: u64 points directly into trainer's params_buf
- param_sizes computed from real config (bottleneck_dim=16, market_dim=42)
- CublasForward with correct s1_input_dim=54 for bottleneck
- Bottleneck forward activated (bn_hidden + tanh + concat)
- Fused context init moved before Phase 2 (experience collection)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-11 23:10:25 +02:00
jgrusewski
dd6143936e fix: IQN 4-branch runtime + order counterfactual + per-branch entropy + histogram
IQN kernel rewrite (critical — was corrupting 75% of gradient budget):
- Eliminate compile-time BRANCH_*_SIZE defines (BRANCH_0_SIZE was 5, should be 3)
- All 9 IQN kernels now take runtime b0/b1/b2/b3 params
- 4-branch forward, backward, decode (was 3-branch, missing magnitude)
- branch_actions buffer B*3 → B*4

Action diversity infrastructure:
- 3-cycle counterfactual: dir mirror / mag relabel / order-type cost delta (50× amplified)
- Per-branch entropy: order (d==2) gets 3× boost in C51 + MSE grad kernels
- Position histogram expanded 6→12 bins (all 4 branches get entropy bonus)
- Boltzmann temperature floor raised to 0.5 for order + urgency branches
- Smoke test epochs 3→10 for diversity verification

Note: experience collector still needs bottleneck forward path — currently reads
trainer's bottleneck-layout weights with state_dim K, producing misaligned Q-values.
Next: eliminate weight copy, use direct pointer views into trainer's params_buf.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-11 22:40:47 +02:00
jgrusewski
a662e54e86 plan: VarStore elimination — zero-copy pointer views into flat params_buf (8 tasks)
DuelingWeightSet becomes raw u64 pointers into params_buf, not separate
CudaSlice allocations. Eliminates ALL D2D copies between weight
representations. flatten/unflatten cycle deleted entirely.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-11 13:35:15 +02:00
jgrusewski
1a3da6f6b0 spec: Candle GpuVarStore elimination — 40+ call sites, 15 files, blocks bottleneck
VarStore is a CPU-trip corrupting data + degrading performance. Must be
replaced with direct pointer buffers (flat params_buf is already the
source of truth). Checkpoint, weight extraction, and polyak updates
all need porting to direct CudaSlice operations.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-11 13:30:12 +02:00
jgrusewski
370319f7c8 plan: ABI Complete — per-branch epsilon, IQN anti-collapse, hindsight relabeling, vaccine, ensemble, bottleneck (8 tasks)
Unified plan combining Sub-plans B+C + novel findings:
1. Fix c51_alpha ramp (eliminate 3 graph recaptures)
2. Per-branch epsilon (magnitude 2×, Boltzmann for order/urgency)
3. IQN quantile spread as anti-collapse bonus
4. Hindsight magnitude relabeling
5. Gradient vaccine with diverse batches
6. Ensemble variance at inference
7. Per-branch bottleneck width
8. Full verification + deploy

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-11 12:27:56 +02:00
jgrusewski
55be1776b5 plan: ABI Foundation — 7-level exposure + PopArt + tau coupling + PER clear (6 tasks, 27 steps)
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-11 11:28:59 +02:00
jgrusewski
553289545a spec: Autonomous Branch Intelligence (ABI) — fix DQN action collapse
10-component design to fix 82% Flat/Small action concentration:
1. Collapse degenerate 9→7 level exposure space
2. Per-branch reward decomposition (direction/magnitude/order/urgency)
3. Hindsight action relabeling for magnitude
4. Position-aware temporal exploration with per-branch epsilon
5. IQN quantile spread as anti-collapse signal
6. Activate PopArt + couple with tau reset
7. Feed the gradient vaccine with diverse batches
8. Per-branch bottleneck widths
9. Ensemble variance at inference
10. Clear PER between folds

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-11 11:23:23 +02:00
jgrusewski
f6991dd8b2 plan: dead code cleanup + GPU per-phase CUDA event profiling (6 tasks, 32 steps) 2026-04-10 22:23:16 +02:00
jgrusewski
1b5af8e9f3 spec: dead code cleanup + GPU per-phase CUDA event profiling 2026-04-10 22:16:24 +02:00
jgrusewski
445c2197f2 feat: unified Argo train workflow — replace 7 templates with 1
New: train-template.yaml with smart caching:
  - ensure-binary: checks /data/bin/{sha}/ on PVC, compiles only on cache miss
  - ensure-fxcache: runs precompute only if cache doesn't exist
  - gpu-warmup: parallel autoscale during compile
  - hyperopt → train-best → evaluate → upload-results

Deleted 7 redundant templates:
  - compile-and-train-template.yaml
  - train-dqn-template.yaml
  - train-baseline-rl-template.yaml
  - train-supervised-template.yaml
  - training-workflow-template.yaml
  - precompute-features-template.yaml
  - train-ppo-template.yaml

Deleted: scripts/argo-precompute.sh (absorbed into ensure-fxcache step)
Rewritten: scripts/argo-train.sh (single template, --sha for commit pinning)
Updated: kustomization.yaml

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-10 20:36:03 +02:00
jgrusewski
8c92db09f3 spec: Argo training pipeline redesign — one workflow, smart caching
Single train template replaces 7 overlapping workflows. Binary cache
on PVC by commit SHA, fxcache skip-if-exists. Delete 5 dead templates.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-10 20:26:55 +02:00
jgrusewski
4842a04011 refactor: eliminate ALL bf16 from entire workspace — pure f32/TF32 pipeline
Complete bf16 elimination across all crates (ml, ml-core, ml-dqn, ml-ppo,
ml-supervised). Zero half::bf16, __nv_bfloat16, or CudaSlice<half::bf16>
references remain (verified by grep).

CUDA: All 60+ .cu kernels and .cuh headers converted to native float.
  - Half-precision intrinsics (__hmul, __hadd, __hdiv) → float operators
  - atomicAddBF16 → native atomicAdd(float)
  - bf16 wrapper functions → f32 identity passthroughs

Rust: All CudaSlice<half::bf16> → CudaSlice<f32> across 90+ files.
  - htod_f32_to_bf16/dtoh_bf16_to_f32 → htod_f32/dtoh_f32 (direct, no conversion)
  - Deleted bf16 mirror infrastructure (DuelingWeightSetBf16, alloc_bf16_mirror, etc.)
  - Renamed params_bf16→params_flat, d_value_logits_bf16→d_value_logits, etc.
  - Fixed .to_f32() sed damage on Decimal::to_f32() and rng.f32()

FxCache: Single f32 disk format (was bf16/f64 dual-version).
  - Deleted --bf16 CLI flag from precompute_features
  - PVC cache files need regeneration via precompute_features

TF32 tensor cores activated via cublasLtMatmul CUBLAS_COMPUTE_32F — no
explicit TF32 types needed. Storage is pure f32 everywhere.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-10 18:52:21 +02:00
jgrusewski
b456691de5 fix: use CUBLAS_COMPUTE_32F for cublasLtMatmul (SM86 compat)
CUBLAS_COMPUTE_32F_FAST_TF32 returns NOT_SUPPORTED on RTX 3050 (SM86)
for certain (m,n,k) via cublasLtMatmul (e.g., 128×512×64). Plain
CUBLAS_COMPUTE_32F works for all dimensions. TF32 tensor cores are
still enabled via CUBLAS_TF32_TENSOR_OP_MATH math mode on the cuBLAS
handle — this activates TF32 on Ampere+ automatically when the
hardware supports the specific matrix dimensions.

Also: use sys::cublasLtMatmul directly (bypass result:: wrapper)
for clearer argument ordering.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-10 10:33:36 +02:00
jgrusewski
49c8c1745e fix(critical): branch-major d_adv_logits layout + revert diagnostic hacks
Root cause of H100 gradient collapse: c51_grad, mse_grad, and cql_grad
kernels wrote d_adv_logits in sample-major interleaved layout [B, TBA]
but cuBLAS backward read it as branch-major [B*B0*NA | B*B1*NA | ...].
At batch=16384, the GEMM read cross-contaminated data from wrong branches,
producing zero weight gradients by symmetry cancellation at scale.

Fix: changed indexing in all 3 grad kernels to branch-major.
Reverted diagnostic hacks (ungraphed forward, forced diagnostics).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-09 22:05:46 +02:00
jgrusewski
bf3091c6f2 fix: re-enable IQN + remove diagnostics for H100 baseline
- iqn_lambda restored to 0.25 (was 0.0 for NaN isolation)
- STEP_DIAG per-step logging removed (was temporary)
- FOXHUNT_GRAD_DIAG env var removed from Argo template

IQN NaN root cause fixed in 8cbabcef5 (f32-as-bf16 type mismatch).
Ready for H100 baseline deployment.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-09 20:04:01 +02:00
jgrusewski
49bedfcd69 feat(magnitude): per-branch loss weighting — 0.2× C51 + 4.0× MSE for magnitude
C51 cross-entropy structurally prefers low-variance actions (Small positions
have tighter return distributions). MSE is variance-neutral. By reducing
C51's gradient to 20% and amplifying MSE to 4× for the magnitude branch,
MSE becomes the dominant loss signal for position sizing.

Direction/order/urgency keep full C51 gradient for distributional risk awareness.
Replaces the previous mag_amp=1.5 which addressed a symptom (Flat gradient
starvation) rather than the root cause (C51 variance bias).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-08 22:23:19 +02:00
jgrusewski
193cb11035 docs: volume bar pipeline spec + implementation plan
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-08 20:26:40 +02:00
jgrusewski
4eaa431739 fix(critical): disable mirror universe — only negates 4/42 features but inverts direction
The mirror universe feature negated only features[0..3] (4 return-like
features) but inverted the direction action (Short↔Long). The remaining
38 directional features (momentum, trend, patterns) were NOT negated.
This taught the model the WRONG direction on 50% of epochs, cancelling
out the directional signal and producing worse-than-random performance.

Disabled until proper full-feature mirroring is implemented.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-08 20:05:22 +02:00
jgrusewski
7b1f825d17 docs: Phase 2 hierarchical 4-branch implementation plan
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-08 14:12:12 +02:00
jgrusewski
c94af7523e docs: Phase 2 hierarchical 4-branch DQN spec — direction(3) × magnitude(3) × order(3) × urgency(3)
Replaces broken 9-output exposure branch with two 3-output branches.
Each 3-output branch has -1/2 gradient (33%) — strong enough for dueling.
Eliminates i%3 Q-value degeneracy permanently.

3 novel gems: direction-specific dense reward, per-branch epsilon,
Flat detection shortcut with gradient zeroing.

~480 lines of dead code removed (aux optimizer, CEA, pre-training).
20+ files changed. Full CUDA, no CPU path, no stubs.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-08 12:04:23 +02:00
jgrusewski
58ff8db406 fix: aux GEMM gradient explosion — scale 0.5→0.01 + clip after backward
The exposure aux backward GEMM amplifies gradients through the
hidden activation matrix (d_logits × h_b0), producing grad_norm=5000+.
With max_grad_norm=10, this throttles ALL gradients by 500x (lr/500).

Fix: reduce aux_weight 0.5→0.01 (50x) + clip_grad_buf_inplace after
aux GEMM to cap combined gradient at max_grad_norm.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-08 10:03:54 +02:00
jgrusewski
fdc8f30c8d docs: H100 graph-level optimization spec — 4 deferred fixes (~13s/epoch)
Fix 2: Eliminate validation graph re-capture (DtoD into same buffers)
Fix 3: Async validation on separate CUDA stream (overlap with experience)
Fix 4: Aux GEMM in graph_aux (GPU scalar + kernel sig change)
Fix 7: Mega-graph fusion (spectral+forward+aux → 2 launches)

Combined with 5 implemented fixes: 47s → ~16s/epoch

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-08 08:48:36 +02:00
jgrusewski
bfb96fb062 fix: update loss threshold for v8 batch_size=16384 + wire 5 kernels
- Pre-training: 50 batch supervised direction init at epoch 0
- Exposure aux targets: DtoD copy from collector to fused context
- PopArt: wired behind config flag (disabled by default)
- TD(λ)/hindsight/curriculum: stubs with config guards
- Loss threshold 500→100K for v8 reward distribution

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-08 02:25:58 +02:00