0
Fork 0
mirror of https://github.com/zml/zml.git synced 2026-11-16 19:11:09 +00:00
Commit graph

63 commits

Author SHA1 Message Date
Hugo Mano
e5bc971c75
xla: bump to 9a77a88 (#357) 2025-11-12 11:55:48 +01:00
Corentin Kerisit
06842784d3
workspace: use apple_support cc toolchains vs rules_cc (#355)
This is the recommended toolchain and is where all further improvements
is done.
2025-10-28 17:08:23 +01:00
Corentin Kerisit
e2c27b790b
workspace: default to LLVM backend for all zig compile actions (#356)
Use the new zigopt global setting from rules_zig to set -fllvm to all
zig copmile actions.

The Zig self-hosted backend is more fragile that we thought before. It
fails in numerous cases, in debug, but also in release sometimes. USe
LLVM backend until it is more stable.
2025-10-28 17:06:48 +01:00
Guillaume Wenzek
13aa52b1d7
tools/hf: add hf_transfer implicit dependency (#344)
Fix #339
2025-10-20 12:28:45 +02:00
Corentin Kerisit
711ed46f5b
workspace: update zig version to 0.15.2 (#349) 2025-10-17 19:05:47 +02:00
Corentin Kerisit
2613c1137c
workspace: use rules_zig archive_override pre 0.12.2 (#345)
Fixes shared_library and PJRT loading.
Fixes os/log.h non inclusion.
2025-10-17 19:04:17 +02:00
Corentin Kerisit
bc05231f30
workspace: use libxev from the BCR (#341)
This marks the last PR for getting out of our custom registry.

Module is now at https://registry.bazel.build/modules/libxev and @steeve
is a maintainer as well.
2025-10-16 11:48:09 +02:00
Corentin Kerisit
36d583dd58
workspace: use upstreamed rules_zig instead of our fork (#340)
This PR uses the new release of rules_zig where we upstreamed all the
work from the zml rules_zig fork.

Not much changes from the POV of the public API except for `copts`
becoming `zigopts`.

Also, the global `c` module is only available to Zig modules that depend
on a non empty `cc_library`.
This is behavior that can probably be modified in `rules_zig` later on.

Finally, ZLS support had to be completely rethought to comply with the
change in shape of ZigModuleInfo providers and subsequent rules.

This PR is blocked until `rules_zig` exposes `ZigModuleInfo` for
`zig_binaries`.
2025-10-13 14:34:33 +02:00
Steeve Morin
57fd9cda27
workspace: zig 0.15 (#316)
Much of the work was done by @gwenzek

Sadly we drop the torch loader in the process, to be added back later !

---------

Co-authored-by: Guillaume Wenzek <wzk@zml.ai>
2025-08-27 14:11:22 +02:00
Steeve Morin
5f3a2e74c3
workspace: buildifier pass, remove rules_uv, rework tools/hf deps (#315)
Title says it all
2025-08-22 16:37:36 +02:00
Steeve Morin
fc384eb43e
runtimes/neuron: fix neuron runtime (#314)
This PR fixes the neuron runtime with the following:

Proxy the PJRT Api method to enforce the client struct sizes since the
neuron PJRT plugin doesn't use `>=` but `==` to assert them, breaking
PJRT compatibility guarantees.
Fixes https://github.com/aws-neuron/aws-neuron-sdk/issues/1095

Reimplement `libneuronxla` in Zig to control neuronx-cc sandboxing and
invocation.

Implement a python bootstrapper in Zig to create a full blown
`neuronx-cc` executable, avoiding the infamous chicken and egg problem
of python executables boostrapping when sandboxed (due to fixed path
shebangs).

---------

Co-authored-by: Corentin Kerisit <corentin.kerisit@gmail.com>
2025-08-22 16:28:23 +02:00
Steeve Morin
24575c2232
workspace: switch from zig_cc_binary to zig_binary (#311)
Following the rules_zig bump that adds the `linkmode` setting, we can
use the C linker directly.

We can now remove the `zig_cc_binary` hack.
2025-08-21 13:12:15 +02:00
Steeve Morin
cd8a65334f
zml: remove nemo, sentencepiece loaders, remove zig-yaml (#310)
Progress towards #298
2025-08-20 00:15:55 +02:00
Steeve Morin
de4a0e0beb
third_party/xla: de-modularize xla (#309)
This PR intends to remove XLA as a bzlmod and transfer it as a non
bzlmod dep.

This is because this module will never be upstreamed as is, so keep it
private.

Also, we fetch llvm-raw and stablehlo from it, which is fine.

While there, dummify the various local_config XLA symbols to please the
imports, as we don't use those parts in ZML itself.

Closes #305
2025-08-19 23:35:01 +02:00
Steeve Morin
3b81c5630e
zml: remove examples workspace (#308)
Closes #302
2025-08-19 19:42:50 +02:00
Steeve Morin
2044cd2de5
zml: remove zig-protobuf, switch to upb (#307)
Closes #301
2025-08-19 16:14:54 +02:00
Guillaume Wenzek
9f2ccf8a54
package HF cli so users don't have to create Python venv (#293) 2025-08-01 16:42:29 +02:00
Corentin Kerisit
52d36e1c7e
runtimes/neuron: sandbox neuron dependencies (#290)
The difference with other sandboxing PRs is that we also define a
trampoline PJRT so file which will prove itself useful to circumvent
PJRT version mismatch because of
https://github.com/aws-neuron/aws-neuron-sdk/issues/1095

Additionally, we artificially create a empty repository so that we can
sandbox the distroless deps inside the neuron module extension.

---------

Co-authored-by: EC2 Default User <ec2-user@ip-172-31-64-93.ec2.internal>
2025-07-25 11:35:04 +02:00
Hugo Mano
4cf4ee3c14
workspace: xla 20250718.0-6319f0d with ROCm 6.4.1 (#289)
Note: CUDA plugin is not bumped due to an error with libnvptxcompiler. A
specific update will be done in another commit.
2025-07-22 23:50:38 +02:00
Guillaume Wenzek
ba8ff439ba
protobuf, libxev: remove usingnamespace (#280)
remove usingnamespace from libxev and zig-protobuf
    
relevant PRs:
* libxev:
7f803181b1
 * zig-protobuf: https://github.com/zml/zig-protobuf/pull/1/files

This means we can now build ZML with `-fincremental` (in debug mode only
and linux x86-64)

---------

Signed-off-by: Guillaume Wenzek <wzk@zml.ai>
2025-07-21 18:03:01 +02:00
Steeve Morin
81fa2ec44c
workspace: disable glibc constraint, bump rules_rust, re-enable framepointers (#286)
Since the rework of runtimes sandboxing, explicitely compiling against a certain glibc version isn't needed anymore.
2025-07-17 18:20:07 +02:00
Corentin Kerisit
4362fe323e
workspace: bump rules_zig to 20250714.0-b14a4f1 (#283)
This dummy fixes the presence of the static-lib in the runfiles of the
final target in case of kind != exe.
2025-07-16 18:01:09 +02:00
Corentin Kerisit
4c14652fb7
runtimes/rocm: sandbox ROCm dependencies (#276)
ROCm counterpart of #275 

The most important thing with this change is that ROCm dependencies
(along with the PJRT plugin) must be loaded in the main thread.

This is because some ROCm dependencies (amdhip64) use Thread Local
Storage in the destructor of static C++ instances.
Because all dependencies are unloaded at exit of the main program,
destructors are run on whatever thread exited (in general the main
thread), and any access to the TLS will except values from a different
threads....
2025-07-16 14:41:07 +02:00
Corentin Kerisit
8274f9c2c0
runtimes/cuda: sandbox CUDA dependencies (#275)
This PR introduces CUDA sandboxing.

This essentially means:
- Removing all CUDA related dependencies off the leaf binary.
- Sandboxing the whole CUDA dependency graph.
- Mark dlopen direct dependencies of the PJRT shared library as NEEDED.
- Set the RPATH to the sandbox for all libraries that have sandbox
dependencies.
- Load the PJRT plugin from the sandbox.

And in the case of CUDA specifically for now:
- Enable usage of weak CUDA symbols without linking against CUDA
directly.
2025-07-16 11:33:48 +02:00
Corentin Kerisit
57abcb5aab
workspace: bump toolchains_llvm_bootstrapped to 0.2.4 (#274)
This update is important because it orders correctly the CRT which
contains .init and .fini family sections.
2025-07-15 14:54:57 +02:00
Guillaume Wenzek
ee1163a113
Bump rules_zig, add zig_srcs targets, cleanup build (#267)
This is the non-controversial part of #262 

It contains:
* the new `zig_srcs` helper,
* bug fix related to sources in rules_zig,
* cleanups of zml/BUILD.bazel
* test fixes in async/coro.zig (those tests weren't run in CI but now
are)
* disabled nemo and yaml models loader (don't compile anymore since
0.14.0 bump)
2025-07-15 14:18:15 +02:00
Hugo Mano
b0168d1c63
workspace: bump xla to version 20250710.0-22ea002 (#271)
Also:
- Bump XLA deps : `com_github_grpc_grpc` and `com_google_protobuf`
- Inject `rules_ml_toolchain`
- Fix `zig_proto_library` rule
2025-07-11 17:45:57 +02:00
Corentin Godeau
989d85be2a
workspace: bump xla to version 20250612.0-6e48cbb (#263) 2025-06-16 17:37:57 +02:00
Steeve Morin
2502c44c0f
workspace: switch to toolchains_llvm_bootstrapped (#245)
Notably, this will enable using custom linkers or enable LTO.

---------

Co-authored-by: Corentin Kerisit <corentin.kerisit@gmail.com>
2025-06-05 21:45:15 +02:00
Hugo Mano
bde41243bc
workspace: bump xla to version 20250527.0-cb67f2f (#238)
third_party/modules/xla: refactor XLA module extensions
ci: disable failing cache temporarily

XLA diff:
71c67e2a4f...cb67f2f7ce

---------

Co-authored-by: Steeve Morin <steeve@zml.ai>
2025-06-02 21:44:39 +02:00
Steeve Morin
23c7335592
workspace: bump to zig=0.14.1 (#242)
In the process, add a case where an empty tuple syntax (`&.{}`) was
detected as `*const @TypeOf(.{})`
2025-05-30 16:51:55 +02:00
Steeve Morin
42cf435f48
runtimes/neuron: bump runtime (#241)
In the process, expose the `nrt.h` header to zig.
2025-05-29 23:40:51 +02:00
Steeve Morin
a566e396d2
workspace: add debug/release configurations and various stdx (#234)
This PR bumps rules_zig to add command line to the zig compilation in
order to enable debug and release configs from the bazel command line
(and bazelrc).

Most notably, this is useful for passing `-mcpu` flags to Zig
(especially for SIMD support like AVX512).

While we're there, add `stdx.time.Duration.hz()` and
`stdx.math.roundeven()`.
2025-05-19 21:26:28 +02:00
Steeve Morin
7ccfeaf524
workspace: various fixes and bumps (#229)
This PR add various fixes and bumps in the workspace, notably to prevent
dual builds for LLVM tools.
2025-04-22 16:12:26 +02:00
Guillaume Wenzek
7db76fdaeb
pjrt: add ffi bindings for custom calls (#223)
---------

Co-authored-by: Hugo Mano <hugo@zml.ai>
Co-authored-by: Corentin Kerisit <corentin.kerisit@gmail.com>
2025-04-08 16:28:39 +02:00
Steeve Morin
e0336dc9b3
workspace: fetch llvm, stablehlo and triton from xla, bump XLA (#206)
This enables making sure versions are the same across the board.

Also, import `triton` repo for later use.

---------

Co-authored-by: Hugo Mano <hugo@zml.ai>
2025-03-19 10:00:27 +01:00
Victor Moin
123082de35
runtimes: add macOS x86_64 (#175)
This PR showcases an initial implementation to run ZML on MacOS Intel
(x86_64). While Mac Intel is *deprecated*, this work allowed me to
contribute to [modernbert example](https://github.com/zml/zml/pull/149).
It relies on a custom
[pjrt-cpu_darwin-amd64.tar.gz](https://github.com/vctrmn/pjrt-artifacts/releases/download/v3.0.0-rc/pjrt-cpu_darwin-amd64.tar.gz),
which is not officially supported by the ZML team.

This PR __is not intended for merging__ but serves as a reference for
users who want to experiment with ZML on older Mac.

https://github.com/zml/zml/issues/105
2025-03-18 16:52:18 +01:00
Steeve Morin
a93c7631e5
workspace,third_party/rules_zig: minor fixes for zls+zig 0.14.0 (#200)
ZLS now requires `--version` to be the first param, account for that.

Also, added missing keys to the BuildConfig object used for code
completion.
2025-03-14 13:42:10 +01:00
Guillaume Wenzek
a85b53fba0
zig 0.14.0 (#189)
Co-authored-by: Hugo Mano <hugo@zml.ai>
2025-03-14 09:49:23 +01:00
Steeve Morin
5bb1d46640
workspace: rework runtimes sandboxing, bump PJRT plugins, cuda=12.8 and ROCm=6.3.4 (#199)
This PR significantly reworks the runtimes sandboxing to leverage
rules_distroless apt resolution, bump pjrt-artifacts=7.0.0 which inclues
Triton ROCm fixes.

Finally, bump CUDA=12.8 cuDNN=9.8, ROCm=6.3.4
2025-03-13 22:17:41 +01:00
jaco-bro
7e62b6551c
workspace: update rules_cc=0.1.1 and bazel=8.1.1 (#196)
This PR updates the `rules_cc` dependency from `0.1.0` to `0.1.1` and
the Bazel version from `8.0.1` to `8.1.1`.

### Changes:
1. Updated `rules_cc` version in `zml/MODULE.bazel` from 0.1.0 to 0.1.1:
    ```bazel
    bazel_dep(name = "rules_cc", version = "0.1.1")
    ```
2. Updated the Bazel version in `zml/examples/.bazelversion` from
`8.0.1` to `8.1.1`.

### Context:
1. Initially, running `bazel run -c opt //mnist` failed due to a Bazel
version mismatch (required `8.0.1` but the currently brew-installable
version is `8.1.1`). This was resolved by updating `.bazelversion`.
2. After fixing the Bazel version, the build failed again this time due
to a yanked version of `rules_cc` (`0.1.0`).

> ERROR: Error computing the main repository mapping: Yanked version
detected in your resolved dependency graph: rules_cc@0.1.0, for the
reason: rules_cc 0.1.0 is yanked due to incompatible change (prematurely
removing cc_proto_library from defs.bzl), please upgrade to 0.1.1.
> Yanked versions may contain serious vulnerabilities and should not be
used. To fix this, use a bazel_dep on a newer version of this module. To
continue using this version, allow it using the --allow_yanked_versions
flag or the BZLMOD_ALLOW_YANKED_VERSIONS env variable.

3. Updating `rules_cc` to `0.1.1` resolved this issue.

### Testing:
1. Verified the update by running:
    ```zsh
    git clone https://github.com/jaco-bro/zml
    cd zml/examples
    bazel run -c opt //mnist
    ```
2. The build and execution succeeded without errors.

    ```
    info(mnist): ✅ RECOGNIZED DIGIT:
               +-------------+
               |     ###     |
               |    #   #    |
               |   #     #   |
               |   #     #   |
               |   #     #   |
               |    #   #    |
               |     ###     |
               +-------------+
    ```
2025-03-03 16:46:50 +01:00
Steeve Morin
cb1010948b
workspace: bump to libxev=20250222.0-07bcffa (#197)
This introduces `Dynamic`, which will switch between IO Uring and Epoll
in linux depending on availablity.
2025-03-03 16:46:34 +01:00
Hugo Mano
d712ab7534
workspace: fix libxev version (#195) 2025-02-21 12:48:00 +01:00
Corentin Kerisit
44b74dea40
workspace: fix mistakes in modules bumps (#191)
Fix missing = in stbalehlo integrity.
Changes back - by . in xla module name and folders.
Correctly depend on `xla@20250204.1-6789523`
2025-02-18 15:54:56 +01:00
Corentin Kerisit
9227fc9ad4
stablehlo: bump to head and use new dialect capi (#190)
This drastically reduce the number of build steps (from 3589 to 2553 steps)
2025-02-17 18:43:07 +01:00
Hugo Mano
ceec8a8c9a
workspace: bump xla to version 20250204.0-6789523 (#184)
Also improves Bazel 8 compatibility

---------

Co-authored-by: Corentin Kerisit <corentin.kerisit@gmail.com>
2025-02-07 15:36:15 +01:00
Steeve Morin
86dc444964
workspace: MODULE.bazel cleanup (#183)
Title says it all !
2025-02-05 17:34:06 +01:00
Steeve Morin
cbd9e50a79
workspace: bump libxev to 20252401.0-31eed4e (#182)
Includes:
- https://github.com/mitchellh/libxev/pull/128
- https://github.com/mitchellh/libxev/pull/141
2025-02-05 13:40:03 +01:00
Corentin Kerisit
71fa3764d1
bazel: use prebuilt protoc binaries (#178)
This removes ~1300 build steps by depending on prebuilt binaries.

Note that this PR is blocked by
https://github.com/aspect-build/toolchains_protoc/pull/44 since
`rules_proto` depends on `protobuf@29.1` and
https://github.com/aspect-build/toolchains_protoc doesn't expose
`protoc@29.1` and we can't pin module versions unless adding an entry in
the local BCR which I think is overkill for this.
2025-01-31 23:12:04 +01:00
Rene Schallner
f41e023e22
zml/tokenizer: use HuggingFace Tokenizers and SentencePiece & Llama improvements (#162)
# HF tokenizers & Llama improvements

1. Added HuggingFace tokenizer and SentencePiece bindings, removed old
tokenizers
2. Improved Llama example

## 1. zml/tokenizer: add HuggingFace tokenizers binding, remove old
tokenizers

`zml.Tokenizer` now uses the new HuggingFace tokenizer bindings when
loading a `tokenizer.json`.

To move fast, we dropped the `tinyllama`, `gguf`, and `sentencepiece`
tokenizers.

## 2. examples/llama

Changes to the llama example:

- config.json support -> less cmdline flags
- switched to [zig-clap](https://github.com/Hejsil/zig-clap) for cmdline
args parsing
- using HuggingFace tokenizer
- re-worked and simplified the code
    - single token prediction
- removed esoteric models from BUILD.bazel
- default container now uses Llama-3.2-1B-Instruct

---------

Co-authored-by: Steeve Morin <steeve@zml.ai>
Co-authored-by: Corentin Godeau <corentin.godeau@zml.ai>
Co-authored-by: Corentin Kerisit <corentin.kerisit@gmail.com>
2025-01-24 18:25:57 +01:00