2023-01-03 10:21:07 +00:00
|
|
|
load("@aspect_bazel_lib//lib:tar.bzl", "mtree_spec", "tar")
|
|
|
|
|
load("@aspect_bazel_lib//lib:transitions.bzl", "platform_transition_filegroup")
|
2025-06-20 13:23:06 +00:00
|
|
|
load("@bazel_skylib//rules:build_test.bzl", "build_test")
|
2023-01-03 10:21:07 +00:00
|
|
|
load("@rules_oci//oci:defs.bzl", "oci_image", "oci_load", "oci_push")
|
2025-07-04 15:10:46 +00:00
|
|
|
load("@rules_zig//zig:defs.bzl", "zig_binary")
|
2023-01-03 10:21:07 +00:00
|
|
|
|
2025-07-04 15:10:46 +00:00
|
|
|
zig_binary(
|
2023-01-03 10:21:07 +00:00
|
|
|
name = "llama",
|
|
|
|
|
srcs = [
|
|
|
|
|
"llama.zig",
|
|
|
|
|
],
|
|
|
|
|
main = "main.zig",
|
2025-07-29 16:07:11 +00:00
|
|
|
visibility = ["//visibility:public"],
|
2023-01-03 10:21:07 +00:00
|
|
|
deps = [
|
2025-06-20 13:23:06 +00:00
|
|
|
"//async",
|
|
|
|
|
"//stdx",
|
|
|
|
|
"//zml",
|
2024-03-04 12:11:13 +00:00
|
|
|
"@com_github_hejsil_clap//:clap",
|
2023-01-03 10:21:07 +00:00
|
|
|
],
|
|
|
|
|
)
|
|
|
|
|
|
2025-07-04 15:10:46 +00:00
|
|
|
# TODO(steeve): Re-enable with a small, tokenless huggingface model.
|
2025-06-20 13:23:06 +00:00
|
|
|
#
|
2025-07-04 15:10:46 +00:00
|
|
|
# zig_test(
|
2025-06-20 13:23:06 +00:00
|
|
|
# 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",
|
|
|
|
|
# ],
|
|
|
|
|
# )
|
2023-01-03 10:21:07 +00:00
|
|
|
|
2025-06-20 13:23:06 +00:00
|
|
|
# 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"],
|
|
|
|
|
# )
|
2024-02-02 10:25:48 +00:00
|
|
|
|
2023-01-03 10:21:07 +00:00
|
|
|
mtree_spec(
|
|
|
|
|
name = "mtree",
|
2025-05-28 13:21:00 +00:00
|
|
|
srcs = [":llama"],
|
2023-01-03 10:21:07 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
|
|
tar(
|
|
|
|
|
name = "archive",
|
2025-05-28 13:21:00 +00:00
|
|
|
srcs = [":llama"],
|
2023-01-03 10:21:07 +00:00
|
|
|
args = [
|
|
|
|
|
"--options",
|
2025-06-20 13:23:06 +00:00
|
|
|
",".join([
|
|
|
|
|
"zstd:compression-level=9",
|
|
|
|
|
"zstd:threads=16",
|
|
|
|
|
]),
|
2023-01-03 10:21:07 +00:00
|
|
|
],
|
|
|
|
|
compress = "zstd",
|
|
|
|
|
mtree = ":mtree",
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
oci_image(
|
|
|
|
|
name = "image_",
|
2025-06-20 13:23:06 +00:00
|
|
|
base = "@distroless_cc_debian12",
|
|
|
|
|
entrypoint = ["/{}/llama".format(package_name())],
|
|
|
|
|
target_compatible_with = [
|
|
|
|
|
"@platforms//os:linux",
|
2023-08-21 09:15:48 +00:00
|
|
|
],
|
2025-06-20 13:23:06 +00:00
|
|
|
tars = [":archive"],
|
2023-01-03 10:21:07 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
|
|
platform_transition_filegroup(
|
|
|
|
|
name = "image",
|
|
|
|
|
srcs = [":image_"],
|
2025-06-20 13:23:06 +00:00
|
|
|
tags = ["manual"],
|
|
|
|
|
target_platform = "//platforms:linux_amd64",
|
2023-01-03 10:21:07 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
|
|
oci_load(
|
|
|
|
|
name = "load",
|
|
|
|
|
image = ":image",
|
2025-06-20 13:23:06 +00:00
|
|
|
repo_tags = ["zmlai/llama:latest"],
|
|
|
|
|
tags = ["manual"],
|
2023-01-03 10:21:07 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
|
|
oci_push(
|
|
|
|
|
name = "push",
|
|
|
|
|
image = ":image",
|
|
|
|
|
remote_tags = ["latest"],
|
2025-06-20 13:23:06 +00:00
|
|
|
repository = "index.docker.io/zmlai/llama",
|
|
|
|
|
tags = ["manual"],
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
build_test(
|
|
|
|
|
name = "test",
|
|
|
|
|
targets = [":llama"],
|
2023-01-03 10:21:07 +00:00
|
|
|
)
|