Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: hermetic ctk with deliverable #285

Open
wants to merge 7 commits into
base: cloudhan/hermetic-breaking-changes
Choose a base branch
from

Conversation

cloudhan
Copy link
Collaborator

@cloudhan cloudhan commented Oct 21, 2024

Related: #283

This adds a new repo rule cuda_component and existing repo rule is adapt respectively.

We organize the generated repo as follows, for both local_cuda and local_cuda_<component_repo_name>

<repo_root>              # bazel unconditionally creates a directory for us
├── %{component_name}/   # cuda for local ctk, component name otherwise
│   ├── include/         #
│   └── %{libpath}/      # lib or lib64, platform dependent
├── defs.bzl             # generated
├── BUILD                # generated from BUILD.local_cuda and one/all of the component(s)
└── WORKSPACE            # generated

If the repo is local_cuda, we additionally generate toolchain config as follows

<repo_root>
└── toolchain/
    ├── BUILD            # the default nvcc toolchain
    ├── clang/           # the optional clang toolchain
    │   └── BUILD        #
    └── disabled/        # the fallback toolchain
        └── BUILD        #

How are component repositories and @local_cuda connected?

The registry.bzl file holds mappings from our (rules_cuda) components name to various things.

The registry serve the following purpose:

  1. maps our component names to full component names used redistrib.json file.

    This is purely for looking up the json files.

  2. maps our component names to target names to be exposed under @local_cuda repo.

    To expose those targets, we use a components_mapping attr from our component names to labels of component repository (for example, @local_cuda_nvcc) as follows

# in registry.bzl
...
    "cudart": ["cuda", "cuda_runtime", "cuda_runtime_static"],
...

# in WORKSPACE.bazel
cuda_component(
    name = "local_cuda_cudart_v12.6.77",
    component_name = "cudart",
    ...
)

local_cuda(
    name = "local_cuda",
    components_mapping = {"cudart": "@local_cuda_cudart_v12.6.77"},
    ...
)

This basically means the component cudart has cuda, cuda_runtime and cuda_runtime_static targets defined.

  • In locally installed CTK, we setup the targets in @local_cuda directly.
  • In a deliverable CTK, we setup the targets in @local_cuda_cudart_v12.6.77 repo. And alias all targets to @local_cuda as follows
alias(name = "cuda", actual = "@local_cuda_cudart_v12.6.77//:cuda")
alias(name = "cuda_runtime", actual = "@local_cuda_cudart_v12.6.77//:cuda_runtime")
alias(name = "cuda_runtime_static", actual = "@local_cuda_cudart_v12.6.77//:cuda_runtime_static")

cuda_component is in charge of setting up the repo @local_cuda_cudart_v12.6.77.

@cloudhan cloudhan changed the base branch from main to cloudhan/hermetic-ctk-1 October 21, 2024 14:29
@cloudhan cloudhan force-pushed the cloudhan/hermetic-ctk-1 branch from 0ced2e2 to 35d3cbd Compare December 10, 2024 17:30
@cloudhan cloudhan force-pushed the cloudhan/hermetic-ctk-2 branch from 2660487 to 49aaa29 Compare December 10, 2024 17:31
@cloudhan cloudhan force-pushed the cloudhan/hermetic-ctk-1 branch 4 times, most recently from 44c74a6 to b886a49 Compare December 15, 2024 05:49
@cloudhan cloudhan force-pushed the cloudhan/hermetic-ctk-2 branch from 49aaa29 to 9fd0d83 Compare December 15, 2024 05:56
@cloudhan cloudhan force-pushed the cloudhan/hermetic-ctk-1 branch 2 times, most recently from 255a4df to 31495ea Compare December 22, 2024 17:07
Base automatically changed from cloudhan/hermetic-ctk-1 to main December 22, 2024 17:15
@cloudhan cloudhan force-pushed the cloudhan/hermetic-ctk-2 branch 2 times, most recently from f922cb1 to 06bbedf Compare December 30, 2024 13:22
@cloudhan cloudhan mentioned this pull request Dec 30, 2024
12 tasks
@cloudhan cloudhan force-pushed the cloudhan/hermetic-ctk-2 branch 2 times, most recently from daeceb6 to 9506e4c Compare December 30, 2024 14:33
@cloudhan cloudhan force-pushed the cloudhan/hermetic-ctk-2 branch 6 times, most recently from 5491ada to 81b26d3 Compare January 8, 2025 14:22
@cloudhan cloudhan marked this pull request as ready for review January 8, 2025 14:27
Also stop using `Label(...)` in local_cuda as the dev experience is
really awful when components_mapping fallbacks to `attr.string_dict`
@cloudhan cloudhan force-pushed the cloudhan/hermetic-ctk-2 branch from eafca8d to 9106b4e Compare January 9, 2025 16:43
@cloudhan cloudhan changed the base branch from main to cloudhan/hermetic-breaking-changes January 9, 2025 16:45
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.

1 participant