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

30 commits

Author SHA1 Message Date
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
Guillaume Wenzek
dda7f6c3f0
zml: remove old writer interface APIs (#324)
We still had a few old reader/writer left over.
I think we are good now
2025-09-18 11:36:23 +02:00
Guillaume Wenzek
df77b33d8e
async: remove asynk, asyncc, awaitt, await_ (#325) 2025-09-18 10:05:54 +02:00
Hugo Mano
5d6c04ec69
ci: revamp commit workflow (#320)
- Deduplicate workflows (introduced by
57fd9cda27)
- Fix linking issue on Linux since upb was introduced
- Fix duplicated `_start` symbol for some tests targets
- Temporarily use `-c opt` instead of `--config=debug` to bypass static
archive bug
2025-09-03 14:23:22 +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
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
Guillaume Wenzek
981b6becc3
remove usingnamespace from asyncio (#205)
Small PR to remove our last usingnamespace. 

Also usingnamespace will be out in 0.15.0:
https://github.com/ziglang/zig/pull/24362
2025-07-21 16:21:05 +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
Corentin Kerisit
00ebef1a32
async/coro: make coroutines unwindable (#273)
The first stack of each new coroutines were holding not zeroed and hold
random memory data, which get popped in rbp during first coroutine stack
swap.

Which made unwinding random or even SIGSEGV when _Unwind_Backtrace was
used (during C++ exception for instance).

Zeroing the first part of the stack makes unwinding stop gracefully when
it encounters $rbp=0x00.
2025-07-12 20:48:37 +02:00
Corentin Godeau
a6469229d2
async: use stronger memory ordering (#268)
This was probably causing a segfault on some specific ordering of
things.
2025-06-18 12:55:36 +02:00
Guillaume Wenzek
5aa1a22d9f
async should only use sync logging (#225)
currently using async.LogFn inside async runtime itself panics.
So I'm avoiding that by forcing async.zig logging to go through
std.log.defaultLog which is synchronous.

you can reproduce the crash by changing log level to .debug
2025-04-16 09:35:18 +02:00
Corentin Godeau
c348da9446
async: fix due to xev bump (#221) 2025-04-08 10:51:51 +02:00
Corentin Godeau
1bd161d46c
async: TCP connect fixes (#219)
Co-authored-by: Jean-Baptiste Dalido <jb@zml.ai>
2025-04-08 10:51:33 +02:00
Hugo Mano
d0f5f0c7be
async: detect xev only if the API is dynamic (fix macOS) (#216)
ref: 94ed6af7b2/src/dynamic.zig (L44)
2025-03-27 15:26:28 +01:00
Hugo Mano
6be509e5b6
async: detect xev most preferable backend to use (#212)
Since change allow use to leverage io_uring instead of xev if the
backend is supported.
2025-03-25 16:41:58 +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
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
Steeve Morin
f0c2be0280
async: async mutex on log and fixes on ResetCondition (#166)
Stop using a real mutex for the `logFn` and use an `Mutex` and allow for
a fallback logger if outside a coroutine.
2025-01-24 20:58:14 +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
Steeve Morin
f228ec2edc
async: fix async hangs (#154)
Rework the libxev epoll backend to play nice with zigcoro based
scheduler.

In the process, load the PJRT plugins using `callBlocking` because it
can a bit slow sometimes.

Should have a slight performance increase, too.
2025-01-18 00:50:51 +01:00
Steeve Morin
5309a25420
async: vendor zigcoro and unify APIs (#152)
This PR merges zigcoro inside the repo and reworks its internals to play
well with `stdx.meta`.

It also adds `Channel.try_{send,recv}` methods as well as dynamically
sized channels (with a `comptime` capacity).

Although not used, it also introduces a `PoolStackAllocator` for
allocating coroutine stacks from a pool
2025-01-14 19:33:16 +01:00
Guillaume Wenzek
8cbfe48fe4
async: add intrusive queue (#122)
all code contributed by @steeve

* add intrusive queue
* change the constructor of Channel with default AsyncThread executor

---------

Co-authored-by: Steeve Morin <steeve@zml.ai>
2024-12-06 15:15:51 +01:00
Steeve Morin
db88158518
async: rework async runtime to use coroutines and cross thread signaling (#100)
This mostly reworks the runtime to enable proper cross thread signaling
for `callBlocking`.

API changes include:
- `async_ -> asyncc`
- `await_ -> awaitt`
- proper type inference for non generic arguments even for generic
functions
- bump `libxev`
- use `epoll` on linux by default (can be comptime overridden through
`xev_options.linux_backend` in the root module)

Mostly, also, it's pretty fast.
2024-11-22 17:56:22 +01:00
Steeve Morin
783a3cdeb8
zml: add stdx, rework async signature inference (#89)
This one is a chonky.

This commit adds a new `stdx` module with a few utility functions. It is
very far reaching. Forgive the size.

Also, clean the logs in the executables.
2024-11-15 17:12:07 +01:00
Steeve Morin
fad7cc0876
zml: reintroduce pjrtx (#78)
In an async scenario, it is very easy to footgun yourself and block the
reactor, especially with Events.

Reintroduce pjrtx that deals with the specifics.
2024-11-05 19:25:50 +01:00
Steeve Morin
44d1b24beb
async: add threaded implementation (#77)
This implements the `async` module using a thread pool. This is now the
default.

Implementations can be swapped using the
`@zml//async:impl=[threaded,zigcoro]` flag.

Because io_uring is not enabled in the default seccomp profile, some
container implementations will block on io_uring calls. Use the threaded
implementation to work around this, for now.
2024-11-05 16:47:41 +01:00
Steeve Morin
ccd925309b
async: rename async_ to asyncc and add Generic slugs (#71)
`asyncc` is arguably nicer to write than `async_`, so use that.

Also, add an explicit `Generic` version that can work with `anytype`
functions (but on which type inference will be disabled).
2024-11-01 17:36:08 +01:00
Guillaume Wenzek
ec9f69add7
zml: remove pjrtx (#38)
pjrtx.zig was mean to be a ZML specific wrapper over pjrt.zig.
But pjrt.zig in its current form is pretty usable without wrapper,
the extra layer of indirection is IMHO confusing because it mostly
transfer the calls directly to pjrt.zig but make some call suspending.

I moved the few helpers left in pjrtx.zig where they are used, ie 

`pjrtx.Buffer.bufferFromHostBuffer`-> in `buffer.Buffer.from`
`pjrtx.Client.compile` -> in `module.compileModuleToPjrtExecutable`
`pjrtx.Event.await` -> `zml.Platform.awaitEvent()`

This also fix a bug in `pjrtx.Event.await` which was blocking for the
event before suspending for the event.
2024-10-04 09:32:53 +02:00
Steeve Morin
13d84615bb zml: initial release 2024-09-17 11:11:18 +02:00