feat[next-dace]: Add synchronization for multi-stream scheduling - #2744
Draft
edopao wants to merge 11 commits into
Draft
feat[next-dace]: Add synchronization for multi-stream scheduling#2744edopao wants to merge 11 commits into
edopao wants to merge 11 commits into
Conversation
edopao
force-pushed
the
dace_sync_streams
branch
3 times, most recently
from
August 4, 2026 05:32
2364531 to
4dcaf8f
Compare
Adds GT4PY_MAX_CONCURRENT_GPU_STREAMS config and external_sync_stream support so external-memory mode can safely run when DaCe schedules GPU kernels on multiple concurrent streams. - GT4PY_MAX_CONCURRENT_GPU_STREAMS maps to DaCe max_concurrent_streams. - DaCeBackend stores the non-picklable cupy stream and injects it at load. - CUDA/HIP event tasklets fence external workspace access across calls. - Reject POOL mode with multi-stream scheduling. - Add tests and ADR.
edopao
force-pushed
the
dace_sync_streams
branch
from
August 4, 2026 13:18
5253b4a to
0280e19
Compare
Contributor
Author
|
cscs-ci run default |
Contributor
Author
|
cscs-ci run default |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR makes DaCe's multi-stream scheduling opt-in and safe for GT4Py's external workspace mode. When
max_concurrent_gpu_streams >= 1, the DaCe backend injects CUDA/HIP event-based synchronization around SDFG execution, ordering the internal DaCe streams with respect to a caller-provided external stream (or the default stream).Motivation
External workspace mode (
transient_memory_mode=EXTERNAL) avoids per-call GPU allocations by reusing a caller-provided workspace. This is only safe when no other GPU work touches the workspace between two consecutive calls. A concrete use case that breaks this assumption is overlapping GT4Py program execution with MPI halo exchange: halo exchange runs on one CUDA/HIP stream while the GT4Py program runs on DaCe's internal streams. Without explicit ordering, the external workspace can be reused before previous kernels or the halo exchange finish, causing data races.Changes
Replaced the global
GT4PY_MAX_CONCURRENT_GPU_STREAMSconfig with a backend parameter:max_concurrent_gpu_streamstomake_dace_backend,DaCeBackendFactory,DaCeWorkflowFactory,DaCeTranslationStepFactory,DaCeCompiler, andDaCeTranslator.DaCeTranslator.__post_init__.0preserves the historical default-stream-only behavior (sets DaCe'scompiler.cuda.max_concurrent_streamsto-1).>= 1enables DaCe's internal stream pool.Added optional
external_sync_streamsupport:external_sync_stream: cupy.cuda.Stream | None = Nonetomake_dace_backend.DaCeBackend(not the picklable workflow) and injected at artifact load time.max_concurrent_gpu_streams == 0,external_sync_streamis ignored and no validation occurs.Implemented event-based SDFG synchronization:
add_external_stream_syncin the translation step.__external_ws_eventand__external_sync_stream, passed asuint64scalars.max_concurrent_gpu_streams == 0, emits DaCe init code that forces all internal streams to the default stream instead.Added runtime stream validation:
cupy.cuda.Stream.cudaStreamQuery(accepting bothcudaSuccessandcudaErrorNotReady).Added safeguards:
transient_memory_mode=POOLcombined withmax_concurrent_gpu_streams >= 1is rejected, because the memory-pool pass assumes default-stream ordering.Added / updated unit tests:
Default behavior
No behavioral change unless explicitly requested:
max_concurrent_gpu_streams=0(default) produces the same SDFG and execution as before.Testing
Out of scope
Related documents