Skip to content

[Global-PGM S5] S=1000 memory: streaming targets + float32-preserving collapse (#235, resolves C-212) - #255

Merged
Polichinel merged 2 commits into
developmentfrom
feat/global-pgm-s5-memory
Jul 21, 2026
Merged

[Global-PGM S5] S=1000 memory: streaming targets + float32-preserving collapse (#235, resolves C-212)#255
Polichinel merged 2 commits into
developmentfrom
feat/global-pgm-s5-memory

Conversation

@Polichinel

Copy link
Copy Markdown
Contributor

Closes #235. Part of epic #230 (tracker #237).

The finding that grew the story

The issue scoped the loader (~28 GB all-targets-at-once). Implementation found the larger term: every collapse call forced a float64 copy of the whole sample array, boolean-masked it again, then cast back to float32 for the tower — ~5× the source at peak, ≈46 GB for ONE global S=1000 target, repeated per layer. Both mechanisms are now registered as C-212 and resolved in this PR.

What (RED→GREEN)

  • Collapse (the big win): float32-preserving path — no float64 force (the tower computes in float32 by frame contract), no mask copy on the all-finite norm, zero-copy ephemeral wrap. Numerically identical: 49 value-pinning tests green untouched.
  • Loading: iter_predictions streams (target, frame) one at a time — laziness is test-pinned (second target's files untouched until the consumer pulls); the template releases each target's samples + layers before the next loads. load_predictions dict API unchanged.
  • Guard: subprocess RSS test pins collapse peak < 3.5× source (RED measured 3.8× on the old path; GREEN measures ~1×).

Measured

Quarter-scale probe (194k rows × S=1000, all four layers, subprocess RSS): collapse delta ≈ 0.00 GB over the resident source, 61 s. Extrapolated full global S=1000: ~9.3 GB/target streamed → peak ≈ 12 GB on the 31 GB machine; ~12 min collapse wall per target. mmap_mode evaluated and NOT adopted (4× re-read I/O for a peak already ~1× source; rationale documented in the loader).

Ritual

Register C-212 added (RED) and resolved (GREEN) with numbers; docs validator green; ruff clean; 401 passed (2 skipped, 1 xfailed).

🤖 Generated with Claude Code

Polichinel and others added 2 commits July 21, 2026 04:04
…12, #235)

Registers C-212 (tier 2): the S=1000 global goal is blocked twice over —
all-targets-at-once loading (~28 GB) and, larger, the collapse path's
float64 detour (float64 copy + masked copy + float32 cast ≈ 5x source per
call, ~46 GB for one global S=1000 target). The subprocess RSS probe
measures 3.8x today; the guard demands <3.5x (float32-preserving path
measures ~1-2x). Fails at this commit by design.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
… (C-212, #235)

The S=1000 global goal is unblocked, measured:

Collapse: the float64 detour is gone — calculate_map/hdi/exceedance work on
the frame's float32 directly, skip the boolean-mask copy on the all-finite
norm, and the ephemeral tower wrap is zero-copy. Numerically identical (the
tower always computed in float32; 49 value-pinning tests green). Subprocess
RSS probe, 194k rows x S=1000, all four layers: collapse delta over the
resident source ~0.00 GB (was ~3.8x); CI guard pins < 3.5x.

Loading: iter_predictions streams (target, frame) pairs one at a time
(laziness test-pinned: the second target's files stay untouched until the
consumer asks); the template releases each target's samples + layers before
the next loads. load_predictions keeps its dict API.

Extrapolated full global S=1000: ~9.3 GB/target streamed, peak ~12 GB on
the 31 GB machine; all-four-layer collapse wall ~12 min/target. mmap_mode
evaluated and NOT adopted: 4x re-read I/O for a peak already ~1x source.

Register: C-212 registered (RED commit) and resolved here with the numbers.
401 tests green.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@Polichinel
Polichinel merged commit 3889938 into development Jul 21, 2026
1 check passed
@Polichinel
Polichinel deleted the feat/global-pgm-s5-memory branch July 21, 2026 02:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant