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

44 commits

Author SHA1 Message Date
Corentin Godeau
59a888f7e2
third_party/zls: allow all 0.17 zig versions (#1036) 2026-11-06 15:14:38 +01:00
Damien Mehala
dd82a8a10b
third_party/zls: bump to 0.17.0 (#966) 2026-10-20 11:36:07 +02:00
Guillaume Wenzek
00a0af4a55
zig 0.17 (second attempt) (#923)
Bump for zig 0.17

Deps:
- uucode bumped to
1fb73433bb
- zigimg bumped to
734fa919fb
- libvaxis bumped to
14b7684272
- zio bumped to:
417757935e
- rules_zig upgraded to [version
0.17](https://github.com/hermeticbuild/rules_zig/releases/tag/v0.17.0)
- zls is using a commit from master, but they don't have yet a tagged
release so Codex did a bit of packaging. I confirmed it correctly
autocompletes on my machine
2026-10-13 17:11:38 +02:00
Corentin Kerisit
77711b949d
workspace: support zig-only local execution (#546)
This PR bumps rules_zig back to upstream/main where we now have all the
necessary
features to enable zig local actions while the reste on remote.

It also adds the necessary configurable to actually enable this.

Additionally, since rules_zig now ships ZLS support, we remove zls
entirely from zml.

### How the Bazel resolution works

Bazel resolves execution platforms and toolchains during analysis for
each
target that requires toolchains. If a rule defines exe, resolution
happens separately for the default target execution group and for each
`exec_group`;
actions assigned to an exec group use that group’s selected execution
platform
and toolchains.

Execution platforms come from an ordered set. In this repository’s
remote
configuration, the relevant order is:

1. `//:rbe_platform`, supplied by
`--extra_execution_platforms=@zml//:rbe_platform`
2. `//bazel/zig_toolchain_config:local_execution_platform`, registered
by this PR
3. the host platform, included automatically by Bazel

Earlier platforms are selected when they can satisfy the requested
toolchains.

For each target or exec group, Bazel takes the required toolchain types,
the
target platform, the ordered execution platforms, and the ordered
registered
toolchains. It filters execution platforms by execution constraints,
then tries
to find a matching toolchain for every required toolchain type. A
toolchain
matches when:

- its `exec_compatible_with` constraints are present on the candidate
execution
platform
- its `target_compatible_with` constraints are present on the target
platform
- its `target_settings` match the current configuration

Any execution platform missing a required toolchain is rejected. The
first
remaining execution platform wins, and the first matching toolchain for
each type
is selected.

### How this makes Zig local-only

This PR defines a custom execution constraint:

- `//bazel/zig_toolchain_config:local_zig_execution`

It then defines a host-derived execution platform:

- `//bazel/zig_toolchain_config:local_execution_platform`

That platform inherits the host OS/CPU constraints from
`@platforms//host`, adds
`local_zig_execution`, and sets:

```starlark
exec_properties = {
    "no-remote-exec": "1",
}
```

The zig.toolchain(...) module extension call now passes:

extra_exec_compatible_with =
["//bazel/zig_toolchain_config:local_zig_execution"]

rules_zig appends that extra execution constraint to every generated Zig
SDK
toolchain. As a result, when rules_zig resolves
@rules_zig//zig:toolchain_type
for its zig execution group:

- the remote execution platform is considered first, but it does not
have
local_zig_execution, so it cannot match the Zig SDK toolchain
- the custom local execution platform has both the host OS/CPU
constraints and
local_zig_execution, so it matches
- the selected platform carries no-remote-exec, so Zig actions execute
locally
even in remote builds

Other toolchains are not constrained by local_zig_execution, so they can
continue
to resolve to the remote execution platform first. This keeps the build
remote by
default while carving out Zig actions as local-only.

---------

Co-authored-by: Steeve Morin <steeve@zml.ai>
2026-05-20 16:13:59 +02:00
Corentin Kerisit
55474ea31f
zls: resolve translate-c toolchain in zls rules (#538)
This one slipped from #537 

It worked because if there is no translate-c toolchain, zig uses zig
translate-c.
But we want to respect user choice here too.
2026-05-16 09:58:34 +02:00
Corentin Kerisit
886d9000be
workspace: use latest version of upstreamable rules_zig (#537)
The upstreamable branch now contains only 2 minor commits. Everything
else inccluding test-obj, translatec and bootstrap have been upstreamed.
2026-05-15 21:01:50 +02:00
loupicaaa
dd0ab6c334
zml/moe : Moe backend triton zig, qwen3_5_moe model (#529)
### Overview
Context: Modern models utilize a MLP called Mixture of Experts (MoE). In
a MoE, the MLP is organized into "experts," where specific sub-tensors
are specialized to process particular linguistic patterns or elements.
During inference, the hidden states of each token are routed to the most
relevant experts, ensuring that matrix multiplications (matmul) are
performed only on the active parameters.

Problem: Due to the sparse and dynamic nature of MoE where token
assignment is determined at runtime via routing, treating an MoE layer
as a standard matmul results in significant performance degradation.
Standard kernels are not optimized for the irregular memory access
patterns in sparse routing.

Approach: MoE is implemented as a primitive in the ZML operation set.
The generic MoE Backend is designed to support various specialized
kernels tailored to specific hardware and weight precisions. The primary
implementation currently features a Triton MoE backend optimized for
NVIDIA Hopper architecture using BF16 and FP8 weights. This
implementation is utilized in the Qwen 3.5 MoE model.

### Features
**Generic MoE Backend (zml/moe/moe.zig)**
- Integrate specialized MoE backends (e.g., Triton).
- Select the optimal backend based on hardware and precision.
- Implements essential utilities and structures for registration,
parameter loading, and metadata management.
- The forwardMoe() function acts as the entry point to invoke the
appropriate backend.

**Triton MoE Backend (zml/moe/triton.zig)**
- Generates TTIR (Triton Intermediate Representation) at compile time.
- Leverages Triton's custom calls exposed via XLA.
Execution Flow:
1. Select the optimal configuration for the fused MoE kernel.
2. Determine token distribution: use naive assignment if the
distribution is sparse; otherwise, sort and align tokens for efficiency.
3. Quantization: quantize activations if using FP8 weights.
4. Fused Kernel: execute the fused MoE kernel for the gate and
up-projection layers.
5. Post-Processing: split the output and apply the activation function.
6. Quantization : re-quantize activations for the next stage if required
by the FP8 path.
7. Fused Kernel: execute the fused MoE kernel for the down-projection
layer.
8. Aggregation: sum the Top-K results for each token.

Qwen 3.5 MoE
- Fully utilizes the Triton MoE backend.
- BF16 weights implementation (also tested with FP8 but not implemented
here)

---------

Co-authored-by: loupicaaa <louis@zml.ai>
Co-authored-by: Raphael NAHOUM <raphael@zml.ai>
2026-05-15 11:06:02 +02:00
Steeve Morin
c8cc476042 third_party/zls: adapt to rules_zig changes
notably when using with_cfg targets
2026-05-13 11:35:34 +00:00
Kevin Barre
0fd551e4d5
zml/zls: Add compatibility for aarch64-linux platform in zls_toolchain (#508) 2026-04-28 09:32:40 +02:00
Corentin Kerisit
bd66cfa1f3
Update ZLS to 0.16.0 and rules_zig new providers (#483)
Bump rules_zig to latest zig_toolchain changes (for bootstrap)
Bump ZLS to 0.16.0
Amend ZLS completion rules and runners to match rules_zig new providers
2026-04-17 13:42:37 +02:00
Hugo Mano
8b12d2ef1e
bazel: make repo-wide cquery work across host and linux target analysis (#465)
This PR fixes several Bazel analysis regressions so both of these
commands work reliably:

- `bazel cquery //...`
- `bazel cquery --platforms=@zml//platforms:linux_amd64 //...`

After recent changes and the rebase, repo-wide cquery was failing for
three separate reasons:

- ZLS toolchains were over-constrained by target platform: updated ZLS
toolchain registration to constrain only the exec platform.
This avoids cross-target analysis failures when host-side completion
tooling is analyzed under a foreign target platform.
- OCI packaging targets were analyzed on host platforms where their base
images do not apply: marked Linux OCI image targets as Linux x86_64
compatible only. Also switched the Debian base image pull from Docker
Hub to the GCR mirror to avoid CI fetch failures when resolving
packaging images manifests due to rate limiting
- Triton Python deps were fetched for the host Python platform instead
of the Linux wheel platform the lockfile was generated for: restored
Linux x86_64 wheel resolution for `triton_py_deps` in `MODULE.bazel`.
This prevents macOS host analysis from attempting to fetch a
`triton==3.6.0` wheel for an unsupported host platform.


Also added a step in ci to prevent regression
2026-04-17 11:48:09 +02:00
Hugo Mano
a68f0f9c85
workspace/zls: add non regression test (#426) 2026-03-23 18:33:02 +01:00
Benjamin Rabier
3b76703430
workspace: fixes for build and test //... green
Fixes:
- Added `target_compatible_with = ["@platforms//os:linux"],` for neuron
& rocm
- Updated the zig in neuron
- Updated neuron to use Python 3.12, it's at best a mess to handle two
different python version with `build //...`
- renamed `third_party/flashattn/BUILD.bazel` to
`third_party/flashattn/flashattention.BUILD.bazel` as it's not part of
this module.
- Used HTTPS & fallback URL for swig, sometimes we would end up with an
incorrect archive (wrong sha256)
- Using `--@rules_python//python/config_settings:bootstrap_impl=script`
for hermetic Python build, it relied on the system Python otherwise.
- Used a separate pip extension for neuron to avoid the extra pip args
to leak to other installations.
- Fix `zml/testing` `fn autoCall` function

---------

Co-authored-by: Hugo Mano <hugo@zml.ai>
2026-03-23 14:55:48 +01:00
Steeve Morin
b065d976d3 third_party/zls: fix completion on single dep targets
take the opportunity to bump ZLS to a version compatible with our
current nighly.
2026-03-21 17:33:46 +01:00
Steeve Morin
06f13f9a22 platforms: uncompress http_archives using http_bsdtar_archive
Roughly a 2x speedup according to @cerisier. So take it for what it is.
2026-03-20 16:22:26 +00:00
Benjamin Rabier
9422836884
third_party/zls: Remove absent attributes from latest rules_zig (#414) 2026-03-17 18:06:31 +01:00
Benjamin Rabier
c7ca488f3b
third_party/zls: faillible canonicalization of modules (#406)
Files provided by bazel may not exist when zls starts, so
canonicalization would fail and break zls. Now we fall back to the
provided path instead. Furthermore, to make it a bit more robust, if any
part of the post process/canonicalization fails, we return the provided
input string instead of failing.

I'm now also using the same struct definition as ZLS instead of
manipulating `std.json.Value`.
2026-03-10 09:34:22 +01:00
Benjamin Rabier
1df41a8ee1
zls: neovim fix canonicalizing paths (#399)
- Fix incorrect build config path by using runfiles.
- Canonicalize paths like neovim does for ZLS (doesn't work otherwise)
2026-03-04 08:05:37 +01:00
Benjamin Rabier
8f85fc1c06
bazel: fix zls completion for zig_test (#389)
Co-authored-by: Benjamin Rabier <benjamin@zml.ai>
2026-02-24 09:52:19 +01:00
Steeve Morin
44f28b0335 third_party/zls: allow using outside of ZML repo 2026-02-16 20:52:23 +00:00
Steeve Morin
f64ad1ef79 workspace: remove apple_support 2026-02-16 19:59:38 +00:00
Steeve Morin
51a36fa8d8 third_party/zls: update hashes 2026-02-16 14:13:14 +00:00
Steeve Morin
dcbf5f2e27 workspace: update to 0.16.0-dev.2611+f996d2866, add remote exec
also:
- use toolchains_llvm_bootstrapped for macOS builds
2026-02-16 12:05:01 +01:00
Steeve Morin
3a94593467 workspace: fix and bump ZLS 2026-01-06 09:05:56 +00:00
Steeve Morin
e7ee7175dd third_party/zls: update to 0.16.0-dev.82+cbb62284 2026-01-06 08:54:16 +00:00
Corentin Kerisit
0f1d49daf4 Fix ZLS 2026-01-05 16:02:06 +00:00
Steeve Morin
db3ded4f80 WIP 2026-01-01 08:49:18 +00:00
Corentin Kerisit
299aaac7a7 cc_infos should be exposed as direct since translate_c use direct_public_headers 2025-12-05 16:08:15 +01:00
Corentin Kerisit
ddb05f5cde Remove cat 2025-12-02 16:26:23 +01:00
Corentin Kerisit
55b2073542 fix workspace_printer for all versions of zig 2025-12-02 16:23:25 +01:00
Steeve Morin
133abd1c7f WIP 2025-12-02 15:21:57 +01:00
Steeve Morin
de6b1a570b WIP 2025-12-02 15:21:25 +01:00
Steeve Morin
36760aec62 WIPREADER 2025-12-02 14:31:52 +01:00
Guillaume Wenzek
e58a5359f9
zml/aio: fix pickle loader for Zig 0.15.2 (#354)
zig 0.15.2 changed the meaning of `reader.takeDelimiterExclusive` to not
consume the separator. I rewrote the code to use
`takeDelimiterInclusive` since we want to consume the delimiter.
2025-10-22 17:43:44 +02:00
Corentin Kerisit
892766c652
zls: add missing cc toolchain (#347) 2025-10-17 19:04:39 +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
Guillaume Wenzek
df77b33d8e
async: remove asynk, asyncc, awaitt, await_ (#325) 2025-09-18 10:05:54 +02:00
Steeve Morin
6df48e39de
workspace: make zls runner target explicit (#240)
Easier for future reference
2025-05-29 23:04:20 +02:00
Victor Moin
3fd5c49c32
workspace: fix ZLS macOS x86_64 incorrect checksum (#214) 2025-03-27 15:13:28 +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
e0041974d2
workspace: rework code completion using a custom build runner (#131)
Following the new release of the VSCode Zig plugin, rework the code
completion logic to leverage a build runner. This is much lighter,
faster and more reliable.
2024-12-16 13:20:27 +01:00
Steeve Morin
13d84615bb zml: initial release 2024-09-17 11:11:18 +02:00