Commit Graph

144 Commits

Author SHA1 Message Date
Byungchul Kim
f474e0b8f2 Fix incorrect python interpreter path of non-bzlmod
Remove duplicated "_host" suffix.

PiperOrigin-RevId: 819229058
2025-10-14 08:36:47 -07:00
Yun Peng
134503de2b Support building XLA with Bzlmod
- Added MODULE.bazel and module extensions to introduce external dependencies with Bzlmod.
- Added a CI config for Linux CPU build with Bzlmod (enabled by `--config=bzlmod`)

TODOs:
- Support overriding Python runtime
- Support build with more configs and platforms
PiperOrigin-RevId: 817711851
2025-10-10 11:09:33 -07:00
Yulia Baturina
735467e89c Fix protobuf.patch label in tensorflow repository.
PiperOrigin-RevId: 816890159
2025-10-08 15:54:58 -07:00
Yulia Baturina
b7ae3e4fcd Add released cpython 3.14 version in rules_python patch.
PiperOrigin-RevId: 816381097
2025-10-07 14:45:29 -07:00
Yun Peng
bfc4d2d2e4 Update pip dependency reference from @pypi_XXX//:pkg to @pypi//XXX.
The `@pypi_<name>` references are deprecated and their repo names are
an implementation detail of how an underlying library is downloaded.
The modern, supported, way is to go through the hub (`@pypi`). This
also makes the code compatible with both workspace and bzlmod.

PiperOrigin-RevId: 812915387
2025-09-29 13:31:45 -07:00
A. Unique TensorFlower
b1c831dd12 Replace local wheel file prefix file:// with file: for Windows platforms to fix installation of local wheels.
PiperOrigin-RevId: 811851560
2025-09-26 09:50:46 -07:00
A. Unique TensorFlower
db851a6e99 Fix freethreaded aarch64 builds in JAX.
The urls for all python versions can use `pgo+lto-full`.

PiperOrigin-RevId: 810595592
2025-09-23 15:28:20 -07:00
A. Unique TensorFlower
62b4c5b763 Add rules_python_versions.patch to fix usage of custom python versions.
A custom runtime can be specified by setting the `HERMETIC_PYTHON_URL`, which
may point to a mostly arbitrary URL, i.e. one not following the same format
as python-build-standalone URLs, such e.g. `file:///__w/jax/jax/python-tsan.tgz`.
Internally, some rules_python code assumes the python-build-standalone URL
format and eventually errors.

To fix, the python version is used to determine the URL build suffix.

This also patches the rule_python versions URL generation logic to add musl
to the list of platforms it generates freethreaded runtime urls for.

Work around for https://github.com/bazel-contrib/rules_python/issues/3285, https://github.com/bazel-contrib/rules_python/issues/3286

PiperOrigin-RevId: 810132685
2025-09-22 13:32:10 -07:00
A. Unique TensorFlower
bde9934322 Fix installation of local wheels by adjusting the wheel module names in the merged lock files.
Some wheels like `jax-cuda12-plugin` have `-` symbol in the name, but `_` symbol in the filename (e.g. `jax_cuda12_plugin-0.8.0.dev0+selfbuilt-cp313-cp313t-manylinux_2_27_x86_64.whl`). Older `rules_python` implementation didn't make a difference whether the lock file had `jax-cuda12-plugin` or `jax_cuda12_plugin` records. `rules_python` v1.6 treats them differently: if there are records like below, then the local wheel doesn't override the one that should be downloaded from pypi.

```
jax-cuda12-plugin==0.7.2 ; sys_platform == "linux" and python_version < "3.14" \
    --hash=sha256:05b6942985f015be82becd2cec363f0aceb25311981821d7613a51f630490e8c \
    --hash=sha256:1d00f9f5c5f68ae0f41cb7b589005ed5cb556517d65bbab5a891be46ed7a781c \
    --hash=sha256:23b8f1050c48b4020610fb818930d3cbe0304c6681b069687e5416ee349bd734 \
    --hash=sha256:2a727a89ae69ac21c1f5093d8d5aef89a0e692e66b034fc934c8accc72e40290 \
    --hash=sha256:45d5a1cbf0b9d05318722382fc71c4cede0c028bad6aa8e53f7a7032392f719c \
    --hash=sha256:5e3e2aa4d721fb02dd1028262aaeaec2958e45bca5c4d3512b29151b570cb425 \
    --hash=sha256:7212c12d75b7dc51275f271827df4a6d378430c06f650e6c31c162fe9579ff12 \
    --hash=sha256:7ad3afc51bcbc4e8117845d359e5d02cbc5ca2b152efdebd3c55fb9e4c2f848e \
    --hash=sha256:8284e7cf7f544906604f111702a6f0011a96df7f0113878b381bec0905172536 \
    --hash=sha256:98a975655382858d874d6471ce97194310609d0a2a7c4283c6e07e37933b7768 \
    --hash=sha256:adc924ebc7a45c8d3400ea0118dc70a7082b2a86e35711738d403dd3815d09bf \
    --hash=sha256:e881b56fe27e6870db2f2e9c574b81965fe1102b1532eae60e240a40c065daf5
    # via -r build/requirements.in

jax_cuda12_plugin @ file:///jax_cuda12_plugin-0.8.0.dev0+selfbuilt-cp311-cp311-manylinux_2_27_x86_64.whl

```

To fix this, `python_repo()` implementation was changed to add the local wheels with exactly the same module names as in the original lock file.

PiperOrigin-RevId: 809147267
2025-09-19 13:25:11 -07:00
A. Unique TensorFlower
94e89d1103 Fix freethreaded builds by passing HERMETIC_PYTHON_VERSION_KIND in repository rules.
The problem was that `@python_<>_host` repository wasn't aware of the python type (controlled by the build flag `@rules_python//python/config_settings:py_freethreaded`) and selected the first candidate, e.g. GIL version of the python.

PiperOrigin-RevId: 808825370
2025-09-18 18:54:36 -07:00
A. Unique TensorFlower
3eae65361b Update rules_python to v1.6 in XLA and TensorFlow projects.
`com_google_protobuf` and `rules_cc` initialization was moved to `python_init_rules` macros.

The JAX repository update will be done [in the next step](https://github.com/jax-ml/jax/pull/31709)

PiperOrigin-RevId: 808689003
2025-09-18 12:30:45 -07:00
A. Unique TensorFlower
5feca55740 Put NVIDIA wheels in ci/official/requirements_updater/nvidia-requirements.txt to have central place defining wheel versions.
This change is made to have consistency in parsing NVIDIA dependencies with [JAX repository](https://github.com/jax-ml/jax/pull/30706)

`nvidia-requirements.txt` is used in Bazel hermetic python lock files and in the `tools/pip_package/setup.py` with the package requirements.

The file content is saved in the `nvidia_wheel_versions repository` and passed as an argument to `modify_setup_py.py` that populates `setup_py.tpl` script.

PiperOrigin-RevId: 802755816
2025-09-03 16:57:17 -07:00
Richard Levasseur
a82378ba8e Allow passing extra patches to python_init_rules
This allows downstream projects to apply project-specific patches without
having to redefine the entire rules_python repo and the custom patches.

PiperOrigin-RevId: 792220068
2025-08-07 10:56:51 -07:00
Kanglan Tang
04a85585ab Fix python build standalone url for python 3.14-ft on aarch64-unknown-linux-gnu
The url for 3.14-ft uses `pgo+lto-full` instead of the `lto-full` found in the 3.13-ft url.

PiperOrigin-RevId: 789843742
2025-08-01 12:21:22 -07:00
Kanglan Tang
0960cc8ee0 Update rules_python patch file to get python 3.14.0rc1
Python 3.14.0rc1 was released, and [python-build-standalone](https://github.com/astral-sh/python-build-standalone/releases/tag/20250723) released support for it.

PiperOrigin-RevId: 787235978
2025-07-25 14:19:23 -07:00
A. Unique TensorFlower
32659eaf63 Update deps:
- grpc to 1.72.2
- pybind11 to 2.13.6
- pybind11_abseil to commit 13d4f99d5309df3d5afa80fe2ae332d7a2a64c6b
- pybind11_bazel to 2.13.6
- bazel-skylib to 1.7.1

PiperOrigin-RevId: 786616601
2025-07-24 02:30:32 -07:00
A. Unique TensorFlower
fd417fa133 Refactor py_import macros to avoid unpacking pypi wheels twice.
Instead, the macros and underlying rule copies all the files belonging to `:pkg` target into the output dir.

Action wall time from JSON profiler tracing results:

Action   | Old implementation | New implementation
:------: | :----------------: | :----------------:
jaxlib/tools/jax_cuda_pjrt_py_import_unpacked_wheel   | 73,309.311 ms | 6,249.759 ms
jax_py_import_unpacked_wheel   | 631.268 ms             | 1,442.022 ms
jaxlib/tools/jaxlib_py_import_unpacked_wheel   | 8,807.849 ms       | 3,942.539 ms
jaxlib/tools/jax_cuda_plugin_py_import_unpacked_wheel  | 7,873.122 ms | 7,968.307 ms

PiperOrigin-RevId: 777741244
2025-06-30 15:32:14 -07:00
Kanglan Tang
f81238e3c0 Update rules_python patch file to get python 3.14.0b1
The python standalone repo supports python 3.14.0b1 now: https://github.com/astral-sh/python-build-standalone/releases/tag/20250604.

PiperOrigin-RevId: 769281706
2025-06-09 14:02:18 -07:00
David Dunleavy
c5f3cdb243 Internal dir restructure
PiperOrigin-RevId: 756084150
2025-05-07 18:32:02 -07:00
Kanglan Tang
f52e681448 Fix: Use the prerelease label for Python 3.14.0a6 rules_python url path
Without including `a6` in the url, the file cannot be found by bazel.

PiperOrigin-RevId: 753375367
2025-04-30 17:38:47 -07:00
Kanglan Tang
800b32d996 Update rules_python patch file to get python 3.14.0a6
PiperOrigin-RevId: 752374982
2025-04-28 11:25:55 -07:00
Peter Hawkins
552c1ee1c7 Patch rules_python to support free-threading.
Forked from https://github.com/openxla/xla/pull/25183

Without this change rules_python doesn't correctly install free-threaded wheels for a free-threaded Python build.

PiperOrigin-RevId: 749128015
2025-04-18 14:14:16 -07:00
Nitin Srinivasan
a115df9ae7 Update rules_python2.patch to download archives from python-build-standalone's new location
Stewardship of python-build-standalone repo was transferred to Astral: https://github.com/astral-sh/python-build-standalone/discussions/396

This also fixes JAX's Windows Python 3.13 build: https://btx.cloud.google.com/invocations/89927854-5ee3-4cee-bf6a-f9f607d95ef8/log

PiperOrigin-RevId: 747607057
2025-04-14 17:10:44 -07:00
vfdev-5
464bc87b03 Updated rules_python patch to get 3.13.2 python 2025-04-11 14:18:12 +00:00
vfdev
0ea6e0a60a PR #24255: Fixed rules_python patch for python 3.14
Imported from GitHub PR https://github.com/openxla/xla/pull/24255

Returning from finally clause raises SyntaxWarning in python 3.14

cc @hawkinsp
Copybara import of the project:

--
2f7a929473cc67b3498ed88df4ab8e080e7def0f by vfdev-5 <vfdev.5@gmail.com>:

Fixed rules_python patch for python 3.14

Returning from finally clause raises SyntaxWarning in python 3.14

Merging this change closes #24255

PiperOrigin-RevId: 741203333
2025-03-27 10:57:42 -07:00
David Dunleavy
994febe935 Add .bazel suffix to some third_party files
PiperOrigin-RevId: 734359305
2025-03-06 18:29:15 -08:00
A. Unique TensorFlower
bd4d8fccee Fix Win2022 RBE builds.
PiperOrigin-RevId: 733764869
2025-03-05 09:41:11 -08:00
David Dunleavy
40998f44c0 Move TSL's third_party to XLA, update users
Mostly updating `WORKSPACE` and related files from `@tsl//third_party` -> `@xla//third_party`. Please tag me if this change breaks you.

PiperOrigin-RevId: 733489153
2025-03-04 15:51:50 -08:00
Vladimir Belitskiy
e69ca844ce Patch rules_python to point to the newest Python 3.12 patch version.
This should hopefully resolve Windows RBE test runs on Python3.12 flaking with
WMI query errors (https://github.com/python/cpython/issues/125315).

PiperOrigin-RevId: 730930044
2025-02-25 10:32:39 -08:00
Antonio Sanchez
c49fbe6cc0 Update ml_dtypes version and path.
The include paths for headers within the ml_dtypes package have changed.
We therefore need to adjust the TF/XLA build rules and paths to account
for this.  Also updated the pip ml_dtypes version to match.

The main ml_dtypes repo name needed to be changed to avoid
conflicts with the ml_dtypes subfolder.  The subfolder contains the main
python package that needs to be added to the PYTHON_PATH.

PiperOrigin-RevId: 723654395
2025-02-05 14:47:55 -08:00
A. Unique TensorFlower
25a0fd1b4f Fix mxfloat build dependencies and remove test BUILD file, to remove duplication.
PiperOrigin-RevId: 720447556
2025-01-27 23:33:57 -08:00
Reed Wanderman-Milne
42bd1d3c65 Update ml_dtypes version to 0fa5313b65efe848c5968a15dd37dd220cc29567.
Also add mxfloat as a dependency to TensorFlow and TSL. This is needed to merge https://github.com/openxla/xla/pull/19096. Previously this was done in the merge commit for that PR, but the PR was rolled back since the new types caused an internal TF Android build to fail. Now it's being done in this separate, smaller change so its easier to rollback if issues occur.

PiperOrigin-RevId: 714285735
2025-01-10 18:19:57 -08:00
Peter Hawkins
5f9409e7b2 Update packaging and pip versions in rules_python to enable freethreading support.
The same change has been sent upstream as https://github.com/bazelbuild/rules_python/pull/2514

Forked from https://github.com/openxla/xla/pull/20723 for merging.

PiperOrigin-RevId: 712538044
2025-01-06 08:36:22 -08:00
A. Unique TensorFlower
49d80051ec Replace manyLinux compliance check action in TF wheel build rule with macros for Linux platforms.
Example of usage:

```
load(
    "@tsl//:third_party/py/py_manylinux_compliance_test.bzl",
    "verify_manylinux_compliance_test",
)

verify_manylinux_compliance_test(
    name = "manylinux_compliance_test",
    aarch64_compliance_tag = "manylinux_2_17_aarch64",
    test_tags = [
        "mac_excluded",
        "windows_excluded",
    ],
    wheel = ":wheel",
    x86_64_compliance_tag = "manylinux_2_17_x86_64",
)
```

The test target is executed only when specified in Bazel command line. The test passes if `auditwheel show` results have the compliance tag value (depends on the machine type). The test fails otherwise and prints the `auditwheel show` results.

PiperOrigin-RevId: 708024471
2024-12-19 14:17:53 -08:00
Amit Sabne
5c562ebf1c [XLA] Add S1 and U1 as data types
PiperOrigin-RevId: 707136925
2024-12-17 10:04:59 -08:00
Vadym Matsishevskyi
bb90355488 Add more flexible custom hermetic Python setup
PiperOrigin-RevId: 700855957
2024-11-27 18:18:35 -08:00
vfdev
6332b90c66 PR #19346: Bumped rules_python version to 0.39.0
Imported from GitHub PR https://github.com/openxla/xla/pull/19346

cc @hawkinsp
Copybara import of the project:

--
292e7ebb7ee57e5af5977c08f0aaf28fc1f852e2 by vfdev-5 <vfdev.5@gmail.com>:

Bumped rules_python version to 0.39.0

Merging this change closes #19346

PiperOrigin-RevId: 699100796
2024-11-22 02:42:21 -08:00
A. Unique TensorFlower
2b6976dd8a Refactor TF wheel build rule, common python rules and flag names.
For Linux platforms the build rule generates the `auditwheel show` log in the output regardless of compliance check flag.

PiperOrigin-RevId: 698048983
2024-11-19 09:55:09 -08:00
A. Unique TensorFlower
5667b2dfa8 Add TF wheel compliance verification in Bazel build rule.
The compliance check is disabled by default, but can be turned on by `--@local_tsl//third_party/py:wheel_compliance=true` option.

PiperOrigin-RevId: 695870736
2024-11-12 14:33:28 -08:00
Sergey Kozub
0431df7fd4 Bump ml_dtypes version to include MX floating point types
Bumping the jax-ml/ml_dtypes version:

Unblocks the implementation of MX floating point types in XLA (https://github.com/openxla/xla/discussions/18085)
Allows enabling E3M4/E4M3 dtypes in XLA python client (https://github.com/openxla/xla/blob/main/xla/python/xla_client.py#L279)

This closes https://github.com/openxla/xla/pull/18198

PiperOrigin-RevId: 693502196
2024-11-05 16:01:32 -08:00
A. Unique TensorFlower
58a9b3ae13 Refactor tf_wheel build rule: return wheel file instead of wheel containing folder.
This change will enable future Bazel tests that use wheel build rule.

PiperOrigin-RevId: 689003106
2024-10-23 10:29:27 -07:00
A. Unique TensorFlower
82d1840d20 Move wheel_dependency flag to TSL repository.
PiperOrigin-RevId: 688223277
2024-10-21 12:11:27 -07:00
Vadym Matsishevskyi
5720ab7845 Introduce pywrap bazel rules and migrate Tensorflow to it
The gist of this change (the new rules implementation) is contained within `rules_pywrap` folder. The rules are generic and not tensorflow-specific

1) (internal-specific)

2) (internal-specific)

3) It provides same linking strategy of final artifacts on all 3 supported platforms (no major differences between Linux, Mac and Windows).

4) It makes it possible to abandon usage of header-only targets to prevent ODR violations. Simply speaking you can now depend on generated protobuf message classes normally, without need to worry how that is linked afterwards.

5) The current version is backward-compatible and unless explicitly enabled is a no-op. To enable the new rules pass `--repo_env=USE_PYWRAP_RULES=True` flag to build/test command.

6) The `if_pywrap` construct is temporary and will be removed once full migration is completed. Currently if_pywrap is mainly used to pass normal dependencies (instead of header-only). The header-only stuff is kept for backward compatibility and smoother migration but will be eventually removed.

7) This CL migrates TF and the most problematic among all google ML repositories. Once TF is sabilized the other repositories, such as JAX and XLA will be migrated too (which should be way easier than migrating TF anyways)

PiperOrigin-RevId: 684324990
2024-10-10 00:12:03 -07:00
A. Unique TensorFlower
e5b160bd70 Update rules_python.patch to support Python 3.13.0 and update python 3.13 packages in JAX.
The downloaded Python `tar.gz` files should have suffix `install_only`.

PiperOrigin-RevId: 684113192
2024-10-09 12:15:57 -07:00
A. Unique TensorFlower
55ca3b150c Add TF wheel API test.
This test verifies whether the API v2 packages can be imported from the
current build. It utilizes the `_api/v2/api_packages.txt` list of packages from
the local wheel file specified in the `requirements_lock_<python_version>.txt`.

The test should be executed after the TF wheel was built and put into `dist` dir inside Tensorflow repository.

PiperOrigin-RevId: 676893008
2024-09-20 10:43:17 -07:00
Alexander Pivovarov
1d7a921409 [TSL] Bump ml_dtypes. Add float8_e4m3, float8_e3m4
ml_dtypes Updates:
Add float8_e4m3 and float8_e3m4 types support
Fix float divmod with zero denominator
Add int2 and uint2 types
ml_dtypes/commits

Related PRs
ml_dtypes PR Add float8_e4m3 jax-ml/ml_dtypes#161 Add float8_e4m3 (Merged)
XLA PR Add support for float8_e4m3 #16585 (In Review)

This closes https://github.com/openxla/xla/pull/17075

PiperOrigin-RevId: 675687080
2024-09-17 14:12:12 -07:00
Vadym Matsishevskyi
ab504aaf07 Add Python 3.13.0rc2 support to rules_python in a form of a patch.
TODO: once rules_python has 3.13 out of the box, the patch can be safely removed.

rules_python does not depend on rc versions of Python (seems to be against its philosophy), while JAX wants to support it, that is why adding RC support in a form of a patch instead of adding it directly to rules_python.

PiperOrigin-RevId: 675261914
2024-09-16 13:14:21 -07:00
Vadym Matsishevskyi
0b49ca6c5a Minor fixes and documentation update for custom hermetic Python interpreter support.
PiperOrigin-RevId: 663784042
2024-08-16 11:40:24 -07:00
David Dunleavy
20e13667ba Update @rules_python to 0.34.0 after LLVM integrate
Should fix XLA/JAX CI

PiperOrigin-RevId: 655626888
2024-07-24 11:04:15 -07:00
Vadym Matsishevskyi
5dd1758095 Add support for local wheel whitelisting and blacklisting
Also fix python version matching logic for wheels which do not require a specific python version.

PiperOrigin-RevId: 650383841
2024-07-08 15:23:41 -07:00