Skip to content

cudax/stf: cuda_try migration — stream_task (PR9)#10003

Open
andralex wants to merge 6 commits into
NVIDIA:mainfrom
andralex:andralex/stf-cuda-try-stream-task
Open

cudax/stf: cuda_try migration — stream_task (PR9)#10003
andralex wants to merge 6 commits into
NVIDIA:mainfrom
andralex:andralex/stf-cuda-try-stream-task

Conversation

@andralex

@andralex andralex commented Jul 18, 2026

Copy link
Copy Markdown
Contributor

Summary

  • migrate throwing-capable CUDA calls in stream_task.cuh from cuda_safe_call to cuda_try
  • make timing-event setup and destruction exception-safe across stream tasks, host launches, and kernel launches
  • separate successful timing collection from failure cleanup and remove redundant timing_active state
  • use the capture-aware stream-device helper and scoped device activation for multi-place stream dependencies
  • simplify related timing predicates in graph tasks

Test plan

  • pre-commit run --files cudax/include/cuda/experimental/__stf/graph/graph_task.cuh cudax/include/cuda/experimental/__stf/internal/host_launch_scope.cuh cudax/include/cuda/experimental/__stf/internal/launch.cuh cudax/include/cuda/experimental/__stf/stream/stream_task.cuh
  • ninja -j 12 -C build/cudax-cpp20 cudax.test.stf.dot.with_events cudax.test.stf.cpp.task_get_stream cudax.test.stf.interface.host_launch_deps cudax.test.stf.stress.launch_overhead cudax.test.stf.places.execution_policy_kernel_launch_test
  • ctest --test-dir build/cudax-cpp20 -j 12 -R 'cudax\.test\.stf\.(examples\.01-axpy-places|places\.(cuda_stream_place|non_current_device))' --output-on-failure
  • CUDASTF_DOT_TIMING=1 ./build/cudax-cpp20/bin/cudax.test.stf.examples.01-axpy-places

Migrate throwing-capable stream task setup to cuda_try while retaining
cuda_safe_call in noexcept scope guards. Make timing-event ownership
exception-safe and use the capture-aware stream-device helper so partial
failures restore device state and release events.
@andralex
andralex requested a review from a team as a code owner July 18, 2026 03:12
@andralex
andralex requested a review from caugonnet July 18, 2026 03:12
@github-project-automation github-project-automation Bot moved this to Todo in CCCL Jul 18, 2026
@copy-pr-bot

copy-pr-bot Bot commented Jul 18, 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.

@cccl-authenticator-app cccl-authenticator-app Bot moved this from Todo to In Review in CCCL Jul 18, 2026
@andralex

Copy link
Copy Markdown
Contributor Author

/ok to test caf42e7

@coderabbitai

coderabbitai Bot commented Jul 18, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: f8895329-5eb5-4b39-9cb5-e30b3c22e25a

📥 Commits

Reviewing files that changed from the base of the PR and between f89181b and 7e45b83.

📒 Files selected for processing (1)
  • cudax/include/cuda/experimental/__stf/internal/launch.cuh
🚧 Files skipped from review as they are similar to previous changes (1)
  • cudax/include/cuda/experimental/__stf/internal/launch.cuh

📝 Walkthrough

Summary by CodeRabbit

  • Bug Fixes
    • Improved CUDA task timing reliability by creating timing events only when needed and ensuring they’re properly destroyed on both success and failure.
    • Refined stream and graph task timing so elapsed-time reporting happens only when valid timing data is available.
    • Strengthened synchronization and dependency insertion during launches, including safer handling of cooperative-group arrived lists and improved cleanup of temporary managed resources in error scenarios.

Walkthrough

Changes

STF timing paths now use conditionally created CUDA events with RAII cleanup and explicit success/failure handling. Stream dependency insertion is device-scoped, launch cleanup covers temporary and cooperative-group allocations, and graph task timing decisions combine scheduling with calibration state.

STF timing and cleanup

Layer / File(s) Summary
Stream task event lifecycle
cudax/include/cuda/experimental/__stf/stream/stream_task.cuh
Both stream task variants guard timing event creation, measurement, failure cleanup, and destruction; dependency insertion uses a device-scoped synchronization event.
Launch cleanup and timing flow
cudax/include/cuda/experimental/__stf/internal/launch.cuh, cudax/include/cuda/experimental/__stf/internal/host_launch_scope.cuh
Launch paths separate success and failure cleanup, free temporary and arrived-list allocations, correct constructor and allocation sizing, and measure timing only when events exist.
Graph task timing decision
cudax/include/cuda/experimental/__stf/graph/graph_task.cuh
Typed and untyped graph tasks compute record_time from scheduling and calibration state.

Possibly related PRs

  • NVIDIA/cccl#9303: Updates related STF event dependency insertion and guarded CUDA event lifecycles.

Suggested labels: stf

Suggested reviewers: caugonnet, srinivasyadav18, jacobfaib


Comment @coderabbitai help to get the list of available commands.

Destroy timing events reliably and separate successful timing collection from failure cleanup across stream and launch tasks.
@andralex

Copy link
Copy Markdown
Contributor Author

/ok to test 19bb001

@coderabbitai coderabbitai Bot 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.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
cudax/include/cuda/experimental/__stf/internal/launch.cuh (1)

399-403: 🩺 Stability & Availability | 🟠 Major | ⚡ Quick win

important: pass grid_size - 1 to deallocateManagedMemory here deallocateManagedMemory keys the pool by sz, so freeing the allocateManagedMemory(grid_size - 1) buffer with grid_size reinserts it under the wrong size and can later return a short buffer for a grid_size allocation.

🧹 Nitpick comments (1)
cudax/include/cuda/experimental/__stf/internal/launch.cuh (1)

389-389: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

suggestion: Declare free_launch_temps as const; it is never reassigned. As per coding guidelines, “All variables that are not modified must be declared const.”

Source: Coding guidelines


ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 56b6c5a9-8b62-4e1d-8591-f6c5a43c262b

📥 Commits

Reviewing files that changed from the base of the PR and between caf42e7 and 19bb001.

📒 Files selected for processing (4)
  • cudax/include/cuda/experimental/__stf/graph/graph_task.cuh
  • cudax/include/cuda/experimental/__stf/internal/host_launch_scope.cuh
  • cudax/include/cuda/experimental/__stf/internal/launch.cuh
  • cudax/include/cuda/experimental/__stf/stream/stream_task.cuh

andralex added 2 commits July 18, 2026 00:32
Build the execution policy before starting the task so teardown guards
cover occupancy failures, adopt arrived-list ownership atomically, and
install the device-temp free guard before set_device_tmp.
The 3-arg constructor forwarded arg and streams in the wrong order to
the primary constructor.
@andralex

Copy link
Copy Markdown
Contributor Author

/ok to test f89181b

andralex added 2 commits July 18, 2026 00:57
A SCOPE(fail) guard only runs during unwinding, so it can directly free an unadopted arrived list without tracking redundant state.
@andralex

Copy link
Copy Markdown
Contributor Author

/ok to test 7e45b83

@github-actions

Copy link
Copy Markdown
Contributor

😬 CI Workflow Results

🟥 Finished in 1h 24m: Pass: 28%/57 | Total: 1d 11h | Max: 1h 24m | Hits: 14%/30082

See results here.

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

Labels

None yet

Projects

Status: In Review

Development

Successfully merging this pull request may close these issues.

1 participant