Skip to content

Set CU_CTX_SCHED_BLOCKING_SYNC option in tests. - #1209

Merged
Andy-Jost merged 2 commits into
NVIDIA:mainfrom
Andy-Jost:avoid-spin-wait-in-tests
Nov 4, 2025
Merged

Set CU_CTX_SCHED_BLOCKING_SYNC option in tests.#1209
Andy-Jost merged 2 commits into
NVIDIA:mainfrom
Andy-Jost:avoid-spin-wait-in-tests

Conversation

@Andy-Jost

Copy link
Copy Markdown
Contributor

By default, CPU threads spin while waiting for GPU synchronization. This changes the option to block instead while testing.

See cuDevicePrimaryCtxSetFlags for details.

@Andy-Jost
Andy-Jost requested review from leofang and rparolin November 3, 2025 20:37
@copy-pr-bot

copy-pr-bot Bot commented Nov 3, 2025

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.

@Andy-Jost
Andy-Jost force-pushed the avoid-spin-wait-in-tests branch from 22e42c2 to c301d9c Compare November 3, 2025 20:38
@leofang

leofang commented Nov 3, 2025

Copy link
Copy Markdown
Member

Q: Why is this needed? We don't expect our users to do this.

@Andy-Jost

Andy-Jost commented Nov 3, 2025

Copy link
Copy Markdown
Contributor Author

This is not essential. It just reduces load on the test machines. I was annoyed by the spinning when working with certain multiprocessing tests and happened to come across this option in the docs. It's a 5-minute change so I figured why not.

@Andy-Jost

Copy link
Copy Markdown
Contributor Author

/ok to test c301d9ceb070e002ba1e427b773600e0ddf5fcc6

@github-actions

This comment has been minimized.

@leofang leofang left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This is not essential. It just reduces load on the test machines.

Then we should not make this change. We need to test the real-life use scenarios. With the upcoming coverage of various Windows driver modes (#985) our test env will get more sensitive to the underlying driver than ever. Changing the global state is not helping if any issue comes up.

@leofang

leofang commented Nov 3, 2025

Copy link
Copy Markdown
Member

I was annoyed by the spinning when working with certain multiprocessing tests

This is why I kept pushing for IPC events so as to enabling stream-ordered IPC tests. Device synchronization is expansive at the library test scale. We should avoid writing tests that require synchronization. We've had enough in the past to learn in a hard way that stream ordering is critical 😅

@leofang

leofang commented Nov 3, 2025

Copy link
Copy Markdown
Member

I'll take a look at the performance issue. @Andy-Jost do you have in mind speeding up the aggregate performance of all tests under cuda_core/tests/memory_ipc?

@Andy-Jost

Copy link
Copy Markdown
Contributor Author

Let me clarify: I'm not saying there's any performance issue. The annoyance I ran into was during development, especially while using code.interact when a latch kernel was spinning. My laptop was burning up haha!

I believe most of the wait in memory_ipc is on multiprocessing.Queue or similar objects, so it is already blocking. As far as I know, we don't have any significant CUDA synchronization waits in those tests.

@leofang

leofang commented Nov 3, 2025

Copy link
Copy Markdown
Member

I would be OK if you could guard this change behind a test-time env var (say, CUDA_CORE_TEST_BLOCKING_SYNC) that makes your development workflow faster. I am still concerned about the blocking nature of our tests, though, but let's make your life easier first.

@Andy-Jost
Andy-Jost force-pushed the avoid-spin-wait-in-tests branch from c301d9c to b867b3b Compare November 4, 2025 00:50
@Andy-Jost

Copy link
Copy Markdown
Contributor Author

Sounds good. Latest upload adds an environment variable guard.

@Andy-Jost

Copy link
Copy Markdown
Contributor Author

/ok to test b867b3b

leofang
leofang previously approved these changes Nov 4, 2025
Comment thread cuda_core/tests/conftest.py Outdated
Co-authored-by: Leo Fang <leo80042@gmail.com>
@Andy-Jost
Andy-Jost force-pushed the avoid-spin-wait-in-tests branch from bf8295c to e86d5b7 Compare November 4, 2025 15:03
@Andy-Jost

Copy link
Copy Markdown
Contributor Author

/ok to test e86d5b7

@Andy-Jost
Andy-Jost enabled auto-merge (squash) November 4, 2025 19:36
@Andy-Jost
Andy-Jost merged commit 85d57c2 into NVIDIA:main Nov 4, 2025
57 checks passed
@github-actions

github-actions Bot commented Nov 4, 2025

Copy link
Copy Markdown
Doc Preview CI
Preview removed because the pull request was closed or merged.

@Andy-Jost
Andy-Jost deleted the avoid-spin-wait-in-tests branch November 4, 2025 21:05
@leofang leofang added the P2 Low priority - Nice to have label Nov 10, 2025
@leofang leofang added test Improvements or additions to tests cuda.core Everything related to the cuda.core module labels Nov 10, 2025
@leofang leofang added this to the cuda.core beta 9 milestone Nov 10, 2025
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 P2 Low priority - Nice to have test Improvements or additions to tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants