Skip to content

Add missing CUDA repo rule features to bzlmod#195

Open
ybaturina wants to merge 3 commits into
google-ml-infra:mainfrom
ybaturina:yb-bzlmod
Open

Add missing CUDA repo rule features to bzlmod#195
ybaturina wants to merge 3 commits into
google-ml-infra:mainfrom
ybaturina:yb-bzlmod

Conversation

@ybaturina
Copy link
Copy Markdown
Collaborator

@ybaturina ybaturina commented Feb 9, 2026

Bazel workspace mode allowed to pass custom redistributions and build templates to the repository rules.
Now this feature is added to bzlmod too.

Example of MODULE.bazel configuration:

CCCL_DIST_DICT = {
 "cuda_cccl;linux-sbsa;full_path": "\"https://github.com/NVIDIA/cccl/releases/download/v2.8.5/cccl-src-v2.8.5.tar.gz\"",
 "cuda_cccl;linux-sbsa;sha256": "\"631cb620e78904fb30f4ef6e033efb7716af1934bc170dce9cbbf4cc48777ca2\"",
 "cuda_cccl;linux-sbsa;strip_prefix": "\"cccl-src-v2.8.5\"",
 "cuda_cccl;linux-x86_64;full_path": "\"https://github.com/NVIDIA/cccl/releases/download/v2.8.5/cccl-src-v2.8.5.tar.gz\"",
 "cuda_cccl;linux-x86_64;sha256": "\"631cb620e78904fb30f4ef6e033efb7716af1934bc170dce9cbbf4cc48777ca2\"",
 "cuda_cccl;linux-x86_64;strip_prefix": "\"cccl-src-v2.8.5\""
}
CCCL_GITHUB_VERSIONS_TO_BUILD_TEMPLATES = {
  "cuda_cccl;repo_name": "\"cuda_cccl\"",
  "cuda_cccl;local;source_dirs": "[\"include\",\"lib\"]",
  "cuda_cccl;version_to_template;any": "\"@rules_ml_toolchain//gpu/cuda/build_templates:cuda_cccl_github.BUILD.tpl\"",
  "cuda_cccl;local;version_to_template;any": "\"@rules_ml_toolchain//gpu/cuda/build_templates:cuda_cccl.BUILD.tpl\""
}

cuda_json_ext = use_extension("@rules_ml_toolchain//extensions:cuda_json.bzl", "cuda_json_ext")
use_repo(cuda_json_ext, "cuda_redist_json")

cuda_redist_init_ext = use_extension("@rules_ml_toolchain//extensions:cuda_redist_init.bzl", "cuda_redist_init_ext")
cuda_redist_init_ext.configure(
    cuda_redistributions = CCCL_DIST_DICT,
    redist_versions_to_build_templates = CCCL_GITHUB_VERSIONS_TO_BUILD_TEMPLATES,
)
use_repo(
    cuda_redist_init_ext,
    "cuda_cccl",
    "cuda_crt",
    "cuda_cublas",
    "cuda_cudart",
    "cuda_cudnn",
    "cuda_cufft",
    "cuda_cupti",
    "cuda_curand",
    "cuda_cusolver",
    "cuda_cusparse",
    "cuda_driver",
    "cuda_nvcc",
    "cuda_nvrtc",
    "cuda_nvdisasm",
    "cuda_nvjitlink",
    "cuda_nvml",
    "cuda_nvtx",
    "cuda_nvvm",
    "cuda_profiler_api",
)

cuda_configure_ext = use_extension("@rules_ml_toolchain//extensions:cuda_configure.bzl", "cuda_configure_ext")
use_repo(cuda_configure_ext, "local_config_cuda")

nvshmem_json_ext = use_extension("@rules_ml_toolchain//extensions:nvshmem_json.bzl", "nvshmem_json_ext")
use_repo(nvshmem_json_ext, "nvshmem_redist_json")

nvshmem_redist_init_ext = use_extension("@rules_ml_toolchain//extensions:nvshmem_redist_init.bzl", "nvshmem_redist_init_ext")
use_repo(
    nvshmem_redist_init_ext,
    "nvidia_nvshmem",
)

nccl_redist = use_extension("@rules_ml_toolchain//extensions:nccl_redist.bzl", "nccl_redist_ext")
use_repo(nccl_redist, "cuda_nccl")

nccl_configure = use_extension("@rules_ml_toolchain//extensions:nccl_configure.bzl", "nccl_configure_ext")
use_repo(nccl_configure, "local_config_nccl")

CCCL_DIST_DICT and CCCL_GITHUB_VERSIONS_TO_BUILD_TEMPLATES are nested dictionaries that were processed by flatten_dict_for_string_dict defined in in //gpu:nvidia_common_rules.bzl.

@ybaturina ybaturina changed the title Add missing CUDA repo rule features to bzlmode. Add missing CUDA repo rule features to bzlmod Feb 9, 2026
@ybaturina ybaturina requested a review from yuriivcs February 10, 2026 00:19
Copy link
Copy Markdown
Collaborator

@yuriivcs yuriivcs left a comment

Choose a reason for hiding this comment

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

LGTM

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