[STF] Blocking context resources: unpin host memory once a graph context has run #12874
All Vouch review confidence checks passed
Residual risk 0.18 = Change Risk (0.46) × (1 − Review Confidence (0.60)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.46 · 466 lines diff across 5 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.368
Shallow Review Depth
shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #12874"
general
weight: 0.35
caugonnet
Description
No issue is filed for this yet.
The bug. The graph backend pins a host buffer the user gives to a logical data and never unpins it:
unpin_host_memory()is a no-op there, because the copies are graph nodes that run later. The registration outlives the context. When the same address range is reused, a later and unrelated context either fails withcudaErrorHostMemoryAlreadyRegistered, or skips the pin and fails a copy withcudaErrorInvalidValue. This shows up as an intermittent failure of the Python STF tests, e.g.test_cuda_kernel_chainedright after a graph test on the same worker (job log of #12556).Blocking context resources. A
ctx_resourcecan now declare that its release needs the work submitted on the stream to be complete (release_is_blocking()):add_resource();Unpinning host memory. The graph data interfaces get a real
unpin_host_memory()and reportunpin_host_memory_is_deferred(). When a logical data that STF pinned is destroyed in a graph context, the unpinning becomes a blocking resource, released when the context finalizes. The stream backend is unchanged.A graph context bound to a caller-provided stream cannot hold that resource, so it refuses a host buffer that is not registered, when the logical data is created. This is an error on purpose rather than a silent fall back to copies from pageable memory, which would make such a context slower with nothing to show why. The remedy is to register the buffer first, or to use a context whose
finalize()is blocking. A buffer the caller registered is left alone everywhere.Scope allocator. The stackable context had its own version of the same mechanism for
stream_adapter: a nested scope passed its adapter to its parent through a dedicated list, and a top-level scope cleared it at the pop, synchronizing its stream when a buffer was not stream-ordered. The pending frees are now resources of the scope's context: stream-ordered buffers are freed behind the launch as before, the others are a blocking resource. The dedicated list and its hand-off code are removed.Behavior changes to review:
Not addressed here: a context that is never finalized still leaves its registrations in place, and
address_is_pinned()still checks only the start address.Checklist
cudax/test/stf/graph/host_unpin.cu(unpin after finalize, refusal and acceptance on a caller-provided stream, hand-off through one and two scopes, release ordered after the graph of the scope, host memory of the scope allocator, concurrentadd_resource),python/cuda_stf/tests/stf/test_host_pinning.py.docs/cudax/stf/custom_data_interface.rst.🤖 Generated with Claude Code