Skip to content

cuda.core: add LaunchConfig.programmatic_stream_serialization for programmatic dependent launch - #2456

Open
lijinf2 wants to merge 5 commits into
NVIDIA:mainfrom
lijinf2:feat/1334-pdl-launch-config
Open

cuda.core: add LaunchConfig.programmatic_stream_serialization for programmatic dependent launch#2456
lijinf2 wants to merge 5 commits into
NVIDIA:mainfrom
lijinf2:feat/1334-pdl-launch-config

Conversation

@lijinf2

@lijinf2 lijinf2 commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

Description

Part of #1334

Expose LaunchConfig.programmatic_stream_serialization to set
CU_LAUNCH_ATTRIBUTE_PROGRAMMATIC_STREAM_SERIALIZATION, and add mapping plus
Hopper+ primary/secondary overlap tests.

Reference: https://docs.nvidia.com/cuda/cuda-programming-guide/04-special-topics/programmatic-dependent-launch.html

Release notes / Graph showcase will be in next PR.

Checklist

  • New or existing tests cover these changes.
  • The documentation is up to date with these changes.

lijinf2 added 3 commits July 29, 2026 20:55
…alization

Allow users to set CU_LAUNCH_ATTRIBUTE_PROGRAMMATIC_STREAM_SERIALIZATION
through LaunchConfig, matching the is_cooperative attribute pattern (NVIDIA#1334).
Add an end-to-end Hopper+ test that launches primary and secondary kernels
on the same stream with programmatic_stream_serialization, and asserts
overlap only when the PDL attribute is enabled (NVIDIA#1334).
Drop unused secondary sync/sleep from the overlap test, clarify the
primary clock window comment, and print a short success line for CI.
@copy-pr-bot

copy-pr-bot Bot commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

@lijinf2 lijinf2 self-assigned this Jul 30, 2026
@github-actions github-actions Bot added the cuda.core Everything related to the cuda.core module label Jul 30, 2026
@lijinf2 lijinf2 added this to the cuda.core 1.2.0 milestone Jul 30, 2026
@lijinf2

lijinf2 commented Jul 30, 2026

Copy link
Copy Markdown
Contributor Author

/ok to test d3b3b25

@github-actions

Copy link
Copy Markdown

@lijinf2 lijinf2 changed the title cuda.core: add LaunchConfig.programmatic_stream_serialization for programatic dependent launch cuda.core: add LaunchConfig.programmatic_stream_serialization for programmatic dependent launch Jul 30, 2026
@lijinf2
lijinf2 marked this pull request as ready for review July 30, 2026 16:30
@lijinf2
lijinf2 requested a review from isVoid July 30, 2026 16:31
@lijinf2 lijinf2 linked an issue Jul 30, 2026 that may be closed by this pull request
2 tasks
@lijinf2 lijinf2 added the feature New feature or request label Jul 30, 2026

@isVoid isVoid left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I have one question regarding the test, another small comment for the documentation.

is_cooperative : bool, optional
Whether this config can be used to launch a cooperative kernel.
programmatic_stream_serialization : bool, optional
Whether to allow programmatic stream serialization (PDL). When True,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

PDL is programmatic dependent launch, "programmatic stream serialization" is a sub-concept inside PDL?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I think so. PDL looks to include both programmatic stream serialization and programmatic event.

CUDA programming guide PDL webpage shows an example of cudaLaunchAttributeProgrammaticStreamSerialization.

The page also describes cudaLaunchAttributeProgrammaticEvent but no code example.

attr.value.cooperative = 1
attrs.append(attr)

if config.programmatic_stream_serialization:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Non blocking Q: I see from the comment to this function "once all modules are cythonized, this function can be dropped in favor of the cdef method above". Are all modules cythonized?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I have no answer. this cpdef function might still be needed for tests / non-Cython callers.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Just checked codebase. This function is used in tests/test_launcher.py::test_to_native_launch_config_no_cluster, where there is a python caller "from cuda.core._launch_config import _to_native_launch_config"

Comment on lines +273 to +278
# PDL overlap is opportunistic; retry a few times on a quiet GPU.
saw_overlap = False
for _ in range(5):
if _run(secondary_cfg) == 1:
saw_overlap = True
break

@isVoid isVoid Jul 30, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Frankly, I have huge doubt over testing a non-deterministic behavior and asserting it in the test. We shouldn't be introducing flakiness in the test ourselves.

However kernel overlapping is opportunistic in nature. I vibe coded with my agent for a few rounds and I couldn't find a way to write a kernel and turn this into a deterministic test. My agent suggested that we should actually inspect the edge data from cuda graph to validate its dependency. But we don't have PDL in graph for now. (right?)

IMO, it's probably also acceptable to not expect saw_overlap here to always pass. Instead, we can use pytest.xfail when we didn't observe an overlap run. In that case, we validate the API via inspecting over a period of CI runs, not just through a single flaky failure.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yes, graph support is planed in next PR.

Done. Revised to xfail.

@lijinf2

lijinf2 commented Aug 3, 2026

Copy link
Copy Markdown
Contributor Author

/ok to test 717fe7f

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cuda.core Everything related to the cuda.core module feature New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support programatic dependent launch (PDL)

2 participants