fix(analytics): O(block×N) correlation snapshot — tiled corr build + screened lead-lag (#75) #76
No reviewers
Labels
No labels
bug
documentation
duplicate
enhancement
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
gertjan/bodega!76
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "fix/correlation-tiled-memory"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Full durable fix for #75, in two reviewable commits.
Commit 1 — tiled correlation build + load hygiene (Phases 1+3)
compute_corr_matrixfills one preallocated N×N float32corr+ int16overlapin row-block stripes (mirrored upper-triangle blocks → exactly symmetric by construction); per-block masked-BLAS temporaries are O(block × N) instead of ~6 simultaneous N×N float32 (~13 GB at N≈24k)top_k_neighbors; in-place distance transform + blockwise symmetrization inhierarchical_clusterscorrelation_refreshpivots asyncpg records straight into the float32 matrix on a worker thread (the old path held ~8M intermediate Python tuples, multi-GB, for the whole compute); fixes an accidental O(N²)symbols.index()loopCommit 2 — screened lead-lag scan + stopgap reverts (Phases 2+4)
find_lead_lag_pairsno longer materialises any N×N matrix: a tiled screen sweeps each lag's improvement surface (|lagged_corr| − |sync_corr|) in row-blocks keeping per-lag row/column top-k improvements, then rescans the surviving ~10·k·N pairs exactly across all lags with chunked elementwise correlation and a vectorised group-by selection (replacing the O(N²) Python double loop — ~40 min of interpreter time at N=24k)lag_zero_overlapparameter; frees the overlap matrix before the scipy clustering peakcorrelation_refreshtimeout 14400 → 5400 s; analyticsmem_limit48g → 24g (contained container kill instead of host-level OOM victim selection)Verification
main) vs new, N=300 synthetic factor universe with ragged listings and injected pure lead-lag structure: identical top-k buckets (900/900), identical cluster partition, identical ordered lead-lag lists (6497/6497 pairs, 20/20 injected pairs), values within 8e-7Remaining #75 acceptance items (ops, post-merge)
docker stats//proc) and confirm ≤ 90 min in RAMmomentum_refreshback adjacent to correlation once confirmed🤖 Generated with Claude Code
https://claude.ai/code/session_01JRnthdVhGGt5FeSQ8m3aUA
fix(analytics): tile correlation build to cut O(N²) peak memory (#75)to fix(analytics): O(block×N) correlation snapshot — tiled corr build + screened lead-lag (#75)