How google-ml-infra/rules_ml_toolchain works
rules_ml_toolchain is a Bazel rules repository for reproducible, hermetic C++ and GPU builds. A workspace adds the rules, initializes toolchain dependencies, and registers a target toolchain; Bazel then selects compilers and sysroots for the requested platform. Separate configuration branches cover CUDA-family libraries, ROCm, SYCL, sanitizers, and Python wrapping. The README documents these capabilities, but most implementation files were not sampled, so edges below use only documented relationships; the ROCm and SYCL discovery scripts are shown as configuration components, not assumed to be wired into a particular caller.
Main entry points: gpu GPU configuration · impls Toolchain definitions · pywrap.impl.bzl Python extension rules · cc_toolchain_deps.bzl Toolchain dependencies
Components 21
C++ toolchains
- Toolchain dependencies
cc/deps/cc_toolchain_deps.bzl - Toolchain definitions
cc/impls - LLVM configuration
cc/llvms - Sysroot configuration
cc/sysroots - Compiler features
cc/features
GPU integrations
- GPU configuration
gpu - CUDA libraries
gpu/cuda - NCCL libraries
gpu/nccl - NVSHMEM libraries
gpu/nvshmem - ROCm discovery
gpu/rocm/find_rocm_config.py - SYCL discovery
gpu/sycl/find_sycl_config.py
Build features
- Sanitizer rules
cc/sanitizers - Header modules
cc/features - Clang CUDA wrapper
cc/cuda/clang/clang_cuda_runtime_wrapper.h
Python wrapping
- Python extension rules
py/rules_pywrap/pywrap.impl.bzl - Windows export filter
py/rules_pywrap/def_file_filter_tool.py - Wrapped module init
py/rules_pywrap/wrapped_py_init.cc
Other components
- Bazel workspace
- Bazel
- LLVM distributions
- GPU libraries
Connections 19
- Bazel workspace → Toolchain dependencies: loads
README.md - Toolchain dependencies → Toolchain definitions: provides for registration
README.md - Bazel workspace → Toolchain definitions: registers
README.md - Bazel → Toolchain definitions: selects toolchain
README.md - Toolchain definitions → LLVM configuration: uses LLVM
- Toolchain definitions → Sysroot configuration: uses sysroot
- Toolchain definitions → Compiler features: configures features
- Bazel workspace → GPU configuration: initializes GPU
README.md - GPU configuration → CUDA libraries: configures
- GPU configuration → NCCL libraries: configures
- GPU configuration → NVSHMEM libraries: configures
- GPU configuration → ROCm discovery: discovers ROCm
- GPU configuration → SYCL discovery: discovers SYCL
- Bazel → Sanitizer rules: uses rules
README.md - Bazel → Header modules: enables features
README.md - Python extension rules → Windows export filter: filters exports
- Python extension rules → Wrapped module init: wraps initializer
- LLVM configuration → LLVM distributions: downloads or configures
- GPU configuration → GPU libraries: configures libraries