Skip to content

test(cuda.core): keep the cycle collector out of the latch window in test_error_timing_incomplete - #3310

Merged
Andy-Jost merged 2 commits into
NVIDIA:mainfrom
Andy-Jost:ajost/fix-3296-timing-gc
Nov 2, 2026
Merged

Andy-Jost merged 2 commits into
NVIDIA:mainfrom
Andy-Jost:ajost/fix-3296-timing-gc

Conversation

@Andy-Jost

Copy link
Copy Markdown
Contributor

Summary

test_error_timing_incomplete failed with "DID NOT RAISE" on 3 of the last 3 nightlies, always repetition 3 of 5 on the Windows T4 x2 TCC row, and each failure took about 60 s, the latch timeout. The test's own calls do not wait for the latch, so the host most likely blocked in a finalizer that the cycle collector ran while the latch held the stream: a free of memory synchronizes the context and waits for the latch. The analysis is in #3296.

This change keeps the collector out of that window and makes a future stall fail fast with the blocked time instead of "DID NOT RAISE".

Changes

  • cuda_core/tests/test_event.py: test_error_timing_incomplete collects garbage and disables the collector before the latch launch, and releases the latch and enables the collector again in a finally block.
  • The end event is created before the launch and recorded after it, so no event creation runs while the stream is held.
  • The latch timeout is 10 s instead of 60 s, and the test fails with the blocked time if the record call stalls.

Related Work

Closes #3296.

🤖 Generated with Claude Code

…test_error_timing_incomplete

The test failed with "DID NOT RAISE" after about 60 s, the latch
timeout, on one CI row. The likely cause is a finalizer that the cycle
collector runs while the latch holds the stream: a free of memory
synchronizes the context and waits for the latch.

Collect before the launch and disable the collector until the latch
is released. Create the end event before the launch. Use a 10 s latch
and fail with the blocked time when the record call stalls.

Closes NVIDIA#3296.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Andy-Jost Andy-Jost added this to the cuda.core 1.3.0 milestone Oct 31, 2026
@Andy-Jost Andy-Jost added bug Something isn't working P0 High priority - Must do! cuda.core Everything related to the cuda.core module labels Oct 31, 2026
@Andy-Jost Andy-Jost self-assigned this Oct 31, 2026
@coderabbitai

coderabbitai Bot commented Oct 31, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review.

Recent review info
Run configuration
Commits

Reviewing files that changed from the base of the PR and between 9569417 and 55565e4.

Files selected for processing: 1
  • cuda_core/tests/test_event.py

Included review availability: This review used your included allowance. Your plan provides up to 12 included reviews per hour; 11 remain after this review.

Summary

Summary by CodeRabbit

  • Tests
    • Expanded automated coverage for event timing when an event has not yet completed. The checks now verify that recording an event on a temporarily blocked stream returns promptly, that elapsed-time calculations behave as expected before and after completion, and that the test reliably releases the stream and restores cleanup state even if a check fails.

The incomplete-event timing test now creates its second event before launching a 10-second latch. It checks event-recording latency and incomplete-event subtraction while the latch is active. Nested cleanup releases the latch and restores the prior garbage-collection state.

Changes: Incomplete event test

Layer / File(s) Summary
Latch timing and cleanup
cuda_core/tests/test_event.py
The test sets a 10-second latch timeout, prepares the event before launching the latch, and disables garbage collection during the latch window. It checks recording latency and incomplete-event subtraction, then releases the latch and restores garbage collection if it was previously enabled.

Assessment against linked issues

Objective Addressed Explanation
Reliably check subtraction while the second event is incomplete and always release the latch during cleanup [#3296] ❓ The test adds timing checks and cleanup. The issue does not identify the blocking operation, so the available evidence does not confirm that the change prevents the intermittent failure.

Possibly related issues

Suggested labels

test

Suggested reviewers

carterbox, leofang

Change: Bug fix · Severity of issue fixed: Medium

Merge Risk: Low · up to 55565

A delayed test can still fail without a timing diagnostic. This is a narrow CI reliability risk.

- [ ] Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 2


Review info
Run configuration
Commits

Reviewing files that changed from the base of the PR and between 80b3359 and 9569417.

Files selected for processing: 1
  • cuda_core/tests/test_event.py

Included review availability: This review used your included allowance. Your plan provides up to 12 included reviews per hour; 11 remain after this review.

Comment thread cuda_core/tests/test_event.py Resolved
Comment thread cuda_core/tests/test_event.py Resolved
@github-actions

github-actions Bot commented Oct 31, 2026 •

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

Start the blocked-time check before the latch launch, so that a stall
in the launch or the record reports the time. Re-enable the collector
in its own finally block. Request init_cuda, as the test builds a
pinned memory resource through the latch.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Andy-Jost
Andy-Jost requested review from juenglin and mdboom October 31, 2026 16:53
latch = LatchKernel(device)
@pytest.mark.agent_authored(model="claude-opus-5-5")
def test_error_timing_incomplete(init_cuda):
device = init_cuda

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.

Is this change coherent, instead of device = Device(), device.set_current()? It looks like we're not testing that behavior now. (this may be fine)

@Andy-Jost
Andy-Jost merged commit 2ff8747 into NVIDIA:main Nov 2, 2026
115 checks passed
@Andy-Jost
Andy-Jost deleted the ajost/fix-3296-timing-gc branch November 2, 2026 21:01
github-actions Bot pushed a commit that referenced this pull request Nov 3, 2026
Removed preview folders for the following PRs:
- PR #3031
- PR #3222
- PR #3223
- PR #3235
- PR #3236
- PR #3269
- PR #3277
- PR #3294
- PR #3302
- PR #3304
- PR #3307
- PR #3308
- PR #3310
- PR #3331
- PR #3335
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working cuda.core Everything related to the cuda.core module P0 High priority - Must do!

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG]: Repeated flaky test_error_timing_incomplete after approximately 60 seconds

2 participants