rocm_jax/jaxlib/tools/BUILD.bazel
Jieying Luo 462ef165c4 [PJRT C API] Change build wheel script to build a separate package for cuda kernels.
With this change, `python3 build/build.py --enable_cuda --build_gpu_plugin --gpu_plugin_cuda_version=12` will generate three wheels:

|                      |size|wheel name                                                               |
|----------------------|----|-------------------------------------------------------------------------|
|jaxlib w/o cuda kernels|76M |jaxlib-0.4.20.dev20231101-cp310-cp310-manylinux2014_x86_64.whl           |
|cuda pjrt              |73M|jax_cuda12_pjrt-0.4.20.dev20231101-py3-none-manylinux2014_x86_64.whl                    |
|cuda kernels           |6.6M|jax_cuda12_plugin-0.4.20.dev20231101-cp310-cp310-manylinux2014_x86_64.whl|

The size of jaxlib with cuda kernels and pjrt is 119M.

The cuda kernel wheel contains all the cuda kernels. A plugin_setup.py and plugin_pyproject.toml are added for this new pacakge.

PiperOrigin-RevId: 579861480
2023-11-06 09:13:44 -08:00

87 lines
2.5 KiB
Python

# Copyright 2018 The JAX Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# JAX is Autograd and XLA
load("@local_config_cuda//cuda:build_defs.bzl", "if_cuda")
load("@local_config_rocm//rocm:build_defs.bzl", "if_rocm")
load("//jaxlib:jax.bzl", "if_windows")
licenses(["notice"]) # Apache 2
package(default_visibility = ["//visibility:public"])
py_binary(
name = "build_wheel",
srcs = ["build_wheel.py"],
data = [
"LICENSE.txt",
"//jaxlib",
"//jaxlib:README.md",
"//jaxlib:setup.py",
"@xla//xla/python:xla_client",
] + if_windows([
"//jaxlib/mlir/_mlir_libs:jaxlib_mlir_capi.dll",
]) + if_cuda([
"//jaxlib/cuda:cuda_gpu_support",
# TODO(jieying): move it out from jaxlib
"//jaxlib:cuda_plugin_extension",
"@local_config_cuda//cuda:cuda-nvvm",
]) + if_rocm([
"//jaxlib/rocm:rocm_gpu_support",
]),
deps = [
"//jax/tools:build_utils",
"@bazel_tools//tools/python/runfiles"
],
)
py_binary(
name = "build_gpu_plugin_wheel",
srcs = ["build_gpu_plugin_wheel.py"],
data = [
"LICENSE.txt",
"@xla//xla/pjrt/c:pjrt_c_api_gpu_plugin.so",
] + if_cuda([
"//jaxlib:version",
"//jaxlib/cuda:cuda_gpu_support",
"//plugins/cuda:pyproject.toml",
"//plugins/cuda:setup.py",
"//plugins/cuda:__init__.py",
"@local_config_cuda//cuda:cuda-nvvm",
]),
deps = [
"//jax/tools:build_utils",
"@bazel_tools//tools/python/runfiles"
],
)
py_binary(
name = "build_cuda_kernels_wheel",
srcs = ["build_cuda_kernels_wheel.py"],
data = [
"LICENSE.txt",
] + if_cuda([
"//jaxlib:version",
"//jaxlib/cuda:cuda_gpu_support",
"//plugins/cuda:plugin_pyproject.toml",
"//plugins/cuda:plugin_setup.py",
"@local_config_cuda//cuda:cuda-nvvm",
]),
deps = [
"//jax/tools:build_utils",
"@bazel_tools//tools/python/runfiles"
],
)