Remove example workspace and related documentation files.
This commit is contained in:
parent
e789e26008
commit
a540564744
@ -14,21 +14,14 @@ We also recommend to add a `weights.bzl` file to your project root directory, so
|
||||
you don't "pollute" your build file with long URLs and SHAs:
|
||||
|
||||
```python
|
||||
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_file")
|
||||
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
|
||||
|
||||
def _weights_impl(mctx):
|
||||
http_file(
|
||||
name = "com_github_zml_cdn_mnist",
|
||||
downloaded_file_path = "mnist.pt",
|
||||
sha256 = "d8a25252e28915e147720c19223721f0f53e3317493727ca754a2dd672450ba9",
|
||||
url = "https://github.com/ggerganov/ggml/raw/18703ad600cc68dbdb04d57434c876989a841d12/examples/mnist/models/mnist/mnist_model.state_dict",
|
||||
)
|
||||
|
||||
http_file(
|
||||
name = "com_github_zml_cdn_mnist_data",
|
||||
downloaded_file_path = "mnist.ylc",
|
||||
sha256 = "0fa7898d509279e482958e8ce81c8e77db3f2f8254e26661ceb7762c4d494ce7",
|
||||
url = "https://github.com/ggerganov/ggml/raw/18703ad600cc68dbdb04d57434c876989a841d12/examples/mnist/models/mnist/t10k-images.idx3-ubyte",
|
||||
http_archive(
|
||||
name = "mnist",
|
||||
sha256 = "075905e433ea0cce13c3fc08832448ab86225d089b5d412be67f59c29388fb19",
|
||||
url = "https://mirror.zml.ai/data/mnist.tar.zst",
|
||||
build_file_content = """exports_files(glob(["**"]), visibility = ["//visibility:public"])""",
|
||||
)
|
||||
|
||||
return mctx.extension_metadata(
|
||||
@ -54,12 +47,12 @@ the following way:
|
||||
zig_cc_binary(
|
||||
name = "mnist",
|
||||
args = [
|
||||
"$(location @com_github_zml_cdn_mnist//file)",
|
||||
"$(location @com_github_zml_cdn_mnist_data//file)",
|
||||
"$(location @mnist//:mnist.pt)",
|
||||
"$(location @mnist//:t10k-images.idx3-ubyte)",
|
||||
],
|
||||
data = [
|
||||
"@com_github_zml_cdn_mnist//file",
|
||||
"@com_github_zml_cdn_mnist_data//file",
|
||||
"@mnist//:mnist.pt",
|
||||
"@mnist//:t10k-images.idx3-ubyte",
|
||||
],
|
||||
main = "mnist.zig",
|
||||
deps = [
|
||||
@ -74,4 +67,3 @@ See how:
|
||||
- we use `data = [ ... ]` to reference the files in `weights.bzl`
|
||||
- we use `args = [ ... ]` to pass the files as command-line arguments to the
|
||||
MNIST executable at runtime, automatically.
|
||||
|
||||
|
||||
@ -24,8 +24,7 @@ So, to run the Llama model from above **on your development machine**
|
||||
housing an NVIDIA GPU, run the following:
|
||||
|
||||
```
|
||||
cd examples
|
||||
bazel run --config=release //llama --@zml//runtimes:cuda=true -- --hf-model-path=$HOME/Llama-3.2-1B-Instruct
|
||||
bazel run --config=release //examples/llama --@zml//runtimes:cuda=true -- --hf-model-path=$HOME/Llama-3.2-1B-Instruct
|
||||
```
|
||||
|
||||
|
||||
@ -41,8 +40,7 @@ architectures:
|
||||
As an example, here is how you build above Llama for CUDA on Linux X86_64:
|
||||
|
||||
```
|
||||
cd examples
|
||||
bazel build --config=release //llama \
|
||||
bazel build --config=release //examples/llama \
|
||||
--@zml//runtimes:cuda=true \
|
||||
--@zml//runtimes:cpu=false \
|
||||
--platforms=@zml//platforms:linux_amd64
|
||||
@ -83,7 +81,6 @@ tar(
|
||||
... and then build the TAR archive:
|
||||
|
||||
```
|
||||
# cd examples
|
||||
bazel build --config=release //mnist:archive \
|
||||
--@zml//runtimes:cuda=true \
|
||||
--@zml//runtimes:cpu=false \
|
||||
@ -134,4 +131,3 @@ INFO: Running command line: bazel-bin/mnist/mnist ../_main~_repo_rules~com_githu
|
||||
|
||||
You see the command line right up there. On the server, you just need to replace
|
||||
`../` with the 'runfiles' directory of your TAR.
|
||||
|
||||
|
||||
@ -133,8 +133,7 @@ platform_transition_filegroup(
|
||||
And that's almost it! You can already build the image:
|
||||
|
||||
```
|
||||
# cd examples
|
||||
bazel build --config=release //simple_layer:image
|
||||
bazel build --config=release //examples/simple_layer:image
|
||||
|
||||
INFO: Analyzed target //simple_layer:image (1 packages loaded, 8 targets configured).
|
||||
INFO: Found 1 target...
|
||||
@ -375,4 +374,3 @@ MNIST model, including weights and dataset, to the docker registry:
|
||||
```
|
||||
bazel run //mnist:push --@zml//runtimes:cuda=true -- --repository index.docker.io/my_org/zml_mnist
|
||||
```
|
||||
|
||||
|
||||
@ -30,8 +30,6 @@ Now you're ready to download a gated model like `Meta-Llama-3.2-1b`!
|
||||
```
|
||||
# requires token in $HOME/.cache/huggingface/token, as created by the
|
||||
# `huggingface-cli login` command, or the `HUGGINGFACE_TOKEN` environment variable.
|
||||
cd examples
|
||||
bazel run @zml//tools:hf -- download meta-llama/Llama-3.2-1B-Instruct --local-dir $HOME/Llama-3.2-1B-Instruct --exclude='*.pth'
|
||||
bazel run --config=release //llama -- --hf-model-path=$HOME/Llama-3.2-1B-Instruct --prompt="What is the capital of France?"
|
||||
bazel run --config=release //examples/llama -- --hf-model-path=$HOME/Llama-3.2-1B-Instruct --prompt="What is the capital of France?"
|
||||
```
|
||||
|
||||
|
||||
@ -49,7 +49,6 @@ compile it, and classify a randomly picked example from the test dataset.
|
||||
On the command line:
|
||||
|
||||
```
|
||||
cd examples
|
||||
bazel run --config=release //mnist
|
||||
```
|
||||
|
||||
@ -74,9 +73,8 @@ Once you've been granted access, you're ready to download a gated model like
|
||||
```
|
||||
# requires token in $HOME/.cache/huggingface/token, as created by the
|
||||
# `huggingface-cli login` command, or the `HUGGINGFACE_TOKEN` environment variable.
|
||||
cd examples
|
||||
bazel run @zml//tools:hf -- download meta-llama/Llama-3.1-8B-Instruct --local-dir $HOME/Llama-3.1-8B-Instruct --exclude='*.pth'
|
||||
bazel run --config=release //llama -- --hf-model-path=$HOME/Llama-3.1-8B-Instruct
|
||||
bazel run --config=release //examples/llama -- --hf-model-path=$HOME/Llama-3.1-8B-Instruct
|
||||
bazel run --config=release //llama -- --hf-model-path=$HOME/Llama-3.1-8B-Instruct --prompt="What is the capital of France?"
|
||||
```
|
||||
|
||||
@ -88,9 +86,8 @@ Like the 8B model above, this model also requires approval. See
|
||||
[here](https://huggingface.co/meta-llama/Llama-3.2-1B-Instruct) for access requirements.
|
||||
|
||||
```
|
||||
cd examples
|
||||
bazel run @zml//tools:hf -- download meta-llama/Llama-3.2-1B-Instruct --local-dir $HOME/Llama-3.2-1B-Instruct --exclude='*.pth'
|
||||
bazel run --config=release //llama -- --hf-model-path=$HOME/Llama-3.2-1B-Instruct
|
||||
bazel run --config=release //examples/llama -- --hf-model-path=$HOME/Llama-3.2-1B-Instruct
|
||||
bazel run --config=release //llama -- --hf-model-path=$HOME/Llama-3.2-1B-Instruct --prompt="What is the capital of France?"
|
||||
```
|
||||
|
||||
@ -121,9 +118,8 @@ So, to run the OpenLLama model from above on your host sporting an NVIDIA GPU,
|
||||
run the following:
|
||||
|
||||
```
|
||||
cd examples
|
||||
bazel run --config=release //llama:Llama-3.2-1B-Instruct \
|
||||
--@zml//runtimes:cuda=true \
|
||||
bazel run --config=release //examples/llama:Llama-3.2-1B-Instruct \
|
||||
--@zml//runtimes:cuda=true \
|
||||
-- --prompt="What is the capital of France?"
|
||||
```
|
||||
|
||||
@ -140,4 +136,3 @@ You might also want to check out the
|
||||
[documentation](../README.md), start
|
||||
[writing your first model](../tutorials/write_first_model.md), or read about more
|
||||
high-level [ZML concepts](../learn/concepts.md).
|
||||
|
||||
|
||||
@ -381,8 +381,7 @@ With everything in place now, running the model is easy:
|
||||
|
||||
```
|
||||
# run release (--config=release)
|
||||
cd examples
|
||||
bazel run --config=release //simple_layer
|
||||
bazel run --config=release //examples/simple_layer
|
||||
|
||||
# compile and run debug version
|
||||
bazel run //simple_layer
|
||||
|
||||
@ -1,11 +1,17 @@
|
||||
load("@zml//bazel:zig.bzl", "zig_cc_binary")
|
||||
load("@bazel_skylib//rules:build_test.bzl", "build_test")
|
||||
load("//bazel:zig.bzl", "zig_cc_binary")
|
||||
|
||||
zig_cc_binary(
|
||||
name = "benchmark",
|
||||
main = "main.zig",
|
||||
deps = [
|
||||
"@zml//async",
|
||||
"@zml//stdx",
|
||||
"@zml//zml",
|
||||
"//async",
|
||||
"//stdx",
|
||||
"//zml",
|
||||
],
|
||||
)
|
||||
|
||||
build_test(
|
||||
name = "test",
|
||||
targets = [":benchmark"],
|
||||
)
|
||||
|
||||
@ -1,11 +1,8 @@
|
||||
load("@aspect_bazel_lib//lib:expand_template.bzl", "expand_template")
|
||||
load("@aspect_bazel_lib//lib:tar.bzl", "mtree_spec", "tar")
|
||||
load("@aspect_bazel_lib//lib:transitions.bzl", "platform_transition_filegroup")
|
||||
load("@bazel_skylib//rules:native_binary.bzl", "native_test")
|
||||
load("@bazel_skylib//rules:write_file.bzl", "write_file")
|
||||
load("@rules_cc//cc:cc_binary.bzl", "cc_binary")
|
||||
load("@bazel_skylib//rules:build_test.bzl", "build_test")
|
||||
load("@rules_oci//oci:defs.bzl", "oci_image", "oci_load", "oci_push")
|
||||
load("@zml//bazel:zig.bzl", "zig_cc_binary")
|
||||
load("//bazel:zig.bzl", "zig_cc_binary")
|
||||
|
||||
zig_cc_binary(
|
||||
name = "llama",
|
||||
@ -14,65 +11,58 @@ zig_cc_binary(
|
||||
],
|
||||
main = "main.zig",
|
||||
deps = [
|
||||
"//async",
|
||||
"//stdx",
|
||||
"//zml",
|
||||
"@com_github_hejsil_clap//:clap",
|
||||
"@zml//async",
|
||||
"@zml//stdx",
|
||||
"@zml//zml",
|
||||
],
|
||||
)
|
||||
|
||||
zig_cc_binary(
|
||||
name = "test-implementation",
|
||||
srcs = ["llama.zig"],
|
||||
args = [
|
||||
"--weights=$(location @Meta-Llama-3.1-8B-Instruct//:model.safetensors.index.json)",
|
||||
"--config=$(location @Meta-Llama-3.1-8B-Instruct//:config.json)",
|
||||
],
|
||||
data = [
|
||||
"@Meta-Llama-3.1-8B-Instruct//:config.json",
|
||||
"@Meta-Llama-3.1-8B-Instruct//:model.safetensors.index.json",
|
||||
],
|
||||
main = "test.zig",
|
||||
tags = [
|
||||
"manual",
|
||||
],
|
||||
deps = [
|
||||
"@zml//async",
|
||||
"@zml//stdx",
|
||||
"@zml//zml",
|
||||
],
|
||||
)
|
||||
# TODO(steeve): Re-enable when rules_zig linkmode is fixed.
|
||||
#
|
||||
# zig_cc_binary(
|
||||
# name = "test-implementation",
|
||||
# srcs = ["llama.zig"],
|
||||
# args = [
|
||||
# "--weights=$(location @Meta-Llama-3.1-8B-Instruct//:model.safetensors.index.json)",
|
||||
# "--config=$(location @Meta-Llama-3.1-8B-Instruct//:config.json)",
|
||||
# ],
|
||||
# data = [
|
||||
# "@Meta-Llama-3.1-8B-Instruct//:config.json",
|
||||
# "@Meta-Llama-3.1-8B-Instruct//:model.safetensors.index.json",
|
||||
# ],
|
||||
# main = "test.zig",
|
||||
# deps = [
|
||||
# "//async",
|
||||
# "//stdx",
|
||||
# "//zml",
|
||||
# ],
|
||||
# )
|
||||
|
||||
native_test(
|
||||
name = "test_tokenizer",
|
||||
src = "@zml//zml/tokenizer:main",
|
||||
# Note: all Llama-3.x tokenizers are the same,
|
||||
# but using the 3.2-1B version because downloading the tokenizer triggers downloading the model.
|
||||
args = [
|
||||
"--tokenizer=$(location @Meta-Llama-3.2-1B-Instruct//:tokenizer.json)",
|
||||
"""--prompt='Examples of titles:
|
||||
📉 Stock Market Trends
|
||||
🍪 Perfect Chocolate Chip Recipe
|
||||
Evolution of Music Streaming
|
||||
Remote Work Productivity Tips
|
||||
Artificial Intelligence in Healthcare
|
||||
🎮 Video Game Development Insights
|
||||
'""",
|
||||
# this correspond to encoding with HF tokenizers, with bos=False
|
||||
"--expected=41481,315,15671,512,9468,241,231,12937,8152,50730,198,9468,235,103,24118,39520,32013,26371,198,35212,3294,315,10948,45910,198,25732,5664,5761,1968,26788,198,9470,16895,22107,304,39435,198,9468,236,106,8519,4140,11050,73137,198",
|
||||
],
|
||||
data = ["@Meta-Llama-3.2-1B-Instruct//:tokenizer.json"],
|
||||
tags = [
|
||||
"manual",
|
||||
],
|
||||
)
|
||||
# native_test(
|
||||
# name = "test_tokenizer",
|
||||
# src = "//zml/tokenizer:main",
|
||||
# # Note: all Llama-3.x tokenizers are the same,
|
||||
# # but using the 3.2-1B version because downloading the tokenizer triggers downloading the model.
|
||||
# args = [
|
||||
# "--tokenizer=$(location @Meta-Llama-3.2-1B-Instruct//:tokenizer.json)",
|
||||
# """--prompt='Examples of titles:
|
||||
# 📉 Stock Market Trends
|
||||
# 🍪 Perfect Chocolate Chip Recipe
|
||||
# Evolution of Music Streaming
|
||||
# Remote Work Productivity Tips
|
||||
# Artificial Intelligence in Healthcare
|
||||
# 🎮 Video Game Development Insights
|
||||
# '""",
|
||||
# # this correspond to encoding with HF tokenizers, with bos=False
|
||||
# "--expected=41481,315,15671,512,9468,241,231,12937,8152,50730,198,9468,235,103,24118,39520,32013,26371,198,35212,3294,315,10948,45910,198,25732,5664,5761,1968,26788,198,9470,16895,22107,304,39435,198,9468,236,106,8519,4140,11050,73137,198",
|
||||
# ],
|
||||
# data = ["@Meta-Llama-3.2-1B-Instruct//:tokenizer.json"],
|
||||
# )
|
||||
|
||||
mtree_spec(
|
||||
name = "mtree",
|
||||
srcs = [":llama"],
|
||||
tags = [
|
||||
"manual",
|
||||
],
|
||||
)
|
||||
|
||||
tar(
|
||||
@ -80,54 +70,48 @@ tar(
|
||||
srcs = [":llama"],
|
||||
args = [
|
||||
"--options",
|
||||
"zstd:compression-level=9",
|
||||
",".join([
|
||||
"zstd:compression-level=9",
|
||||
"zstd:threads=16",
|
||||
]),
|
||||
],
|
||||
compress = "zstd",
|
||||
mtree = ":mtree",
|
||||
tags = [
|
||||
"manual",
|
||||
],
|
||||
)
|
||||
|
||||
oci_image(
|
||||
name = "image_",
|
||||
base = "@distroless_cc_debian12_debug",
|
||||
entrypoint = ["./{}/llama".format(package_name())],
|
||||
tags = [
|
||||
"manual",
|
||||
],
|
||||
tars = [
|
||||
"@zml//runtimes:layers",
|
||||
":archive",
|
||||
base = "@distroless_cc_debian12",
|
||||
entrypoint = ["/{}/llama".format(package_name())],
|
||||
target_compatible_with = [
|
||||
"@platforms//os:linux",
|
||||
],
|
||||
tars = [":archive"],
|
||||
)
|
||||
|
||||
platform_transition_filegroup(
|
||||
name = "image",
|
||||
srcs = [":image_"],
|
||||
tags = [
|
||||
"manual",
|
||||
],
|
||||
target_platform = "@zml//platforms:linux_amd64",
|
||||
tags = ["manual"],
|
||||
target_platform = "//platforms:linux_amd64",
|
||||
)
|
||||
|
||||
oci_load(
|
||||
name = "load",
|
||||
image = ":image",
|
||||
repo_tags = [
|
||||
"distroless/llama:latest",
|
||||
],
|
||||
tags = [
|
||||
"manual",
|
||||
],
|
||||
repo_tags = ["zmlai/llama:latest"],
|
||||
tags = ["manual"],
|
||||
)
|
||||
|
||||
oci_push(
|
||||
name = "push",
|
||||
image = ":image",
|
||||
remote_tags = ["latest"],
|
||||
repository = "index.docker.io/steeve/llama",
|
||||
tags = [
|
||||
"manual",
|
||||
],
|
||||
repository = "index.docker.io/zmlai/llama",
|
||||
tags = ["manual"],
|
||||
)
|
||||
|
||||
build_test(
|
||||
name = "test",
|
||||
targets = [":llama"],
|
||||
)
|
||||
|
||||
@ -1,108 +1,24 @@
|
||||
load("@aspect_bazel_lib//lib:expand_template.bzl", "expand_template")
|
||||
load("@aspect_bazel_lib//lib:tar.bzl", "mtree_spec", "tar")
|
||||
load("@aspect_bazel_lib//lib:transitions.bzl", "platform_transition_filegroup")
|
||||
load("@rules_oci//oci:defs.bzl", "oci_image", "oci_load", "oci_push")
|
||||
load("@zml//bazel:zig.bzl", "zig_cc_binary")
|
||||
load("@bazel_skylib//rules:build_test.bzl", "build_test")
|
||||
load("//bazel:zig.bzl", "zig_cc_binary")
|
||||
|
||||
# Executable
|
||||
zig_cc_binary(
|
||||
name = "mnist",
|
||||
args = [
|
||||
"$(location @com_github_ggerganov_ggml_mnist//file)",
|
||||
"$(location @com_github_ggerganov_ggml_mnist_data//file)",
|
||||
"$(location @mnist//:mnist.pt)",
|
||||
"$(location @mnist//:t10k-images.idx3-ubyte)",
|
||||
],
|
||||
data = [
|
||||
"@com_github_ggerganov_ggml_mnist//file",
|
||||
"@com_github_ggerganov_ggml_mnist_data//file",
|
||||
"@mnist//:mnist.pt",
|
||||
"@mnist//:t10k-images.idx3-ubyte",
|
||||
],
|
||||
main = "mnist.zig",
|
||||
deps = [
|
||||
"@zml//async",
|
||||
"@zml//zml",
|
||||
"//async",
|
||||
"//zml",
|
||||
],
|
||||
)
|
||||
|
||||
mtree_spec(
|
||||
name = "mtree",
|
||||
srcs = [":mnist"],
|
||||
)
|
||||
|
||||
tar(
|
||||
name = "archive",
|
||||
srcs = [":mnist"],
|
||||
args = [
|
||||
"--options",
|
||||
"zstd:compression-level=9",
|
||||
],
|
||||
compress = "zstd",
|
||||
mtree = ":mtree",
|
||||
)
|
||||
|
||||
expand_template(
|
||||
name = "entrypoint",
|
||||
data = [
|
||||
":mnist",
|
||||
"@com_github_ggerganov_ggml_mnist//file",
|
||||
"@com_github_ggerganov_ggml_mnist_data//file",
|
||||
],
|
||||
substitutions = {
|
||||
":model": "$(rlocationpath @com_github_ggerganov_ggml_mnist//file)",
|
||||
":data": "$(rlocationpath @com_github_ggerganov_ggml_mnist_data//file)",
|
||||
},
|
||||
template = [
|
||||
"./{}/mnist".format(package_name()),
|
||||
"./{}/mnist.runfiles/:model".format(package_name()),
|
||||
"./{}/mnist.runfiles/:data".format(package_name()),
|
||||
],
|
||||
)
|
||||
|
||||
oci_image(
|
||||
name = "image_",
|
||||
base = "@distroless_cc_debian12",
|
||||
entrypoint = ":entrypoint",
|
||||
target_compatible_with = [
|
||||
"@platforms//os:linux",
|
||||
],
|
||||
tars = [":archive"],
|
||||
)
|
||||
|
||||
platform_transition_filegroup(
|
||||
name = "image",
|
||||
srcs = [":image_"],
|
||||
target_compatible_with = [
|
||||
"@platforms//os:linux",
|
||||
],
|
||||
target_platform = "@zml//platforms:linux_amd64",
|
||||
)
|
||||
|
||||
oci_load(
|
||||
name = "load",
|
||||
image = ":image",
|
||||
repo_tags = [
|
||||
"distroless/mnist:latest",
|
||||
],
|
||||
target_compatible_with = [
|
||||
"@platforms//os:linux",
|
||||
],
|
||||
)
|
||||
|
||||
oci_push(
|
||||
name = "push",
|
||||
image = ":image",
|
||||
remote_tags = ["latest"],
|
||||
repository = "index.docker.io/steeve/mnist",
|
||||
target_compatible_with = [
|
||||
"@platforms//os:linux",
|
||||
],
|
||||
)
|
||||
|
||||
oci_load(
|
||||
name = "debug_image",
|
||||
image = ":image",
|
||||
repo_tags = [
|
||||
"distroless/mnist:latest",
|
||||
],
|
||||
target_compatible_with = [
|
||||
"@platforms//os:linux",
|
||||
],
|
||||
build_test(
|
||||
name = "test",
|
||||
targets = [":mnist"],
|
||||
)
|
||||
|
||||
@ -1,70 +1,46 @@
|
||||
load("@rules_cc//cc:cc_binary.bzl", "cc_binary")
|
||||
load("@zml//bazel:zig.bzl", "zig_cc_binary")
|
||||
load("@bazel_skylib//rules:build_test.bzl", "build_test")
|
||||
load("//bazel:zig.bzl", "zig_cc_binary")
|
||||
|
||||
zig_cc_binary(
|
||||
name = "modernbert",
|
||||
srcs = ["modernbert.zig"],
|
||||
main = "main.zig",
|
||||
deps = [
|
||||
"@com_github_hejsil_clap//:clap",
|
||||
"@zml//async",
|
||||
"@zml//stdx",
|
||||
"@zml//zml",
|
||||
],
|
||||
)
|
||||
|
||||
cc_binary(
|
||||
name = "ModernBERT-base",
|
||||
args = [
|
||||
"--model=$(location @ModernBERT-base//:model.safetensors)",
|
||||
"--tokenizer=$(location @ModernBERT-base//:tokenizer)",
|
||||
"--tokenizer=$(location @ModernBERT-base//:tokenizer.json)",
|
||||
"--num-attention-heads=12",
|
||||
"--tie-word-embeddings=true",
|
||||
],
|
||||
data = [
|
||||
"@ModernBERT-base//:model.safetensors",
|
||||
"@ModernBERT-base//:tokenizer",
|
||||
],
|
||||
tags = [
|
||||
"manual",
|
||||
],
|
||||
deps = [":modernbert_lib"],
|
||||
)
|
||||
|
||||
cc_binary(
|
||||
name = "ModernBERT-large",
|
||||
args = [
|
||||
"--model=$(location @ModernBERT-large//:model.safetensors)",
|
||||
"--tokenizer=$(location @ModernBERT-large//:tokenizer)",
|
||||
"--num-attention-heads=16",
|
||||
"--tie-word-embeddings=true",
|
||||
],
|
||||
data = [
|
||||
"@ModernBERT-large//:model.safetensors",
|
||||
"@ModernBERT-large//:tokenizer",
|
||||
],
|
||||
tags = [
|
||||
"manual",
|
||||
],
|
||||
deps = [":modernbert_lib"],
|
||||
)
|
||||
|
||||
zig_cc_binary(
|
||||
name = "test-implementation",
|
||||
srcs = ["modernbert.zig"],
|
||||
args = [
|
||||
"--model=$(location @ModernBERT-base//:model.safetensors)",
|
||||
],
|
||||
data = [
|
||||
"@ModernBERT-base//:model.safetensors",
|
||||
],
|
||||
main = "test.zig",
|
||||
tags = [
|
||||
"manual",
|
||||
"@ModernBERT-base//:tokenizer.json",
|
||||
],
|
||||
main = "main.zig",
|
||||
deps = [
|
||||
"//async",
|
||||
"//stdx",
|
||||
"//zml",
|
||||
"@com_github_hejsil_clap//:clap",
|
||||
"@zml//async",
|
||||
"@zml//zml",
|
||||
],
|
||||
)
|
||||
|
||||
# zig_cc_binary(
|
||||
# name = "test-implementation",
|
||||
# srcs = ["modernbert.zig"],
|
||||
# args = [
|
||||
# "--model=$(location @ModernBERT-base//:model.safetensors)",
|
||||
# ],
|
||||
# data = [
|
||||
# "@ModernBERT-base//:model.safetensors",
|
||||
# ],
|
||||
# main = "test.zig",
|
||||
# deps = [
|
||||
# "//async",
|
||||
# "//zml",
|
||||
# "@com_github_hejsil_clap//:clap",
|
||||
# ],
|
||||
# )
|
||||
|
||||
build_test(
|
||||
name = "test",
|
||||
targets = [":modernbert"],
|
||||
)
|
||||
|
||||
@ -1,14 +1,15 @@
|
||||
load("@aspect_bazel_lib//lib:tar.bzl", "mtree_spec", "tar")
|
||||
load("@aspect_bazel_lib//lib:transitions.bzl", "platform_transition_filegroup")
|
||||
load("@bazel_skylib//rules:build_test.bzl", "build_test")
|
||||
load("@rules_oci//oci:defs.bzl", "oci_image", "oci_load", "oci_push")
|
||||
load("@zml//bazel:zig.bzl", "zig_cc_binary")
|
||||
load("//bazel:zig.bzl", "zig_cc_binary")
|
||||
|
||||
zig_cc_binary(
|
||||
name = "simple_layer",
|
||||
main = "main.zig",
|
||||
deps = [
|
||||
"@zml//async",
|
||||
"@zml//zml",
|
||||
"//async",
|
||||
"//zml",
|
||||
],
|
||||
)
|
||||
|
||||
@ -24,7 +25,10 @@ tar(
|
||||
srcs = [":simple_layer"],
|
||||
args = [
|
||||
"--options",
|
||||
"zstd:compression-level=9",
|
||||
",".join([
|
||||
"zstd:compression-level=9",
|
||||
"zstd:threads=16",
|
||||
]),
|
||||
],
|
||||
compress = "zstd",
|
||||
mtree = ":mtree",
|
||||
@ -34,7 +38,7 @@ tar(
|
||||
oci_image(
|
||||
name = "image_",
|
||||
base = "@distroless_cc_debian12",
|
||||
entrypoint = ["./{}/simple_layer".format(package_name())],
|
||||
entrypoint = ["/{}/simple_layer".format(package_name())],
|
||||
target_compatible_with = [
|
||||
"@platforms//os:linux",
|
||||
],
|
||||
@ -45,10 +49,8 @@ oci_image(
|
||||
platform_transition_filegroup(
|
||||
name = "image",
|
||||
srcs = [":image_"],
|
||||
target_compatible_with = [
|
||||
"@platforms//os:linux",
|
||||
],
|
||||
target_platform = "@zml//platforms:linux_amd64",
|
||||
tags = ["manual"],
|
||||
target_platform = "//platforms:linux_amd64",
|
||||
)
|
||||
|
||||
# Load will immediatly load the image (eg: docker load)
|
||||
@ -58,9 +60,7 @@ oci_load(
|
||||
repo_tags = [
|
||||
"distroless/simple_layer:latest",
|
||||
],
|
||||
target_compatible_with = [
|
||||
"@platforms//os:linux",
|
||||
],
|
||||
tags = ["manual"],
|
||||
)
|
||||
|
||||
# Bazel target for pushing the Linux image to the docker registry
|
||||
@ -69,8 +69,11 @@ oci_push(
|
||||
image = ":image",
|
||||
remote_tags = ["latest"],
|
||||
# override with -- --repository foo.bar/org/image
|
||||
repository = "index.docker.io/renerocksai/simple_layer",
|
||||
target_compatible_with = [
|
||||
"@platforms//os:linux",
|
||||
],
|
||||
repository = "index.docker.io/zmlai/simple_layer",
|
||||
tags = ["manual"],
|
||||
)
|
||||
|
||||
build_test(
|
||||
name = "test",
|
||||
targets = [":simple_layer"],
|
||||
)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user