Repository navigation
Expand file tree
/
Copy pathWORKSPACE
More file actions
191 lines (145 loc) · 5.62 KB
/
Copy pathWORKSPACE
File metadata and controls
191 lines (145 loc) · 5.62 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
# Commit 2025-06-09: 244cec869d12e53378fa0efb610cd4c32a454ec8
http_archive(
name = "com_google_googletest",
sha256 = "f253ca1a07262f8efde8328e4b2c68979e40ddfcfc001f70d1d5f612c7de2974",
strip_prefix = "googletest-28e9d1f26771c6517c3b4be10254887673c94018",
urls = [
"https://github.com/google/googletest/archive/28e9d1f26771c6517c3b4be10254887673c940189.zip",
],
)
# rules_cc 0.1.2 or higher is necessary for @rules_cc//cc:core_rules target
http_archive(
name = "rules_cc",
sha256 = "0d3b4f984c4c2e1acfd1378e0148d35caf2ef1d9eb95b688f8e19ce0c41bdf5b",
strip_prefix = "rules_cc-0.1.4",
url = "https://github.com/bazelbuild/rules_cc/releases/download/0.1.4/rules_cc-0.1.4.tar.gz",
)
http_archive(
name = "rules_license",
sha256 = "26d4021f6898e23b82ef953078389dd49ac2b5618ac564ade4ef87cced147b38",
urls = [
"https://mirror.bazel.build/github.com/bazelbuild/rules_license/releases/download/1.0.0/rules_license-1.0.0.tar.gz",
"https://github.com/bazelbuild/rules_license/releases/download/1.0.0/rules_license-1.0.0.tar.gz",
],
)
# XLA defines rules_ml_toolchain, but does so too late in the ordering of its
# own setup, so we have to manually define it before XLA's setup runs.
# Commit 2026-03-27 : 40efd07eb8e6565e506562f36d7dc43cd83e5b32
http_archive(
name = "rules_ml_toolchain",
sha256 = "9bd46bc5e06a56a9335897be630d4b820c678281aa88302518c250921338ad22",
strip_prefix = "rules_ml_toolchain-40efd07eb8e6565e506562f36d7dc43cd83e5b32",
urls = [
"https://github.com/google-ml-infra/rules_ml_toolchain/archive/40efd07eb8e6565e506562f36d7dc43cd83e5b32.tar.gz",
],
)
# Pinned to google/tcmalloc commit from 2026-06-05.
http_archive(
name = "com_google_tcmalloc",
sha256 = "6596bbcefc061afa7b8bf919748eb411ba46ae57aa1f9c943b9e6ee289685de1",
strip_prefix = "tcmalloc-add88b498a65e92a30e83dbcd436adf2a91c3cc9",
urls = [
"https://github.com/google/tcmalloc/archive/add88b498a65e92a30e83dbcd436adf2a91c3cc9.tar.gz",
],
)
load("//bazel:wheel_deps.bzl", "torch_tpu_deps_repo")
load("//bazel:wheel_version.bzl", "torch_tpu_version_repo")
# Python 3.12 is the established default version for the TorchTPU repository, aligning with the
# `HERMETIC_PYTHON_VERSION` in .bazelrc and our base Docker images (Dockerfile.multistage).
# Hardcoding it here ensures standard local Bazel builds resolve dependencies correctly
# without requiring manual flags. CI jobs testing other Python versions will dynamically
# override this lockfile via the `python_init_repositories` configuration below.
torch_tpu_deps_repo(
name = "torch_tpu_deps",
pyproject_toml = "//:pyproject.toml",
requirements_txt = "//requirements:requirements_3_12.txt",
)
torch_tpu_version_repo(
name = "torch_tpu_version",
pyproject_toml = "//:pyproject.toml",
)
load("//bazel:xla_repo.bzl", "xla_repo")
xla_repo()
# Fetch jax_tpu_embedding dependency
load("//bazel:jax_tpu_embedding_repo.bzl", "jax_tpu_embedding_repo")
jax_tpu_embedding_repo()
load("@xla//:workspace4.bzl", "xla_workspace4")
xla_workspace4()
load("@xla//:workspace3.bzl", "xla_workspace3")
xla_workspace3()
# Initialize hermetic Python
load("//bazel:rules_python.bzl", "rules_python_repo")
rules_python_repo()
load("@xla//third_party/py:python_init_repositories.bzl", "python_init_repositories")
python_init_repositories(
default_python_version = "system",
local_wheel_dist_folder = "dist",
local_wheel_inclusion_list = [
"torch-*",
"nvidia*",
],
local_wheel_workspaces = ["//:WORKSPACE"],
requirements = {
"3.11": "//requirements:requirements_3_11.txt",
"3.12": "//requirements:requirements_3_12.txt",
"3.13": "//requirements:requirements_3_13.txt",
"3.14": "//requirements:requirements_3_14.txt",
"3.15": "//requirements:requirements_3_15.txt",
},
)
load("@xla//third_party/py:python_init_toolchains.bzl", "python_init_toolchains")
python_init_toolchains()
load("//bazel:pip_parse.bzl", "torch_tpu_pip_parse")
torch_tpu_pip_parse()
load("@pypi//:requirements.bzl", "install_deps")
install_deps()
load("@pypi_cuda//:requirements.bzl", install_cuda_deps = "install_deps")
install_cuda_deps()
load("@xla//:workspace2.bzl", "xla_workspace2")
xla_workspace2()
load("@xla//:workspace1.bzl", "xla_workspace1")
xla_workspace1()
load("@xla//:workspace0.bzl", "xla_workspace0")
xla_workspace0()
load(
"@rules_ml_toolchain//cc/deps:cc_toolchain_deps.bzl",
"cc_toolchain_deps",
)
cc_toolchain_deps()
load(
"@rules_ml_toolchain//gpu/cuda:cuda_json_init_repository.bzl",
"cuda_json_init_repository",
)
cuda_json_init_repository()
load(
"@cuda_redist_json//:distributions.bzl",
"CUDA_REDISTRIBUTIONS",
"CUDNN_REDISTRIBUTIONS",
)
load(
"@rules_ml_toolchain//gpu/cuda:cuda_redist_init_repositories.bzl",
"cuda_redist_init_repositories",
"cudnn_redist_init_repository",
)
cuda_redist_init_repositories(
cuda_redistributions = CUDA_REDISTRIBUTIONS,
)
cudnn_redist_init_repository(
cudnn_redistributions = CUDNN_REDISTRIBUTIONS,
)
load(
"@rules_ml_toolchain//gpu/cuda:cuda_configure.bzl",
"cuda_configure",
)
cuda_configure(name = "local_config_cuda")
register_toolchains("@rules_ml_toolchain//cc:linux_x86_64_linux_x86_64")
# --- Local Torch Support ---
# Load the custom repository rule
load("//bazel:torch_local_repo.bzl", "torch_local_repo")
# Define the local torch repository.
# It will check for the TORCH_SOURCE env var.
# If set, it uses that path. If not, it creates a dummy stub to prevent crashes.
torch_local_repo(
name = "local_torch",
)