#1 [high] S1: duplicated pool=None fallback in capture_forwards
File: ignition/preparation/capture.py:118-122 (verbatim): warmup_pool = warmup_storage.warmup_pool() if hasattr(warmup_storage, "warmup_pool") else None if warmup_pool is not None: _seed_warmup_workspaces(warm, device, warmup_pool) else: _seed_warmup_workspaces(warm, device)
already handles pool=None: ignition/preparation/capture.py:65-71: with torch.cuda.device(device): index = torch.cuda.current_device() if pool is None: pool = _warmup_pools.get(index) if pool is None: pool = _warmup_pools[index] = torch.cuda.MemPool() with torch.cuda.device(index), torch.cuda.stream(stream), torch.cuda.use_mem_pool(pool):
So passing pool=None is byte-for-byte the same path as the 2-argument call. Collapse to:
_seed_warmup_workspaces(warm, device,
warmup_storage.warmup_pool() if hasattr(warmup_storage, "warmup_pool") else None)
4 lines -> 1, behavior identical. The hasattr capability probe is the only reason the branch looks needed; it exists for test doubles (tests/preparation/test_capture_cublas_workspace_cuda.py:60, :140; test_transient_retention.py:141; test_capture_rank_readiness.py:70 pass SimpleNamespace without warmup_pool). AGENTS.md:188-193 rejects "fallback layers ... without a concrete requirement".
#2 [high] S2: CoreStorage.warmup_pool duplicates CoreStorage.pool
File: ignition/preparation/core_storage.py:300-309 (verbatim): def warmup_pool(self): """Own a persistent pool for cuBLAS warmup workspaces inside core mappings.""" import torch
pool = getattr(self, "_warmup_pool", None)
if pool is None:
pool = torch.cuda.MemPool(self._allocator.allocator())
self._warmup_pool = pool
self._preparation_pools.add(pool.id)
return pool
Every property it delivers already exists on CoreStorage.pool, core_storage.py:113-117:
self.pool = torch.cuda.MemPool(allocator.allocator())
self.graph_pool = torch.cuda.MemPool(allocator.allocator())
self._preparation_pools = {self.pool.id}
self._scope = torch.cuda.use_mem_pool(self.pool, device=device)
i.e. backed by the same allocator, persistent for the process (transient()/_retire_retention_pool/ScratchPool.retire never touch it), and already registered in _preparation_pools so unused_ranges() (core_storage.py:319-334) treats it identically.
So: either return self.pool and delete the method (+ the _warmup_pool attribute + tests/preparation/test_core_storage.py:83-105, 25 lines), or the one-line docstring must state why a separate pool is required. Also: getattr(self, "_warmup_pool", None) departs from __init__ declaration convention used for the neighbouring lazy member (core_storage.py:73 self._retention_pool = None, and :82 self._persistent_arena = None); the getattr is only load-bearing because the unit test builds via CoreStorage.new (test_core_storage.py:95).
#5 [high] Research summary
Reviewed the four changed files for subtraction, simplicity/duplication and structural conventions. The diff is small (23 production lines) but not lean: two of the four suggestions are deletions that would remove most of the new production code, because both the branching in capture_forwards and the new CoreStorage.warmup_pool() method re-implement behaviour that already exists a few lines away.
Findings (all with verbatim quotes and file:line in the scratchpad):
capture.py:118-122re-implements thepool=Nonefallback that_seed_warmup_workspacesalready contains atcapture.py:67-70— the whole 4-line if/else collapses to one call, and thehasattrprobe only exists to accommodate test doubles that passSimpleNamespacestorage.core_storage.py:300-309creates a private duplicate ofCoreStorage.pool(core_storage.py:113-117): sameself._allocator.allocator()backing, already persistent, already in_preparation_pools. Either returnself.pooland delete the method plus its 25-line unit test, or justify the separate pool;getattr(self, "_warmup_pool", None)also departs from the__init__-declared convention used for_retention_pool/_persistent_arena.capture.py:59-63: the PR appends "seed inside [the caller's pool]" directly after the surviving "outside … any caller-owned pool" invariant from #331, leaving a self-contradictory docstring; the sentence should be replaced, not appended.docs/preparation-development.md:88-91is also now stale.- The new 53-line GPU test duplicates the setup of the adjacent test (
:33-120) and asserts the same pool twice (:159-161is strictly weaker than:166;:164-165re-seeds whatcapture_forwardsalready did). A shared helper plus dropping the weaker assertions removes ~25 lines.
I deliberately did not repeat the correctness points (that the test uses a fake storage rather than a real CoreStorage, and that registering the pool id changes exported inactive/zero_ranges content) — those belong to the Correctness & Contracts lens, though both are noted where they reinforce a simplification.
#6 [high] S5: verdict, coverage of the diff, and deferred items
Verdict for this lens: NOT lean. 23 production lines, of which ~15 are removable duplication (S1 4 lines, S2 11 lines), plus a 25-line unit test (tests/preparation/test_core_storage.py:83-105) that only exists to test the duplicated method, and ~25 lines of duplicated test setup (S4).
Diff inventory checked (4 files, +101/-5, single commit 2535841):
- ignition/preparation/capture.py:52 (
pool=Noneparameter), :59-63 (docstring append), :67-70 (fallback now nested underif pool is None), :118-122 (branch) — the only production change in this file. - ignition/preparation/core_storage.py:300-309 — the only production change in this file.
- tests/preparation/test_core_storage.py:83-105 and tests/preparation/test_capture_cublas_workspace_cuda.py:123-173 — new tests.
Nothing else in the diff: no flag, no config knob, no environment variable (AGENTS.md:452-455 respected), no dead code left behind, module-level
_warmup_pools/_warmup_streamsstill used by the non-export path (tests/preparation/test_capture_cublas_workspace_cuda.py:97 still reads_capture._warmup_pools[0]), so no subtraction finding there.
Deliberately NOT raised here (belongs to the Correctness & Contracts lens, do not duplicate): (a) the new GPU test fakes the storage with SimpleNamespace instead of a real CoreStorage and never asserts the seed lands inside CoreStorage.mappings; (b) adding the warmup pool id to _preparation_pools changes exported inactive/zero_ranges content via unused_ranges() → runtime_core.py:300-301; (c) whether reversing #331's invariant is an accepted design change; (d) missing evidence/reproduction for the GB10 rejection. Where these reinforce a simplification they are noted inside S1/S2/S4 instead of being restated.
AGENTS.md rules cited: :188-193 ("Do not add frameworks, extension points, speculative compatibility, fallback layers, or configuration switches without a concrete requirement") for S1/S2; :43-50 (required prose skill applies to docstrings) for S3; :494-495 / :512-513 (add only the checks the affected behavior needs; keep ordinary tests) for S4.
#3 [medium] S3: appended docstring sentence contradicts the one it patches
File: ignition/preparation/capture.py:52-64 docstring now states two contradictory rules in adjacent sentences (verbatim, lines 59-63): later call could reuse it; a dedicated pool keeps the seed's backing mapped for the life of the cache entry, outside transient storage, any caller-owned pool, and the exported graph pool. When an export storage supplies a persistent warmup pool, seed inside it so the allocation stays within declared core mappings. "outside ... any caller-owned pool" directly contradicts "seed inside [the caller's] persistent warmup pool". The PR added a sentence instead of replacing the invariant it reverses (that invariant came from #331, commit 1eb61e81). Replace both sentences with one: the seed's backing must stay mapped for the life of the cache entry, outside transient storage and the exported graph pool, in the export storage's persistent core pool when one is supplied. AGENTS.md:43-50 requires the repo prose skill for docstrings; also captures the #331 reversal the PR description does not state. Also stale, not updated by this PR: docs/preparation-development.md:88-91 ("eager warmups allocate from its transient pools and release them before capture") no longer describes where the warmup seed lives.
#4 [medium] S4: new GPU test duplicates setup and double-asserts the pool
tests/preparation/test_capture_cublas_workspace_cuda.py:123-173 (new 53-line test) repeats the setup of the existing test at :33-120 verbatim-ish: set_device, save/set/restore preferred_blas_library, source/weight/output randn bf16, forward, graph_pool_handle, session = SimpleNamespace(capture=nullcontext), stream = torch.cuda.Stream(), try/finally graph reset. Extract one module helper (e.g. _capture_once(storage, forward, ...) or a fixture yielding source/weight/output/session) and use it in both tests: ~25 lines removed.
Inside the new test, two assertions duplicate each other: tests/preparation/test_capture_cublas_workspace_cuda.py:158-168 (verbatim): assert not _active_pool_blocks(transient.id) assert torch.cuda.memory_snapshot(export_warmup.id, include_traces=False), ( "capture_forwards did not allocate warmup seed inside storage.warmup_pool()" ) # On a fresh stream with no prior cached cuBLASLt workspace, seeding must # retain the persistent workspace block inside export_warmup. fresh_stream = torch.cuda.Stream() _seed_warmup_workspaces(fresh_stream, 0, export_warmup) assert _active_pool_blocks(export_warmup.id), ( "seeded cuBLASLt workspace did not land inside storage.warmup_pool()" )
memory_snapshot(...)non-empty at :159 is strictly weaker than_active_pool_blocks(export_warmup.id)at :166 (any segment vs an active_allocated block), so :159-161 can be dropped after thecapture_forwardscall is checked with_active_pool_blocks.- :164-165 re-invokes the private
_seed_warmup_workspacesdirectly, duplicating whatcapture_forwardsalready did at :147; if the point is a fresh stream, seed the first call onfresh_streaminstead of adding a second seeding call.