Skip to content

[CUDA] Fall back to default granularity when VMM is not supported - #1640

Open
tfortunx wants to merge 3 commits into
oneapi-src:mainfrom
tfortunx:cuda-provider-granularity-fallback
Open

tfortunx wants to merge 3 commits into
oneapi-src:mainfrom
tfortunx:cuda-provider-granularity-fallback

Conversation

@tfortunx

Copy link
Copy Markdown
Contributor

Description

On a Windows machine with an NVIDIA A100 GPU without VMM, cuMemGetAllocationGranularity() returns CUDA_ERROR_NOT_SUPPORTED. This makes post_initialize fail, so the CUDA provider can't be created. The provider allocates with cuMemAlloc, cuMemHostAlloc and cuMemAllocManaged, which don't need virtual memory management (VMM).

@tfortunx
tfortunx marked this pull request as ready for review November 27, 2026 14:22
@tfortunx
tfortunx requested a review from a team as a code owner November 27, 2026 14:22
@bratpiorka
bratpiorka requested a balanced review from Copilot November 27, 2026 14:24

Copilot AI 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.

🟡 Changes recommended

The 2 MiB minimum-page-size fallback assumes alignment that non-VMM allocations do not guarantee, potentially leaving disjoint-pool slabs undersized and causing out-of-bounds writes.

1 open issue
What changed in this PR

This PR lets the CUDA memory provider initialize when a device does not support virtual memory management, which its allocation APIs do not require.

Changes:

  • Centralizes CUDA allocation-granularity queries in a helper.
  • Returns a 2 MiB fallback for CUDA_ERROR_NOT_SUPPORTED, while preserving other errors.
  • Uses the helper during initialization and both page-size queries.
File Description
src/​provider/​provider_cuda.c Adds the fallback helper and replaces three direct granularity queries.

Review effort: Balanced

Comment thread src/provider/provider_cuda.c Resolved

Copilot AI 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.

🟡 Changes recommended

The CUDA_ERROR_NOT_SUPPORTED fallback lacks deterministic test coverage for successful provider creation, the 256-byte minimum, the 2 MiB recommendation, and continued failure on other CUDA errors.

1 open issue
1 resolved since last review

Review effort: Balanced

Comment on lines +176 to +179
if (cu_result == CUDA_ERROR_NOT_SUPPORTED) {
*granularity = (option == CU_MEM_ALLOC_GRANULARITY_RECOMMENDED)
? CU_FALLBACK_RECOMMENDED_GRANULARITY
: CU_FALLBACK_MIN_GRANULARITY;

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

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants