diff --git a/.github/workflows/build_kernel.yaml b/.github/workflows/build_kernel.yaml index a16899e8..ca50b12e 100644 --- a/.github/workflows/build_kernel.yaml +++ b/.github/workflows/build_kernel.yaml @@ -40,49 +40,49 @@ jobs: run: nix-shell -p nix-info --run "nix-info -m" - name: Build relu kernel - run: ( cd builder/examples/relu && nix build .\#redistributable.torch29-cxx11-cu126-${{ matrix.arch }} ) + run: ( cd examples/kernels/relu && nix build .\#redistributable.torch29-cxx11-cu126-${{ matrix.arch }} ) - name: Copy relu kernel - run: cp -rL builder/examples/relu/result relu-kernel + run: cp -rL examples/kernels/relu/result relu-kernel - name: Build relu-tvm-ffi kernel - run: ( cd builder/examples/relu-tvm-ffi && nix build .\#redistributable.tvm-ffi01-cu126-${{ matrix.arch }} ) + run: ( cd examples/kernels/relu-tvm-ffi && nix build .\#redistributable.tvm-ffi01-cu126-${{ matrix.arch }} ) - name: Copy relu-tvm-ffi kernel - run: cp -rL builder/examples/relu-tvm-ffi/result relu-tvm-ffi-kernel + run: cp -rL examples/kernels/relu-tvm-ffi/result relu-tvm-ffi-kernel - name: Build extra-data kernel - run: ( cd builder/examples/extra-data && nix build .\#redistributable.torch29-cxx11-cu126-${{ matrix.arch }} ) + run: ( cd examples/kernels/extra-data && nix build .\#redistributable.torch29-cxx11-cu126-${{ matrix.arch }} ) - name: Copy extra-data kernel - run: cp -rL builder/examples/extra-data/result extra-data + run: cp -rL examples/kernels/extra-data/result extra-data - name: Build relu kernel (CPU) - run: ( cd builder/examples/relu && nix build .\#redistributable.torch29-cxx11-cpu-${{ matrix.arch }} ) + run: ( cd examples/kernels/relu && nix build .\#redistributable.torch29-cxx11-cpu-${{ matrix.arch }} ) - name: Copy relu kernel (CPU) - run: cp -rL builder/examples/relu/result relu-kernel-cpu + run: cp -rL examples/kernels/relu/result relu-kernel-cpu - name: Build cutlass GEMM kernel - run: ( cd builder/examples/cutlass-gemm && nix build .\#redistributable.torch29-cxx11-cu126-${{ matrix.arch }} ) + run: ( cd examples/kernels/cutlass-gemm && nix build .\#redistributable.torch29-cxx11-cu126-${{ matrix.arch }} ) - name: Copy cutlass GEMM kernel - run: cp -rL builder/examples/cutlass-gemm/result cutlass-gemm-kernel + run: cp -rL examples/kernels/cutlass-gemm/result cutlass-gemm-kernel - name: Build relu-backprop-compile kernel - run: ( cd builder/examples/relu-backprop-compile && nix build .\#redistributable.torch29-cxx11-cu126-${{ matrix.arch }} ) + run: ( cd examples/kernels/relu-backprop-compile && nix build .\#redistributable.torch29-cxx11-cu126-${{ matrix.arch }} ) - name: Copy relu-backprop-compile kernel - run: cp -rL builder/examples/relu-backprop-compile/result relu-backprop-compile-kernel + run: cp -rL examples/kernels/relu-backprop-compile/result relu-backprop-compile-kernel # Just test that we build with the extra torchVersions argument. - name: Build relu kernel (specific Torch version) - run: ( cd builder/examples/relu-specific-torch && nix build . ) + run: ( cd examples/kernels/relu-specific-torch && nix build . ) - name: Build relu kernel (compiler flags) - run: ( cd builder/examples/relu-compiler-flags && nix build .\#redistributable.torch29-cxx11-cu126-${{ matrix.arch }} ) + run: ( cd examples/kernels/relu-compiler-flags && nix build .\#redistributable.torch29-cxx11-cu126-${{ matrix.arch }} ) - name: Test that we can build a test shell (e.g. that gcc corresponds to CUDA-required) - run: ( cd builder/examples/relu && nix build .#devShells.${{ matrix.arch }}.test ) + run: ( cd examples/kernels/relu && nix build .#devShells.${{ matrix.arch }}.test ) - name: Build silu-and-mul kernel - run: ( cd builder/examples/silu-and-mul && nix build .\#redistributable.torch-cuda ) + run: ( cd examples/kernels/silu-and-mul && nix build .\#redistributable.torch-cuda ) - name: Copy silu-and-mul kernel - run: cp -rL builder/examples/silu-and-mul/result silu-and-mul-kernel + run: cp -rL examples/kernels/silu-and-mul/result silu-and-mul-kernel - name: Upload kernel artifacts uses: actions/upload-artifact@v6 @@ -118,7 +118,7 @@ jobs: uses: docker/build-push-action@v6 with: context: . - file: builder/tests/Dockerfile.test-kernel + file: nix-builder/tests/Dockerfile.test-kernel platforms: linux/amd64 load: true push: false diff --git a/.github/workflows/build_kernel_macos.yaml b/.github/workflows/build_kernel_macos.yaml index 2fd307b3..aaa88787 100644 --- a/.github/workflows/build_kernel_macos.yaml +++ b/.github/workflows/build_kernel_macos.yaml @@ -28,7 +28,7 @@ jobs: # For now we only test that there are no regressions in building macOS # kernels. Also run tests once we have a macOS runner. - name: Build relu kernel - run: ( cd builder/examples/relu && nix build .\#redistributable.torch29-metal-aarch64-darwin -L ) + run: ( cd examples/kernels/relu && nix build .\#redistributable.torch29-metal-aarch64-darwin -L ) - name: Build relu metal cpp kernel - run: ( cd builder/examples/relu-metal-cpp && nix build .\#redistributable.torch29-metal-aarch64-darwin -L ) + run: ( cd examples/kernels/relu-metal-cpp && nix build .\#redistributable.torch29-metal-aarch64-darwin -L ) diff --git a/.github/workflows/build_kernel_rocm.yaml b/.github/workflows/build_kernel_rocm.yaml index 1b74b59f..415676ac 100644 --- a/.github/workflows/build_kernel_rocm.yaml +++ b/.github/workflows/build_kernel_rocm.yaml @@ -34,7 +34,7 @@ jobs: # For now we only test that there are no regressions in building ROCm # kernels. Also run tests once we have a ROCm runner. - name: Build relu kernel - run: ( cd builder/examples/relu && nix build .\#redistributable.torch29-cxx11-rocm63-x86_64-linux -L ) + run: ( cd examples/kernels/relu && nix build .\#redistributable.torch29-cxx11-rocm63-x86_64-linux -L ) - name: Build relu kernel (compiler flags) - run: ( cd builder/examples/relu-compiler-flags && nix build .\#redistributable.torch29-cxx11-rocm63-x86_64-linux ) + run: ( cd examples/kernels/relu-compiler-flags && nix build .\#redistributable.torch29-cxx11-rocm63-x86_64-linux ) diff --git a/.github/workflows/build_kernel_windows.yaml b/.github/workflows/build_kernel_windows.yaml index 1eb1af95..e9adcf32 100644 --- a/.github/workflows/build_kernel_windows.yaml +++ b/.github/workflows/build_kernel_windows.yaml @@ -51,8 +51,8 @@ jobs: profile: minimal override: true - - name: Build build2cmake - run: ( cd build2cmake && cargo build --release ) + - name: Build kernel-builder + run: ( cd kernel-builder && cargo build --release ) # Python environment setup - uses: actions/setup-python@v6 @@ -64,13 +64,13 @@ jobs: run: pip install torch --index-url https://download.pytorch.org/whl/cu${{ matrix.torch.wheel }} - name: Build cutlass GEMM kernel - run: ( builder\scripts\windows\builder.ps1 -SourceFolder builder/examples/cutlass-gemm -BuildConfig Release -Backend cuda -Build -Force ) + run: ( builder\scripts\windows\builder.ps1 -SourceFolder examples/kernels/cutlass-gemm -BuildConfig Release -Backend cuda -Build -Force ) - name: Build relu kernel - run: ( builder\scripts\windows\builder.ps1 -SourceFolder builder/examples/relu -BuildConfig Release -Backend cuda -Build -Force ) + run: ( builder\scripts\windows\builder.ps1 -SourceFolder examples/kernels/relu -BuildConfig Release -Backend cuda -Build -Force ) - name: Build relu-backprop-compile kernel - run: ( builder\scripts\windows\builder.ps1 -SourceFolder builder/examples/relu-backprop-compile -BuildConfig Release -Backend cuda -Build -Force ) + run: ( builder\scripts\windows\builder.ps1 -SourceFolder examples/kernels/relu-backprop-compile -BuildConfig Release -Backend cuda -Build -Force ) - name: Build silu-and-mul kernel - run: ( builder\scripts\windows\builder.ps1 -SourceFolder builder/examples/silu-and-mul -BuildConfig Release -Backend cuda -Build -Force) + run: ( builder\scripts\windows\builder.ps1 -SourceFolder examples/kernels/silu-and-mul -BuildConfig Release -Backend cuda -Build -Force) diff --git a/.github/workflows/build_kernel_xpu.yaml b/.github/workflows/build_kernel_xpu.yaml index a51d731d..e10caf3b 100644 --- a/.github/workflows/build_kernel_xpu.yaml +++ b/.github/workflows/build_kernel_xpu.yaml @@ -34,10 +34,10 @@ jobs: # For now we only test that there are no regressions in building XPU # kernels. Also run tests once we have a XPU runner. - name: Build relu kernel - run: ( cd builder/examples/relu && nix build .\#redistributable.torch29-cxx11-xpu20252-x86_64-linux -L ) + run: ( cd examples/kernels/relu && nix build .\#redistributable.torch29-cxx11-xpu20252-x86_64-linux -L ) - name: Build relu kernel (compiler flags) - run: ( cd builder/examples/relu-compiler-flags && nix build .\#redistributable.torch29-cxx11-xpu20252-x86_64-linux ) + run: ( cd examples/kernels/relu-compiler-flags && nix build .\#redistributable.torch29-cxx11-xpu20252-x86_64-linux ) - name: Build cutlass-gemm kernel - run: ( cd builder/examples/cutlass-gemm && nix build .\#redistributable.torch29-cxx11-xpu20252-x86_64-linux -L ) + run: ( cd examples/kernels/cutlass-gemm && nix build .\#redistributable.torch29-cxx11-xpu20252-x86_64-linux -L ) diff --git a/.github/workflows/check_variants.yaml b/.github/workflows/check_variants.yaml index 0e049cf0..c27101ea 100644 --- a/.github/workflows/check_variants.yaml +++ b/.github/workflows/check_variants.yaml @@ -20,22 +20,22 @@ jobs: with: nix_path: nixpkgs=channel:nixos-unstable - name: Generate variants JSON - run: nix eval --raw .#lib.allBuildVariantsJSON | nix run nixpkgs#jq 'walk(if type == "array" then sort else . end)' > builder/build-variants.json + run: nix eval --raw .#lib.allBuildVariantsJSON | nix run nixpkgs#jq 'walk(if type == "array" then sort else . end)' > nix-builder/build-variants.json - name: Check if variants JSON is up-to-date run: | - if git diff --exit-code builder/build-variants.json; then + if git diff --exit-code nix-builder/build-variants.json; then echo "✅ variants.json is up-to-date" else - echo "🛑 regenerate variants.json: nix eval --raw .#lib.allBuildVariantsJSON | nix run nixpkgs#jq 'walk(if type == "array" then sort else . end)' > builder/build-variants.json" + echo "🛑 regenerate variants.json: nix eval --raw .#lib.allBuildVariantsJSON | nix run nixpkgs#jq 'walk(if type == "array" then sort else . end)' > nix-builder/build-variants.json" exit 1 fi - name: Generate variants Markdown - run: nix run nixpkgs#python3 builder/scripts/gen_variants_markdown.py + run: nix run nixpkgs#python3 nix-builder/scripts/gen_variants_markdown.py - name: Check if variants Markdown is up-to-date run: | if git diff --exit-code docs/source/builder/build-variants.md; then echo "✅ docs/source/buidler/build-variants.md is up-to-date" else - echo "🛑 regenerate docs/build-variants: nix run nixpkgs#python3 builder/scripts/gen_variants_markdown.py" + echo "🛑 regenerate docs/build-variants: nix run nixpkgs#python3 nix-builder/scripts/gen_variants_markdown.py" exit 1 fi diff --git a/.github/workflows/docker-build-push.yaml b/.github/workflows/docker-build-push.yaml index cf034710..86d920a3 100644 --- a/.github/workflows/docker-build-push.yaml +++ b/.github/workflows/docker-build-push.yaml @@ -6,8 +6,8 @@ on: - main paths: # Only run on changes to the Dockerfile or workflow file - - "buidler/Dockerfile" - - "builder/dockerfiles/**" + - "nix-buidler/Dockerfile" + - "nix-builder/dockerfiles/**" - ".github/workflows/docker-build-push.yaml" workflow_dispatch: # Allow manual triggering @@ -56,7 +56,7 @@ jobs: uses: docker/build-push-action@v6 with: context: . - file: ./builder/dockerfiles/Dockerfile.user + file: ./nix-builder/dockerfiles/Dockerfile.user platforms: linux/amd64,linux/arm64 push: true tags: ${{ steps.meta.outputs.tags }} @@ -107,7 +107,7 @@ jobs: uses: docker/build-push-action@v6 with: context: . - file: ./builder/dockerfiles/Dockerfile + file: ./nix-builder/dockerfiles/Dockerfile platforms: linux/amd64,linux/arm64 push: true tags: ${{ steps.meta-root.outputs.tags }} diff --git a/.github/workflows/rust.yaml b/.github/workflows/rust.yaml index d764b06e..d2b5f120 100644 --- a/.github/workflows/rust.yaml +++ b/.github/workflows/rust.yaml @@ -15,8 +15,8 @@ jobs: run: | ( cd kernel-abi-check/kernel-abi-check && cargo fmt --all -- --check ) ( cd kernel-abi-check/bindings/python && cargo fmt --all -- --check ) - - name: Cargo fmt (build2cmake) - run: ( cd build2cmake && cargo fmt --all -- --check ) + - name: Cargo fmt (kernel-builder) + run: ( cd kernel-builder && cargo fmt --all -- --check ) clippy: name: Clippy @@ -39,5 +39,5 @@ jobs: run: | ( cd kernel-abi-check/kernel-abi-check && cargo clippy -- -D warnings ) ( cd kernel-abi-check/bindings/python && cargo clippy -- -D warnings ) - - name: Clippy (build2cmake) - run: ( cd build2cmake && cargo clippy -- -D warnings ) + - name: Clippy (kernel-builder) + run: ( cd kernel-builder && cargo clippy -- -D warnings ) diff --git a/.github/workflows/test_extra_commands.yaml b/.github/workflows/test_extra_commands.yaml index 5993a172..86353ab7 100644 --- a/.github/workflows/test_extra_commands.yaml +++ b/.github/workflows/test_extra_commands.yaml @@ -28,4 +28,4 @@ jobs: env: USER: runner - name: Test nix run .#kernels - run: ( cd builder/examples/relu ; nix run .#kernels -- lock ../../tests/run-kernels ) + run: ( cd examples/kernels/relu ; nix run .#kernels -- lock ../../../nix-builder/tests/run-kernels ) diff --git a/.gitignore b/.gitignore index 1a433828..26741b98 100644 --- a/.gitignore +++ b/.gitignore @@ -165,4 +165,4 @@ mamba/ poetry.lock # Nix -builder/examples/**/flake.lock +examples/kernels/**/flake.lock diff --git a/docs/source/builder/docker.md b/docs/source/builder/docker.md index 5a48ff1f..03f9e0e4 100644 --- a/docs/source/builder/docker.md +++ b/docs/source/builder/docker.md @@ -58,7 +58,7 @@ The kernel builder includes a command-line interface for easier interaction. The # Build the example relu kernel from the root of the repository docker run --rm \ -v $(pwd):/kernel-builder \ - -w /kernel-builder/examples/relu \ + -w /kernel-builder/examples/kernels/relu \ ghcr.io/huggingface/kernel-builder:main \ build diff --git a/docs/source/builder/local-dev.md b/docs/source/builder/local-dev.md index 426a9b9c..614dc8a9 100644 --- a/docs/source/builder/local-dev.md +++ b/docs/source/builder/local-dev.md @@ -9,30 +9,30 @@ with older C library versions and avoiding accidental dependencies. However, this is not ideal during kernel development, since language servers and IDEs do not interpret the `build.toml` file. As a result, code completion will typically not work. `kernel-builder` provides the -`build2cmake` utility to generate CMake files to build native code and +`kernel-builder` utility to generate CMake files to build native code and setuptools files for building the kernel as a regular Python package. Since CMake and setuptools are widely supported by IDEs, this provides a much-improved development experience. -## Installing `build2cmake` +## Installing `kernel-builder` -`build2cmake` is available as a Rust crate. After [installing Rust](https://rustup.rs), +`kernel-builder` is available as a Rust crate. After [installing Rust](https://rustup.rs), it can be built and installed as follows: ```bash -$ cargo install build2cmake +$ cargo install hf-kernel-builder ``` -## Generating a Python project with `build2cmake` +## Generating a Python project with `kernel-builder` -`build2cmake` generates a CMake/Python project from a [`build.toml`](./writing-kernels.md) +`kernel-builder` generates a CMake/Python project from a [`build.toml`](./writing-kernels.md) file. The invocation is as follows: ```bash -$ build2cmake generate build.toml -f +$ kernel-builder generate build.toml -f ``` -The `-f` flag is optional and instructs `build2cmake` to overwrite +The `-f` flag is optional and instructs `kernel-builder` to overwrite existing files. It is recommended to do an editable install of the generated project into @@ -47,7 +47,7 @@ $ pip install --no-build-isolation -e . - Kernels built in this way should **not** be published on the Kernel Hub. They do not fulfill the [kernel requirements](../kernel-requirements.md). -- Do not add the generated files to Git. `build2cmake` has regular updates +- Do not add the generated files to Git. `kernel-builder` has regular updates and you generally want to use files generated by the latest version. ## Testing kernel builds before publishing diff --git a/docs/source/builder/nix.md b/docs/source/builder/nix.md index bfbc3975..05981788 100644 --- a/docs/source/builder/nix.md +++ b/docs/source/builder/nix.md @@ -12,7 +12,7 @@ We recommend installing Nix in the following way: The easiest way get all the Nix functionality is by putting a `flake.nix` in your kernel repository. To do so, copy -[`examples/relu/flake.nix`](https://github.com/huggingface/kernels/blob/main/builder/examples/relu/flake.nix) into the +[`examples/relu/flake.nix`](https://github.com/huggingface/kernels/blob/main/examples/kernels/relu/flake.nix) into the same directory as your `build.toml` file. Then run `nix flake update`. This generates a `flake.lock` file that pins the kernel builder and _all_ its transitive dependencies. Commit both `flake.nix` @@ -57,12 +57,12 @@ The compiled kernel will then be in the local `build/` directory. ## Shell for local development `kernel-builder` provides shells for developing kernels. In such a shell, -all required dependencies are available, as well as `build2cmake` for generating +all required dependencies are available, as well as `kernel-builder` for generating project files. For example: ```bash $ nix develop -$ build2cmake generate build.toml +$ kernel-builder generate build.toml $ cmake -B build-ext $ cmake --build build-ext ``` @@ -74,7 +74,7 @@ Python package in this virtual environment: ```bash $ nix develop -$ build2cmake generate build.toml +$ kernel-builder generate build.toml $ pip install --no-build-isolation -e . ``` diff --git a/docs/source/builder/writing-kernels.md b/docs/source/builder/writing-kernels.md index 5db6005d..b602af91 100644 --- a/docs/source/builder/writing-kernels.md +++ b/docs/source/builder/writing-kernels.md @@ -30,9 +30,9 @@ of CMake or setuptools. This page describes the directory layout of a kernel-builder project, the format of the `build.toml` file, and some additional Python glue that -`kernel-builder` provides. We will use a [simple ReLU kernel](https://github.com/huggingface/kernels/tree/main/builder/examples/relu) +`kernel-builder` provides. We will use a [simple ReLU kernel](https://github.com/huggingface/kernels/tree/main/examples/kernels/relu) as the running example. After reading this page, you may also want to have -a look at the more realistic [ReLU kernel with backprop and `torch.compile`](https://github.com/huggingface/kernels/tree/main/builder/examples/relu-backprop-compile) +a look at the more realistic [ReLU kernel with backprop and `torch.compile`](https://github.com/huggingface/kernels/tree/main/examples/kernels/relu-backprop-compile) support. ## Setting up environment diff --git a/builder/examples/cutlass-gemm/build.toml b/examples/kernels/cutlass-gemm/build.toml similarity index 100% rename from builder/examples/cutlass-gemm/build.toml rename to examples/kernels/cutlass-gemm/build.toml diff --git a/builder/examples/cutlass-gemm/flake.nix b/examples/kernels/cutlass-gemm/flake.nix similarity index 100% rename from builder/examples/cutlass-gemm/flake.nix rename to examples/kernels/cutlass-gemm/flake.nix diff --git a/builder/examples/cutlass-gemm/gemm.cu b/examples/kernels/cutlass-gemm/gemm.cu similarity index 100% rename from builder/examples/cutlass-gemm/gemm.cu rename to examples/kernels/cutlass-gemm/gemm.cu diff --git a/builder/examples/cutlass-gemm/gemm_sycl.cpp b/examples/kernels/cutlass-gemm/gemm_sycl.cpp similarity index 100% rename from builder/examples/cutlass-gemm/gemm_sycl.cpp rename to examples/kernels/cutlass-gemm/gemm_sycl.cpp diff --git a/builder/examples/cutlass-gemm/tests/test_gemm.py b/examples/kernels/cutlass-gemm/tests/test_gemm.py similarity index 100% rename from builder/examples/cutlass-gemm/tests/test_gemm.py rename to examples/kernels/cutlass-gemm/tests/test_gemm.py diff --git a/builder/examples/cutlass-gemm/torch-ext/cutlass_gemm/__init__.py b/examples/kernels/cutlass-gemm/torch-ext/cutlass_gemm/__init__.py similarity index 100% rename from builder/examples/cutlass-gemm/torch-ext/cutlass_gemm/__init__.py rename to examples/kernels/cutlass-gemm/torch-ext/cutlass_gemm/__init__.py diff --git a/builder/examples/cutlass-gemm/torch-ext/registration.h b/examples/kernels/cutlass-gemm/torch-ext/registration.h similarity index 100% rename from builder/examples/cutlass-gemm/torch-ext/registration.h rename to examples/kernels/cutlass-gemm/torch-ext/registration.h diff --git a/builder/examples/cutlass-gemm/torch-ext/torch_binding.cpp b/examples/kernels/cutlass-gemm/torch-ext/torch_binding.cpp similarity index 100% rename from builder/examples/cutlass-gemm/torch-ext/torch_binding.cpp rename to examples/kernels/cutlass-gemm/torch-ext/torch_binding.cpp diff --git a/builder/examples/cutlass-gemm/torch-ext/torch_binding.h b/examples/kernels/cutlass-gemm/torch-ext/torch_binding.h similarity index 100% rename from builder/examples/cutlass-gemm/torch-ext/torch_binding.h rename to examples/kernels/cutlass-gemm/torch-ext/torch_binding.h diff --git a/builder/examples/extra-data/build.toml b/examples/kernels/extra-data/build.toml similarity index 100% rename from builder/examples/extra-data/build.toml rename to examples/kernels/extra-data/build.toml diff --git a/builder/examples/extra-data/flake.nix b/examples/kernels/extra-data/flake.nix similarity index 100% rename from builder/examples/extra-data/flake.nix rename to examples/kernels/extra-data/flake.nix diff --git a/builder/examples/extra-data/relu_cpu/relu_cpu.cpp b/examples/kernels/extra-data/relu_cpu/relu_cpu.cpp similarity index 100% rename from builder/examples/extra-data/relu_cpu/relu_cpu.cpp rename to examples/kernels/extra-data/relu_cpu/relu_cpu.cpp diff --git a/builder/examples/extra-data/relu_cuda/relu.cu b/examples/kernels/extra-data/relu_cuda/relu.cu similarity index 100% rename from builder/examples/extra-data/relu_cuda/relu.cu rename to examples/kernels/extra-data/relu_cuda/relu.cu diff --git a/builder/examples/extra-data/relu_metal/common.h b/examples/kernels/extra-data/relu_metal/common.h similarity index 100% rename from builder/examples/extra-data/relu_metal/common.h rename to examples/kernels/extra-data/relu_metal/common.h diff --git a/builder/examples/extra-data/relu_metal/relu.metal b/examples/kernels/extra-data/relu_metal/relu.metal similarity index 100% rename from builder/examples/extra-data/relu_metal/relu.metal rename to examples/kernels/extra-data/relu_metal/relu.metal diff --git a/builder/examples/extra-data/relu_metal/relu.mm b/examples/kernels/extra-data/relu_metal/relu.mm similarity index 100% rename from builder/examples/extra-data/relu_metal/relu.mm rename to examples/kernels/extra-data/relu_metal/relu.mm diff --git a/builder/examples/extra-data/relu_xpu/relu.cpp b/examples/kernels/extra-data/relu_xpu/relu.cpp similarity index 100% rename from builder/examples/extra-data/relu_xpu/relu.cpp rename to examples/kernels/extra-data/relu_xpu/relu.cpp diff --git a/builder/examples/extra-data/tests/__init__.py b/examples/kernels/extra-data/tests/__init__.py similarity index 100% rename from builder/examples/extra-data/tests/__init__.py rename to examples/kernels/extra-data/tests/__init__.py diff --git a/builder/examples/extra-data/tests/test_relu.py b/examples/kernels/extra-data/tests/test_relu.py similarity index 100% rename from builder/examples/extra-data/tests/test_relu.py rename to examples/kernels/extra-data/tests/test_relu.py diff --git a/builder/examples/extra-data/torch-ext/extra_data/__init__.py b/examples/kernels/extra-data/torch-ext/extra_data/__init__.py similarity index 100% rename from builder/examples/extra-data/torch-ext/extra_data/__init__.py rename to examples/kernels/extra-data/torch-ext/extra_data/__init__.py diff --git a/builder/examples/extra-data/torch-ext/extra_data/data.json b/examples/kernels/extra-data/torch-ext/extra_data/data.json similarity index 100% rename from builder/examples/extra-data/torch-ext/extra_data/data.json rename to examples/kernels/extra-data/torch-ext/extra_data/data.json diff --git a/builder/examples/extra-data/torch-ext/extra_data/layers/__init__.py b/examples/kernels/extra-data/torch-ext/extra_data/layers/__init__.py similarity index 100% rename from builder/examples/extra-data/torch-ext/extra_data/layers/__init__.py rename to examples/kernels/extra-data/torch-ext/extra_data/layers/__init__.py diff --git a/builder/examples/extra-data/torch-ext/torch_binding.cpp b/examples/kernels/extra-data/torch-ext/torch_binding.cpp similarity index 100% rename from builder/examples/extra-data/torch-ext/torch_binding.cpp rename to examples/kernels/extra-data/torch-ext/torch_binding.cpp diff --git a/builder/examples/extra-data/torch-ext/torch_binding.h b/examples/kernels/extra-data/torch-ext/torch_binding.h similarity index 100% rename from builder/examples/extra-data/torch-ext/torch_binding.h rename to examples/kernels/extra-data/torch-ext/torch_binding.h diff --git a/builder/examples/relu-backprop-compile/build.toml b/examples/kernels/relu-backprop-compile/build.toml similarity index 100% rename from builder/examples/relu-backprop-compile/build.toml rename to examples/kernels/relu-backprop-compile/build.toml diff --git a/builder/examples/relu-backprop-compile/flake.nix b/examples/kernels/relu-backprop-compile/flake.nix similarity index 100% rename from builder/examples/relu-backprop-compile/flake.nix rename to examples/kernels/relu-backprop-compile/flake.nix diff --git a/builder/examples/relu-backprop-compile/relu_cuda/relu.cu b/examples/kernels/relu-backprop-compile/relu_cuda/relu.cu similarity index 100% rename from builder/examples/relu-backprop-compile/relu_cuda/relu.cu rename to examples/kernels/relu-backprop-compile/relu_cuda/relu.cu diff --git a/builder/examples/relu-backprop-compile/tests/__init__.py b/examples/kernels/relu-backprop-compile/tests/__init__.py similarity index 100% rename from builder/examples/relu-backprop-compile/tests/__init__.py rename to examples/kernels/relu-backprop-compile/tests/__init__.py diff --git a/builder/examples/relu-backprop-compile/tests/test_relu.py b/examples/kernels/relu-backprop-compile/tests/test_relu.py similarity index 100% rename from builder/examples/relu-backprop-compile/tests/test_relu.py rename to examples/kernels/relu-backprop-compile/tests/test_relu.py diff --git a/builder/examples/relu-backprop-compile/torch-ext/relu_backprop_compile/__init__.py b/examples/kernels/relu-backprop-compile/torch-ext/relu_backprop_compile/__init__.py similarity index 100% rename from builder/examples/relu-backprop-compile/torch-ext/relu_backprop_compile/__init__.py rename to examples/kernels/relu-backprop-compile/torch-ext/relu_backprop_compile/__init__.py diff --git a/builder/examples/relu-backprop-compile/torch-ext/torch_binding.cpp b/examples/kernels/relu-backprop-compile/torch-ext/torch_binding.cpp similarity index 100% rename from builder/examples/relu-backprop-compile/torch-ext/torch_binding.cpp rename to examples/kernels/relu-backprop-compile/torch-ext/torch_binding.cpp diff --git a/builder/examples/relu-backprop-compile/torch-ext/torch_binding.h b/examples/kernels/relu-backprop-compile/torch-ext/torch_binding.h similarity index 100% rename from builder/examples/relu-backprop-compile/torch-ext/torch_binding.h rename to examples/kernels/relu-backprop-compile/torch-ext/torch_binding.h diff --git a/builder/examples/relu-compiler-flags/build.toml b/examples/kernels/relu-compiler-flags/build.toml similarity index 100% rename from builder/examples/relu-compiler-flags/build.toml rename to examples/kernels/relu-compiler-flags/build.toml diff --git a/builder/examples/relu-compiler-flags/flake.nix b/examples/kernels/relu-compiler-flags/flake.nix similarity index 100% rename from builder/examples/relu-compiler-flags/flake.nix rename to examples/kernels/relu-compiler-flags/flake.nix diff --git a/builder/examples/relu-compiler-flags/relu_cuda/relu.cu b/examples/kernels/relu-compiler-flags/relu_cuda/relu.cu similarity index 100% rename from builder/examples/relu-compiler-flags/relu_cuda/relu.cu rename to examples/kernels/relu-compiler-flags/relu_cuda/relu.cu diff --git a/builder/examples/relu-compiler-flags/relu_xpu/relu.cpp b/examples/kernels/relu-compiler-flags/relu_xpu/relu.cpp similarity index 100% rename from builder/examples/relu-compiler-flags/relu_xpu/relu.cpp rename to examples/kernels/relu-compiler-flags/relu_xpu/relu.cpp diff --git a/builder/examples/relu-compiler-flags/torch-ext/relu_compiler_flags/__init__.py b/examples/kernels/relu-compiler-flags/torch-ext/relu_compiler_flags/__init__.py similarity index 100% rename from builder/examples/relu-compiler-flags/torch-ext/relu_compiler_flags/__init__.py rename to examples/kernels/relu-compiler-flags/torch-ext/relu_compiler_flags/__init__.py diff --git a/builder/examples/relu-compiler-flags/torch-ext/torch_binding.cpp b/examples/kernels/relu-compiler-flags/torch-ext/torch_binding.cpp similarity index 100% rename from builder/examples/relu-compiler-flags/torch-ext/torch_binding.cpp rename to examples/kernels/relu-compiler-flags/torch-ext/torch_binding.cpp diff --git a/builder/examples/relu-compiler-flags/torch-ext/torch_binding.h b/examples/kernels/relu-compiler-flags/torch-ext/torch_binding.h similarity index 100% rename from builder/examples/relu-compiler-flags/torch-ext/torch_binding.h rename to examples/kernels/relu-compiler-flags/torch-ext/torch_binding.h diff --git a/builder/examples/relu-metal-cpp/build.toml b/examples/kernels/relu-metal-cpp/build.toml similarity index 100% rename from builder/examples/relu-metal-cpp/build.toml rename to examples/kernels/relu-metal-cpp/build.toml diff --git a/builder/examples/relu-metal-cpp/flake.nix b/examples/kernels/relu-metal-cpp/flake.nix similarity index 100% rename from builder/examples/relu-metal-cpp/flake.nix rename to examples/kernels/relu-metal-cpp/flake.nix diff --git a/builder/examples/relu-metal-cpp/relu/common.h b/examples/kernels/relu-metal-cpp/relu/common.h similarity index 100% rename from builder/examples/relu-metal-cpp/relu/common.h rename to examples/kernels/relu-metal-cpp/relu/common.h diff --git a/builder/examples/relu-metal-cpp/relu/metallib_loader.mm b/examples/kernels/relu-metal-cpp/relu/metallib_loader.mm similarity index 100% rename from builder/examples/relu-metal-cpp/relu/metallib_loader.mm rename to examples/kernels/relu-metal-cpp/relu/metallib_loader.mm diff --git a/builder/examples/relu-metal-cpp/relu/relu.cpp b/examples/kernels/relu-metal-cpp/relu/relu.cpp similarity index 100% rename from builder/examples/relu-metal-cpp/relu/relu.cpp rename to examples/kernels/relu-metal-cpp/relu/relu.cpp diff --git a/builder/examples/relu-metal-cpp/relu/relu_cpp.metal b/examples/kernels/relu-metal-cpp/relu/relu_cpp.metal similarity index 100% rename from builder/examples/relu-metal-cpp/relu/relu_cpp.metal rename to examples/kernels/relu-metal-cpp/relu/relu_cpp.metal diff --git a/builder/examples/relu-metal-cpp/tests/__init__.py b/examples/kernels/relu-metal-cpp/tests/__init__.py similarity index 100% rename from builder/examples/relu-metal-cpp/tests/__init__.py rename to examples/kernels/relu-metal-cpp/tests/__init__.py diff --git a/builder/examples/relu-metal-cpp/tests/test_relu.py b/examples/kernels/relu-metal-cpp/tests/test_relu.py similarity index 100% rename from builder/examples/relu-metal-cpp/tests/test_relu.py rename to examples/kernels/relu-metal-cpp/tests/test_relu.py diff --git a/builder/examples/relu-metal-cpp/torch-ext/relu/__init__.py b/examples/kernels/relu-metal-cpp/torch-ext/relu/__init__.py similarity index 100% rename from builder/examples/relu-metal-cpp/torch-ext/relu/__init__.py rename to examples/kernels/relu-metal-cpp/torch-ext/relu/__init__.py diff --git a/builder/examples/relu-metal-cpp/torch-ext/torch_binding.cpp b/examples/kernels/relu-metal-cpp/torch-ext/torch_binding.cpp similarity index 100% rename from builder/examples/relu-metal-cpp/torch-ext/torch_binding.cpp rename to examples/kernels/relu-metal-cpp/torch-ext/torch_binding.cpp diff --git a/builder/examples/relu-metal-cpp/torch-ext/torch_binding.h b/examples/kernels/relu-metal-cpp/torch-ext/torch_binding.h similarity index 100% rename from builder/examples/relu-metal-cpp/torch-ext/torch_binding.h rename to examples/kernels/relu-metal-cpp/torch-ext/torch_binding.h diff --git a/builder/examples/relu-nki/build.toml b/examples/kernels/relu-nki/build.toml similarity index 100% rename from builder/examples/relu-nki/build.toml rename to examples/kernels/relu-nki/build.toml diff --git a/builder/examples/relu-nki/torch-ext/relu_nki/__init__.py b/examples/kernels/relu-nki/torch-ext/relu_nki/__init__.py similarity index 100% rename from builder/examples/relu-nki/torch-ext/relu_nki/__init__.py rename to examples/kernels/relu-nki/torch-ext/relu_nki/__init__.py diff --git a/builder/examples/relu-nki/torch-ext/relu_nki/layers/__init__.py b/examples/kernels/relu-nki/torch-ext/relu_nki/layers/__init__.py similarity index 100% rename from builder/examples/relu-nki/torch-ext/relu_nki/layers/__init__.py rename to examples/kernels/relu-nki/torch-ext/relu_nki/layers/__init__.py diff --git a/builder/examples/relu-specific-torch/build.toml b/examples/kernels/relu-specific-torch/build.toml similarity index 100% rename from builder/examples/relu-specific-torch/build.toml rename to examples/kernels/relu-specific-torch/build.toml diff --git a/builder/examples/relu-specific-torch/flake.nix b/examples/kernels/relu-specific-torch/flake.nix similarity index 100% rename from builder/examples/relu-specific-torch/flake.nix rename to examples/kernels/relu-specific-torch/flake.nix diff --git a/builder/examples/relu-specific-torch/relu_cuda/relu.cu b/examples/kernels/relu-specific-torch/relu_cuda/relu.cu similarity index 100% rename from builder/examples/relu-specific-torch/relu_cuda/relu.cu rename to examples/kernels/relu-specific-torch/relu_cuda/relu.cu diff --git a/builder/examples/relu-specific-torch/tests/__init__.py b/examples/kernels/relu-specific-torch/tests/__init__.py similarity index 100% rename from builder/examples/relu-specific-torch/tests/__init__.py rename to examples/kernels/relu-specific-torch/tests/__init__.py diff --git a/builder/examples/relu-specific-torch/tests/test_relu.py b/examples/kernels/relu-specific-torch/tests/test_relu.py similarity index 100% rename from builder/examples/relu-specific-torch/tests/test_relu.py rename to examples/kernels/relu-specific-torch/tests/test_relu.py diff --git a/builder/examples/relu-specific-torch/torch-ext/relu_specific_torch/__init__.py b/examples/kernels/relu-specific-torch/torch-ext/relu_specific_torch/__init__.py similarity index 100% rename from builder/examples/relu-specific-torch/torch-ext/relu_specific_torch/__init__.py rename to examples/kernels/relu-specific-torch/torch-ext/relu_specific_torch/__init__.py diff --git a/builder/examples/relu-specific-torch/torch-ext/torch_binding.cpp b/examples/kernels/relu-specific-torch/torch-ext/torch_binding.cpp similarity index 100% rename from builder/examples/relu-specific-torch/torch-ext/torch_binding.cpp rename to examples/kernels/relu-specific-torch/torch-ext/torch_binding.cpp diff --git a/builder/examples/relu-specific-torch/torch-ext/torch_binding.h b/examples/kernels/relu-specific-torch/torch-ext/torch_binding.h similarity index 100% rename from builder/examples/relu-specific-torch/torch-ext/torch_binding.h rename to examples/kernels/relu-specific-torch/torch-ext/torch_binding.h diff --git a/builder/examples/relu-torch-bounds/build.toml b/examples/kernels/relu-torch-bounds/build.toml similarity index 100% rename from builder/examples/relu-torch-bounds/build.toml rename to examples/kernels/relu-torch-bounds/build.toml diff --git a/builder/examples/relu-torch-bounds/flake.nix b/examples/kernels/relu-torch-bounds/flake.nix similarity index 100% rename from builder/examples/relu-torch-bounds/flake.nix rename to examples/kernels/relu-torch-bounds/flake.nix diff --git a/builder/examples/relu-torch-bounds/relu_cuda/relu.cu b/examples/kernels/relu-torch-bounds/relu_cuda/relu.cu similarity index 100% rename from builder/examples/relu-torch-bounds/relu_cuda/relu.cu rename to examples/kernels/relu-torch-bounds/relu_cuda/relu.cu diff --git a/builder/examples/relu-torch-bounds/tests/__init__.py b/examples/kernels/relu-torch-bounds/tests/__init__.py similarity index 100% rename from builder/examples/relu-torch-bounds/tests/__init__.py rename to examples/kernels/relu-torch-bounds/tests/__init__.py diff --git a/builder/examples/relu-torch-bounds/tests/test_relu.py b/examples/kernels/relu-torch-bounds/tests/test_relu.py similarity index 100% rename from builder/examples/relu-torch-bounds/tests/test_relu.py rename to examples/kernels/relu-torch-bounds/tests/test_relu.py diff --git a/builder/examples/relu-torch-bounds/torch-ext/relu/__init__.py b/examples/kernels/relu-torch-bounds/torch-ext/relu/__init__.py similarity index 100% rename from builder/examples/relu-torch-bounds/torch-ext/relu/__init__.py rename to examples/kernels/relu-torch-bounds/torch-ext/relu/__init__.py diff --git a/builder/examples/relu-torch-bounds/torch-ext/torch_binding.cpp b/examples/kernels/relu-torch-bounds/torch-ext/torch_binding.cpp similarity index 100% rename from builder/examples/relu-torch-bounds/torch-ext/torch_binding.cpp rename to examples/kernels/relu-torch-bounds/torch-ext/torch_binding.cpp diff --git a/builder/examples/relu-torch-bounds/torch-ext/torch_binding.h b/examples/kernels/relu-torch-bounds/torch-ext/torch_binding.h similarity index 100% rename from builder/examples/relu-torch-bounds/torch-ext/torch_binding.h rename to examples/kernels/relu-torch-bounds/torch-ext/torch_binding.h diff --git a/builder/examples/relu-tvm-ffi/build.toml b/examples/kernels/relu-tvm-ffi/build.toml similarity index 100% rename from builder/examples/relu-tvm-ffi/build.toml rename to examples/kernels/relu-tvm-ffi/build.toml diff --git a/builder/examples/relu-tvm-ffi/flake.nix b/examples/kernels/relu-tvm-ffi/flake.nix similarity index 100% rename from builder/examples/relu-tvm-ffi/flake.nix rename to examples/kernels/relu-tvm-ffi/flake.nix diff --git a/builder/examples/relu-tvm-ffi/relu_cpu/relu_cpu.cpp b/examples/kernels/relu-tvm-ffi/relu_cpu/relu_cpu.cpp similarity index 100% rename from builder/examples/relu-tvm-ffi/relu_cpu/relu_cpu.cpp rename to examples/kernels/relu-tvm-ffi/relu_cpu/relu_cpu.cpp diff --git a/builder/examples/relu-tvm-ffi/relu_cuda/relu.cu b/examples/kernels/relu-tvm-ffi/relu_cuda/relu.cu similarity index 100% rename from builder/examples/relu-tvm-ffi/relu_cuda/relu.cu rename to examples/kernels/relu-tvm-ffi/relu_cuda/relu.cu diff --git a/builder/examples/relu-tvm-ffi/tests/__init__.py b/examples/kernels/relu-tvm-ffi/tests/__init__.py similarity index 100% rename from builder/examples/relu-tvm-ffi/tests/__init__.py rename to examples/kernels/relu-tvm-ffi/tests/__init__.py diff --git a/builder/examples/relu-tvm-ffi/tests/test_relu.py b/examples/kernels/relu-tvm-ffi/tests/test_relu.py similarity index 100% rename from builder/examples/relu-tvm-ffi/tests/test_relu.py rename to examples/kernels/relu-tvm-ffi/tests/test_relu.py diff --git a/builder/examples/relu-tvm-ffi/tvm-ffi-ext/relu_tvm_ffi/__init__.py b/examples/kernels/relu-tvm-ffi/tvm-ffi-ext/relu_tvm_ffi/__init__.py similarity index 100% rename from builder/examples/relu-tvm-ffi/tvm-ffi-ext/relu_tvm_ffi/__init__.py rename to examples/kernels/relu-tvm-ffi/tvm-ffi-ext/relu_tvm_ffi/__init__.py diff --git a/builder/examples/relu-tvm-ffi/tvm-ffi-ext/tvm_ffi_binding.cpp b/examples/kernels/relu-tvm-ffi/tvm-ffi-ext/tvm_ffi_binding.cpp similarity index 100% rename from builder/examples/relu-tvm-ffi/tvm-ffi-ext/tvm_ffi_binding.cpp rename to examples/kernels/relu-tvm-ffi/tvm-ffi-ext/tvm_ffi_binding.cpp diff --git a/builder/examples/relu-tvm-ffi/util.hh b/examples/kernels/relu-tvm-ffi/util.hh similarity index 100% rename from builder/examples/relu-tvm-ffi/util.hh rename to examples/kernels/relu-tvm-ffi/util.hh diff --git a/builder/examples/relu/build.toml b/examples/kernels/relu/build.toml similarity index 100% rename from builder/examples/relu/build.toml rename to examples/kernels/relu/build.toml diff --git a/builder/examples/relu/flake.nix b/examples/kernels/relu/flake.nix similarity index 100% rename from builder/examples/relu/flake.nix rename to examples/kernels/relu/flake.nix diff --git a/builder/examples/relu/relu_cpu/relu_cpu.cpp b/examples/kernels/relu/relu_cpu/relu_cpu.cpp similarity index 100% rename from builder/examples/relu/relu_cpu/relu_cpu.cpp rename to examples/kernels/relu/relu_cpu/relu_cpu.cpp diff --git a/builder/examples/relu/relu_cuda/relu.cu b/examples/kernels/relu/relu_cuda/relu.cu similarity index 100% rename from builder/examples/relu/relu_cuda/relu.cu rename to examples/kernels/relu/relu_cuda/relu.cu diff --git a/builder/examples/relu/relu_metal/common.h b/examples/kernels/relu/relu_metal/common.h similarity index 100% rename from builder/examples/relu/relu_metal/common.h rename to examples/kernels/relu/relu_metal/common.h diff --git a/builder/examples/relu/relu_metal/relu.metal b/examples/kernels/relu/relu_metal/relu.metal similarity index 100% rename from builder/examples/relu/relu_metal/relu.metal rename to examples/kernels/relu/relu_metal/relu.metal diff --git a/builder/examples/relu/relu_metal/relu.mm b/examples/kernels/relu/relu_metal/relu.mm similarity index 100% rename from builder/examples/relu/relu_metal/relu.mm rename to examples/kernels/relu/relu_metal/relu.mm diff --git a/builder/examples/relu/relu_xpu/relu.cpp b/examples/kernels/relu/relu_xpu/relu.cpp similarity index 100% rename from builder/examples/relu/relu_xpu/relu.cpp rename to examples/kernels/relu/relu_xpu/relu.cpp diff --git a/builder/examples/relu/tests/__init__.py b/examples/kernels/relu/tests/__init__.py similarity index 100% rename from builder/examples/relu/tests/__init__.py rename to examples/kernels/relu/tests/__init__.py diff --git a/builder/examples/relu/tests/test_relu.py b/examples/kernels/relu/tests/test_relu.py similarity index 100% rename from builder/examples/relu/tests/test_relu.py rename to examples/kernels/relu/tests/test_relu.py diff --git a/builder/examples/relu/torch-ext/relu/__init__.py b/examples/kernels/relu/torch-ext/relu/__init__.py similarity index 100% rename from builder/examples/relu/torch-ext/relu/__init__.py rename to examples/kernels/relu/torch-ext/relu/__init__.py diff --git a/builder/examples/relu/torch-ext/relu/layers/__init__.py b/examples/kernels/relu/torch-ext/relu/layers/__init__.py similarity index 100% rename from builder/examples/relu/torch-ext/relu/layers/__init__.py rename to examples/kernels/relu/torch-ext/relu/layers/__init__.py diff --git a/builder/examples/relu/torch-ext/torch_binding.cpp b/examples/kernels/relu/torch-ext/torch_binding.cpp similarity index 100% rename from builder/examples/relu/torch-ext/torch_binding.cpp rename to examples/kernels/relu/torch-ext/torch_binding.cpp diff --git a/builder/examples/relu/torch-ext/torch_binding.h b/examples/kernels/relu/torch-ext/torch_binding.h similarity index 100% rename from builder/examples/relu/torch-ext/torch_binding.h rename to examples/kernels/relu/torch-ext/torch_binding.h diff --git a/builder/examples/silu-and-mul/build.toml b/examples/kernels/silu-and-mul/build.toml similarity index 100% rename from builder/examples/silu-and-mul/build.toml rename to examples/kernels/silu-and-mul/build.toml diff --git a/builder/examples/silu-and-mul/flake.nix b/examples/kernels/silu-and-mul/flake.nix similarity index 100% rename from builder/examples/silu-and-mul/flake.nix rename to examples/kernels/silu-and-mul/flake.nix diff --git a/builder/examples/silu-and-mul/tests/test_silu_and_mul.py b/examples/kernels/silu-and-mul/tests/test_silu_and_mul.py similarity index 100% rename from builder/examples/silu-and-mul/tests/test_silu_and_mul.py rename to examples/kernels/silu-and-mul/tests/test_silu_and_mul.py diff --git a/builder/examples/silu-and-mul/torch-ext/silu_and_mul/__init__.py b/examples/kernels/silu-and-mul/torch-ext/silu_and_mul/__init__.py similarity index 100% rename from builder/examples/silu-and-mul/torch-ext/silu_and_mul/__init__.py rename to examples/kernels/silu-and-mul/torch-ext/silu_and_mul/__init__.py diff --git a/builder/examples/silu-and-mul/torch-ext/silu_and_mul/op.py b/examples/kernels/silu-and-mul/torch-ext/silu_and_mul/op.py similarity index 100% rename from builder/examples/silu-and-mul/torch-ext/silu_and_mul/op.py rename to examples/kernels/silu-and-mul/torch-ext/silu_and_mul/op.py diff --git a/flake.nix b/flake.nix index 3496b514..cf2e0dbe 100644 --- a/flake.nix +++ b/flake.nix @@ -28,14 +28,14 @@ }: let inherit - (import ./builder/lib/build-sets.nix { + (import ./nix-builder/lib/build-sets.nix { inherit nixpkgs rust-overlay; }) mkBuildSets partitionBuildSetsBySystem partitionBuildSetsBySystemBackend ; - inherit (import ./builder/lib/cache.nix) mkForCache; + inherit (import ./nix-builder/lib/cache.nix) mkForCache; systems = with flake-utils.lib.system; [ aarch64-darwin @@ -43,7 +43,7 @@ x86_64-linux ]; - torchVersions' = import ./builder/versions.nix; + torchVersions' = import ./nix-builder/versions.nix; defaultBuildSets = mkBuildSets torchVersions' systems; defaultBuildSetsPerSystem = partitionBuildSetsBySystem defaultBuildSets; @@ -53,7 +53,7 @@ builtins.listToAttrs ( builtins.map (system: { name = system; - value = nixpkgs.legacyPackages.${system}.callPackage builder/lib/build.nix { }; + value = nixpkgs.legacyPackages.${system}.callPackage ./nix-builder/lib/build.nix { }; }) systems ); buildPerSystem = mkBuildPerSystem systems; @@ -67,7 +67,7 @@ allBuildVariantsJSON = let buildVariants = - (import ./builder/lib/build-variants.nix { + (import ./nix-builder/lib/build-variants.nix { inherit (nixpkgs) lib; }).buildVariants torchVersions'; @@ -103,7 +103,7 @@ in flake-utils.lib.eachSystem systems ( system: - nixpkgs.legacyPackages.${system}.callPackage ./builder/lib/gen-flake-outputs.nix { + nixpkgs.legacyPackages.${system}.callPackage ./nix-builder/lib/gen-flake-outputs.nix { inherit system path @@ -145,7 +145,7 @@ in mkShell { nativeBuildInputs = [ - build2cmake + kernel-builder kernel-abi-check nodejs # For hf-doc-builder. pkg-config @@ -193,7 +193,7 @@ ) buildSetsByBackend; in rec { - checks.default = pkgs.callPackage ./builder/lib/checks.nix { + checks.default = pkgs.callPackage ./nix-builder/lib/checks.nix { inherit buildSets; build = buildPerSystem.${system}; }; @@ -205,11 +205,11 @@ formatter = pkgs.nixfmt-tree; packages = rec { - inherit (buildSet.pkgs) build2cmake kernel-abi-check; + inherit (buildSet.pkgs) kernel-builder kernel-abi-check; inherit (buildSet.pkgs.python3.pkgs) kernels; update-build = pkgs.writeShellScriptBin "update-build" '' - ${build2cmake}/bin/build2cmake update-build ''${1:-build.toml} + ${kernel-builder}/bin/kernel-builder update-build ''${1:-build.toml} ''; forCache = mkForCache pkgs ( diff --git a/build2cmake/Cargo.lock b/kernel-builder/Cargo.lock similarity index 99% rename from build2cmake/Cargo.lock rename to kernel-builder/Cargo.lock index a6ffa3ea..ec5dbd91 100644 --- a/build2cmake/Cargo.lock +++ b/kernel-builder/Cargo.lock @@ -78,26 +78,6 @@ version = "2.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5c8214115b7bf84099f1309324e63141d4c5d7cc26862f97a0a857dbefe165bd" -[[package]] -name = "build2cmake" -version = "0.13.0-dev0" -dependencies = [ - "base32", - "clap", - "eyre", - "git2", - "itertools", - "minijinja", - "minijinja-embed", - "rand", - "regex", - "serde", - "serde-value", - "serde_json", - "thiserror", - "toml", -] - [[package]] name = "byteorder" version = "1.5.0" @@ -247,6 +227,26 @@ version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea" +[[package]] +name = "hf-kernel-builder" +version = "0.13.0-dev0" +dependencies = [ + "base32", + "clap", + "eyre", + "git2", + "itertools", + "minijinja", + "minijinja-embed", + "rand", + "regex", + "serde", + "serde-value", + "serde_json", + "thiserror", + "toml", +] + [[package]] name = "icu_collections" version = "2.0.0" diff --git a/build2cmake/Cargo.toml b/kernel-builder/Cargo.toml similarity index 82% rename from build2cmake/Cargo.toml rename to kernel-builder/Cargo.toml index d19c9637..8df3bab0 100644 --- a/build2cmake/Cargo.toml +++ b/kernel-builder/Cargo.toml @@ -1,11 +1,11 @@ [package] -name = "build2cmake" +name = "hf-kernel-builder" version = "0.13.0-dev0" edition = "2021" description = "Generate CMake files for kernel-builder projects" homepage = "https://github.com/huggingface/kernel-builder" license = "Apache-2.0" -documentation = "https://docs.rs/build2cmake" +documentation = "https://docs.rs/hf-kernel-builder" repository = "https://github.com/huggingface/kernel-builder" [dependencies] @@ -26,3 +26,7 @@ toml = "0.8" [build-dependencies] minijinja-embed = "2.5" + +[[bin]] +name = "kernel-builder" +path = "src/main.rs" diff --git a/build2cmake/build.rs b/kernel-builder/build.rs similarity index 100% rename from build2cmake/build.rs rename to kernel-builder/build.rs diff --git a/build2cmake/flake.lock b/kernel-builder/flake.lock similarity index 100% rename from build2cmake/flake.lock rename to kernel-builder/flake.lock diff --git a/build2cmake/flake.nix b/kernel-builder/flake.nix similarity index 100% rename from build2cmake/flake.nix rename to kernel-builder/flake.nix diff --git a/build2cmake/src/config/compat.rs b/kernel-builder/src/config/compat.rs similarity index 100% rename from build2cmake/src/config/compat.rs rename to kernel-builder/src/config/compat.rs diff --git a/build2cmake/src/config/deps.rs b/kernel-builder/src/config/deps.rs similarity index 100% rename from build2cmake/src/config/deps.rs rename to kernel-builder/src/config/deps.rs diff --git a/build2cmake/src/config/mod.rs b/kernel-builder/src/config/mod.rs similarity index 100% rename from build2cmake/src/config/mod.rs rename to kernel-builder/src/config/mod.rs diff --git a/build2cmake/src/config/name.rs b/kernel-builder/src/config/name.rs similarity index 100% rename from build2cmake/src/config/name.rs rename to kernel-builder/src/config/name.rs diff --git a/build2cmake/src/config/v1.rs b/kernel-builder/src/config/v1.rs similarity index 100% rename from build2cmake/src/config/v1.rs rename to kernel-builder/src/config/v1.rs diff --git a/build2cmake/src/config/v2.rs b/kernel-builder/src/config/v2.rs similarity index 100% rename from build2cmake/src/config/v2.rs rename to kernel-builder/src/config/v2.rs diff --git a/build2cmake/src/config/v3.rs b/kernel-builder/src/config/v3.rs similarity index 100% rename from build2cmake/src/config/v3.rs rename to kernel-builder/src/config/v3.rs diff --git a/build2cmake/src/cuda_supported_archs.json b/kernel-builder/src/cuda_supported_archs.json similarity index 100% rename from build2cmake/src/cuda_supported_archs.json rename to kernel-builder/src/cuda_supported_archs.json diff --git a/build2cmake/src/fileset.rs b/kernel-builder/src/fileset.rs similarity index 100% rename from build2cmake/src/fileset.rs rename to kernel-builder/src/fileset.rs diff --git a/build2cmake/src/main.rs b/kernel-builder/src/main.rs similarity index 99% rename from build2cmake/src/main.rs rename to kernel-builder/src/main.rs index c64500fc..0e7bb0c6 100644 --- a/build2cmake/src/main.rs +++ b/kernel-builder/src/main.rs @@ -296,7 +296,7 @@ fn generate_file_set( if matches!(build_compat, BuildCompat::V1(_) | BuildCompat::V2(_)) { eprintln!( - "build.toml is in the deprecated V1 or V2 format, use `build2cmake update-build` to update." + "build.toml is in the deprecated V1 or V2 format, use `kernel-builder update-build` to update." ) } diff --git a/build2cmake/src/metadata.rs b/kernel-builder/src/metadata.rs similarity index 100% rename from build2cmake/src/metadata.rs rename to kernel-builder/src/metadata.rs diff --git a/build2cmake/src/ops_identifier.rs b/kernel-builder/src/ops_identifier.rs similarity index 100% rename from build2cmake/src/ops_identifier.rs rename to kernel-builder/src/ops_identifier.rs diff --git a/build2cmake/src/python_dependencies.json b/kernel-builder/src/python_dependencies.json similarity index 100% rename from build2cmake/src/python_dependencies.json rename to kernel-builder/src/python_dependencies.json diff --git a/build2cmake/src/templates/_ops.py b/kernel-builder/src/templates/_ops.py similarity index 100% rename from build2cmake/src/templates/_ops.py rename to kernel-builder/src/templates/_ops.py diff --git a/build2cmake/src/templates/_ops.py.in b/kernel-builder/src/templates/_ops.py.in similarity index 100% rename from build2cmake/src/templates/_ops.py.in rename to kernel-builder/src/templates/_ops.py.in diff --git a/build2cmake/src/templates/add_gpu_arch_metadata.py b/kernel-builder/src/templates/add_gpu_arch_metadata.py similarity index 100% rename from build2cmake/src/templates/add_gpu_arch_metadata.py rename to kernel-builder/src/templates/add_gpu_arch_metadata.py diff --git a/build2cmake/src/templates/build-variants.cmake b/kernel-builder/src/templates/build-variants.cmake similarity index 100% rename from build2cmake/src/templates/build-variants.cmake rename to kernel-builder/src/templates/build-variants.cmake diff --git a/build2cmake/src/templates/compat.py b/kernel-builder/src/templates/compat.py similarity index 100% rename from build2cmake/src/templates/compat.py rename to kernel-builder/src/templates/compat.py diff --git a/build2cmake/src/templates/cpu/kernel.cmake b/kernel-builder/src/templates/cpu/kernel.cmake similarity index 100% rename from build2cmake/src/templates/cpu/kernel.cmake rename to kernel-builder/src/templates/cpu/kernel.cmake diff --git a/build2cmake/src/templates/cuda/dep-cutlass.cmake b/kernel-builder/src/templates/cuda/dep-cutlass.cmake similarity index 100% rename from build2cmake/src/templates/cuda/dep-cutlass.cmake rename to kernel-builder/src/templates/cuda/dep-cutlass.cmake diff --git a/build2cmake/src/templates/cuda/hipify.py b/kernel-builder/src/templates/cuda/hipify.py similarity index 100% rename from build2cmake/src/templates/cuda/hipify.py rename to kernel-builder/src/templates/cuda/hipify.py diff --git a/build2cmake/src/templates/cuda/kernel.cmake b/kernel-builder/src/templates/cuda/kernel.cmake similarity index 100% rename from build2cmake/src/templates/cuda/kernel.cmake rename to kernel-builder/src/templates/cuda/kernel.cmake diff --git a/build2cmake/src/templates/get_gpu_lang.cmake b/kernel-builder/src/templates/get_gpu_lang.cmake similarity index 100% rename from build2cmake/src/templates/get_gpu_lang.cmake rename to kernel-builder/src/templates/get_gpu_lang.cmake diff --git a/build2cmake/src/templates/get_gpu_lang.py b/kernel-builder/src/templates/get_gpu_lang.py similarity index 100% rename from build2cmake/src/templates/get_gpu_lang.py rename to kernel-builder/src/templates/get_gpu_lang.py diff --git a/build2cmake/src/templates/kernel.cmake b/kernel-builder/src/templates/kernel.cmake similarity index 100% rename from build2cmake/src/templates/kernel.cmake rename to kernel-builder/src/templates/kernel.cmake diff --git a/build2cmake/src/templates/metal/compile-metal.cmake b/kernel-builder/src/templates/metal/compile-metal.cmake similarity index 100% rename from build2cmake/src/templates/metal/compile-metal.cmake rename to kernel-builder/src/templates/metal/compile-metal.cmake diff --git a/build2cmake/src/templates/metal/kernel.cmake b/kernel-builder/src/templates/metal/kernel.cmake similarity index 100% rename from build2cmake/src/templates/metal/kernel.cmake rename to kernel-builder/src/templates/metal/kernel.cmake diff --git a/build2cmake/src/templates/metal/metallib_to_header.py b/kernel-builder/src/templates/metal/metallib_to_header.py similarity index 100% rename from build2cmake/src/templates/metal/metallib_to_header.py rename to kernel-builder/src/templates/metal/metallib_to_header.py diff --git a/build2cmake/src/templates/metal/utils.cmake b/kernel-builder/src/templates/metal/utils.cmake similarity index 100% rename from build2cmake/src/templates/metal/utils.cmake rename to kernel-builder/src/templates/metal/utils.cmake diff --git a/build2cmake/src/templates/noarch/_ops.py b/kernel-builder/src/templates/noarch/_ops.py similarity index 100% rename from build2cmake/src/templates/noarch/_ops.py rename to kernel-builder/src/templates/noarch/_ops.py diff --git a/build2cmake/src/templates/noarch/pyproject.toml b/kernel-builder/src/templates/noarch/pyproject.toml similarity index 100% rename from build2cmake/src/templates/noarch/pyproject.toml rename to kernel-builder/src/templates/noarch/pyproject.toml diff --git a/build2cmake/src/templates/noarch/setup.py b/kernel-builder/src/templates/noarch/setup.py similarity index 99% rename from build2cmake/src/templates/noarch/setup.py rename to kernel-builder/src/templates/noarch/setup.py index 77fb73a8..613260d0 100644 --- a/build2cmake/src/templates/noarch/setup.py +++ b/kernel-builder/src/templates/noarch/setup.py @@ -89,7 +89,7 @@ def build_backend( metadata_file: Path = project_root / f"metadata-{backend}.json" if not metadata_file.exists(): raise ValueError( - f"Metadata file {metadata_file} does not exist, run build2cmake to create it" + f"Metadata file {metadata_file} does not exist, run kernel-builder to create it" ) shutil.copy2(metadata_file, variant_dir / "metadata.json") diff --git a/build2cmake/src/templates/preamble.cmake b/kernel-builder/src/templates/preamble.cmake similarity index 100% rename from build2cmake/src/templates/preamble.cmake rename to kernel-builder/src/templates/preamble.cmake diff --git a/build2cmake/src/templates/pyproject.toml b/kernel-builder/src/templates/pyproject.toml similarity index 100% rename from build2cmake/src/templates/pyproject.toml rename to kernel-builder/src/templates/pyproject.toml diff --git a/build2cmake/src/templates/registration.h b/kernel-builder/src/templates/registration.h similarity index 100% rename from build2cmake/src/templates/registration.h rename to kernel-builder/src/templates/registration.h diff --git a/build2cmake/src/templates/setup.py b/kernel-builder/src/templates/setup.py similarity index 100% rename from build2cmake/src/templates/setup.py rename to kernel-builder/src/templates/setup.py diff --git a/build2cmake/src/templates/torch-binding.cmake b/kernel-builder/src/templates/torch-binding.cmake similarity index 100% rename from build2cmake/src/templates/torch-binding.cmake rename to kernel-builder/src/templates/torch-binding.cmake diff --git a/build2cmake/src/templates/torch-extension.cmake b/kernel-builder/src/templates/torch-extension.cmake similarity index 100% rename from build2cmake/src/templates/torch-extension.cmake rename to kernel-builder/src/templates/torch-extension.cmake diff --git a/build2cmake/src/templates/tvm_ffi/_ops.py.in b/kernel-builder/src/templates/tvm_ffi/_ops.py.in similarity index 100% rename from build2cmake/src/templates/tvm_ffi/_ops.py.in rename to kernel-builder/src/templates/tvm_ffi/_ops.py.in diff --git a/build2cmake/src/templates/tvm_ffi/binding.cmake b/kernel-builder/src/templates/tvm_ffi/binding.cmake similarity index 100% rename from build2cmake/src/templates/tvm_ffi/binding.cmake rename to kernel-builder/src/templates/tvm_ffi/binding.cmake diff --git a/build2cmake/src/templates/tvm_ffi/build-variants.cmake b/kernel-builder/src/templates/tvm_ffi/build-variants.cmake similarity index 100% rename from build2cmake/src/templates/tvm_ffi/build-variants.cmake rename to kernel-builder/src/templates/tvm_ffi/build-variants.cmake diff --git a/build2cmake/src/templates/tvm_ffi/preamble.cmake b/kernel-builder/src/templates/tvm_ffi/preamble.cmake similarity index 100% rename from build2cmake/src/templates/tvm_ffi/preamble.cmake rename to kernel-builder/src/templates/tvm_ffi/preamble.cmake diff --git a/build2cmake/src/templates/tvm_ffi/pyproject.toml b/kernel-builder/src/templates/tvm_ffi/pyproject.toml similarity index 100% rename from build2cmake/src/templates/tvm_ffi/pyproject.toml rename to kernel-builder/src/templates/tvm_ffi/pyproject.toml diff --git a/build2cmake/src/templates/tvm_ffi/setup.py b/kernel-builder/src/templates/tvm_ffi/setup.py similarity index 100% rename from build2cmake/src/templates/tvm_ffi/setup.py rename to kernel-builder/src/templates/tvm_ffi/setup.py diff --git a/build2cmake/src/templates/tvm_ffi/tvm-ffi-extension.cmake b/kernel-builder/src/templates/tvm_ffi/tvm-ffi-extension.cmake similarity index 100% rename from build2cmake/src/templates/tvm_ffi/tvm-ffi-extension.cmake rename to kernel-builder/src/templates/tvm_ffi/tvm-ffi-extension.cmake diff --git a/build2cmake/src/templates/utils.cmake b/kernel-builder/src/templates/utils.cmake similarity index 100% rename from build2cmake/src/templates/utils.cmake rename to kernel-builder/src/templates/utils.cmake diff --git a/build2cmake/src/templates/xpu/dep-sycl-tla.cmake b/kernel-builder/src/templates/xpu/dep-sycl-tla.cmake similarity index 100% rename from build2cmake/src/templates/xpu/dep-sycl-tla.cmake rename to kernel-builder/src/templates/xpu/dep-sycl-tla.cmake diff --git a/build2cmake/src/templates/xpu/kernel.cmake b/kernel-builder/src/templates/xpu/kernel.cmake similarity index 100% rename from build2cmake/src/templates/xpu/kernel.cmake rename to kernel-builder/src/templates/xpu/kernel.cmake diff --git a/build2cmake/src/torch/common.rs b/kernel-builder/src/torch/common.rs similarity index 100% rename from build2cmake/src/torch/common.rs rename to kernel-builder/src/torch/common.rs diff --git a/build2cmake/src/torch/deps.rs b/kernel-builder/src/torch/deps.rs similarity index 100% rename from build2cmake/src/torch/deps.rs rename to kernel-builder/src/torch/deps.rs diff --git a/build2cmake/src/torch/kernel.rs b/kernel-builder/src/torch/kernel.rs similarity index 100% rename from build2cmake/src/torch/kernel.rs rename to kernel-builder/src/torch/kernel.rs diff --git a/build2cmake/src/torch/mod.rs b/kernel-builder/src/torch/mod.rs similarity index 100% rename from build2cmake/src/torch/mod.rs rename to kernel-builder/src/torch/mod.rs diff --git a/build2cmake/src/torch/noarch.rs b/kernel-builder/src/torch/noarch.rs similarity index 100% rename from build2cmake/src/torch/noarch.rs rename to kernel-builder/src/torch/noarch.rs diff --git a/build2cmake/src/tvm_ffi/mod.rs b/kernel-builder/src/tvm_ffi/mod.rs similarity index 100% rename from build2cmake/src/tvm_ffi/mod.rs rename to kernel-builder/src/tvm_ffi/mod.rs diff --git a/build2cmake/src/version.rs b/kernel-builder/src/version.rs similarity index 100% rename from build2cmake/src/version.rs rename to kernel-builder/src/version.rs diff --git a/kernels/Makefile b/kernels/Makefile index 580f53ab..7d6b214c 100644 --- a/kernels/Makefile +++ b/kernels/Makefile @@ -4,7 +4,7 @@ export check_dirs := src tests all: src/kernels/python_depends.json -src/kernels/python_depends.json: ../build2cmake/src/python_dependencies.json +src/kernels/python_depends.json: ../kernel-builder/src/python_dependencies.json cp $< $@ style: diff --git a/builder/LICENSE b/nix-builder/LICENSE similarity index 100% rename from builder/LICENSE rename to nix-builder/LICENSE diff --git a/builder/README.md b/nix-builder/README.md similarity index 100% rename from builder/README.md rename to nix-builder/README.md diff --git a/builder/build-variants.json b/nix-builder/build-variants.json similarity index 100% rename from builder/build-variants.json rename to nix-builder/build-variants.json diff --git a/builder/dockerfiles/Dockerfile b/nix-builder/dockerfiles/Dockerfile similarity index 100% rename from builder/dockerfiles/Dockerfile rename to nix-builder/dockerfiles/Dockerfile diff --git a/builder/dockerfiles/Dockerfile.user b/nix-builder/dockerfiles/Dockerfile.user similarity index 100% rename from builder/dockerfiles/Dockerfile.user rename to nix-builder/dockerfiles/Dockerfile.user diff --git a/builder/dockerfiles/README.md b/nix-builder/dockerfiles/README.md similarity index 100% rename from builder/dockerfiles/README.md rename to nix-builder/dockerfiles/README.md diff --git a/builder/docs/toolchain.md b/nix-builder/docs/toolchain.md similarity index 100% rename from builder/docs/toolchain.md rename to nix-builder/docs/toolchain.md diff --git a/builder/lib/build-sets.nix b/nix-builder/lib/build-sets.nix similarity index 97% rename from builder/lib/build-sets.nix rename to nix-builder/lib/build-sets.nix index 42493aaf..34878135 100644 --- a/builder/lib/build-sets.nix +++ b/nix-builder/lib/build-sets.nix @@ -6,7 +6,7 @@ let inherit (nixpkgs) lib; - overlay = import ../../nix/overlay.nix; + overlay = import ../nix/overlay.nix; inherit (import ./torch-version-utils.nix { inherit lib; }) backend diff --git a/builder/lib/build-variants.nix b/nix-builder/lib/build-variants.nix similarity index 100% rename from builder/lib/build-variants.nix rename to nix-builder/lib/build-variants.nix diff --git a/builder/lib/build.nix b/nix-builder/lib/build.nix similarity index 98% rename from builder/lib/build.nix rename to nix-builder/lib/build.nix index 876eb05d..343f6ab8 100644 --- a/builder/lib/build.nix +++ b/nix-builder/lib/build.nix @@ -13,7 +13,7 @@ let supportedCudaCapabilities = builtins.fromJSON ( - builtins.readFile ../../build2cmake/src/cuda_supported_archs.json + builtins.readFile ../../kernel-builder/src/cuda_supported_archs.json ); in rec { @@ -28,7 +28,7 @@ rec { in assert lib.assertMsg hasBackends '' build.toml seems to be of an older version, update it with: - nix run github:huggingface/kernel-builder#build2cmake update-build build.toml''; + nix run github:huggingface/kernel-builder#kernel-builder update-build build.toml''; buildToml; # Backends supported by the kernel. @@ -385,7 +385,7 @@ rec { nativeBuildInputs = with pkgs; [ - build2cmake + kernel-builder kernel-abi-check ] ++ (pythonNativeCheckInputs python3.pkgs); diff --git a/builder/lib/cache.nix b/nix-builder/lib/cache.nix similarity index 97% rename from builder/lib/cache.nix rename to nix-builder/lib/cache.nix index c9ece688..30dd04d2 100644 --- a/builder/lib/cache.nix +++ b/nix-builder/lib/cache.nix @@ -19,7 +19,7 @@ ( allOutputs buildSet.torch ++ lib.concatMap allOutputs buildSet.extension.extraBuildDeps - ++ allOutputs build2cmake + ++ allOutputs kernel-builder ++ allOutputs kernel-abi-check ++ allOutputs python3.pkgs.kernels ++ allOutputs python3.pkgs.tvm-ffi diff --git a/builder/lib/checks.nix b/nix-builder/lib/checks.nix similarity index 86% rename from builder/lib/checks.nix rename to nix-builder/lib/checks.nix index 7ce6716e..5566e010 100644 --- a/builder/lib/checks.nix +++ b/nix-builder/lib/checks.nix @@ -9,7 +9,7 @@ let kernelBuildSets = build.applicableBuildSets { inherit buildSets; - path = ../examples/relu-torch-bounds; + path = ../../examples/kernels/relu-torch-bounds; }; in assert lib.assertMsg (builtins.all (buildSet: buildSet.torch.version == "2.9.0") kernelBuildSets) '' diff --git a/builder/lib/deps.nix b/nix-builder/lib/deps.nix similarity index 94% rename from builder/lib/deps.nix rename to nix-builder/lib/deps.nix index db2b91a9..28dadb1b 100644 --- a/builder/lib/deps.nix +++ b/nix-builder/lib/deps.nix @@ -35,7 +35,7 @@ let pythonDeps = let - depsJson = builtins.fromJSON (builtins.readFile ../../build2cmake/src/python_dependencies.json); + depsJson = builtins.fromJSON (builtins.readFile ../../kernel-builder/src/python_dependencies.json); # Map the Nix package names to actual Nix packages. updatePackage = _name: dep: dep // { nix = map (pkg: pkgs.python3.pkgs.${pkg}) dep.nix; }; updateBackend = _backend: backendDeps: lib.mapAttrs updatePackage backendDeps; diff --git a/builder/lib/extension/default.nix b/nix-builder/lib/extension/default.nix similarity index 96% rename from builder/lib/extension/default.nix rename to nix-builder/lib/extension/default.nix index e2979343..ef41e488 100644 --- a/builder/lib/extension/default.nix +++ b/nix-builder/lib/extension/default.nix @@ -31,7 +31,7 @@ let ); cuda_nvcc = cudaPackages.cuda_nvcc.override { - backendStdenv = import ../../../nix/pkgs/cuda/backendStdenv { + backendStdenv = import ../../pkgs/cuda/backendStdenv { inherit (pkgs) _cuda config diff --git a/builder/lib/extension/torch/arch.nix b/nix-builder/lib/extension/torch/arch.nix similarity index 97% rename from builder/lib/extension/torch/arch.nix rename to nix-builder/lib/extension/torch/arch.nix index 8a7d19ae..b3deebc7 100644 --- a/builder/lib/extension/torch/arch.nix +++ b/nix-builder/lib/extension/torch/arch.nix @@ -9,7 +9,7 @@ writeText, # Native build inputs - build2cmake, + kernel-builder, cmake, cmakeNvccThreadsHook, cuda_nvcc, @@ -109,13 +109,13 @@ stdenv.mkDerivation (prevAttrs: { framework = "torch"; - # We run build2cmake here rather than patchPhase or preConfigure, + # We run kernel-builder here rather than patchPhase or preConfigure, # so that external users of `src` get the source tree with the files - # generated by build2cmake. + # generated by kernel-builder. src = pkgs.runCommand "source" { } '' mkdir -p $out cp -r --no-preserve=mode ${src}/* $out/ - ${pkgs.build2cmake}/bin/build2cmake generate-torch \ + ${pkgs.kernel-builder}/bin/kernel-builder generate-torch \ --ops-id ${rev} $out/build.toml ''; @@ -147,7 +147,7 @@ stdenv.mkDerivation (prevAttrs: { nativeBuildInputs = [ cmake ninja - build2cmake + kernel-builder kernel-abi-check kernel-layout-check remove-bytecode-hook diff --git a/builder/lib/extension/torch/no-arch.nix b/nix-builder/lib/extension/torch/no-arch.nix similarity index 95% rename from builder/lib/extension/torch/no-arch.nix rename to nix-builder/lib/extension/torch/no-arch.nix index 7cca1d42..70a2907c 100644 --- a/builder/lib/extension/torch/no-arch.nix +++ b/nix-builder/lib/extension/torch/no-arch.nix @@ -7,7 +7,7 @@ pkgs, stdenv, - build2cmake, + kernel-builder, get-kernel-check, kernel-layout-check, python3, @@ -65,7 +65,7 @@ stdenv.mkDerivation (prevAttrs: { src = pkgs.runCommand "source" { } '' mkdir -p $out cp -r --no-preserve=mode ${src}/* $out/ - ${pkgs.build2cmake}/bin/build2cmake generate-torch \ + ${pkgs.kernel-builder}/bin/kernel-builder generate-torch \ --ops-id ${rev} $out/build.toml ''; @@ -76,7 +76,7 @@ stdenv.mkDerivation (prevAttrs: { buildInputs = [ torch ]; nativeBuildInputs = [ - build2cmake + kernel-builder kernel-layout-check remove-bytecode-hook ] diff --git a/builder/lib/extension/tvm-ffi/arch.nix b/nix-builder/lib/extension/tvm-ffi/arch.nix similarity index 99% rename from builder/lib/extension/tvm-ffi/arch.nix rename to nix-builder/lib/extension/tvm-ffi/arch.nix index 22e7969b..7361b837 100644 --- a/builder/lib/extension/tvm-ffi/arch.nix +++ b/nix-builder/lib/extension/tvm-ffi/arch.nix @@ -9,7 +9,7 @@ writeText, # Native build inputs - build2cmake, + kernel-builder, cmake, cmakeNvccThreadsHook, cuda_nvcc, @@ -112,7 +112,7 @@ stdenv.mkDerivation (prevAttrs: { # Generate build files. postPatch = '' - build2cmake generate \ + kernel-builder generate \ --ops-id ${rev} build.toml ''; @@ -144,7 +144,7 @@ stdenv.mkDerivation (prevAttrs: { nativeBuildInputs = [ cmake ninja - build2cmake + kernel-builder kernel-abi-check kernel-layout-check remove-bytecode-hook diff --git a/builder/lib/gen-flake-outputs.nix b/nix-builder/lib/gen-flake-outputs.nix similarity index 100% rename from builder/lib/gen-flake-outputs.nix rename to nix-builder/lib/gen-flake-outputs.nix diff --git a/builder/lib/join-paths/default.nix b/nix-builder/lib/join-paths/default.nix similarity index 100% rename from builder/lib/join-paths/default.nix rename to nix-builder/lib/join-paths/default.nix diff --git a/builder/lib/mk-build-set.nix b/nix-builder/lib/mk-build-set.nix similarity index 98% rename from builder/lib/mk-build-set.nix rename to nix-builder/lib/mk-build-set.nix index 72fca408..eca5a707 100644 --- a/builder/lib/mk-build-set.nix +++ b/nix-builder/lib/mk-build-set.nix @@ -6,7 +6,7 @@ let inherit (nixpkgs) lib; - overlay = import ../../nix/overlay.nix; + overlay = import ../overlay.nix; flattenVersion = version: lib.replaceStrings [ "." ] [ "_" ] (lib.versions.pad 2 version); diff --git a/builder/lib/source-set.nix b/nix-builder/lib/source-set.nix similarity index 100% rename from builder/lib/source-set.nix rename to nix-builder/lib/source-set.nix diff --git a/builder/lib/torch-version-utils.nix b/nix-builder/lib/torch-version-utils.nix similarity index 100% rename from builder/lib/torch-version-utils.nix rename to nix-builder/lib/torch-version-utils.nix diff --git a/builder/lib/version-utils.nix b/nix-builder/lib/version-utils.nix similarity index 100% rename from builder/lib/version-utils.nix rename to nix-builder/lib/version-utils.nix diff --git a/nix/overlay.nix b/nix-builder/overlay.nix similarity index 98% rename from nix/overlay.nix rename to nix-builder/overlay.nix index 8342e392..9aabb44b 100644 --- a/nix/overlay.nix +++ b/nix-builder/overlay.nix @@ -8,7 +8,7 @@ in blas = if useMKL then prev.blas.override { blasProvider = prev.mkl; } else prev.blas; lapack = if useMKL then prev.lapack.override { lapackProvider = prev.mkl; } else prev.blas; - build2cmake = prev.callPackage ./pkgs/build2cmake { }; + kernel-builder = prev.callPackage ./pkgs/kernel-builder { }; cmakeNvccThreadsHook = prev.callPackage ./pkgs/cmake-nvcc-threads-hook { }; diff --git a/nix/pkgs/aotriton/default.nix b/nix-builder/pkgs/aotriton/default.nix similarity index 100% rename from nix/pkgs/aotriton/default.nix rename to nix-builder/pkgs/aotriton/default.nix diff --git a/nix/pkgs/aotriton/explicit-cast-for-narrowing.diff b/nix-builder/pkgs/aotriton/explicit-cast-for-narrowing.diff similarity index 100% rename from nix/pkgs/aotriton/explicit-cast-for-narrowing.diff rename to nix-builder/pkgs/aotriton/explicit-cast-for-narrowing.diff diff --git a/nix/pkgs/aotriton/generic.nix b/nix-builder/pkgs/aotriton/generic.nix similarity index 100% rename from nix/pkgs/aotriton/generic.nix rename to nix-builder/pkgs/aotriton/generic.nix diff --git a/nix/pkgs/aotriton/no-ld-script.diff b/nix-builder/pkgs/aotriton/no-ld-script.diff similarity index 100% rename from nix/pkgs/aotriton/no-ld-script.diff rename to nix-builder/pkgs/aotriton/no-ld-script.diff diff --git a/nix/pkgs/aotriton/triton-remove-distutils.patch b/nix-builder/pkgs/aotriton/triton-remove-distutils.patch similarity index 100% rename from nix/pkgs/aotriton/triton-remove-distutils.patch rename to nix-builder/pkgs/aotriton/triton-remove-distutils.patch diff --git a/nix/pkgs/aotriton/v0.10b-explicit-cast-for-narrowing.diff b/nix-builder/pkgs/aotriton/v0.10b-explicit-cast-for-narrowing.diff similarity index 100% rename from nix/pkgs/aotriton/v0.10b-explicit-cast-for-narrowing.diff rename to nix-builder/pkgs/aotriton/v0.10b-explicit-cast-for-narrowing.diff diff --git a/nix/pkgs/aotriton/v0.10b-no-ld-script.diff b/nix-builder/pkgs/aotriton/v0.10b-no-ld-script.diff similarity index 100% rename from nix/pkgs/aotriton/v0.10b-no-ld-script.diff rename to nix-builder/pkgs/aotriton/v0.10b-no-ld-script.diff diff --git a/nix/pkgs/aotriton/v0.11.1b-no-ld-script.diff b/nix-builder/pkgs/aotriton/v0.11.1b-no-ld-script.diff similarity index 100% rename from nix/pkgs/aotriton/v0.11.1b-no-ld-script.diff rename to nix-builder/pkgs/aotriton/v0.11.1b-no-ld-script.diff diff --git a/nix/pkgs/aotriton/v0.11b-no-ld-script.diff b/nix-builder/pkgs/aotriton/v0.11b-no-ld-script.diff similarity index 100% rename from nix/pkgs/aotriton/v0.11b-no-ld-script.diff rename to nix-builder/pkgs/aotriton/v0.11b-no-ld-script.diff diff --git a/nix/pkgs/cmake-nvcc-threads-hook/cmake-nvcc-threads-hook.sh b/nix-builder/pkgs/cmake-nvcc-threads-hook/cmake-nvcc-threads-hook.sh similarity index 100% rename from nix/pkgs/cmake-nvcc-threads-hook/cmake-nvcc-threads-hook.sh rename to nix-builder/pkgs/cmake-nvcc-threads-hook/cmake-nvcc-threads-hook.sh diff --git a/nix/pkgs/cmake-nvcc-threads-hook/default.nix b/nix-builder/pkgs/cmake-nvcc-threads-hook/default.nix similarity index 100% rename from nix/pkgs/cmake-nvcc-threads-hook/default.nix rename to nix-builder/pkgs/cmake-nvcc-threads-hook/default.nix diff --git a/nix/pkgs/cuda/backendStdenv/default.nix b/nix-builder/pkgs/cuda/backendStdenv/default.nix similarity index 100% rename from nix/pkgs/cuda/backendStdenv/default.nix rename to nix-builder/pkgs/cuda/backendStdenv/default.nix diff --git a/nix/pkgs/cutlass/builder.nix b/nix-builder/pkgs/cutlass/builder.nix similarity index 100% rename from nix/pkgs/cutlass/builder.nix rename to nix-builder/pkgs/cutlass/builder.nix diff --git a/nix/pkgs/cutlass/default.nix b/nix-builder/pkgs/cutlass/default.nix similarity index 100% rename from nix/pkgs/cutlass/default.nix rename to nix-builder/pkgs/cutlass/default.nix diff --git a/nix/pkgs/get-kernel-check/default.nix b/nix-builder/pkgs/get-kernel-check/default.nix similarity index 100% rename from nix/pkgs/get-kernel-check/default.nix rename to nix-builder/pkgs/get-kernel-check/default.nix diff --git a/nix/pkgs/get-kernel-check/get-kernel-check-hook.sh b/nix-builder/pkgs/get-kernel-check/get-kernel-check-hook.sh similarity index 100% rename from nix/pkgs/get-kernel-check/get-kernel-check-hook.sh rename to nix-builder/pkgs/get-kernel-check/get-kernel-check-hook.sh diff --git a/nix/pkgs/kernel-abi-check/default.nix b/nix-builder/pkgs/kernel-abi-check/default.nix similarity index 100% rename from nix/pkgs/kernel-abi-check/default.nix rename to nix-builder/pkgs/kernel-abi-check/default.nix diff --git a/nix/pkgs/kernel-abi-check/kernel-abi-check-hook.sh b/nix-builder/pkgs/kernel-abi-check/kernel-abi-check-hook.sh similarity index 100% rename from nix/pkgs/kernel-abi-check/kernel-abi-check-hook.sh rename to nix-builder/pkgs/kernel-abi-check/kernel-abi-check-hook.sh diff --git a/nix/pkgs/build2cmake/default.nix b/nix-builder/pkgs/kernel-builder/default.nix similarity index 71% rename from nix/pkgs/build2cmake/default.nix rename to nix-builder/pkgs/kernel-builder/default.nix index 8d16f730..afa37266 100644 --- a/nix/pkgs/build2cmake/default.nix +++ b/nix-builder/pkgs/kernel-builder/default.nix @@ -7,11 +7,12 @@ }: let - version = (builtins.fromTOML (builtins.readFile ../../../build2cmake/Cargo.toml)).package.version; + version = + (builtins.fromTOML (builtins.readFile ../../../kernel-builder/Cargo.toml)).package.version; in rustPlatform.buildRustPackage { inherit version; - pname = "build2cmake"; + pname = "kernel-builder"; src = let @@ -31,12 +32,12 @@ rustPlatform.buildRustPackage { ]); in lib.fileset.toSource { - root = ../../../build2cmake; - fileset = lib.fileset.fileFilter sourceFiles ../../../build2cmake; + root = ../../../kernel-builder; + fileset = lib.fileset.fileFilter sourceFiles ../../../kernel-builder; }; cargoLock = { - lockFile = ../../../build2cmake/Cargo.lock; + lockFile = ../../../kernel-builder/Cargo.lock; }; nativeBuildInputs = [ pkg-config ]; diff --git a/nix/pkgs/kernel-layout-check/default.nix b/nix-builder/pkgs/kernel-layout-check/default.nix similarity index 100% rename from nix/pkgs/kernel-layout-check/default.nix rename to nix-builder/pkgs/kernel-layout-check/default.nix diff --git a/nix/pkgs/kernel-layout-check/kernel-layout-check-hook.sh b/nix-builder/pkgs/kernel-layout-check/kernel-layout-check-hook.sh similarity index 100% rename from nix/pkgs/kernel-layout-check/kernel-layout-check-hook.sh rename to nix-builder/pkgs/kernel-layout-check/kernel-layout-check-hook.sh diff --git a/nix/pkgs/metal-cpp/default.nix b/nix-builder/pkgs/metal-cpp/default.nix similarity index 100% rename from nix/pkgs/metal-cpp/default.nix rename to nix-builder/pkgs/metal-cpp/default.nix diff --git a/nix/pkgs/nvtx/default.nix b/nix-builder/pkgs/nvtx/default.nix similarity index 100% rename from nix/pkgs/nvtx/default.nix rename to nix-builder/pkgs/nvtx/default.nix diff --git a/nix/pkgs/python-modules/cuda-bindings/default.nix b/nix-builder/pkgs/python-modules/cuda-bindings/default.nix similarity index 100% rename from nix/pkgs/python-modules/cuda-bindings/default.nix rename to nix-builder/pkgs/python-modules/cuda-bindings/default.nix diff --git a/nix/pkgs/python-modules/cuda-pathfinder/default.nix b/nix-builder/pkgs/python-modules/cuda-pathfinder/default.nix similarity index 100% rename from nix/pkgs/python-modules/cuda-pathfinder/default.nix rename to nix-builder/pkgs/python-modules/cuda-pathfinder/default.nix diff --git a/nix/pkgs/python-modules/cuda-python/default.nix b/nix-builder/pkgs/python-modules/cuda-python/default.nix similarity index 100% rename from nix/pkgs/python-modules/cuda-python/default.nix rename to nix-builder/pkgs/python-modules/cuda-python/default.nix diff --git a/nix/pkgs/python-modules/hooks/default.nix b/nix-builder/pkgs/python-modules/hooks/default.nix similarity index 100% rename from nix/pkgs/python-modules/hooks/default.nix rename to nix-builder/pkgs/python-modules/hooks/default.nix diff --git a/nix/pkgs/python-modules/hooks/python-relax-wheel-deps-hook.sh b/nix-builder/pkgs/python-modules/hooks/python-relax-wheel-deps-hook.sh similarity index 100% rename from nix/pkgs/python-modules/hooks/python-relax-wheel-deps-hook.sh rename to nix-builder/pkgs/python-modules/hooks/python-relax-wheel-deps-hook.sh diff --git a/nix/pkgs/python-modules/hooks/python-wheel-deps-check-hook.py b/nix-builder/pkgs/python-modules/hooks/python-wheel-deps-check-hook.py similarity index 100% rename from nix/pkgs/python-modules/hooks/python-wheel-deps-check-hook.py rename to nix-builder/pkgs/python-modules/hooks/python-wheel-deps-check-hook.py diff --git a/nix/pkgs/python-modules/hooks/python-wheel-deps-check-hook.sh b/nix-builder/pkgs/python-modules/hooks/python-wheel-deps-check-hook.sh similarity index 100% rename from nix/pkgs/python-modules/hooks/python-wheel-deps-check-hook.sh rename to nix-builder/pkgs/python-modules/hooks/python-wheel-deps-check-hook.sh diff --git a/nix/pkgs/python-modules/kernel-abi-check/default.nix b/nix-builder/pkgs/python-modules/kernel-abi-check/default.nix similarity index 100% rename from nix/pkgs/python-modules/kernel-abi-check/default.nix rename to nix-builder/pkgs/python-modules/kernel-abi-check/default.nix diff --git a/nix/pkgs/python-modules/kernels/default.nix b/nix-builder/pkgs/python-modules/kernels/default.nix similarity index 100% rename from nix/pkgs/python-modules/kernels/default.nix rename to nix-builder/pkgs/python-modules/kernels/default.nix diff --git a/nix/pkgs/python-modules/nvidia-cutlass-dsl-libs/default.nix b/nix-builder/pkgs/python-modules/nvidia-cutlass-dsl-libs/default.nix similarity index 100% rename from nix/pkgs/python-modules/nvidia-cutlass-dsl-libs/default.nix rename to nix-builder/pkgs/python-modules/nvidia-cutlass-dsl-libs/default.nix diff --git a/nix/pkgs/python-modules/nvidia-cutlass-dsl/default.nix b/nix-builder/pkgs/python-modules/nvidia-cutlass-dsl/default.nix similarity index 100% rename from nix/pkgs/python-modules/nvidia-cutlass-dsl/default.nix rename to nix-builder/pkgs/python-modules/nvidia-cutlass-dsl/default.nix diff --git a/nix/pkgs/python-modules/pyclibrary/default.nix b/nix-builder/pkgs/python-modules/pyclibrary/default.nix similarity index 100% rename from nix/pkgs/python-modules/pyclibrary/default.nix rename to nix-builder/pkgs/python-modules/pyclibrary/default.nix diff --git a/nix/pkgs/python-modules/torch/archs.nix b/nix-builder/pkgs/python-modules/torch/archs.nix similarity index 100% rename from nix/pkgs/python-modules/torch/archs.nix rename to nix-builder/pkgs/python-modules/torch/archs.nix diff --git a/nix/pkgs/python-modules/torch/binary/default.nix b/nix-builder/pkgs/python-modules/torch/binary/default.nix similarity index 100% rename from nix/pkgs/python-modules/torch/binary/default.nix rename to nix-builder/pkgs/python-modules/torch/binary/default.nix diff --git a/nix/pkgs/python-modules/torch/binary/download_torch_versions.py b/nix-builder/pkgs/python-modules/torch/binary/download_torch_versions.py similarity index 100% rename from nix/pkgs/python-modules/torch/binary/download_torch_versions.py rename to nix-builder/pkgs/python-modules/torch/binary/download_torch_versions.py diff --git a/nix/pkgs/python-modules/torch/binary/generate_torch_versions.py b/nix-builder/pkgs/python-modules/torch/binary/generate_torch_versions.py similarity index 100% rename from nix/pkgs/python-modules/torch/binary/generate_torch_versions.py rename to nix-builder/pkgs/python-modules/torch/binary/generate_torch_versions.py diff --git a/nix/pkgs/python-modules/torch/binary/generic.nix b/nix-builder/pkgs/python-modules/torch/binary/generic.nix similarity index 100% rename from nix/pkgs/python-modules/torch/binary/generic.nix rename to nix-builder/pkgs/python-modules/torch/binary/generic.nix diff --git a/nix/pkgs/python-modules/torch/binary/torch-versions-hash.json b/nix-builder/pkgs/python-modules/torch/binary/torch-versions-hash.json similarity index 100% rename from nix/pkgs/python-modules/torch/binary/torch-versions-hash.json rename to nix-builder/pkgs/python-modules/torch/binary/torch-versions-hash.json diff --git a/nix/pkgs/python-modules/torch/binary/torch-versions.json b/nix-builder/pkgs/python-modules/torch/binary/torch-versions.json similarity index 100% rename from nix/pkgs/python-modules/torch/binary/torch-versions.json rename to nix-builder/pkgs/python-modules/torch/binary/torch-versions.json diff --git a/nix/pkgs/python-modules/torch/binary/torch_versions.py b/nix-builder/pkgs/python-modules/torch/binary/torch_versions.py similarity index 100% rename from nix/pkgs/python-modules/torch/binary/torch_versions.py rename to nix-builder/pkgs/python-modules/torch/binary/torch_versions.py diff --git a/nix/pkgs/python-modules/torch/variant.nix b/nix-builder/pkgs/python-modules/torch/variant.nix similarity index 100% rename from nix/pkgs/python-modules/torch/variant.nix rename to nix-builder/pkgs/python-modules/torch/variant.nix diff --git a/nix/pkgs/python-modules/triton-xpu/default.nix b/nix-builder/pkgs/python-modules/triton-xpu/default.nix similarity index 100% rename from nix/pkgs/python-modules/triton-xpu/default.nix rename to nix-builder/pkgs/python-modules/triton-xpu/default.nix diff --git a/nix/pkgs/python-modules/tvm-ffi/default.nix b/nix-builder/pkgs/python-modules/tvm-ffi/default.nix similarity index 100% rename from nix/pkgs/python-modules/tvm-ffi/default.nix rename to nix-builder/pkgs/python-modules/tvm-ffi/default.nix diff --git a/nix/pkgs/python-modules/tvm-ffi/variant.nix b/nix-builder/pkgs/python-modules/tvm-ffi/variant.nix similarity index 100% rename from nix/pkgs/python-modules/tvm-ffi/variant.nix rename to nix-builder/pkgs/python-modules/tvm-ffi/variant.nix diff --git a/nix/pkgs/remove-bytecode-hook/default.nix b/nix-builder/pkgs/remove-bytecode-hook/default.nix similarity index 100% rename from nix/pkgs/remove-bytecode-hook/default.nix rename to nix-builder/pkgs/remove-bytecode-hook/default.nix diff --git a/nix/pkgs/remove-bytecode-hook/remove-bytecode-hook.sh b/nix-builder/pkgs/remove-bytecode-hook/remove-bytecode-hook.sh similarity index 100% rename from nix/pkgs/remove-bytecode-hook/remove-bytecode-hook.sh rename to nix-builder/pkgs/remove-bytecode-hook/remove-bytecode-hook.sh diff --git a/nix/pkgs/rewrite-nix-paths-macho/default.nix b/nix-builder/pkgs/rewrite-nix-paths-macho/default.nix similarity index 100% rename from nix/pkgs/rewrite-nix-paths-macho/default.nix rename to nix-builder/pkgs/rewrite-nix-paths-macho/default.nix diff --git a/nix/pkgs/rewrite-nix-paths-macho/rewrite-nix-paths-macho.py b/nix-builder/pkgs/rewrite-nix-paths-macho/rewrite-nix-paths-macho.py similarity index 100% rename from nix/pkgs/rewrite-nix-paths-macho/rewrite-nix-paths-macho.py rename to nix-builder/pkgs/rewrite-nix-paths-macho/rewrite-nix-paths-macho.py diff --git a/nix/pkgs/rocm-packages/bintools-unwrapped.nix b/nix-builder/pkgs/rocm-packages/bintools-unwrapped.nix similarity index 100% rename from nix/pkgs/rocm-packages/bintools-unwrapped.nix rename to nix-builder/pkgs/rocm-packages/bintools-unwrapped.nix diff --git a/nix/pkgs/rocm-packages/cc-wrapper.sh b/nix-builder/pkgs/rocm-packages/cc-wrapper.sh similarity index 100% rename from nix/pkgs/rocm-packages/cc-wrapper.sh rename to nix-builder/pkgs/rocm-packages/cc-wrapper.sh diff --git a/nix/pkgs/rocm-packages/clang.nix b/nix-builder/pkgs/rocm-packages/clang.nix similarity index 100% rename from nix/pkgs/rocm-packages/clang.nix rename to nix-builder/pkgs/rocm-packages/clang.nix diff --git a/nix/pkgs/rocm-packages/clr.nix b/nix-builder/pkgs/rocm-packages/clr.nix similarity index 100% rename from nix/pkgs/rocm-packages/clr.nix rename to nix-builder/pkgs/rocm-packages/clr.nix diff --git a/nix/pkgs/rocm-packages/components.nix b/nix-builder/pkgs/rocm-packages/components.nix similarity index 100% rename from nix/pkgs/rocm-packages/components.nix rename to nix-builder/pkgs/rocm-packages/components.nix diff --git a/nix/pkgs/rocm-packages/default.nix b/nix-builder/pkgs/rocm-packages/default.nix similarity index 100% rename from nix/pkgs/rocm-packages/default.nix rename to nix-builder/pkgs/rocm-packages/default.nix diff --git a/nix/pkgs/rocm-packages/generic.nix b/nix-builder/pkgs/rocm-packages/generic.nix similarity index 100% rename from nix/pkgs/rocm-packages/generic.nix rename to nix-builder/pkgs/rocm-packages/generic.nix diff --git a/nix/pkgs/rocm-packages/hooks.nix b/nix-builder/pkgs/rocm-packages/hooks.nix similarity index 100% rename from nix/pkgs/rocm-packages/hooks.nix rename to nix-builder/pkgs/rocm-packages/hooks.nix diff --git a/nix/pkgs/rocm-packages/joins.nix b/nix-builder/pkgs/rocm-packages/joins.nix similarity index 100% rename from nix/pkgs/rocm-packages/joins.nix rename to nix-builder/pkgs/rocm-packages/joins.nix diff --git a/nix/pkgs/rocm-packages/ld-wrapper.sh b/nix-builder/pkgs/rocm-packages/ld-wrapper.sh similarity index 100% rename from nix/pkgs/rocm-packages/ld-wrapper.sh rename to nix-builder/pkgs/rocm-packages/ld-wrapper.sh diff --git a/nix/pkgs/rocm-packages/llvm.nix b/nix-builder/pkgs/rocm-packages/llvm.nix similarity index 100% rename from nix/pkgs/rocm-packages/llvm.nix rename to nix-builder/pkgs/rocm-packages/llvm.nix diff --git a/nix/pkgs/rocm-packages/mark-for-rocm-root-hook.sh b/nix-builder/pkgs/rocm-packages/mark-for-rocm-root-hook.sh similarity index 100% rename from nix/pkgs/rocm-packages/mark-for-rocm-root-hook.sh rename to nix-builder/pkgs/rocm-packages/mark-for-rocm-root-hook.sh diff --git a/nix/pkgs/rocm-packages/overrides.nix b/nix-builder/pkgs/rocm-packages/overrides.nix similarity index 100% rename from nix/pkgs/rocm-packages/overrides.nix rename to nix-builder/pkgs/rocm-packages/overrides.nix diff --git a/nix/pkgs/rocm-packages/rhel2nix.py b/nix-builder/pkgs/rocm-packages/rhel2nix.py similarity index 100% rename from nix/pkgs/rocm-packages/rhel2nix.py rename to nix-builder/pkgs/rocm-packages/rhel2nix.py diff --git a/nix/pkgs/rocm-packages/rocm-6.3.4-metadata.json b/nix-builder/pkgs/rocm-packages/rocm-6.3.4-metadata.json similarity index 100% rename from nix/pkgs/rocm-packages/rocm-6.3.4-metadata.json rename to nix-builder/pkgs/rocm-packages/rocm-6.3.4-metadata.json diff --git a/nix/pkgs/rocm-packages/rocm-6.4.2-metadata.json b/nix-builder/pkgs/rocm-packages/rocm-6.4.2-metadata.json similarity index 100% rename from nix/pkgs/rocm-packages/rocm-6.4.2-metadata.json rename to nix-builder/pkgs/rocm-packages/rocm-6.4.2-metadata.json diff --git a/nix/pkgs/rocm-packages/rocm-7.0.2-metadata.json b/nix-builder/pkgs/rocm-packages/rocm-7.0.2-metadata.json similarity index 100% rename from nix/pkgs/rocm-packages/rocm-7.0.2-metadata.json rename to nix-builder/pkgs/rocm-packages/rocm-7.0.2-metadata.json diff --git a/nix/pkgs/rocm-packages/rocm-7.1.1-metadata.json b/nix-builder/pkgs/rocm-packages/rocm-7.1.1-metadata.json similarity index 100% rename from nix/pkgs/rocm-packages/rocm-7.1.1-metadata.json rename to nix-builder/pkgs/rocm-packages/rocm-7.1.1-metadata.json diff --git a/nix/pkgs/rocm-packages/setup-rocm-hook.sh b/nix-builder/pkgs/rocm-packages/setup-rocm-hook.sh similarity index 100% rename from nix/pkgs/rocm-packages/setup-rocm-hook.sh rename to nix-builder/pkgs/rocm-packages/setup-rocm-hook.sh diff --git a/nix/pkgs/stdenv-glibc-2_27/default.nix b/nix-builder/pkgs/stdenv-glibc-2_27/default.nix similarity index 100% rename from nix/pkgs/stdenv-glibc-2_27/default.nix rename to nix-builder/pkgs/stdenv-glibc-2_27/default.nix diff --git a/nix/pkgs/xpu-packages/components.nix b/nix-builder/pkgs/xpu-packages/components.nix similarity index 100% rename from nix/pkgs/xpu-packages/components.nix rename to nix-builder/pkgs/xpu-packages/components.nix diff --git a/nix/pkgs/xpu-packages/default.nix b/nix-builder/pkgs/xpu-packages/default.nix similarity index 100% rename from nix/pkgs/xpu-packages/default.nix rename to nix-builder/pkgs/xpu-packages/default.nix diff --git a/nix/pkgs/xpu-packages/generic.nix b/nix-builder/pkgs/xpu-packages/generic.nix similarity index 100% rename from nix/pkgs/xpu-packages/generic.nix rename to nix-builder/pkgs/xpu-packages/generic.nix diff --git a/nix/pkgs/xpu-packages/hooks.nix b/nix-builder/pkgs/xpu-packages/hooks.nix similarity index 100% rename from nix/pkgs/xpu-packages/hooks.nix rename to nix-builder/pkgs/xpu-packages/hooks.nix diff --git a/nix/pkgs/xpu-packages/intel-deep-learning-2025.1.3.json b/nix-builder/pkgs/xpu-packages/intel-deep-learning-2025.1.3.json similarity index 100% rename from nix/pkgs/xpu-packages/intel-deep-learning-2025.1.3.json rename to nix-builder/pkgs/xpu-packages/intel-deep-learning-2025.1.3.json diff --git a/nix/pkgs/xpu-packages/intel-deep-learning-2025.2.1.json b/nix-builder/pkgs/xpu-packages/intel-deep-learning-2025.2.1.json similarity index 100% rename from nix/pkgs/xpu-packages/intel-deep-learning-2025.2.1.json rename to nix-builder/pkgs/xpu-packages/intel-deep-learning-2025.2.1.json diff --git a/nix/pkgs/xpu-packages/intel-deep-learning-2025.3.1.json b/nix-builder/pkgs/xpu-packages/intel-deep-learning-2025.3.1.json similarity index 100% rename from nix/pkgs/xpu-packages/intel-deep-learning-2025.3.1.json rename to nix-builder/pkgs/xpu-packages/intel-deep-learning-2025.3.1.json diff --git a/nix/pkgs/xpu-packages/mark-for-xpu-root-hook.sh b/nix-builder/pkgs/xpu-packages/mark-for-xpu-root-hook.sh similarity index 100% rename from nix/pkgs/xpu-packages/mark-for-xpu-root-hook.sh rename to nix-builder/pkgs/xpu-packages/mark-for-xpu-root-hook.sh diff --git a/nix/pkgs/xpu-packages/ocloc.nix b/nix-builder/pkgs/xpu-packages/ocloc.nix similarity index 100% rename from nix/pkgs/xpu-packages/ocloc.nix rename to nix-builder/pkgs/xpu-packages/ocloc.nix diff --git a/nix/pkgs/xpu-packages/oneapi-torch-dev.nix b/nix-builder/pkgs/xpu-packages/oneapi-torch-dev.nix similarity index 100% rename from nix/pkgs/xpu-packages/oneapi-torch-dev.nix rename to nix-builder/pkgs/xpu-packages/oneapi-torch-dev.nix diff --git a/nix/pkgs/xpu-packages/onednn-xpu.nix b/nix-builder/pkgs/xpu-packages/onednn-xpu.nix similarity index 100% rename from nix/pkgs/xpu-packages/onednn-xpu.nix rename to nix-builder/pkgs/xpu-packages/onednn-xpu.nix diff --git a/nix/pkgs/xpu-packages/overrides.nix b/nix-builder/pkgs/xpu-packages/overrides.nix similarity index 100% rename from nix/pkgs/xpu-packages/overrides.nix rename to nix-builder/pkgs/xpu-packages/overrides.nix diff --git a/nix/pkgs/xpu-packages/rhel2nix.py b/nix-builder/pkgs/xpu-packages/rhel2nix.py similarity index 100% rename from nix/pkgs/xpu-packages/rhel2nix.py rename to nix-builder/pkgs/xpu-packages/rhel2nix.py diff --git a/nix/pkgs/xpu-packages/setup-xpu-hook.sh b/nix-builder/pkgs/xpu-packages/setup-xpu-hook.sh similarity index 100% rename from nix/pkgs/xpu-packages/setup-xpu-hook.sh rename to nix-builder/pkgs/xpu-packages/setup-xpu-hook.sh diff --git a/nix/pkgs/xpu-packages/sycl-tla.nix b/nix-builder/pkgs/xpu-packages/sycl-tla.nix similarity index 100% rename from nix/pkgs/xpu-packages/sycl-tla.nix rename to nix-builder/pkgs/xpu-packages/sycl-tla.nix diff --git a/builder/scripts/gen_variants_markdown.py b/nix-builder/scripts/gen_variants_markdown.py similarity index 95% rename from builder/scripts/gen_variants_markdown.py rename to nix-builder/scripts/gen_variants_markdown.py index 925f0610..b097cebc 100755 --- a/builder/scripts/gen_variants_markdown.py +++ b/nix-builder/scripts/gen_variants_markdown.py @@ -29,7 +29,7 @@ def json_to_markdown(): project_root = Path(__file__).parent.parent.parent - with open(project_root / "builder" / "build-variants.json", "r") as f: + with open(project_root / "nix-builder" / "build-variants.json", "r") as f: data = json.load(f) with open( diff --git a/builder/scripts/init-kernel.py b/nix-builder/scripts/init-kernel.py similarity index 100% rename from builder/scripts/init-kernel.py rename to nix-builder/scripts/init-kernel.py diff --git a/builder/scripts/windows/builder.ps1 b/nix-builder/scripts/windows/builder.ps1 similarity index 89% rename from builder/scripts/windows/builder.ps1 rename to nix-builder/scripts/windows/builder.ps1 index 07a1ca72..9e49e69f 100644 --- a/builder/scripts/windows/builder.ps1 +++ b/nix-builder/scripts/windows/builder.ps1 @@ -2,10 +2,10 @@ <# .SYNOPSIS - Kernel Builder - Modern PowerShell wrapper for build2cmake tool + Kernel Builder - Modern PowerShell wrapper for kernel-builder tool .DESCRIPTION - This script provides a modular interface to build2cmake for generating CMake + This script provides a modular interface to kernel-builder for generating CMake structures from build.toml configuration files. Supports multiple backends including CUDA, ROCm, Metal, and XPU. @@ -18,8 +18,8 @@ .PARAMETER Backend Target backend: cuda, rocm, metal, xpu, or universal -.PARAMETER Build2CmakePath - Path to build2cmake executable (auto-detected if not specified) +.PARAMETER KernelBuilderPath + Path to kernel-builder executable (auto-detected if not specified) .PARAMETER Force Force overwrite existing files without prompting @@ -105,7 +105,7 @@ param( [string]$Backend, [Parameter()] - [string]$Build2CmakePath, + [string]$KernelBuilderPath, [Parameter(ParameterSetName = 'Generate')] [switch]$Force, @@ -167,26 +167,26 @@ function Write-Status { Write-Host "$prefix $Message" -ForegroundColor $colors[$Type] } -function Find-Build2Cmake { +function Find-KernelBuilder { <# .SYNOPSIS - Locates build2cmake executable in common locations + Locates kernel-builder executable in common locations #> # Check if provided path is valid - if ($Build2CmakePath) { - if (Test-Path $Build2CmakePath -PathType Leaf) { - return $Build2CmakePath + if ($KernelBuilderPath) { + if (Test-Path $KernelBuilderPath -PathType Leaf) { + return $KernelBuilderPath } - throw "Specified build2cmake path not found: $Build2CmakePath" + throw "Specified kernel-builder path not found: $KernelBuilderPath" } # Search common locations $searchPaths = @( - (Join-Path $PSScriptRoot '..' '..' '..' 'build2cmake' 'target' 'release' 'build2cmake.exe'), - (Join-Path $PSScriptRoot '..' '..' '..' 'build2cmake' 'target' 'debug' 'build2cmake.exe'), - 'build2cmake.exe', - 'build2cmake' + (Join-Path $PSScriptRoot '..' '..' '..' 'kernel-builder' 'target' 'release' 'kernel-builder.exe'), + (Join-Path $PSScriptRoot '..' '..' '..' 'kernel-builder' 'target' 'debug' 'kernel-builder.exe'), + 'kernel-builder.exe', + 'kernel-builder' ) foreach ($path in $searchPaths) { @@ -197,19 +197,19 @@ function Find-Build2Cmake { } if (Test-Path $resolved -PathType Leaf) { - Write-Status "Found build2cmake at: $resolved" -Type Info + Write-Status "Found kernel-builder at: $resolved" -Type Info return $resolved } } # Try system PATH - $cmd = Get-Command build2cmake -ErrorAction SilentlyContinue + $cmd = Get-Command kernel-builder -ErrorAction SilentlyContinue if ($cmd) { - Write-Status "Using build2cmake from PATH: $($cmd.Source)" -Type Info + Write-Status "Using kernel-builder from PATH: $($cmd.Source)" -Type Info return $cmd.Source } - throw "build2cmake executable not found. Please build it or specify -Build2CmakePath" + throw "kernel-builder executable not found. Please build it or specify -KernelBuilderPath" } function Get-BuildTomlPath { @@ -224,18 +224,18 @@ function Get-BuildTomlPath { return $buildTomlPath } -function Invoke-Build2Cmake { +function Invoke-KernelBuilder { param( - [string]$Build2CmakeExe, + [string]$KernelBuilderExe, [string[]]$Arguments ) - Write-Status "Executing: $Build2CmakeExe $($Arguments -join ' ')" -Type Info + Write-Status "Executing: $KernelBuilderExe $($Arguments -join ' ')" -Type Info - & $Build2CmakeExe @Arguments + & $KernelBuilderExe @Arguments if ($LASTEXITCODE -ne 0) { - throw "build2cmake failed with exit code $LASTEXITCODE" + throw "kernel-builder failed with exit code $LASTEXITCODE" } } @@ -469,7 +469,7 @@ function Invoke-Backend { Generates CMake files for specified backend #> param( - [string]$Build2CmakeExe, + [string]$KernelBuilderExe, [string]$BuildToml, [string]$Target, [hashtable]$Options, @@ -485,7 +485,7 @@ function Invoke-Backend { if ($Options.Force) { $kwargs += '--force' } if ($Options.OpsId) { $kwargs += '--ops-id', $Options.OpsId } - Invoke-Build2Cmake -Build2CmakeExe $Build2CmakeExe -Arguments $kwargs + Invoke-KernelBuilder -KernelBuilderExe $KernelBuilderExe -Arguments $kwargs } function Set-BackendArchitecture { @@ -524,12 +524,12 @@ try { # Resolve paths $SourceFolder = Resolve-Path $SourceFolder -ErrorAction Stop $buildTomlPath = Get-BuildTomlPath -Folder $SourceFolder - $build2cmakeExe = Find-Build2Cmake + $kernelBuilderExe = Find-KernelBuilder # Validate mode if ($Validate) { Write-Status "Validating $buildTomlPath..." -Type Info - Invoke-Build2Cmake -Build2CmakeExe $build2cmakeExe -Arguments @('validate', $buildTomlPath) + Invoke-KernelBuilder -KernelBuilderExe $kernelBuilderExe -Arguments @('validate', $buildTomlPath) Write-Status "Validation successful!" -Type Success exit 0 } @@ -544,7 +544,7 @@ try { if ($Force) { $kwargs += '--force' } if ($OpsId) { $kwargs += '--ops-id', $OpsId } - Invoke-Build2Cmake -Build2CmakeExe $build2cmakeExe -Arguments $kwargs + Invoke-KernelBuilder -KernelBuilderExe $kernelBuilderExe -Arguments $kwargs Write-Status "Clean completed!" -Type Success exit 0 } @@ -569,7 +569,7 @@ try { if ($Backend) { # Explicit backend specified $targetPath = if ($TargetFolder) { Resolve-Path $TargetFolder } else { $null } - Invoke-Backend -Build2CmakeExe $build2cmakeExe -BuildToml $buildTomlPath -Target $targetPath -Options $options -Backend $Backend.ToLower() + Invoke-Backend -KernelBuilderExe $kernelBuilderExe -BuildToml $buildTomlPath -Target $targetPath -Options $options -Backend $Backend.ToLower() } else { # Auto-detect backend from build.toml Write-Status "Auto-detecting backend from build.toml..." -Type Info @@ -579,7 +579,7 @@ try { if ($Force) { $kwargs += '--force' } if ($OpsId) { $kwargs += '--ops-id', $OpsId } - Invoke-Build2Cmake -Build2CmakeExe $build2cmakeExe -Arguments $kwargs + Invoke-KernelBuilder -KernelBuilderExe $kernelBuilderExe -Arguments $kwargs } Write-Status "Generation completed successfully!" -Type Success diff --git a/builder/tests/Dockerfile.test-kernel b/nix-builder/tests/Dockerfile.test-kernel similarity index 88% rename from builder/tests/Dockerfile.test-kernel rename to nix-builder/tests/Dockerfile.test-kernel index 7876617b..cb99d4f1 100644 --- a/builder/tests/Dockerfile.test-kernel +++ b/nix-builder/tests/Dockerfile.test-kernel @@ -39,7 +39,7 @@ WORKDIR /app/kernel-test # Install PyTorch with the appropriate CUDA version -# NOTE: `markupsafe` must be installed first to avoid a conflict with the torch package. +# NOTE: `markupsafe` must be installed first to avoid a conflict with the torch package. # See: https://github.com/astral-sh/uv/issues/9647 RUN CUDA_MAJOR_MINOR=$(echo ${CUDA_VERSION} | cut -d'.' -f1,2) && \ @@ -68,11 +68,11 @@ COPY relu-tvm-ffi-kernel ./relu-tvm-ffi-kernel COPY relu-kernel-cpu ./relu-kernel-cpu COPY cutlass-gemm-kernel ./cutlass-gemm-kernel COPY silu-and-mul-kernel ./silu-and-mul-kernel -COPY builder/examples/extra-data/tests ./extra_data_tests -COPY builder/examples/relu/tests ./relu_tests -COPY builder/examples/relu-tvm-ffi/tests ./relu_tvm_ffi_tests -COPY builder/examples/cutlass-gemm/tests ./cutlass_gemm_tests +COPY examples/kernels/extra-data/tests ./extra_data_tests +COPY examples/kernels/relu/tests ./relu_tests +COPY examples/kernels/relu-tvm-ffi/tests ./relu_tvm_ffi_tests +COPY examples/kernels/cutlass-gemm/tests ./cutlass_gemm_tests # Run tests -ADD builder/tests/run-tests.sh ./run-tests.sh +ADD nix-builder/tests/run-tests.sh ./run-tests.sh CMD ["sh", "run-tests.sh"] diff --git a/builder/tests/run-kernels/pyproject.toml b/nix-builder/tests/run-kernels/pyproject.toml similarity index 100% rename from builder/tests/run-kernels/pyproject.toml rename to nix-builder/tests/run-kernels/pyproject.toml diff --git a/builder/tests/run-tests.sh b/nix-builder/tests/run-tests.sh similarity index 100% rename from builder/tests/run-tests.sh rename to nix-builder/tests/run-tests.sh diff --git a/builder/versions.nix b/nix-builder/versions.nix similarity index 100% rename from builder/versions.nix rename to nix-builder/versions.nix