Move UV_CUDA_DRIVER_VERSION and UV_AMD_GPU_ARCHITECTURE parsing to EnvironmentOptions#18846
Open
Vastargazing wants to merge 3 commits intoastral-sh:mainfrom
Open
Conversation
zanieb
reviewed
Apr 7, 2026
| 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)?; |
Member
There was a problem hiding this comment.
We should validate this is a valid version earlier instead of using String
zanieb
reviewed
Apr 7, 2026
| 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)?; |
Member
There was a problem hiding this comment.
Same as the above, we should use the AmdGpuArchitecture type to eagerly validate the value.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 centralizedEnvironmentOptions, 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 selectionUV_AMD_GPU_ARCHITECTURE— override for the AMD GPU architecture used in PyTorch backend selectionChanges
uv-torch/src/accelerator.rs:Accelerator::detect()now takescuda_driver_version: Option<&str>andamd_gpu_architecture: Option<&str>parameters instead of reading env vars directlyuv-torch/src/backend.rs:TorchStrategy::from_mode()gains two new parameters and passes them toAccelerator::detect()uv-settings/src/lib.rs:EnvironmentOptionsgainscuda_driver_versionandamd_gpu_architecturefields, parsed inEnvironmentOptions::new()uv/src/settings.rs: fields added toResolverSettingsandPipSettings, populated fromenvironmentin their respectivecombine()methodspip/{compile,sync,install}.rs,project/mod.rs, andlib.rsupdated to thread the values through