Skip to content

Move UV_CUDA_DRIVER_VERSION and UV_AMD_GPU_ARCHITECTURE parsing to EnvironmentOptions#18846

Open
Vastargazing wants to merge 3 commits intoastral-sh:mainfrom
Vastargazing:move-cuda-amd-env-vars-to-environment-options
Open

Move UV_CUDA_DRIVER_VERSION and UV_AMD_GPU_ARCHITECTURE parsing to EnvironmentOptions#18846
Vastargazing wants to merge 3 commits intoastral-sh:mainfrom
Vastargazing:move-cuda-amd-env-vars-to-environment-options

Conversation

@Vastargazing
Copy link
Copy Markdown

@Vastargazing Vastargazing commented Apr 4, 2026

Part of #14720

Summary

Moves the parsing of two torch-related environment variables from direct std::env::var() calls deep in the call stack into the centralized EnvironmentOptions, which is the intended place for all environment variable parsing per #14720.

Variables moved:

  • UV_CUDA_DRIVER_VERSION — override for the CUDA driver version used in PyTorch backend selection
  • UV_AMD_GPU_ARCHITECTURE — override for the AMD GPU architecture used in PyTorch backend selection

Changes

  • uv-torch/src/accelerator.rs: Accelerator::detect() now takes cuda_driver_version: Option<&str> and amd_gpu_architecture: Option<&str> parameters instead of reading env vars directly
  • uv-torch/src/backend.rs: TorchStrategy::from_mode() gains two new parameters and passes them to Accelerator::detect()
  • uv-settings/src/lib.rs: EnvironmentOptions gains cuda_driver_version and amd_gpu_architecture fields, parsed in EnvironmentOptions::new()
  • uv/src/settings.rs: fields added to ResolverSettings and PipSettings, populated from environment in their respective combine() methods
  • Call sites in pip/{compile,sync,install}.rs, project/mod.rs, and lib.rs updated to thread the values through

let driver_version = Version::from_str(&driver_version)?;
// Use the `UV_CUDA_DRIVER_VERSION` override, if provided.
if let Some(driver_version) = cuda_driver_version {
let driver_version = Version::from_str(driver_version)?;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

We should validate this is a valid version earlier instead of using String

let gpu_architecture = AmdGpuArchitecture::from_str(&gpu_architecture)?;
// Use the `UV_AMD_GPU_ARCHITECTURE` override, if provided.
if let Some(gpu_architecture) = amd_gpu_architecture {
let gpu_architecture = AmdGpuArchitecture::from_str(gpu_architecture)?;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Same as the above, we should use the AmdGpuArchitecture type to eagerly validate the value.

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