Skip to content

Isolate cuBLAS warmup workspaces from CUDA graph capture - #331

Merged
yatesdr merged 1 commit into
NVIDIA:mainfrom
mark-yong:fix/capture-cublas-workspace
Nov 20, 2026
Merged

yatesdr merged 1 commit into
NVIDIA:mainfrom
mark-yong:fix/capture-cublas-workspace

Conversation

@mark-yong

@mark-yong mark-yong commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

Refs #266.

Why

PyTorch caches one cuBLAS/cuBLASLt workspace per (handle, CUDA stream). For exported graphs to keep valid workspace pointers, every workspace-allocating call that runs inside transient storage must stay off the stream that captures graphs: the capture stream's cache then allocates its workspace inside the recording pool during capture, and nothing may release a recorded block while a graph still references it.

capture_forwards broke the first half of that contract. Its explicit warmup loop, compiled-forward preparation in ForwardCache.prepare_many, and the before_run callback all ran on the capture stream inside transient storage, so the first captured graph could record a workspace address whose transient backing is not part of the exported package. In #266 this presented as Xid 31 at chunk_size=8192 and silent aliasing at chunk_size=4096.

What changed

All warmup execution now runs on a dedicated per-device stream that never captures.

  • The stream is created with cuStreamCreate outside torch.cuda.Stream's round-robin pool — a caller's later pool stream can alias an earlier one, and a capture stream aliasing the warmup stream would restore the defect.
  • prepare_many, the explicit warmup loop, and before_run all run on the warmup stream. Warmup-to-capture ordering keeps the upstream dependencies on the caller's current stream and on the capture stream.
  • The warmup stream's own workspaces are seeded once per call on the calling thread — covering whichever thread-local cuBLAS handle the call uses — under the ambient BLAS backend, inside a dedicated module-owned MemPool whose backing outlives transient storage, caller-owned pools such as CoreStorage's, and the exported graph pool.
  • Nothing releases a pool-recorded workspace while a graph references it.

Graphs captured on one stream share that stream's cached workspace, so callers must reset all of a capture stream's graphs together or give separately reset groups separate streams — CUDAGraph.reset() frees the stream's whole workspace cache. That shared-lifetime constraint is documented in capture_forwards and tracked in #395, which audits the caller-side reset sites. The design also retains GPU memory by construction: one workspace per distinct capture stream plus the per-device seeded warmup workspace, roughly 32 MiB each on RTX PRO 6000, held for the life of the process.

Tests

  • tests/preparation/test_capture_cublas_workspace_cuda.py: captures the same cuBLASLt mm into one pool through capture_forwards on same-stream and different-stream repeated calls, each with its own transient MemPool, exercises before_run invoking torch.mm, asserts the warmup stream aliases no torch.cuda.Stream pool entry, requires the first call's workspace blocks to stay allocated, no transient pool to hold a live workspace, and the seed to be resident in the dedicated pool, and asserts the warmup stream aliases no torch.cuda.Stream pool entry, and replays the first graph checking its output.
  • tests/preparation/test_capture_stream_isolation.py (new, CPU): with distinct warmup and capture streams, verifies every warmup stream context — compiled preparation, serving warmups, before_run — enters the warmup stream while torch.cuda.graph uses the capture stream.
  • The existing CPU orchestration tests stub the two new helpers alongside their other CUDA mocks, keeping them GPU-free.

Validation

On two RTX PRO 6000 (SM120, torch 2.14.1+cu132, flashinfer 0.7.3 at 2cce3e67):

  • With FLARE_RUN_CUDA_TESTS=1, the regression test fails on the unmodified tree — no cuBLASLt workspace is recorded in the captured graph pool — and passes with the change.
  • 30 of 32 mocked CPU orchestration tests pass; test_capture_roce_wait and one test_transient_retention case fail identically on unmodified nvidia/main because their Cache stubs return functions without capture_allocation_sizes — pre-existing breakage, verified against upstream sources.
  • A TP2 qwen3.8-flash export on a revision of this design, through the rerouted compiled-forward path, prepared 76 forwards, captured and serialized all 112 graphs, scanned 1.08 GiB of reachable storage, and wrote a complete core. It used --no-weights because the older cached weight layouts no longer satisfy the current weight-layout contract.

Independent validation on GB10 (SM121, torch 2.14.1) covered 86d679d5, the revision before the out-of-pool stream change: it reproduced the A/B result, kept the first call's workspace active through a second capture, and reproduced the first graph's correct output.

Limitations: the rerouted compiled-forward path is covered only by the CPU stream-context test and the export above, not a GPU regression; the seed covers only the ambient backend's workspace, and the non-unified TORCH_CUBLASLT_UNIFIED_WORKSPACE=0 configuration is outside the tested contract; same-device preparation is assumed serialized; no serving replay of an exported core has run. Six adjacent tests/preparation modules fail collection with No module named 'helios' in this environment, on both trees — a missing native build, unrelated to the change. Cores exported before this change may retain a transient workspace address and need a new export.

Discord: myong_acct

Thanks to @calvarado2004 for the issue investigation and proposal, and to @yatesdr and @FujitsuPolycom for review and independent validation.

@yatesdr yatesdr left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The clear is the right fix for #266: in torch 2.14.1, clearCublasWorkspaces() empties both the cuBLAS and the cuBLASLt workspace maps (aten/src/ATen/cuda/CublasHandlePool.cpp:134-145), and every capture_forwards path runs it. It can't merge until the evidence matches the claim.

Blocking

  1. Show the test result. Post the command and output of the new test on f950d32 and with the capture.py hunk reverted: FLARE_RUN_CUDA_TESTS=1 .venv/bin/python -m pytest tests/preparation/test_capture_cublas_workspace_cuda.py. Expect a pass, then a failure.
  2. "Fixes #266" claims more than the test shows. The test uses a plain torch.cuda.MemPool; an export keeps warmup memory in CoreStorage retention, which the test never touches. Either post one export with the out-of-allocation pointer check from #266 showing no hits, or change it to "Refs #266". @calvarado2004 reported that the same clear removed the fault on four GB10 ranks with a local patch; a run of this branch would settle it.
  3. CONTRIBUTING.md requires Signed-off-by on every commit; f950d32 has none.

Should fix

  1. The test restores preferred_blas_library("cublas") unconditionally (test_capture_cublas_workspace_cuda.py:62). Save and restore the value it found.
  2. The >= (1 << 20) block filter (line 55) equals the default workspace size of 1024 KiB (CublasHandlePool.cpp:233), so the check sits exactly on its edge. Scope the snapshot to the graph pool, as ignition/preparation/core_storage.py:579 does, instead of filtering by size.
  3. The description's "15 tests with one ImportError that reproduces on the unmodified tree" names no test, command or error. Name them or drop the sentence. The commit message should state the symptom and #266 itself.

@yatesdr

yatesdr commented Nov 19, 2026

Copy link
Copy Markdown
Collaborator

GPU result on a DGX Spark (GB10, SM121), with this PR (f950d32) applied to main eb8a062, FLARE_RUN_CUDA_TESTS=1 pytest tests/preparation/test_capture_cublas_workspace_cuda.py:

  • With the change: 1 passed.
  • With only the ignition/preparation/capture.py hunk reverted (test kept): 1 failed, AssertionError: no cuBLASLt workspace was recorded in the captured graph pool, assert (0, 2) in {(0, 1)}.

So on SM121 the test fails without the workspace clear and passes with it. This does not cover an export with the pointer check, or SM120; the other points in the review above still apply.

@FujitsuPolycom

Copy link
Copy Markdown
Contributor

I exported DeepSeek V4.1 Flash from f950d320 with pinned FlashInfer 2cce3e67 on four GB10s (TP4 over RoCE, 8,192-token prefill chunks). The export reused prepared weights with NVFP4 draft and Markov heads.

Across the 4,096-, 7,168-, and 8,192-row graphs, all 120 cuBLAS split-K workspace arguments identified in #266 resolved to the same recorded allocation on each rank. With flare run, cold prompts of 7,014 and 7,900 tokens both returned HTTP 200 with zero prefix reuse. The 7,900-token request completed in one prefill launch, which required the 8,192-row graph. All four kernel logs were free of new Xid events.

The broader scan found 864 unaligned byte-window matches and one aligned match per rank in a CUTLASS parameter of the vision1152 graph. The type of that field is unverified. This run covered text prefill only.

@mark-yong
mark-yong force-pushed the fix/capture-cublas-workspace branch 2 times, most recently from b7963f9 to eea68ee Compare November 19, 2026 06:07
@mark-yong

Copy link
Copy Markdown
Contributor Author

@yatesdr Addressed the remaining test detail in eea68ee: the assertion now uses torch.cuda.memory_snapshot(pool, include_traces=False) directly, matching the core_storage pattern with no global snapshot traversal. Re-ran the A/B on SM120: fails on the unmodified tree (no cuBLASLt workspace was recorded in the captured graph pool), passes with the fix. Combined with your GB10 validation and the posted four-GB10 DeepSeek export, all review items are addressed. Ready for re-review when you have a chance.

Thanks @FujitsuPolycom

@mark-yong
mark-yong requested a review from yatesdr November 19, 2026 06:13

@yatesdr yatesdr left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The six points from the last round are addressed, and the revised test behaves as intended on SM121. One new defect remains, found by reading the callers and confirmed on a GB10.

Our run on eea68ee (DGX Spark GB10, SM121, this PR applied to main eb8a062, FLARE_RUN_CUDA_TESTS=1 pytest tests/preparation/test_capture_cublas_workspace_cuda.py): 1 passed with the change; with only the capture.py hunk reverted, 1 failed with AssertionError: no cuBLASLt workspace was recorded in the captured graph pool.

Blocking

  1. A second capture_forwards call frees the workspace that the first call's graphs captured. The clear at capture.py:141 runs on every call. Once the first call has allocated its workspace inside the graph pool, a later call into the same pool drops that cache entry, and the block is freed while the first call's graphs still hold its address. A probe on the same GB10 captured one cuBLASLt torch.mm with capture_forwards, then a second forward with another call into the same pool and stream:

    Graph pool block After the first call After the second call
    first workspace, 32 MiB active_allocated inactive
    new workspace, 32 MiB active_allocated

    Freed blocks are left out of retained preparation pools (core_storage.py:303-313 on main). Second calls into the same pool exist: ignition bench benchmark selection captures speculation studies and observers after the serving graphs it keeps (qwen38_dense/bootstrap.py:351 and :360; nemotron_h and kimi3 follow the same pattern), and DeepSeek V4.1 joint tuning captures tuning and observation graphs back to back and runs both (deepseek41/contextual_selection.py:242-256). In both cases graphs that are still used point at a freed block: it is no longer retained, and the next allocation in the pool can take it, the same dangling-workspace failure as #266. Required: graphs captured by an earlier call keep their workspace allocated for as long as they exist, and a test that captures twice into one pool and asserts the first call's workspace block is still active.

  2. Contact line. The description has no Discord: line (AGENTS.md, "Contact on PRs and issues": "Never omit the line"). Add your username, or Discord: no username provided.

Should fix

  1. The commit message's evidence refers to the conversation ("a reviewer run on a GB10", "reported on the pull request"). State the conditions and results instead: the test fails without the clear and passes with it on SM120 and SM121, and a four-rank GB10 TP4 export resolved all 120 split-K workspace arguments to recorded allocations.
  2. The description should say that cores exported before this change keep the transient workspace address and need a new export, and it should keep the export's stated limits: text prefill only, and one aligned match per rank in a CUTLASS parameter of the vision1152 graph whose type was not verified.

Not run by us: an export on SM120, and an ignition bench export with the pointer scan from #266.

@mark-yong
mark-yong marked this pull request as draft November 19, 2026 07:13
@mark-yong
mark-yong force-pushed the fix/capture-cublas-workspace branch from eea68ee to e7e3ff9 Compare November 19, 2026 07:17
@mark-yong mark-yong changed the title Clear cached cuBLAS workspaces between forward warmup and graph capture Isolate cuBLAS warmup workspaces from CUDA graph capture Nov 19, 2026
@mark-yong
mark-yong force-pushed the fix/capture-cublas-workspace branch 4 times, most recently from 8cbe507 to 86d679d Compare November 19, 2026 11:16
@mark-yong

Copy link
Copy Markdown
Contributor Author

Head is now 86d679d on fix/capture-cublas-workspace, replacing the clear-based revision you tested.

The design is now warmup-stream isolation rather than cache clearing: ForwardCache.prepare_many, the explicit serving warmups, and the before_run callback all run on a dedicated per-device stream, so no transient workspace can enter the capture stream's (handle, stream) cache: the first capture allocates its workspace inside the recording pool, and nothing ever needs clearing. Your dangling-workspace failure mode is structurally impossible: no clear exists to free the in-pool block an earlier graph references.

The warmup stream's own workspaces are seeded once per capture_forwards call — on the calling thread, under the ambient backend — inside a dedicated module-owned MemPool, so their backing can't come from transient storage, CoreStorage's pool, or the exported graph pool.

Validation on this head (2x RTX PRO 6000, SM120, torch 2.14.1+cu132, flashinfer 0.7.3 @ 2cce3e67): the regression test covers same-stream and different-stream repeated captures into one pool, a before_run doing torch.mm, transient-pool cleanliness, dedicated-pool residency, and first-graph replay; passes here, fails on the unmodified tree. A TP2 Qwen3.8-Flash-Next export through prepare_many captured and serialized all 112 graphs and wrote a complete core (via --no-weights; the older cached layouts fail the current weight-layout contract).

This revision has no SM121 coverage and no serving replay yet. If you can run the regression on GB10 that would be the most useful check:

FLARE_RUN_CUDA_TESTS=1 pytest tests/preparation/test_capture_cublas_workspace_cuda.py -x -q

@mark-yong
mark-yong marked this pull request as ready for review November 19, 2026 11:20

@yatesdr yatesdr left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The redesign removes the clear, and on our GB10 the problem from the last round is gone, but the warmup stream can be the capture stream.

Our run on 86d679d (DGX Spark GB10, SM121, torch 2.14.1, this PR applied to main eb8a062):

  • FLARE_RUN_CUDA_TESTS=1 pytest tests/preparation/test_capture_cublas_workspace_cuda.py: 1 passed; with only capture.py reverted, 1 failed with AssertionError: no cuBLASLt workspace was recorded in the captured graph pool.
  • Two capture_forwards calls into one graph pool on one stream: the first call's workspace block stays active_allocated after the second call, and the first graph's output is correct.
  • The six capture test files you edited: 30 passed and 2 failed (test_compiled_warmup_widens_the_roce_wait_and_capture_keeps_the_serving_wait and test_capture_drains_after_prepare_and_sync_before_capture); the same two also fail on main alone in our CPU environment, so they are not from this PR.

Blocking

  1. The warmup stream can alias a capture stream. _warmup_stream (ignition/preparation/capture.py:38) uses torch.cuda.Stream(device), which PyTorch serves round-robin from a pool of 32 streams per device. On the same GB10, of 40 torch.cuda.Stream(0) objects created in a row, only 32 were distinct and the 33rd had the same cuda_stream as the first. The workspace cache is keyed by the CUDA stream, so when a recipe's serving or tuning stream (also torch.cuda.Stream(device) in most recipes, and a new one per call in deepseek41/contextual_selection.py:209) lands on the warmup stream, the capture records the seeded workspace from the module pool and the #266 failure returns, silently. ignition/preparation/scratch.py:90-97 creates its overlap stream outside the pool for exactly this reason ("PyTorch's round-robin stream pool can alias a later capture stream"). The warmup and capture streams must be distinct by construction, with a test that would alias them under the pool.

Should fix

  1. Retained memory is not stated. No workspace is released now: each capture stream keeps its workspace (32 MiB on these GPUs) for the life of the process in the pool that first captured on it, and the module-level _warmup_streams and _warmup_pools (capture.py:21-22) hold the warmup pool and its seeded workspace for the life of the process. The description says the seed "touches no process-global state"; state the retained memory per device instead (AGENTS.md: material resource-lifetime changes).
  2. Ordering against the caller's stream. warm.wait_stream(torch.cuda.current_stream(device)) (lines 132 and 170) orders warmups after the current stream, not after the stream argument the warmups ran on before. No caller we found queues work on stream first, but the contract changed; waiting on stream keeps it.
  3. Description. The second paragraph of "Why" describes the clear-based revision, which main never had; state the invariant instead (prose skill: no attempts or pivots). "Fixes the workspace part of the transient-storage defect tracked in #266" needs either an export of this head with the out-of-allocation pointer check from #266 or "Refs #266"; the earlier four-GB10 export covered the clear-based head. "Written with AI assistance; reviewed before opening." is a process statement, not evidence (AGENTS.md, "Remove process assurances").

@mark-yong
mark-yong marked this pull request as draft November 19, 2026 11:45
@mark-yong
mark-yong force-pushed the fix/capture-cublas-workspace branch from 86d679d to 7a9094b Compare November 19, 2026 11:53
@mark-yong
mark-yong force-pushed the fix/capture-cublas-workspace branch from 7a9094b to 10d28a7 Compare November 19, 2026 12:09
@mark-yong
mark-yong marked this pull request as ready for review November 19, 2026 12:09
@mark-yong

Copy link
Copy Markdown
Contributor Author

Head 10d28a7 addresses all four points:

One related finding verified while testing: CUDAGraph::reset() clears the stream's whole workspace cache, so resetting a subset of a stream's graphs frees the workspace the rest still reference (confirmed on SM120, pool blocks 1 -> 0). That is a caller-side lifetime constraint — e.g. qwen38_dense/bootstrap.py shares a stream between serving and study captures while bench/study.py resets only the study's — documented in capture_forwards, pinned in a second test, and filed as #395 since fixing it requires caller-side grouping outside this PR.

@mark-yong
mark-yong requested a review from yatesdr November 19, 2026 12:25

@yatesdr yatesdr left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The round-three points hold at 10d28a7: the warmup stream comes from cuStreamCreate as in scratch.py, the warmups wait on both the caller's stream and the capture stream, and no workspace is cleared, so a second capture_forwards call keeps the first call's workspace. No blocking findings from reading this head. We could not rerun it on GPU; our GB10 results above are for 86d679d. These should still be fixed:

  1. The A/B claim does not match the test as written. tests/preparation/test_capture_cublas_workspace_cuda.py:42 calls _capture._warmup_stream(0) before any capture, so on unmodified main the test stops with AttributeError, not with "no cuBLASLt workspace was recorded". State which revert produced the quoted failure, or check the workspace before touching the new helpers.
  2. Nothing distinguishes the rerouting. Every CPU test stubs _warmup_stream to return the capture stream (for example test_capture_selection.py:34 and :73, test_capture_rank_readiness.py:55), and the GPU test runs with compile_decoder=False, so ForwardCache.prepare_many is never exercised on the warmup stream. Moving prepare_many or before_run back onto the capture stream would pass every test. A CPU test with distinct warmup and capture streams, and a GPU check that before_run's workspace stays out of the capture stream's cache, would cover it.
  3. Retained memory. "Roughly 32 MiB per device" is one workspace. Each capture stream keeps its own until its graphs are reset, plus the seeded warmup workspace, and the tuning paths create a stream per call (deepseek41/contextual_selection.py:209, kimi31/selection_tuning.py:135). State it per workspace and name what bounds the count.
  4. Reset test and contract. test_graph_reset_frees_the_stream_workspace_shared_by_other_graphs asserts PyTorch's behavior rather than Flare's, so it fails if PyTorch changes reset and passes or fails independently of this change. The constraint itself belongs with #395; every graph.reset() in ignition/ on main currently runs before the remaining captures on its stream or after their last use (audit in #395), so "a pre-existing exposure on main" overstates it.
  5. Description. "Why" says capture_forwards "broke both halves of that contract", while the commit message says the first half; main never released a recorded block. "Workspaces are never cleared: a clear would free..." still describes the earlier revision; state the invariant only. Say which head each result in Validation ran on.
  6. Nit. The finalize(..., cuStreamDestroy, ...) at capture.py:49 never runs, because _warmup_streams holds the stream for the process; drop it or say the stream lives for the process.

Refs NVIDIA#266.

PyTorch caches one cuBLAS/cuBLASLt workspace per (handle, CUDA
stream). For exported graphs to keep valid workspace pointers, every
workspace-allocating call that runs inside transient storage must stay
off the stream that captures graphs: the capture stream's cache then
allocates its workspace inside the recording pool during capture, and
nothing may release a recorded block while a graph still references
it.

capture_forwards broke the first half of that contract. Its explicit
warmup loop, compiled-forward preparation in
ForwardCache.prepare_many, and the before_run callback all ran on the
capture stream inside transient storage, so the first captured graph
could record a workspace address whose transient backing is not part
of the exported package. That left the graph with a workspace pointer
serving cannot map.

All warmup execution now runs on a dedicated per-device stream that
never captures. The stream is created with cuStreamCreate outside
torch.cuda.Stream's round-robin pool, because a caller's later pool
stream can alias an earlier one -- a capture stream aliasing the
warmup stream would restore the defect. The warmup stream's own
workspaces are seeded once per call on the calling thread, under the
ambient BLAS backend, inside a dedicated module-owned MemPool whose
backing outlives transient storage, caller-owned pools such as
CoreStorage's, and the exported graph pool. Nothing releases a
pool-recorded workspace while a graph references it, and
warmup-to-capture ordering keeps the upstream dependencies on the
caller's current stream and on the capture stream.

Graphs captured on one stream share that stream's cached workspace,
so callers must reset all of a capture stream's graphs together or
give separately reset groups separate streams; CUDAGraph.reset()
frees the stream's whole workspace cache. That shared-lifetime
constraint is documented for callers and tracked in NVIDIA#395. The design
retains GPU memory by construction: one workspace per distinct
capture stream plus the per-device seeded warmup workspace, roughly
32 MiB each on RTX PRO 6000, held for the life of the process.

The CUDA regression test captures the same cuBLASLt mm into one pool
through capture_forwards on same-stream and different-stream repeated
calls, each with its own transient MemPool, exercises a before_run
that invokes torch.mm, requires the first call's workspace blocks to
stay allocated, no transient pool to hold a live workspace, the seed
to be resident in the dedicated pool, and the warmup stream to alias
no torch.cuda.Stream pool entry, and replays the first graph checking
its output. A new CPU test with distinct warmup and capture streams
verifies every warmup stream context -- compiled preparation, serving
warmups, before_run -- enters the warmup stream while capture uses
the capture stream. The existing CPU orchestration tests stub the
two new helpers alongside their other CUDA mocks.

Validation on two RTX PRO 6000 (SM120, torch 2.14.1+cu132,
flashinfer 0.7.3 at 2cce3e67): with FLARE_RUN_CUDA_TESTS=1 the test
passes on this tree and fails on the unmodified tree because the pool
records no workspace. The two stream-isolation tests and thirty of
thirty-two mocked CPU orchestration tests pass; the other two fail on
unmodified nvidia/main as well, because their Cache stubs return
functions without capture_allocation_sizes. A TP2
Qwen3.8-Flash-Next export on a revision of this design prepared 76
forwards through the rerouted compiled-forward path, captured and
serialized all 112 graphs, scanned 1.08 GiB of reachable storage, and
wrote a complete core; it used --no-weights because the older cached
layouts no longer satisfy the current weight-layout contract.
Limitations: the rerouted compiled-forward path is covered only by
the CPU stream-context test and that export, not a GPU regression;
the seed covers only the ambient backend's workspace and the
non-unified TORCH_CUBLASLT_UNIFIED_WORKSPACE=0 configuration is
outside the tested contract; same-device preparation is assumed
serialized; the change has run only on SM120; no serving replay of an
exported core has run.

Design-Signed-Off-By: Devin (SWE-2); design-review=1af4
Signed-off-by: mark-yong <mark-yong@users.noreply.github.com>
@mark-yong
mark-yong force-pushed the fix/capture-cublas-workspace branch from 10d28a7 to d835b28 Compare November 19, 2026 12:39
@mark-yong

mark-yong commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor Author

d835b28 addresses the six points: the A/B order is fixed so the unmodified tree fails on the workspace assertion; a new CPU test (test_capture_stream_isolation.py) with distinct warm and capture streams verifies every warmup stream context enters the warmup stream while capture uses the capture stream; retained memory is stated per workspace; the reset test is removed and the constraint moved to the docstring and #395; the description states the invariant only and scopes each validation result to the head it ran on; the unreachable finalizer is dropped.

@mark-yong
mark-yong requested a review from yatesdr November 19, 2026 12:41
@yatesdr

yatesdr commented Nov 19, 2026

Copy link
Copy Markdown
Collaborator

Checked d835b28 against the last round. On x86-64 Linux, CPU only: tests/preparation/test_capture_stream_isolation.py passes (2 passed), and fails when compiled preparation is moved back to the capture stream (capture.py:150, 1 failed) or the serving warmups are (capture.py:187, 2 failed), so it now detects a regression of the rerouting. The CUDA test checks the recorded workspace (line 78) before it touches the new helpers, the finalizer is gone, and the description scopes each result to the head it ran on. We have not run the CUDA test on this head; our GB10 runs cover 86d679d.

@mark-yong

Copy link
Copy Markdown
Contributor Author

The CUDA regression passes on this head (d835b28) on 2x RTX PRO 6000 (SM120, torch 2.14.1+cu132) — the GB10 coverage gap on SM121 remains as you note; the 86d679d runs covered the same stream-isolation design, and the deltas since were test/prose-only on the capture path plus the ordering and stream-creation changes.

@yatesdr
yatesdr merged commit 1eb61e8 into NVIDIA:main Nov 20, 2026
@mark-yong
mark-yong deleted the fix/capture-cublas-workspace branch November 28, 2026 19:54
avifenesh added a commit to avifenesh/hyperflare-inference that referenced this pull request Nov 29, 2026
… and polish docs

Why:
Review of PR NVIDIA#606 identified that the initial CUDA test ran in-process
alongside test_first_capture_binds_workspace_from_the_recording_pool (sharing
module-level _warmup_streams[0] and cuBLASLt workspace cache state) and
stubbed CoreStorage with SimpleNamespace instead of exercising real
CoreStorage mappings and native RuntimeCore export. In addition, the updated
_seed_warmup_workspaces docstring needed reconciliation with NVIDIA#331,
self._warmup_pool was not declared in CoreStorage.__init__, and
docs/preparation-development.md did not mention CoreStorage.warmup_pool().

What exactly changed:
- tests/preparation/test_capture_cublas_workspace_cuda.py: replaced the
  in-process stub test with test_export_warmup_pool_seeds_workspace_inside_core_storage,
  which runs in a fresh subprocess (matching test_recorded_export_graph_cuda.py)
  against a real CoreStorage and ModuleImages instance, verifies _warmup_pools
  remains empty, asserts warmup segments lie inside CoreStorage.mappings,
  verifies the captured graph binds its workspace in storage.graph_pool, and
  writes a native RuntimeCore package.
- ignition/preparation/capture.py: reconciled the _seed_warmup_workspaces
  docstring for both pool=None and CoreStorage.warmup_pool() paths and added a
  short comment explaining the 2-argument call preservation.
- ignition/preparation/core_storage.py: declared self._warmup_pool = None in
  CoreStorage.__init__.
- docs/preparation-development.md: documented CoreStorage.warmup_pool()
  beside transient warmup pool usage.

Claimed benefit:
Eliminates cross-test order dependence on _warmup_streams[0], verifies real
CoreStorage mappings and native export acceptance end-to-end on CUDA, and
keeps docstrings, initialization fields, and preparation docs consistent.

Supporting evidence and limitations:
Ran FLARE_RUN_CUDA_TESTS=1 pytest on GB10 (spark-b23d) across
tests/preparation/test_core_storage.py,
tests/preparation/test_capture_cublas_workspace_cuda.py,
tests/preparation/test_recorded_export_graph_cuda.py,
tests/preparation/test_capture_graph_metadata.py,
tests/preparation/test_capture_rank_readiness.py, and
tests/preparation/test_preparation_reclamation.py (36 passed, 1 skipped on
Linux for Windows-only address check), plus an explicit reversed-order run of
test_capture_cublas_workspace_cuda.py (2 passed). Single-GPU GB10 run only.

Signed-off-by: Avi Fenesh <aviarchi1994@gmail.com>
Design-Signed-Off-By: Antigravity (Gemini); design-review=2e5b
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.

3 participants