2024-09-27 14:00:44 +00:00
|
|
|
load("@rules_cc//cc:cc_library.bzl", "cc_library")
|
2023-08-18 17:11:27 +00:00
|
|
|
load("@rules_python//python:pip.bzl", "compile_pip_requirements")
|
|
|
|
|
load("@rules_python//python/entry_points:py_console_script_binary.bzl", "py_console_script_binary")
|
|
|
|
|
load("@rules_uv//uv:pip.bzl", "pip_compile")
|
2025-05-19 17:35:33 +00:00
|
|
|
load("@rules_zig//zig:defs.bzl", "BINARY_KIND", "zig_binary", "zig_library")
|
2023-08-18 17:11:27 +00:00
|
|
|
load(":neuron.bzl", "py_binary_with_script")
|
|
|
|
|
load(":pyenv.bzl", "pyenv_zig")
|
|
|
|
|
|
|
|
|
|
pyenv_zig(
|
|
|
|
|
name = "libneuronxla_pyenv_zig",
|
|
|
|
|
deps = [":libneuronxla"],
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
zig_library(
|
|
|
|
|
name = "libneuronxla_pyenv",
|
|
|
|
|
main = ":libneuronxla_pyenv_zig",
|
|
|
|
|
)
|
|
|
|
|
|
2025-05-19 17:35:33 +00:00
|
|
|
# A proxy PJRT Plugin that loads the Neuron PJRT Plugin
|
|
|
|
|
# and returns the instance from nested GetPjrtApi.
|
|
|
|
|
#
|
|
|
|
|
# Additionally, it provides a way to load implicit transitive dependencies
|
|
|
|
|
# of neuronx-cc (see add_needed of the patchelf target below).
|
|
|
|
|
#
|
|
|
|
|
# TODO(cerisier): Use a zig_cc_shared_library instead.
|
|
|
|
|
zig_binary(
|
|
|
|
|
name = "libpjrt_neuron_proxy",
|
|
|
|
|
kind = BINARY_KIND.shared_lib,
|
|
|
|
|
main = "libpjrt_neuron.zig",
|
|
|
|
|
copts = ["-lc"],
|
|
|
|
|
deps = [
|
|
|
|
|
"//stdx",
|
|
|
|
|
"@rules_zig//zig/runfiles",
|
|
|
|
|
],
|
|
|
|
|
visibility = ["@libpjrt_neuron//:__subpackages__"],
|
|
|
|
|
)
|
|
|
|
|
|
2023-08-18 17:11:27 +00:00
|
|
|
pip_compile(
|
|
|
|
|
name = "update_requirements",
|
|
|
|
|
args = [
|
|
|
|
|
"--generate-hashes",
|
|
|
|
|
"--emit-index-url",
|
|
|
|
|
"--emit-find-links",
|
|
|
|
|
"--no-strip-extras",
|
2024-09-27 14:00:44 +00:00
|
|
|
"--index-strategy=unsafe-best-match",
|
2023-08-18 17:11:27 +00:00
|
|
|
"--upgrade",
|
|
|
|
|
],
|
|
|
|
|
python_platform = "x86_64-unknown-linux-gnu",
|
|
|
|
|
requirements_in = "requirements.in",
|
|
|
|
|
requirements_txt = "requirements.lock.txt",
|
2024-11-22 16:50:20 +00:00
|
|
|
tags = [
|
2025-02-03 14:03:33 +00:00
|
|
|
"manual",
|
2024-11-22 16:50:20 +00:00
|
|
|
],
|
2023-08-18 17:11:27 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
|
|
py_console_script_binary(
|
|
|
|
|
name = "neuronx-cc",
|
|
|
|
|
binary_rule = py_binary_with_script,
|
|
|
|
|
pkg = "@neuron_py_deps//neuronx_cc",
|
|
|
|
|
visibility = ["//visibility:public"],
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
py_binary_with_script(
|
|
|
|
|
name = "libneuronxla",
|
|
|
|
|
srcs = ["empty.py"],
|
|
|
|
|
main = "empty.py",
|
|
|
|
|
deps = [
|
|
|
|
|
":neuronx-cc",
|
|
|
|
|
"@neuron_py_deps//libneuronxla",
|
|
|
|
|
],
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
cc_library(
|
|
|
|
|
name = "libpython",
|
|
|
|
|
hdrs = ["libpython.h"],
|
|
|
|
|
visibility = ["//visibility:public"],
|
|
|
|
|
deps = [
|
|
|
|
|
"@rules_python//python/cc:current_py_cc_headers",
|
|
|
|
|
"@rules_python//python/cc:current_py_cc_libs",
|
|
|
|
|
],
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
compile_pip_requirements(
|
|
|
|
|
name = "requirements",
|
|
|
|
|
src = "requirements.in",
|
|
|
|
|
py_binary = py_binary_with_script,
|
2024-05-20 11:28:25 +00:00
|
|
|
requirements_txt = "requirements.lock.txt",
|
2024-11-22 16:50:20 +00:00
|
|
|
tags = [
|
2025-02-03 14:03:33 +00:00
|
|
|
"manual",
|
2024-11-22 16:50:20 +00:00
|
|
|
],
|
2023-08-18 17:11:27 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
|
|
cc_library(
|
|
|
|
|
name = "zmlxneuron_lib",
|
|
|
|
|
srcs = ["zmlxneuron.c"],
|
|
|
|
|
linkopts = ["-ldl"],
|
2025-05-19 17:35:33 +00:00
|
|
|
visibility = ["@libpjrt_neuron//:__subpackages__"],
|
2023-08-18 17:11:27 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
|
|
alias(
|
|
|
|
|
name = "bootstrap",
|
|
|
|
|
actual = "@rules_python//python/config_settings:bootstrap_impl",
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
cc_library(
|
|
|
|
|
name = "empty",
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
cc_library(
|
|
|
|
|
name = "libpjrt_neuron",
|
2024-11-14 13:37:47 +00:00
|
|
|
hdrs = ["libpjrt_neuron.h"],
|
2023-08-18 17:11:27 +00:00
|
|
|
defines = ["ZML_RUNTIME_NEURON"],
|
2025-05-19 17:35:33 +00:00
|
|
|
deps = [
|
|
|
|
|
"@libpjrt_neuron",
|
|
|
|
|
],
|
2023-08-18 17:11:27 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
|
|
zig_library(
|
|
|
|
|
name = "neuron",
|
|
|
|
|
import_name = "runtimes/neuron",
|
|
|
|
|
main = "neuron.zig",
|
|
|
|
|
visibility = ["//visibility:public"],
|
2025-05-19 17:35:33 +00:00
|
|
|
data = select({
|
|
|
|
|
"//runtimes:neuron.enabled": [
|
|
|
|
|
":libneuronxla",
|
|
|
|
|
],
|
|
|
|
|
"//conditions:default": [],
|
|
|
|
|
}),
|
2023-08-18 17:11:27 +00:00
|
|
|
deps = [
|
|
|
|
|
"//pjrt",
|
|
|
|
|
] + select({
|
|
|
|
|
"//runtimes:neuron.enabled": [
|
|
|
|
|
":libpjrt_neuron",
|
2025-05-19 17:35:33 +00:00
|
|
|
":libneuronxla_pyenv",
|
2023-08-18 17:11:27 +00:00
|
|
|
":libpython",
|
|
|
|
|
"//async",
|
2025-05-19 17:35:33 +00:00
|
|
|
"//stdx",
|
2023-08-18 17:11:27 +00:00
|
|
|
"@rules_zig//zig/runfiles",
|
|
|
|
|
],
|
|
|
|
|
"//conditions:default": [":empty"],
|
|
|
|
|
}),
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
filegroup(
|
|
|
|
|
name = "layers",
|
|
|
|
|
srcs = [
|
2024-11-14 13:37:47 +00:00
|
|
|
"@apt_neuron//bash/amd64",
|
2023-08-18 17:11:27 +00:00
|
|
|
],
|
|
|
|
|
visibility = ["//visibility:public"],
|
|
|
|
|
)
|