← Back to Pull requests

GTEST: Ignore fds opened by a new CUDA context in the fd leak check #12399

Open
unknown opened this pull request with 188 lines diff across 2 files
View on GitHub
unknown unknown commented on Nov 19, 2026 17:34 UTC
Author

What?


Do not count the eventfds and pipes opened by a new CUDA context as leaks in the gtest fd leak check.

Why?


When the CUDA driver creates a context, it opens eventfds and pipes in addition to the /dev/nvidia fds, which are already whitelisted. They stay open until the context is destroyed, and the CUDA runtime keeps primary contexts until the process exits. So each test which first activates the primary context of a device is counted as an fd increase.

On a Vera Rubin node with 4 GPUs (driver 620.70.10), the first context on a device opens 22 /dev/nvidia fds and 2 eventfds, plus 4 pipes for the first context of the process. All of them are closed by cudaDeviceReset(). In a gtest process which runs many tests, a test which switches to another device followed by a test_mem_alloc_device test, whose init() allocates on every device, fails with "fd leaks detected in 2 tests (threshold: 2)". The same tests pass when run alone, since there is at most one such increase.

How?


  • Add mem_buffer::get_active_primary_ctx_count(), which counts the devices whose primary context is active using cuDevicePrimaryCtxGetState().

  • In check_fd_leaks(), compare this count with the one after the previous test. When it increased, log the new eventfds and pipes as "(new CUDA context)" and do not count them as leaks.

  • Other new fds are still counted, as are eventfds and pipes in tests which did not create a context, so leaks of UCX eventfds, such as async or wakeup ones, are still detected.
  • Diff: 188 lines (+141 / -47) across 2 files Reviewer: tvegas1 Review duration: 11662m
    All Vouch review confidence checks passed
    Residual risk 0.19 = Change Risk (0.36) × (1 − Review Confidence (0.47)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.36 · 188 lines diff across 2 files
    0.36
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.02 · 1 substantive comment(s)
    0.02
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    46%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Shallow Review Depth shallow_review_depth
    0.344
    Diff Size diff_size
    0.314
    Real PR Conversation Timeline
    1 comments
    "Review active on #12399"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 46.7% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 35.8% (MEDIUM) · Higher = larger blast radius
    35.8%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 46.7% · Lower = rushed or shallow review
    46.7%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 19.1% · Safe to merge
    19.1%
    Repository