8000 Experimental build.zig by gwenzek · Pull Request #262 · zml/zml · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Experimental build.zig #262

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 34 commits into
base: master
Choose a base branch
from
Open

Experimental build.zig #262

wants to merge 34 commits into from

Conversation

gwenzek
Copy link
Contributor
@gwenzek gwenzek commented Jun 13, 2025

!!! This build.zig is experimental !!!
#67

It shows how to bridge Bazel and build.zig.
It requires the user to have bazel and tar installed on their machine.

Bazel is used to:

  • compile C and C++ deps into .a files.
  • call zig-translate C
  • generating Zig files
  • tarring Zig sources

build.zig finishes the work by:

  • untarring Zig sources
  • copying .a files into zig-cache
  • creating "zig modules" visible to other build.zig.

zig build test --summary all will run a lot of tests
zig build test-zml will stick to ZML test suite
zig build -Druntimes:cpu=true -Druntimes:cuda=false test will enable/disable runtimes

Caveats:

Potential follow ups:

  • The main missing is that Bazel takes care of sandboxing
    ZML executables and the PJRT runtimes and all the dependencies.
    This part has not been added to build.zig beyond mininal rPath for the the libpjrt_xxx.so,
    but for cuda you have more depedencies that would need to be sandboxed.

  • The module graph of the various protobuffers is alson a bit big,
    and if it changes it will be tedious to update. Ideally bazel should generate this graph of deps for us.

@gwenzek gwenzek requested review from Corendos and steeve and removed request for Corendos June 13, 2025 13:02
@@ -450,7 +427,9 @@ fn testSetIdx(val: usize) void {
}

fn testFn() void {
std.debug.assert(remainingStackSize() > 2048);
// Check if the stack was already overflowed
const current = xframe();
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Corendos not sure what this test is doing but it's not compiling anymore.

@@ -18,10 +18,10 @@ pub const log = std.log.scoped(.@"zml/aio");
test {
std.testing.refAllDecls(@This());
std.testing.refAllDecls(gguf);
std.testing.refAllDecls(nemo);
// std.testing.refAllDecls(nemo);
std.testing.refAllDecls(safetensors);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I haven't ported the yaml deps to build.zig, but also not sure it's worth it. The nemo/yaml code doesn't compile anyway.

@@ -25,7 +25,6 @@ zig_library(
visibility = ["//visibility:public"],
deps = [
":posix",
":sentencepiece_model_proto",
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wasn't used

@@ -35,9 +34,7 @@ zig_library(
"//stdx",
"//zml/tokenizer",
"//zml/tools",
"@rules_zig//zig/lib:libc",
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wasn't used

@gwenzek gwenzek requested a review from Corendos June 13, 2025 13:05
@gwenzek gwenzek changed the title build.zig Experimental build.zig Jun 16, 2025
fixup! add "zml_sandbox"
@gwenzek gwenzek force-pushed the gw/build.zig branch 2 times, most recently from 57364d0 to 7be70e8 Compare June 20, 2025 09:31
@gwenzek gwenzek force-pushed the gw/build.zig branch from 7be70e8 to dfd92dd Compare June 20, 2025 10:11 68C4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant
0