Skip to content

Auto backend selection for JAX (parity with --torch-backend=auto) #15461

Description

@nkiyohara

Summary

Hi Astral team, thanks for the amazing work on uv!

Motivation

uv’s PyTorch integration supports automatic backend selection via --torch-backend=auto and UV_TORCH_BACKEND, which transparently installs the appropriate wheels (CPU / CUDA / ROCm / XPU) and switches to the correct PyTorch index. This has been a game-changer for reproducible installs across heterogeneous machines.

The JAX community is growing quickly, and many projects need to “do the right thing” depending on user hardware (CPU vs NVIDIA CUDA). Today this requires manually choosing extras like jax[cuda12] or jax[cuda12-local], which is error-prone for non-experts and complicates distribution.

Proposal

Provide an auto backend selection for JAX, analogous to PyTorch:

  • CLI

    uv pip install "jax" --jax-backend=auto
    uv add jax --jax-backend=auto
  • Config

    [tool.uv.pip]
    jax-backend = "auto"   # cpu | cuda12 | cuda12-local | auto
  • Env var

    UV_JAX_BACKEND=auto

Expected behavior

  • Inspect the environment (e.g., presence of NVIDIA drivers / libcuda, compatible CUDA runtime) and select the appropriate JAX variant.
  • If compatible CUDA is available → install jax[cuda12] (or jax[cuda12-local]) according to JAX’s release mapping; otherwise fall back to CPU.
  • Ensure reproducibility: the resolved variant should be captured in uv.lock with index/marker annotations similar to PyTorch.

Notes

  • JAX release notes indicate current CUDA baseline (e.g., CUDA 12.8) and extras naming conventions (recently cuda12_localcuda12-local). This variability reinforces the need for an “auto” path that stays aligned with upstream.

Thanks for considering JAX parity with the fantastic PyTorch integration!

Example

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or improvement to existing functionality

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions