Stop threshold: max(plan_stop, 0.5%) / (1 + grad_norm_instability).
Tighter when gradient pressure high, wider when stable.
Max hold: 50 * regime_stability → 10-50 bars (shorter in transitions).
Plan's own learned stop_loss is the base — not hardcoded 2%.
Zero hardcoded constants — everything flows through ISV + plan head.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
4 new portfolio features (portfolio_dim 8→12, state_dim 88→96):
- plan_progress: hold_time / target_bars (how far through plan)
- pnl_vs_target: unrealized P&L / profit_target (how close to goal)
- pnl_vs_stop: unrealized P&L / stop_loss (how close to risk limit)
- plan_conviction: conviction at entry (confidence level)
Model now reasons about its own plan through temporal attention.
"I'm 80% through, 83% to target → hold" vs "I'm past stop → exit."
Planning becomes metacognitive — the model sees AND reasons about
its intentions, not just market state.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Hard exit removed for normal plan targets (stop/profit/time).
Model LEARNS exit timing through temporal attention:
- ISV-gated trunk → Mamba2 temporal state → branch Q-values
- Conviction scales reward → model learns confidence calibration
- Portfolio observation includes hold_time, unrealized P&L, drawdown
- Model decides when to exit through Q(Flat) vs Q(Hold)
Safety net remains: hard exit only on catastrophic loss (>2%) or
extreme hold (>50 bars). Everything else is learned, not forced.
Planning, holding, strategic positioning are all attention-driven.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
When a plan is active, the plan's target_bars IS the hold duration.
Adaptive hold was blocking plan exits → model held positions for
entire 5000-bar episodes → 0 completed trades with massive unrealized
P&L. Now: plan_active → hold enforcement bypassed. Plan manages
its own duration. Hold is safety net for plan-less trading only.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Plan head randomly initialized → garbage plans → immediate stop-outs →
model learns to never trade. Fix: gate plan activation + enforcement
by iqn_readiness (pinned device-mapped). readiness < 0.5 → plan
disabled (model trades freely, plan head still learns from outcomes).
readiness ≥ 0.5 → plan activates and enforces. Dynamic, not hardcoded.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
FXCACHE_VERSION in header handles cache invalidation. First attempt
runs precompute — if cache is valid, skips (fast). If version
mismatch, deletes stale cache and regenerates. No more rm on every run.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
graph_adam_m/v/step were allocated but never used — graph_params
are intentionally fixed at near-identity initialization.
q_mean_ema_ptr removed from c51_grad_kernel (ISV replaced Q-drift
penalty, no ABI to maintain for compiled cubins).
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
ISV forward, feature gate, recursive confidence, and trade plan
were only in reduce_current_q_stats (monitoring). Now also in
submit_forward_ops_main (training). Without this, these heads
never affected training Q-values — gamma_mod, branch_gate,
feature gating, and plan params were stale during actual training.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
selectivity_backward, risk_budget_backward, mamba2_scan_backward,
q_denoise_backward — all converted to per-weight-element accumulation
(one thread per weight, loops over batch) with plain deterministic
writes. Zero atomicAdd in these gradient paths.
recursive_confidence_backward, temporal_consistency_penalty,
predictive_coding_loss, compute_expected_q atom_stats — converted to
warp+block tree reduction, reducing to one atomicAdd per BLOCK
(8x fewer warps → near-deterministic).
kan_gate_backward, curiosity, DT linear — documented remaining
atomicAdd as acceptable (auxiliary components, not on primary DQN
gradient path).
Rust launchers updated: grid dimensions now match per-weight-element
thread counts for selectivity, mamba2, and denoise backward kernels.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
OFICalculator + MicrostructureState fed per-tick. Bar close snapshots
and broadcasts 20 features via tokio::watch channel. Intermediate
snapshots available for speculative compute between bars.
Databento live client integration deferred (requires crate dep).
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
speculative_forward() pre-computes from intermediate features.
check_speculative_cache() validates cache vs actual bar-close features
(5% relative L2 threshold). invalidate_speculative_cache() at bar
boundary. Full cuBLAS trunk integration deferred — cache infra ready.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Script rewritten to use argo submit --from=wftmpl/train with
train-epochs=0 — runs ensure-binary + ensure-fxcache only.
Local test fxcache regenerated with FXCACHE_VERSION=2, OFI_DIM=20.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Version constant in fxcache.rs. validate() rejects stale versions
with clear error message. ensure-fxcache Argo template now deletes
old cache and regenerates unconditionally. No manual PVC cleanup
needed — version mismatch triggers automatic regeneration.
v2: OFI_DIM=20 (20 microstructure features).
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Flat->Positioned copies plan_params to ps[23-29]. Auto-exit on
profit_target (ISV*asymmetry), stop_loss (ISV-modulated), target_bars,
regime_stability<0.3. Scale schedule via scale_aggression. Conviction
sizing. Direction locked during active plan. Wired trainer->collector.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Plan slots: target_bars, profit_target, stop_loss, scale_aggression,
conviction, asymmetry, counter_plan_q. Zeroed on episode reset.
Fixed hardcoded i*23 references. All CUDA + Rust files updated.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Backtest evaluator missing isv_signals_ptr arg (passed as NULL).
Regenerated test fxcache with OFI_DIM=20 from MBP-10 + trades data.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
mbp10_data_dir and trades_data_dir uncommented in localdev config.
Doc comments updated: 20 microstructure features always appended.
OFI is no longer optional — it's core to the model's feature set.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
isv_feature_gate kernel: ISV embedding [8] → per-feature gate [SH2].
h_s2 *= sigmoid(w_gate @ isv_emb + b_gate). Near pass-through init
(bias=2.0 → sigmoid≈0.88). Model learns to amplify/suppress features
based on ISV state. 2 new tensors [78-79]. NUM_WEIGHT_TENSORS: 78→80.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
w_risk_fc grows from AH*(SH2+9) to AH*(SH2+13). Risk branch now
sees all 12 ISV signals (including 4 regime: velocity, disagreement,
transition_ema, stability) + predicted_error. Forward + backward
updated with wider stride and 12-signal loop.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Portfolio slots ps[15]-ps[19] are Kelly accumulators (active).
Plan params moved to ps[23]-ps[29]. PORTFOLIO_STRIDE grows 23→30.
Fixed asymmetry: scales profit_target only (not stop_loss).
Clarified epsilon mid-plan: overridden by direction lock (intended).
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
mamba2_temporal_scan forget gate multiplied by regime_stability (ISV[11]).
Stable regime (stability=1.0): full history preserved.
Transition (stability=0.3): gate capped at 0.3 → rapid forgetting.
Model adapts to new regime within 2-3 bars. Backward matches forward.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
12 new tick-level features computed per bar from MBP-10 snapshots:
OFI trajectory, realized variance, Hawkes intensity, book pressure,
spread dynamics, aggression, queue depletion, order count flux,
intra-bar momentum, regime score, OFI acceleration, toxicity gradient.
Combined with existing 8 OFI into [f64; 20] per bar in fxcache.
Also fixes pre-existing bug: no-MBP-10 fallback was [0.0; 8] not [0.0; 20].
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
fxcache: OFI_DIM=20 (pub const), RECORD_F64_COUNT=66, 272 bytes/bar.
constructor: state_dim 74→86 (aligned 88) with OFI.
experience collector: ofi_dim detection 8→20.
All [f64; 8] → [f64; 20]. Existing 8 features preserved at 0-7.
New 12 features zero-padded until precompute is extended.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
The hold enforcement infrastructure (enforce_hold in trade_physics.cuh,
hold_time counter at ps[10], action masking in experience_action_select)
was already fully implemented but disabled by min_hold_bars defaulting
to 1. Change default from 1 to 5 so hold enforcement is active by
default. Production configs already set min_hold_bars=10 via TOML.
Targets ~100-200K trades instead of 619K across 5M bars.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
EMA sync restricted to indices 0-67 (non-ISV params).
ISV weights (68-77) exist only in online params_buf.
Target forward uses online gamma_buf (drift-conditioned) and
online branch_gate_buf — correct for Bellman projection.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
h_s2 → sigmoid(w_conf @ h + b_conf) → predicted_error [B].
MSE loss vs lagged_td_error (0.01× weight). Backward accumulates
into trunk gradient + conf weight gradients in main grad_buf.
Creates self-improvement loop: model learns to predict when wrong.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>