Skip to content

fix(cuda.core): drop the unsynchronized driver version cache in cy_driver_version - #3523

Open
juenglin wants to merge 1 commit into
NVIDIA:mainfrom
juenglin:fix-cy-driver-version-thread-safety
Open

juenglin wants to merge 1 commit into
NVIDIA:mainfrom
juenglin:fix-cy-driver-version-thread-safety

Conversation

@juenglin

@juenglin juenglin commented Nov 21, 2026 •

Copy link
Copy Markdown
Contributor

Description

cy_driver_version() filled a module-level cache without synchronization, so on free-threaded builds, concurrent first calls could leak or over-release the cached tuple. driver_version() is already cached with functools.cache, which is thread-safe, so cy_driver_version() now returns it directly. Callers are unchanged.

The race needs a free-threaded build and several threads making their first version-gated call at the same moment, so there is no issue, release note, or new test. Found while reviewing #3516.

Checklist

  • I have read the Contributing Guidelines.
  • New or existing tests cover these changes.
  • The documentation is up to date with these changes.

…iver_version

cy_driver_version() filled a module-level tuple without synchronization.
On free-threaded builds, concurrent first calls could replace the tuple
while another thread was reading it, leaking it or releasing it too often.
driver_version() is already cached with functools.cache, which is safe
under concurrent calls, so cy_driver_version() now returns it directly.
@juenglin juenglin added this to the cuda.core 1.4.0 milestone Nov 21, 2026
@juenglin juenglin added bug Something isn't working cuda.core Everything related to the cuda.core module labels Nov 21, 2026
@juenglin juenglin self-assigned this Nov 21, 2026
@copy-pr-bot

copy-pr-bot Bot commented Nov 21, 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.

@juenglin
juenglin requested a review from rwgk November 21, 2026 03:35
@juenglin

Copy link
Copy Markdown
Contributor Author

/ok to test f540a59

@juenglin
juenglin enabled auto-merge (squash) November 21, 2026 03:36
@coderabbitai

coderabbitai Bot commented Nov 21, 2026

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Summary

Summary by CodeRabbit

  • Refactor
    • Simplified how the CUDA driver version is retrieved and cached.

cy_driver_version() now delegates to driver_version(), which supplies the cached result. The module-level cache variable and the wrapper’s direct cache management were removed.

Changes: Driver version cache

Layer / File(s) Summary
Delegate driver version retrieval
cuda_core/cuda/core/_utils/version.pyx
cy_driver_version() now calls driver_version() instead of checking and populating its own module-level cache.

Possibly related issues

  • Issue 1389: This change removes one unsynchronized module-level cache in cuda.core. The issue describes broader thread-safety concerns that this change does not fully address.

Suggested reviewers: andy-jost

Change: Bug fix

Merge Risk: Minimal · up to f540a

This change removes a rare race in driver version caching by reusing an existing cached function. No concrete risk to users was identified, and it is ready to merge.

Architecture risk: Low · up to f540a

The change affects 1 system.

Changed systems: cuda_core

Architecture concerns
No architecture-level concerns identified.

Review details

Systems and components

  • observed — cuda_core (service) was modified; 1 changed file maps to changed impact.

Before / after behavior

  • observed — Modified behavior in cuda_core/cuda/core/_utils/version.pyx: cy_driver_version() now delegates to the cached driver_version() instead of checking and populating _cached_driver_version itself; the module-level cache variable was removed.
- [ ] Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 7de038b and f540a59.

Files selected for processing: 1

  • cuda_core/cuda/core/_utils/version.pyx

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

@github-actions

Copy link
Copy Markdown
Contributor

This branch has not been deployed

No deployments
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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant