Repository navigation
fix(nvexec): run work before continues_on on the source scheduler's stream - #2404
Conversation
When continues_on moved between two stream contexts, the work before the transition borrowed the destination context's stream, so both sides ran on the destination context. The work before the transition now gets its own stream from the source context. At the transition, the destination stream waits on an event recorded on the source stream. Transitions within one context still share a single stream.
|
These are a few bigger picture questions/thoughts:
To move forward, it may make sense to split the pr into two separate pieces. A first pr would bring the fix to bring the switching behavior. And then a second pr would address the event mechanism. |
Compare the source and destination schedulers instead of their stream pools, so a change of priority on the same context also gets its own stream for the work before the transition. Drop the event between the two streams. The completion already reaches continues_on through the schedule_from task queue, which only runs the task after the source stream got there, so the destination stream does not need to wait on anything else. Add tests for the priority case and for the destination seeing the work done before the transition.
|
Thanks for looking at this. On what should decide the switch: I think the scheduler. On polling vs events: I looked at this again and the event is not needed for this fix. On So I followed your suggestion and reduced this PR to the switching only:
Ran it on a T4 again (clang 20, CUDA 12.9): main with the new tests: the switch test and the priority test fail. With the change: all 17 If the event part is wanted I can open it as a separate PR after this one. |
|
/ok to test 3e0d3b2 |
|
thanks! |
Follow-up to #1563 (see #1563 (comment)).
With
continues_onbetween two stream schedulers, the work before the transition borrowed the destination's stream, so both sides ran on the destination:Now, if the source and destination schedulers compare unequal (another context, or the same context with another priority), the work before the transition gets its own stream from the source scheduler. Equal schedulers still share one stream.
No extra synchronization is added. The completion already reaches
continues_onthroughschedule_from's task queue, which only runs after the source stream got there.Tests (in
test/nvexec/continues_on.cpp):continues_onwithin one context keeps the same streamTested on a T4 (clang 20, CUDA 12.9): the switch and priority tests fail on main and pass with this change, all
[continues_on]tests pass, the ordering test passed 20/20 runs, and the fulltest.nvexecpasses 3/3 runs (124 test cases). compute-sanitizer memcheck is the same as on main: no leaks, and the only reported errors are the two intentional ones in "continues_on destroys host-constructed storage after a CUDA error".I only have a single GPU, so I haven't tested contexts on two different devices.