Commit Graph

4015 Commits

Author SHA1 Message Date
jgrusewski
6804f0facf fix(dqn): let PSO control batch_size, use VRAM ceiling instead of AutoBatchSizer override
AutoBatchSizer was computing an "optimal" batch_size (128 on L4) and
overriding the PSO-chosen value. On an L4 24GB this meant 3.5% VRAM
utilization per trial. Now the trainer only clamps if the batch_size
would actually OOM, letting PSO explore the full [64, 4096] range.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-28 20:48:43 +01:00
jgrusewski
bdddf4fd7a fix(ci): restore compile-training dependency for CI training jobs
Revert needs: [] back to needs: compile-training (optional). CI training
jobs should wait for fresh binaries when compile runs in the same
pipeline. Independent training via fxt CLI uses the gRPC path instead.

Keeps the writable bin dir fix (${CI_PROJECT_DIR}/bin/) and PATH export.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-28 20:42:10 +01:00
jgrusewski
d6c33325b3 fix(ci): download training binaries to writable dir, not /usr/local/bin
CI runner pods run as non-root — can't write to /usr/local/bin/.
Download to ${CI_PROJECT_DIR}/bin/ and prepend to PATH instead.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-28 20:33:00 +01:00
jgrusewski
e57078aaf1 fix(ci): decouple training jobs from compile-training dependency
Training jobs fetch binaries from S3 via rclone, not CI artifacts.
Remove needs: compile-training so training jobs can be triggered
independently without waiting for a compile stage.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-28 20:30:16 +01:00
jgrusewski
9b65653c93 fix(ci): remove broken rclone include filter in training jobs
The rclone --include "*.{rl,supervised,baseline,uploader}*" glob does
not expand brace patterns like bash — silently downloads zero files.
Replace with unfiltered sync (bucket only has training binaries) and
wildcard chmod.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-28 20:25:54 +01:00
jgrusewski
cd8a45d8a8 fix(gpu): wire PPO GPU experience collection, fix debug log levels, increase hyperopt deadline
- Wire GPU experience collection into PPO hyperopt adapter with CPU fallback
  (ensure_gpu_data, gpu_collect_trajectories, batch-to-trajectory converter)
- Downgrade 6 ERROR-level debug logs to debug!() in DQN hyperopt adapter
- Increase hyperopt activeDeadlineSeconds from 1h to 6h (job-template + train.sh)
- Mark 3 data-dependent real_data_loader tests as #[ignore]
- Fix 4 clippy map_or → is_none_or warnings in trading_service

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-28 19:58:16 +01:00
jgrusewski
64d57e7454 fix(infra): RWO PVC strategy, probe fixes, deploy hardening
- All services: maxSurge=0, maxUnavailable=1 (ReadWriteOnce PVCs
  deadlock with maxSurge=1 — new pod can't attach volume while old
  pod still holds it)
- ml-training-service: switch httpGet /health:8080 to tcpSocket:50053
  (service crashes on log dir permission, never binds health port)
- GPU overlays: same strategy and probe fixes
- job-template.yaml: use generateName instead of placeholder name
  (training-MODEL-TIMESTAMP fails k8s RFC 1123 validation)
- deploy job: increase rollout timeout 120s → 300s

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-28 19:50:53 +01:00
jgrusewski
e6d0abccf0 fix(ci): skip immutable PVCs and job template in deploy apply
training-data-pvc is immutable (already bound with ReadWriteOnce),
and job-template.yaml has placeholder names (MODEL/TIMESTAMP) that
fail k8s validation. Only apply service deployments and binary cache
PVCs in the deploy job.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-28 19:33:35 +01:00
jgrusewski
0d4c90acbe Merge branch 'feature/dynamic-batch-bounds' 2026-02-28 19:27:26 +01:00
jgrusewski
195f880fb4 feat(hyperopt): add batch_size to PPO and Liquid parameter spaces
PPO: add batch_size as 6th param (index 5)
- Static bounds: 512–8192 (PPO needs large batches for variance reduction)
- Default: 2048 (was hardcoded)
- Dynamic: scales with VRAM (200MB overhead, 0.015 MB/sample)
- Wire into PPOConfig in train_with_params()

Liquid CfC: add batch_size as 8th param (index 7)
- Static bounds: 8–512
- Default: 32 (was hardcoded)
- Dynamic: scales with VRAM (100MB overhead, 0.06 MB/sample)
- Wire into CfCTrainConfig in train_with_params()
- NUM_PARAMS: 7 → 8

All 176 hyperopt tests pass, full workspace compiles clean.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-28 19:20:08 +01:00
jgrusewski
b4239e8c43 feat(hyperopt): add VRAM-aware batch_size scaling to 9 existing adapters
Override continuous_bounds_for() in all adapters that already have batch_size:
- TFT (idx 1): 150MB overhead, 0.05 MB/sample, cap 2048
- Mamba2 (idx 1): 200MB overhead, 0.03 MB/sample, cap 2048
- TGGN (idx 7): 100MB overhead, 0.08 MB/sample, cap 1024
- TLOB (idx 6): 120MB overhead, 0.10 MB/sample, cap 1024
- KAN (idx 7): 80MB overhead, 0.04 MB/sample, cap 1024
- xLSTM (idx 6): 180MB overhead, 0.06 MB/sample, cap 1024
- Diffusion (idx 6): 250MB overhead, 0.12 MB/sample, cap 512
- DQN (idx 1): 300MB overhead, 0.02 MB/sample, cap 4096
- ContinuousPPO (idx 9): 250MB overhead, 0.03 MB/sample, cap 4096

On CPU-only, all adapters fall back to existing static bounds.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-28 19:19:25 +01:00
jgrusewski
f82144c977 fix(ci): replace old per-image deploy with S3 binary share deploy
The deploy job was using kubectl set image to stamp per-service Docker
images (api_gateway:<sha>, etc.) — these images no longer exist after
the S3 binary share migration. Replace with kubectl apply + rollout
restart, which picks up YAML changes and triggers initContainers to
fetch latest binaries from S3.

Delete redundant deploy-services job (merged into deploy).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-28 19:17:24 +01:00
jgrusewski
e58ce4f585 fix(ci): halve CPU requests for parallel compilation on single node
Scaleway quota limits POP2-32C-128G to 1 instance. Reduce each compile
job from 28→14 CPUs so compile-services and compile-training run in
parallel on the same 32-vCPU node instead of sequentially.

Also fix data-acquisition-service health probe: service doesn't implement
gRPC health protocol, switch to tcpSocket probe on port 50057.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-28 19:12:34 +01:00
jgrusewski
de2169fbe4 feat(hyperopt): add HardwareBudget + continuous_bounds_for() to ParameterSpace trait
Add VRAM-aware batch size bounds infrastructure:
- HardwareBudget struct with detect(), cpu_only(), with_memory_mb() constructors
- max_batch_size() helper for per-model memory profile scaling
- continuous_bounds_for(budget) default method on ParameterSpace trait
- Default impl delegates to static continuous_bounds() (non-breaking)
- Updated 2 optimizer call sites to detect hardware and use dynamic bounds
- 6 new unit tests for HardwareBudget behavior

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-28 19:03:56 +01:00
jgrusewski
f5b836f98f fix(infra): increase data-acquisition-service memory limit to 1Gi
Was OOMKilled at 512Mi (exit code 137). Increased request to 256Mi
and limit to 1Gi.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-28 18:57:36 +01:00
jgrusewski
5a03e41ee6 fix(infra): run initContainer as root for PVC cache write access
The foxhunt-runtime base image runs as uid 1000 (foxhunt user), but
new PVC volumes are owned by root. The initContainer needs root to
write the cached binary to the PVC. Main container still runs as
foxhunt (non-root) for security.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-28 18:47:50 +01:00
jgrusewski
23ccbf1c66 fix(infra): increase binary cache PVCs from 500Mi to 1Gi
Scaleway block storage minimum volume size is 1Gi. The 500Mi PVCs
were stuck in Pending state, blocking all service pod scheduling.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-28 18:45:16 +01:00
jgrusewski
19aff56123 ci: eliminate foxhunt-node-builder image, use node:22-slim directly
Web dashboard build now uses node:22-slim with inline rclone install
instead of a custom Kaniko-built image. This removes 1 Kaniko build
from the prepare stage, reducing pod scheduling contention.

Only 2 runtime images needed: CPU (foxhunt-runtime) and GPU
(foxhunt-training-runtime). Binary selection is via K8s command.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-28 18:40:51 +01:00
jgrusewski
a36cee8628 infra: update GPU overlay deployments with S3 binary fetch
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-28 18:12:07 +01:00
jgrusewski
aa754d6f32 infra: delete 5 obsolete Dockerfiles replaced by S3 binary share
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-28 18:11:15 +01:00
jgrusewski
6288404c69 infra: update all service deployments with S3 binary fetch initContainer
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-28 18:10:33 +01:00
jgrusewski
3d3083879a infra: update image-prepuller to cache foxhunt-training-runtime
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-28 18:10:16 +01:00
jgrusewski
def4f56d92 infra: update training job template with S3 binary fetch
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-28 18:10:04 +01:00
jgrusewski
08f72a9dfb ci: run compile-services and compile-training in parallel on 2 CPU nodes
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-28 18:09:46 +01:00
jgrusewski
301f778663 ci: delete all Kaniko build jobs, switch training to S3 binary fetch
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-28 18:07:33 +01:00
jgrusewski
3f88797197 ci: add build-web-dashboard, write-manifest, and deploy-services jobs
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-28 18:03:57 +01:00
jgrusewski
2a15f93ae6 ci: compile-training uploads to S3 instead of GitLab artifacts
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-28 18:01:49 +01:00
jgrusewski
a17c89a172 ci: compile-services uploads to S3 instead of GitLab artifacts
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-28 18:00:25 +01:00
jgrusewski
35173d2e90 ci: add build jobs for 3 generic base images in prepare stage
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-28 17:59:20 +01:00
jgrusewski
4ef28a73d8 infra: add 8 binary cache PVCs for S3 fallback during trading
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-28 17:57:29 +01:00
jgrusewski
7f3b511203 infra: add 3 generic base images for S3 binary share
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-28 17:57:19 +01:00
jgrusewski
cf88f73379 infra: add rclone to CI builder images for S3 binary uploads
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-28 17:57:08 +01:00
jgrusewski
5287bbbf66 infra: add foxhunt-binaries S3 bucket for binary distribution
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-28 17:56:57 +01:00
jgrusewski
359f847026 docs: add S3 binary share implementation plan (15 tasks)
Detailed step-by-step plan covering: S3 bucket creation, CI builder
updates, 3 base image Dockerfiles, CI pipeline rewiring, 8 cache PVCs,
all service deployment YAML updates, training job template, and cleanup.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-28 17:50:37 +01:00
jgrusewski
df20ed74d4 docs: add S3 binary share design — eliminate Docker builds, faster pod startup
Replace per-service Docker images with generic base images + S3-based binary
distribution. CI compiles and uploads stripped binaries to S3. Pods fetch
binaries via initContainer with PVC cache fallback for trading resilience.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-28 17:46:13 +01:00
jgrusewski
40febb0061 fix(cuda): enable GPU experience collection for regime-conditional DQN
The GPU experience collector only supported DQNAgentType::Standard, but
enable_regime_qnetwork defaults to true, creating RegimeConditional
agents. This silently fell back to CPU with a debug! message invisible
at INFO log level.

- Add primary_head() accessor to RegimeConditionalDQN (returns trending head)
- Extract weights from primary head for both collector init and weight sync
- Upgrade debug! to warn! for missing GPU collection prerequisites
- Add warn! to PPO for silent GPU skip when raw market data not uploaded

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-28 17:01:01 +01:00
jgrusewski
5a27bde9dd fix(ci): add NVRTC to training image for GPU experience kernel JIT compilation
The GPU experience collection kernels (dqn_experience_kernel.cu,
ppo_experience_kernel.cu) use cudarc::nvrtc::compile_ptx() at runtime.
Without libnvrtc.so the kernel compile fails silently and falls back to
CPU experience collection. Adding cuda-nvrtc-12-4 (~30MB) enables full
GPU-accelerated experience collection.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-28 16:07:00 +01:00
jgrusewski
6d97277b80 refactor(infra): consolidate training-rl and training-supervised into single training image
Both images now use identical cuda:12.4.1-cudnn-runtime base, so maintaining
two separate Dockerfiles and build jobs was wasteful. Single image contains
all 7 training binaries, halving registry storage and Kaniko build time.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-28 15:26:07 +01:00
jgrusewski
4ab97f7698 fix(ci): add cuDNN to training-rl image for CUDA pipeline
candle's CUDA backend links against libcudnn.so.9 for kernel operations.
Switch training-rl base from cuda:12.4.1-runtime to cuda:12.4.1-cudnn-runtime.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-28 15:10:02 +01:00
jgrusewski
fa74f9afcf fix(cuda): add missing gpu_portfolio.rs and experience_kernels.cu files
These files were part of the Phase 2 cuda_pipeline but were untracked
and not included in previous commits. Required for compilation with
--features ml/cuda.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-28 14:41:54 +01:00
jgrusewski
9b2804f9ec feat(cuda): wire GPU experience collection into DQN & PPO training loops
Phase 3 of the CUDA pipeline: both trainers now take a GPU-first path
for experience collection (128×500 = 64K experiences per kernel launch,
zero CPU-GPU roundtrips per timestep) with automatic CPU fallback.

- DQN: upload features alongside targets, GPU collection branch before
  CPU loop, gpu_batch_to_experiences() conversion into replay buffer
- PPO: set_raw_market_data() for CudaSlice upload, GPU collection
  branch bypasses collect_rollouts + prepare_training_batch entirely,
  gpu_batch_to_trajectory_batch() conversion with in-kernel GAE
- Configurable GPU batch sizes (gpu_n_episodes, gpu_timesteps_per_episode)
  and trading params (initial_capital, avg_spread) via hyperparameters
- SAFETY training diagnostics downgraded from warn! to debug!
- 4 new batch index-math validation tests in cuda_pipeline

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-28 14:14:48 +01:00
jgrusewski
d4b22910d7 fix(ppo): replace wildcard match with explicit Device variants for clippy
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-28 13:38:42 +01:00
jgrusewski
341514a4b0 feat(ppo): integrate GPU experience collector with weight sync
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-28 13:32:57 +01:00
jgrusewski
50b360c23c test(cuda): add PPO collector config defaults and source concatenation tests
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-28 13:30:58 +01:00
jgrusewski
6b4c309760 feat(cuda): add GpuPpoExperienceCollector with zero-roundtrip kernel launch
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-28 13:29:24 +01:00
jgrusewski
141aa46848 feat(cuda): add PPO actor/critic weight extraction and GPU upload
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-28 13:25:20 +01:00
jgrusewski
4c22b15ca4 feat(cuda): add PPO experience kernel — actor, critic, GAE, full rollout
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-28 13:20:45 +01:00
jgrusewski
dfcc19538a refactor(cuda): extract shared device functions to common_device_functions.cuh
Move 10 shared device functions (gpu_random, leaky_relu, matvec_leaky_relu,
action_to_exposure, action_to_tx_cost, barrier_init/check/reset,
diversity_entropy, curiosity_inference) and shared constants from
dqn_experience_kernel.cu into a new common_device_functions.cuh header.

The DQN kernel now expects the common header to be prepended via NVRTC
source concatenation at compile time. DQN-specific functions
(q_forward_dueling, argmax_q) remain in the kernel file. This enables
the upcoming PPO kernel to reuse the same shared functions.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-28 13:14:55 +01:00
jgrusewski
f0f779a971 docs: add PPO CUDA pipeline Phase 2c implementation plan — 11 tasks
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-28 13:07:20 +01:00
jgrusewski
a38dd64a71 docs: add PPO CUDA pipeline Phase 2c design — zero-roundtrip experience collection
Single monolithic kernel with in-kernel GAE, full portfolio simulation,
shared device functions header, 5-layer critic matching trainer exactly.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-28 12:59:45 +01:00