From a835ae8f251b02c6508c2dc7adaafd3ff10d4ba1 Mon Sep 17 00:00:00 2001 From: Steeve Morin Date: Mon, 23 Dec 2024 23:39:14 +0100 Subject: [PATCH 01/48] WIP --- MODULE.bazel | 6 + MODULE.bazel.lock | 163 ++++++++-- bazel/swig.bzl | 149 +++++++++ .../com_google_sentencepiece/BUILD.bazel | 38 +++ third_party/com_google_sentencepiece/fwd.bzl | 14 + third_party/com_google_sentencepiece/repo.bzl | 9 + .../sentencepiece.bazel | 95 ++++++ third_party/non_module_deps.bzl | 16 + third_party/org_swig_swig/repo.bzl | 10 + third_party/org_swig_swig/swig.bazel | 109 +++++++ zml/tokenizer/hf_tokenizers/BUILD.bazel | 0 zml/tokenizer/sentencepiece/BUILD.bazel | 61 ++++ zml/tokenizer/sentencepiece/main.zig | 291 ++++++++++++++++++ zml/tokenizer/sentencepiece/sentencepiece.i | 91 ++++++ zml/tokenizer/sentencepiece/sentencepiece.zig | 12 + .../sentencepiece/sentencepiece2.zig | 130 ++++++++ zml/tokenizer/sentencepiece/zig.h | 9 + zml/tokenizer/tokenizer.zig | 27 ++ 18 files changed, 1206 insertions(+), 24 deletions(-) create mode 100644 bazel/swig.bzl create mode 100644 third_party/com_google_sentencepiece/BUILD.bazel create mode 100644 third_party/com_google_sentencepiece/fwd.bzl create mode 100644 third_party/com_google_sentencepiece/repo.bzl create mode 100644 third_party/com_google_sentencepiece/sentencepiece.bazel create mode 100644 third_party/non_module_deps.bzl create mode 100644 third_party/org_swig_swig/repo.bzl create mode 100644 third_party/org_swig_swig/swig.bazel create mode 100644 zml/tokenizer/hf_tokenizers/BUILD.bazel create mode 100644 zml/tokenizer/sentencepiece/BUILD.bazel create mode 100644 zml/tokenizer/sentencepiece/main.zig create mode 100644 zml/tokenizer/sentencepiece/sentencepiece.i create mode 100644 zml/tokenizer/sentencepiece/sentencepiece.zig create mode 100644 zml/tokenizer/sentencepiece/sentencepiece2.zig create mode 100644 zml/tokenizer/sentencepiece/zig.h create mode 100644 zml/tokenizer/tokenizer.zig diff --git a/MODULE.bazel b/MODULE.bazel index 10f43698..0cba87a3 100644 --- a/MODULE.bazel +++ b/MODULE.bazel @@ -12,6 +12,9 @@ bazel_dep(name = "rules_cc", version = "0.0.9") bazel_dep(name = "rules_pkg", version = "1.0.1") bazel_dep(name = "rules_proto", version = "6.0.2") bazel_dep(name = "with_cfg.bzl", version = "0.5.0") +bazel_dep(name = "protobuf", version = "29.2") +bazel_dep(name = "pcre2", version = "10.43") +bazel_dep(name = "abseil-cpp", version = "20240722.0.bcr.2") bazel_dep(name = "buildifier_prebuilt", version = "6.4.0", dev_dependency = True) bazel_dep(name = "aspect_bazel_lib", version = "2.9.3") bazel_dep(name = "rules_distroless", version = "0.3.8") @@ -115,3 +118,6 @@ apt.install( manifest = "//runtimes/neuron:packages.yaml", ) use_repo(apt, "neuron_bookworm") + +non_module_deps = use_extension("//:third_party/non_module_deps.bzl", "non_module_deps") +use_repo(non_module_deps, "com_google_sentencepiece", "org_swig_swig") diff --git a/MODULE.bazel.lock b/MODULE.bazel.lock index a4729897..73371244 100644 --- a/MODULE.bazel.lock +++ b/MODULE.bazel.lock @@ -6,8 +6,13 @@ "https://bazel-registry.zml.ai/modules/abseil-cpp/20230125.1/MODULE.bazel": "not found", "https://bazel-registry.zml.ai/modules/abseil-cpp/20230802.0.bcr.1/MODULE.bazel": "not found", "https://bazel-registry.zml.ai/modules/abseil-cpp/20230802.0/MODULE.bazel": "not found", + "https://bazel-registry.zml.ai/modules/abseil-cpp/20230802.1/MODULE.bazel": "not found", "https://bazel-registry.zml.ai/modules/abseil-cpp/20240116.0/MODULE.bazel": "not found", + "https://bazel-registry.zml.ai/modules/abseil-cpp/20240116.1/MODULE.bazel": "not found", + "https://bazel-registry.zml.ai/modules/abseil-cpp/20240116.2/MODULE.bazel": "not found", + "https://bazel-registry.zml.ai/modules/abseil-cpp/20240722.0.bcr.2/MODULE.bazel": "not found", "https://bazel-registry.zml.ai/modules/apple_support/1.11.1/MODULE.bazel": "not found", + "https://bazel-registry.zml.ai/modules/apple_support/1.15.1/MODULE.bazel": "not found", "https://bazel-registry.zml.ai/modules/apple_support/1.5.0/MODULE.bazel": "not found", "https://bazel-registry.zml.ai/modules/aspect_bazel_lib/2.7.9/MODULE.bazel": "not found", "https://bazel-registry.zml.ai/modules/aspect_bazel_lib/2.8.1/MODULE.bazel": "not found", @@ -16,6 +21,10 @@ "https://bazel-registry.zml.ai/modules/aspect_rules_py/1.0.0-rc0/MODULE.bazel": "not found", "https://bazel-registry.zml.ai/modules/bazel_features/1.1.1/MODULE.bazel": "not found", "https://bazel-registry.zml.ai/modules/bazel_features/1.11.0/MODULE.bazel": "not found", + "https://bazel-registry.zml.ai/modules/bazel_features/1.15.0/MODULE.bazel": "not found", + "https://bazel-registry.zml.ai/modules/bazel_features/1.17.0/MODULE.bazel": "not found", + "https://bazel-registry.zml.ai/modules/bazel_features/1.18.0/MODULE.bazel": "not found", + "https://bazel-registry.zml.ai/modules/bazel_features/1.19.0/MODULE.bazel": "not found", "https://bazel-registry.zml.ai/modules/bazel_features/1.3.0/MODULE.bazel": "not found", "https://bazel-registry.zml.ai/modules/bazel_features/1.4.1/MODULE.bazel": "not found", "https://bazel-registry.zml.ai/modules/bazel_features/1.9.1/MODULE.bazel": "not found", @@ -28,6 +37,7 @@ "https://bazel-registry.zml.ai/modules/bazel_skylib/1.4.2/MODULE.bazel": "not found", "https://bazel-registry.zml.ai/modules/bazel_skylib/1.5.0/MODULE.bazel": "not found", "https://bazel-registry.zml.ai/modules/bazel_skylib/1.6.1/MODULE.bazel": "not found", + "https://bazel-registry.zml.ai/modules/bazel_skylib/1.7.0/MODULE.bazel": "not found", "https://bazel-registry.zml.ai/modules/bazel_skylib/1.7.1/MODULE.bazel": "not found", "https://bazel-registry.zml.ai/modules/buildifier_prebuilt/6.1.2/MODULE.bazel": "not found", "https://bazel-registry.zml.ai/modules/buildifier_prebuilt/6.4.0/MODULE.bazel": "not found", @@ -37,10 +47,13 @@ "https://bazel-registry.zml.ai/modules/googletest/1.11.0/MODULE.bazel": "not found", "https://bazel-registry.zml.ai/modules/googletest/1.14.0.bcr.1/MODULE.bazel": "not found", "https://bazel-registry.zml.ai/modules/googletest/1.14.0/MODULE.bazel": "not found", + "https://bazel-registry.zml.ai/modules/googletest/1.15.2/MODULE.bazel": "not found", "https://bazel-registry.zml.ai/modules/hermetic_cc_toolchain/3.1.0/MODULE.bazel": "not found", + "https://bazel-registry.zml.ai/modules/jsoncpp/1.9.5/MODULE.bazel": "not found", "https://bazel-registry.zml.ai/modules/libpfm/4.11.0/MODULE.bazel": "not found", "https://bazel-registry.zml.ai/modules/nlohmann_json/3.6.1/MODULE.bazel": "not found", "https://bazel-registry.zml.ai/modules/patchelf/0.18.0/MODULE.bazel": "not found", + "https://bazel-registry.zml.ai/modules/pcre2/10.43/MODULE.bazel": "not found", "https://bazel-registry.zml.ai/modules/platforms/0.0.10/MODULE.bazel": "not found", "https://bazel-registry.zml.ai/modules/platforms/0.0.4/MODULE.bazel": "not found", "https://bazel-registry.zml.ai/modules/platforms/0.0.5/MODULE.bazel": "not found", @@ -51,33 +64,49 @@ "https://bazel-registry.zml.ai/modules/protobuf/21.7/MODULE.bazel": "not found", "https://bazel-registry.zml.ai/modules/protobuf/23.1/MODULE.bazel": "not found", "https://bazel-registry.zml.ai/modules/protobuf/24.4/MODULE.bazel": "not found", + "https://bazel-registry.zml.ai/modules/protobuf/27.0/MODULE.bazel": "not found", + "https://bazel-registry.zml.ai/modules/protobuf/29.2/MODULE.bazel": "not found", "https://bazel-registry.zml.ai/modules/protobuf/3.19.0/MODULE.bazel": "not found", "https://bazel-registry.zml.ai/modules/protobuf/3.19.6/MODULE.bazel": "not found", "https://bazel-registry.zml.ai/modules/pybind11_bazel/2.11.1.bzl.1/MODULE.bazel": "not found", "https://bazel-registry.zml.ai/modules/pybind11_bazel/2.11.1/MODULE.bazel": "not found", + "https://bazel-registry.zml.ai/modules/pybind11_bazel/2.12.0/MODULE.bazel": "not found", "https://bazel-registry.zml.ai/modules/re2/2023-09-01/MODULE.bazel": "not found", "https://bazel-registry.zml.ai/modules/re2/2024-02-01/MODULE.bazel": "not found", + "https://bazel-registry.zml.ai/modules/re2/2024-07-02/MODULE.bazel": "not found", + "https://bazel-registry.zml.ai/modules/rules_android/0.1.1/MODULE.bazel": "not found", "https://bazel-registry.zml.ai/modules/rules_apple/3.2.1/MODULE.bazel": "not found", "https://bazel-registry.zml.ai/modules/rules_cc/0.0.1/MODULE.bazel": "not found", + "https://bazel-registry.zml.ai/modules/rules_cc/0.0.10/MODULE.bazel": "not found", + "https://bazel-registry.zml.ai/modules/rules_cc/0.0.16/MODULE.bazel": "not found", "https://bazel-registry.zml.ai/modules/rules_cc/0.0.2/MODULE.bazel": "not found", "https://bazel-registry.zml.ai/modules/rules_cc/0.0.6/MODULE.bazel": "not found", "https://bazel-registry.zml.ai/modules/rules_cc/0.0.8/MODULE.bazel": "not found", "https://bazel-registry.zml.ai/modules/rules_cc/0.0.9/MODULE.bazel": "not found", "https://bazel-registry.zml.ai/modules/rules_distroless/0.3.8/MODULE.bazel": "not found", "https://bazel-registry.zml.ai/modules/rules_foreign_cc/0.9.0/MODULE.bazel": "not found", + "https://bazel-registry.zml.ai/modules/rules_fuzzing/0.5.2/MODULE.bazel": "not found", "https://bazel-registry.zml.ai/modules/rules_java/4.0.0/MODULE.bazel": "not found", "https://bazel-registry.zml.ai/modules/rules_java/5.3.5/MODULE.bazel": "not found", "https://bazel-registry.zml.ai/modules/rules_java/6.3.0/MODULE.bazel": "not found", + "https://bazel-registry.zml.ai/modules/rules_java/6.5.2/MODULE.bazel": "not found", "https://bazel-registry.zml.ai/modules/rules_java/7.1.0/MODULE.bazel": "not found", + "https://bazel-registry.zml.ai/modules/rules_java/7.10.0/MODULE.bazel": "not found", + "https://bazel-registry.zml.ai/modules/rules_java/7.12.2/MODULE.bazel": "not found", + "https://bazel-registry.zml.ai/modules/rules_java/7.2.0/MODULE.bazel": "not found", "https://bazel-registry.zml.ai/modules/rules_java/7.3.2/MODULE.bazel": "not found", + "https://bazel-registry.zml.ai/modules/rules_java/7.6.1/MODULE.bazel": "not found", "https://bazel-registry.zml.ai/modules/rules_java/7.6.5/MODULE.bazel": "not found", "https://bazel-registry.zml.ai/modules/rules_jvm_external/4.4.2/MODULE.bazel": "not found", "https://bazel-registry.zml.ai/modules/rules_jvm_external/5.1/MODULE.bazel": "not found", "https://bazel-registry.zml.ai/modules/rules_jvm_external/5.2/MODULE.bazel": "not found", + "https://bazel-registry.zml.ai/modules/rules_jvm_external/6.3/MODULE.bazel": "not found", + "https://bazel-registry.zml.ai/modules/rules_kotlin/1.9.6/MODULE.bazel": "not found", "https://bazel-registry.zml.ai/modules/rules_license/0.0.3/MODULE.bazel": "not found", "https://bazel-registry.zml.ai/modules/rules_license/0.0.4/MODULE.bazel": "not found", "https://bazel-registry.zml.ai/modules/rules_license/0.0.7/MODULE.bazel": "not found", "https://bazel-registry.zml.ai/modules/rules_license/0.0.8/MODULE.bazel": "not found", + "https://bazel-registry.zml.ai/modules/rules_license/1.0.0/MODULE.bazel": "not found", "https://bazel-registry.zml.ai/modules/rules_multitool/0.4.0/MODULE.bazel": "not found", "https://bazel-registry.zml.ai/modules/rules_pkg/0.7.0/MODULE.bazel": "not found", "https://bazel-registry.zml.ai/modules/rules_pkg/0.9.1/MODULE.bazel": "not found", @@ -88,18 +117,23 @@ "https://bazel-registry.zml.ai/modules/rules_proto/6.0.2/MODULE.bazel": "not found", "https://bazel-registry.zml.ai/modules/rules_python/0.10.2/MODULE.bazel": "not found", "https://bazel-registry.zml.ai/modules/rules_python/0.22.1/MODULE.bazel": "not found", + "https://bazel-registry.zml.ai/modules/rules_python/0.23.1/MODULE.bazel": "not found", "https://bazel-registry.zml.ai/modules/rules_python/0.25.0/MODULE.bazel": "not found", + "https://bazel-registry.zml.ai/modules/rules_python/0.28.0/MODULE.bazel": "not found", "https://bazel-registry.zml.ai/modules/rules_python/0.29.0/MODULE.bazel": "not found", "https://bazel-registry.zml.ai/modules/rules_python/0.31.0/MODULE.bazel": "not found", + "https://bazel-registry.zml.ai/modules/rules_python/0.33.2/MODULE.bazel": "not found", "https://bazel-registry.zml.ai/modules/rules_python/0.34.0/MODULE.bazel": "not found", "https://bazel-registry.zml.ai/modules/rules_python/0.37.0/MODULE.bazel": "not found", "https://bazel-registry.zml.ai/modules/rules_python/0.4.0/MODULE.bazel": "not found", + "https://bazel-registry.zml.ai/modules/rules_shell/0.2.0/MODULE.bazel": "not found", "https://bazel-registry.zml.ai/modules/rules_swift/1.15.1/MODULE.bazel": "not found", "https://bazel-registry.zml.ai/modules/rules_uv/0.34.0/MODULE.bazel": "not found", "https://bazel-registry.zml.ai/modules/stardoc/0.5.1/MODULE.bazel": "not found", "https://bazel-registry.zml.ai/modules/stardoc/0.5.3/MODULE.bazel": "not found", "https://bazel-registry.zml.ai/modules/stardoc/0.5.4/MODULE.bazel": "not found", "https://bazel-registry.zml.ai/modules/stardoc/0.6.2/MODULE.bazel": "not found", + "https://bazel-registry.zml.ai/modules/stardoc/0.7.0/MODULE.bazel": "not found", "https://bazel-registry.zml.ai/modules/upb/0.0.0-20220923-a547704/MODULE.bazel": "not found", "https://bazel-registry.zml.ai/modules/upb/0.0.0-20230516-61a97ef/MODULE.bazel": "not found", "https://bazel-registry.zml.ai/modules/with_cfg.bzl/0.5.0/MODULE.bazel": "not found", @@ -107,6 +141,7 @@ "https://bazel-registry.zml.ai/modules/zlib/1.2.12/MODULE.bazel": "not found", "https://bazel-registry.zml.ai/modules/zlib/1.2.13/MODULE.bazel": "not found", "https://bazel-registry.zml.ai/modules/zlib/1.3.1.bcr.3/MODULE.bazel": "not found", + "https://bazel-registry.zml.ai/modules/zlib/1.3.1/MODULE.bazel": "not found", "https://bazel-registry.zml.ai/modules/zstd/1.5.6/MODULE.bazel": "not found", "https://bcr.bazel.build/bazel_registry.json": "8a28e4aff06ee60aed2a8c281907fb8bcbf3b753c91fb5a5c57da3215d5b3497", "https://bcr.bazel.build/modules/abseil-cpp/20210324.2/MODULE.bazel": "7cd0312e064fde87c8d1cd79ba06c876bd23630c83466e9500321be55c96ace2", @@ -114,10 +149,15 @@ "https://bcr.bazel.build/modules/abseil-cpp/20230125.1/MODULE.bazel": "89047429cb0207707b2dface14ba7f8df85273d484c2572755be4bab7ce9c3a0", "https://bcr.bazel.build/modules/abseil-cpp/20230802.0.bcr.1/MODULE.bazel": "1c8cec495288dccd14fdae6e3f95f772c1c91857047a098fad772034264cc8cb", "https://bcr.bazel.build/modules/abseil-cpp/20230802.0/MODULE.bazel": "d253ae36a8bd9ee3c5955384096ccb6baf16a1b1e93e858370da0a3b94f77c16", + "https://bcr.bazel.build/modules/abseil-cpp/20230802.1/MODULE.bazel": "fa92e2eb41a04df73cdabeec37107316f7e5272650f81d6cc096418fe647b915", "https://bcr.bazel.build/modules/abseil-cpp/20240116.0/MODULE.bazel": "98dc378d64c12a4e4741ad3362f87fb737ee6a0886b2d90c3cdbb4d93ea3e0bf", - "https://bcr.bazel.build/modules/abseil-cpp/20240116.0/source.json": "251927429731bd37831facad38ddfc83b8f6f680f819e1d4d35e811b30479d5b", + "https://bcr.bazel.build/modules/abseil-cpp/20240116.1/MODULE.bazel": "37bcdb4440fbb61df6a1c296ae01b327f19e9bb521f9b8e26ec854b6f97309ed", + "https://bcr.bazel.build/modules/abseil-cpp/20240116.2/MODULE.bazel": "73939767a4686cd9a520d16af5ab440071ed75cec1a876bf2fcfaf1f71987a16", + "https://bcr.bazel.build/modules/abseil-cpp/20240722.0.bcr.2/MODULE.bazel": "c3661b44c9d3f17f0b65ffb544896aaeb89127398ea867537babac18133a002a", + "https://bcr.bazel.build/modules/abseil-cpp/20240722.0.bcr.2/source.json": "464f3012c8f40cd51facbfc6962563971c6bd55f45ba16bd98313f2de73340c5", "https://bcr.bazel.build/modules/apple_support/1.11.1/MODULE.bazel": "1843d7cd8a58369a444fc6000e7304425fba600ff641592161d9f15b179fb896", - "https://bcr.bazel.build/modules/apple_support/1.11.1/source.json": "c797537544f4b76d46d12f488456529d7372b6ccff249c82fca50ce0a665957f", + "https://bcr.bazel.build/modules/apple_support/1.15.1/MODULE.bazel": "a0556fefca0b1bb2de8567b8827518f94db6a6e7e7d632b4c48dc5f865bc7c85", + "https://bcr.bazel.build/modules/apple_support/1.15.1/source.json": "517f2b77430084c541bc9be2db63fdcbb7102938c5f64c17ee60ffda2e5cf07b", "https://bcr.bazel.build/modules/apple_support/1.5.0/MODULE.bazel": "50341a62efbc483e8a2a6aec30994a58749bd7b885e18dd96aa8c33031e558ef", "https://bcr.bazel.build/modules/aspect_bazel_lib/2.7.9/MODULE.bazel": "06e54f2b345b8eb7adceed2329b273da00d0368e28a9ebd9dfc75b4a052dac85", "https://bcr.bazel.build/modules/aspect_bazel_lib/2.8.1/MODULE.bazel": "812d2dd42f65dca362152101fbec418029cc8fd34cbad1a2fde905383d705838", @@ -128,7 +168,11 @@ "https://bcr.bazel.build/modules/aspect_rules_py/1.0.0-rc0/source.json": "b8eaced4b9ab418f3498d9657f98c980e58f6fad397fc17081955dcf3813be3f", "https://bcr.bazel.build/modules/bazel_features/1.1.1/MODULE.bazel": "27b8c79ef57efe08efccbd9dd6ef70d61b4798320b8d3c134fd571f78963dbcd", "https://bcr.bazel.build/modules/bazel_features/1.11.0/MODULE.bazel": "f9382337dd5a474c3b7d334c2f83e50b6eaedc284253334cf823044a26de03e8", - "https://bcr.bazel.build/modules/bazel_features/1.11.0/source.json": "c9320aa53cd1c441d24bd6b716da087ad7e4ff0d9742a9884587596edfe53015", + "https://bcr.bazel.build/modules/bazel_features/1.15.0/MODULE.bazel": "d38ff6e517149dc509406aca0db3ad1efdd890a85e049585b7234d04238e2a4d", + "https://bcr.bazel.build/modules/bazel_features/1.17.0/MODULE.bazel": "039de32d21b816b47bd42c778e0454217e9c9caac4a3cf8e15c7231ee3ddee4d", + "https://bcr.bazel.build/modules/bazel_features/1.18.0/MODULE.bazel": "1be0ae2557ab3a72a57aeb31b29be347bcdc5d2b1eb1e70f39e3851a7e97041a", + "https://bcr.bazel.build/modules/bazel_features/1.19.0/MODULE.bazel": "59adcdf28230d220f0067b1f435b8537dd033bfff8db21335ef9217919c7fb58", + "https://bcr.bazel.build/modules/bazel_features/1.19.0/source.json": "d7bf14517c1b25b9d9c580b0f8795fceeae08a7590f507b76aace528e941375d", "https://bcr.bazel.build/modules/bazel_features/1.3.0/MODULE.bazel": "cdcafe83ec318cda34e02948e81d790aab8df7a929cec6f6969f13a489ccecd9", "https://bcr.bazel.build/modules/bazel_features/1.4.1/MODULE.bazel": "e45b6bb2350aff3e442ae1111c555e27eac1d915e77775f6fdc4b351b758b5d7", "https://bcr.bazel.build/modules/bazel_features/1.9.1/MODULE.bazel": "8f679097876a9b609ad1f60249c49d68bfab783dd9be012faf9d82547b14815a", @@ -141,6 +185,7 @@ "https://bcr.bazel.build/modules/bazel_skylib/1.4.2/MODULE.bazel": "3bd40978e7a1fac911d5989e6b09d8f64921865a45822d8b09e815eaa726a651", "https://bcr.bazel.build/modules/bazel_skylib/1.5.0/MODULE.bazel": "32880f5e2945ce6a03d1fbd588e9198c0a959bb42297b2cfaf1685b7bc32e138", "https://bcr.bazel.build/modules/bazel_skylib/1.6.1/MODULE.bazel": "8fdee2dbaace6c252131c00e1de4b165dc65af02ea278476187765e1a617b917", + "https://bcr.bazel.build/modules/bazel_skylib/1.7.0/MODULE.bazel": "0db596f4563de7938de764cc8deeabec291f55e8ec15299718b93c4423e9796d", "https://bcr.bazel.build/modules/bazel_skylib/1.7.1/MODULE.bazel": "3120d80c5861aa616222ec015332e5f8d3171e062e3e804a2a0253e1be26e59b", "https://bcr.bazel.build/modules/bazel_skylib/1.7.1/source.json": "f121b43eeefc7c29efbd51b83d08631e2347297c95aac9764a701f2a6a2bb953", "https://bcr.bazel.build/modules/buildifier_prebuilt/6.1.2/MODULE.bazel": "2ef4962c8b0b6d8d21928a89190755619254459bc67f870dc0ccb9ba9952d444", @@ -152,15 +197,20 @@ "https://bcr.bazel.build/modules/google_benchmark/1.8.2/MODULE.bazel": "a70cf1bba851000ba93b58ae2f6d76490a9feb74192e57ab8e8ff13c34ec50cb", "https://bcr.bazel.build/modules/googletest/1.11.0/MODULE.bazel": "3a83f095183f66345ca86aa13c58b59f9f94a2f81999c093d4eeaa2d262d12f4", "https://bcr.bazel.build/modules/googletest/1.14.0.bcr.1/MODULE.bazel": "22c31a561553727960057361aa33bf20fb2e98584bc4fec007906e27053f80c6", - "https://bcr.bazel.build/modules/googletest/1.14.0.bcr.1/source.json": "41e9e129f80d8c8bf103a7acc337b76e54fad1214ac0a7084bf24f4cd924b8b4", "https://bcr.bazel.build/modules/googletest/1.14.0/MODULE.bazel": "cfbcbf3e6eac06ef9d85900f64424708cc08687d1b527f0ef65aa7517af8118f", + "https://bcr.bazel.build/modules/googletest/1.15.2/MODULE.bazel": "6de1edc1d26cafb0ea1a6ab3f4d4192d91a312fd2d360b63adaa213cd00b2108", + "https://bcr.bazel.build/modules/googletest/1.15.2/source.json": "dbdda654dcb3a0d7a8bc5d0ac5fc7e150b58c2a986025ae5bc634bb2cb61f470", "https://bcr.bazel.build/modules/hermetic_cc_toolchain/3.1.0/MODULE.bazel": "ea4b3a25a9417a7db57a8a2f9ebdee91d679823c6274b482b817ed128d81c594", "https://bcr.bazel.build/modules/hermetic_cc_toolchain/3.1.0/source.json": "9d1df0459caefdf41052d360469922a73e219f67c8ce4da0628cc604469822b9", + "https://bcr.bazel.build/modules/jsoncpp/1.9.5/MODULE.bazel": "31271aedc59e815656f5736f282bb7509a97c7ecb43e927ac1a37966e0578075", + "https://bcr.bazel.build/modules/jsoncpp/1.9.5/source.json": "4108ee5085dd2885a341c7fab149429db457b3169b86eb081fa245eadf69169d", "https://bcr.bazel.build/modules/libpfm/4.11.0/MODULE.bazel": "45061ff025b301940f1e30d2c16bea596c25b176c8b6b3087e92615adbd52902", "https://bcr.bazel.build/modules/nlohmann_json/3.6.1/MODULE.bazel": "6f7b417dcc794d9add9e556673ad25cb3ba835224290f4f848f8e2db1e1fca74", "https://bcr.bazel.build/modules/nlohmann_json/3.6.1/source.json": "f448c6e8963fdfa7eb831457df83ad63d3d6355018f6574fb017e8169deb43a9", "https://bcr.bazel.build/modules/patchelf/0.18.0/MODULE.bazel": "15a6beff7e828d585c5bd0f9f93589df117b5594e9d19e43096c77de58b9ae5f", "https://bcr.bazel.build/modules/patchelf/0.18.0/source.json": "57caf6bcaa5ba515c6fb1c2eacee00735afbeb1ffacb34a57553fb139c8e4333", + "https://bcr.bazel.build/modules/pcre2/10.43/MODULE.bazel": "08eaa025111bd0fedc14a8187c2905fa6ee4501fbe558193e9bf6cc3e2cdf23c", + "https://bcr.bazel.build/modules/pcre2/10.43/source.json": "8b4149e707094f1d5b57df7216539c3415226e814085c4d960bd9f3d49581b88", "https://bcr.bazel.build/modules/platforms/0.0.10/MODULE.bazel": "8cb8efaf200bdeb2150d93e162c40f388529a25852b332cec879373771e48ed5", "https://bcr.bazel.build/modules/platforms/0.0.10/source.json": "f22828ff4cf021a6b577f1bf6341cb9dcd7965092a439f64fc1bb3b7a5ae4bd5", "https://bcr.bazel.build/modules/platforms/0.0.4/MODULE.bazel": "9b328e31ee156f53f3c416a64f8491f7eb731742655a47c9eec4703a71644aee", @@ -172,42 +222,61 @@ "https://bcr.bazel.build/modules/protobuf/21.7/MODULE.bazel": "a5a29bb89544f9b97edce05642fac225a808b5b7be74038ea3640fae2f8e66a7", "https://bcr.bazel.build/modules/protobuf/23.1/MODULE.bazel": "88b393b3eb4101d18129e5db51847cd40a5517a53e81216144a8c32dfeeca52a", "https://bcr.bazel.build/modules/protobuf/24.4/MODULE.bazel": "7bc7ce5f2abf36b3b7b7c8218d3acdebb9426aeb35c2257c96445756f970eb12", - "https://bcr.bazel.build/modules/protobuf/24.4/source.json": "ace4b8c65d4cfe64efe544f09fc5e5df77faf3a67fbb29c5341e0d755d9b15d6", + "https://bcr.bazel.build/modules/protobuf/27.0/MODULE.bazel": "7873b60be88844a0a1d8f80b9d5d20cfbd8495a689b8763e76c6372998d3f64c", + "https://bcr.bazel.build/modules/protobuf/29.2/MODULE.bazel": "5435497c190d86f79b0568698c45044df7c8d97692886cda9fe9cf9053aea712", + "https://bcr.bazel.build/modules/protobuf/29.2/source.json": "fe7090cc34072609b26d9beafb122916dabc1d47ba61b242c26c4b06c51384ab", "https://bcr.bazel.build/modules/protobuf/3.19.0/MODULE.bazel": "6b5fbb433f760a99a22b18b6850ed5784ef0e9928a72668b66e4d7ccd47db9b0", "https://bcr.bazel.build/modules/protobuf/3.19.6/MODULE.bazel": "9233edc5e1f2ee276a60de3eaa47ac4132302ef9643238f23128fea53ea12858", "https://bcr.bazel.build/modules/pybind11_bazel/2.11.1.bzl.1/MODULE.bazel": "1ef2994c097ee88f8f7ae8fbf991aaefb0603b2540fe575eca14943bc9f220a6", - "https://bcr.bazel.build/modules/pybind11_bazel/2.11.1.bzl.1/source.json": "d8f5b2ebc186b90c6112f92f43d86359dda2c3649c754d9680fd668f8dd28a79", "https://bcr.bazel.build/modules/pybind11_bazel/2.11.1/MODULE.bazel": "88af1c246226d87e65be78ed49ecd1e6f5e98648558c14ce99176da041dc378e", + "https://bcr.bazel.build/modules/pybind11_bazel/2.12.0/MODULE.bazel": "e6f4c20442eaa7c90d7190d8dc539d0ab422f95c65a57cc59562170c58ae3d34", + "https://bcr.bazel.build/modules/pybind11_bazel/2.12.0/source.json": "6900fdc8a9e95866b8c0d4ad4aba4d4236317b5c1cd04c502df3f0d33afed680", "https://bcr.bazel.build/modules/re2/2023-09-01/MODULE.bazel": "cb3d511531b16cfc78a225a9e2136007a48cf8a677e4264baeab57fe78a80206", "https://bcr.bazel.build/modules/re2/2024-02-01/MODULE.bazel": "5ed922cb8b6c110e30969695e73bd0d3159576bf17ce8ee2443a7d07bf500551", - "https://bcr.bazel.build/modules/re2/2024-02-01/source.json": "0b108d5e9836cb66815fbbb70e4395eab52dc29dd2c39a9785f01d6661a8f37e", + "https://bcr.bazel.build/modules/re2/2024-07-02/MODULE.bazel": "0eadc4395959969297cbcf31a249ff457f2f1d456228c67719480205aa306daa", + "https://bcr.bazel.build/modules/re2/2024-07-02/source.json": "547d0111a9d4f362db32196fef805abbf3676e8d6afbe44d395d87816c1130ca", + "https://bcr.bazel.build/modules/rules_android/0.1.1/MODULE.bazel": "48809ab0091b07ad0182defb787c4c5328bd3a278938415c00a7b69b50c4d3a8", + "https://bcr.bazel.build/modules/rules_android/0.1.1/source.json": "e6986b41626ee10bdc864937ffb6d6bf275bb5b9c65120e6137d56e6331f089e", "https://bcr.bazel.build/modules/rules_apple/3.2.1/MODULE.bazel": "55f19b572fdb4a4bd5a1c2231b60c663f8b4e3146769062b2bdeba72226c74b7", "https://bcr.bazel.build/modules/rules_apple/3.2.1/source.json": "b7e8aa85c5fcd9dfec8ea62642b7e93ca161a03b2c403ae05872813f5dfeb7be", "https://bcr.bazel.build/modules/rules_cc/0.0.1/MODULE.bazel": "cb2aa0747f84c6c3a78dad4e2049c154f08ab9d166b1273835a8174940365647", + "https://bcr.bazel.build/modules/rules_cc/0.0.10/MODULE.bazel": "ec1705118f7eaedd6e118508d3d26deba2a4e76476ada7e0e3965211be012002", + "https://bcr.bazel.build/modules/rules_cc/0.0.16/MODULE.bazel": "7661303b8fc1b4d7f532e54e9d6565771fea666fbdf839e0a86affcd02defe87", + "https://bcr.bazel.build/modules/rules_cc/0.0.16/source.json": "227e83737046aa4f50015da48e98e0d8ab42fd0ec74d8d653b6cc9f9a357f200", "https://bcr.bazel.build/modules/rules_cc/0.0.2/MODULE.bazel": "6915987c90970493ab97393024c156ea8fb9f3bea953b2f3ec05c34f19b5695c", "https://bcr.bazel.build/modules/rules_cc/0.0.6/MODULE.bazel": "abf360251023dfe3efcef65ab9d56beefa8394d4176dd29529750e1c57eaa33f", "https://bcr.bazel.build/modules/rules_cc/0.0.8/MODULE.bazel": "964c85c82cfeb6f3855e6a07054fdb159aced38e99a5eecf7bce9d53990afa3e", "https://bcr.bazel.build/modules/rules_cc/0.0.9/MODULE.bazel": "836e76439f354b89afe6a911a7adf59a6b2518fafb174483ad78a2a2fde7b1c5", - "https://bcr.bazel.build/modules/rules_cc/0.0.9/source.json": "1f1ba6fea244b616de4a554a0f4983c91a9301640c8fe0dd1d410254115c8430", "https://bcr.bazel.build/modules/rules_distroless/0.3.8/MODULE.bazel": "7d7cf5b71d0f05ea30308c379ee7c3e69caddb2c94878796799333ffcd6aa840", "https://bcr.bazel.build/modules/rules_distroless/0.3.8/source.json": "a2421c594d7685202be9a18e89e88fb0c8e1acfea55d0e0cf0452244cb1bf250", "https://bcr.bazel.build/modules/rules_foreign_cc/0.9.0/MODULE.bazel": "c9e8c682bf75b0e7c704166d79b599f93b72cfca5ad7477df596947891feeef6", + "https://bcr.bazel.build/modules/rules_fuzzing/0.5.2/MODULE.bazel": "40c97d1144356f52905566c55811f13b299453a14ac7769dfba2ac38192337a8", + "https://bcr.bazel.build/modules/rules_fuzzing/0.5.2/source.json": "c8b1e2c717646f1702290959a3302a178fb639d987ab61d548105019f11e527e", "https://bcr.bazel.build/modules/rules_java/4.0.0/MODULE.bazel": "5a78a7ae82cd1a33cef56dc578c7d2a46ed0dca12643ee45edbb8417899e6f74", "https://bcr.bazel.build/modules/rules_java/5.3.5/MODULE.bazel": "a4ec4f2db570171e3e5eb753276ee4b389bae16b96207e9d3230895c99644b86", "https://bcr.bazel.build/modules/rules_java/6.3.0/MODULE.bazel": "a97c7678c19f236a956ad260d59c86e10a463badb7eb2eda787490f4c969b963", + "https://bcr.bazel.build/modules/rules_java/6.5.2/MODULE.bazel": "1d440d262d0e08453fa0c4d8f699ba81609ed0e9a9a0f02cd10b3e7942e61e31", "https://bcr.bazel.build/modules/rules_java/7.1.0/MODULE.bazel": "30d9135a2b6561c761bd67bd4990da591e6bdc128790ce3e7afd6a3558b2fb64", + "https://bcr.bazel.build/modules/rules_java/7.10.0/MODULE.bazel": "530c3beb3067e870561739f1144329a21c851ff771cd752a49e06e3dc9c2e71a", + "https://bcr.bazel.build/modules/rules_java/7.12.2/MODULE.bazel": "579c505165ee757a4280ef83cda0150eea193eed3bef50b1004ba88b99da6de6", + "https://bcr.bazel.build/modules/rules_java/7.12.2/source.json": "b0890f9cda8ff1b8e691a3ac6037b5c14b7fd4134765a3946b89f31ea02e5884", + "https://bcr.bazel.build/modules/rules_java/7.2.0/MODULE.bazel": "06c0334c9be61e6cef2c8c84a7800cef502063269a5af25ceb100b192453d4ab", "https://bcr.bazel.build/modules/rules_java/7.3.2/MODULE.bazel": "50dece891cfdf1741ea230d001aa9c14398062f2b7c066470accace78e412bc2", + "https://bcr.bazel.build/modules/rules_java/7.6.1/MODULE.bazel": "2f14b7e8a1aa2f67ae92bc69d1ec0fa8d9f827c4e17ff5e5f02e91caa3b2d0fe", "https://bcr.bazel.build/modules/rules_java/7.6.5/MODULE.bazel": "481164be5e02e4cab6e77a36927683263be56b7e36fef918b458d7a8a1ebadb1", - "https://bcr.bazel.build/modules/rules_java/7.6.5/source.json": "a805b889531d1690e3c72a7a7e47a870d00323186a9904b36af83aa3d053ee8d", "https://bcr.bazel.build/modules/rules_jvm_external/4.4.2/MODULE.bazel": "a56b85e418c83eb1839819f0b515c431010160383306d13ec21959ac412d2fe7", "https://bcr.bazel.build/modules/rules_jvm_external/5.1/MODULE.bazel": "33f6f999e03183f7d088c9be518a63467dfd0be94a11d0055fe2d210f89aa909", "https://bcr.bazel.build/modules/rules_jvm_external/5.2/MODULE.bazel": "d9351ba35217ad0de03816ef3ed63f89d411349353077348a45348b096615036", - "https://bcr.bazel.build/modules/rules_jvm_external/5.2/source.json": "10572111995bc349ce31c78f74b3c147f6b3233975c7fa5eff9211f6db0d34d9", + "https://bcr.bazel.build/modules/rules_jvm_external/6.3/MODULE.bazel": "c998e060b85f71e00de5ec552019347c8bca255062c990ac02d051bb80a38df0", + "https://bcr.bazel.build/modules/rules_jvm_external/6.3/source.json": "6f5f5a5a4419ae4e37c35a5bb0a6ae657ed40b7abc5a5189111b47fcebe43197", + "https://bcr.bazel.build/modules/rules_kotlin/1.9.6/MODULE.bazel": "d269a01a18ee74d0335450b10f62c9ed81f2321d7958a2934e44272fe82dcef3", + "https://bcr.bazel.build/modules/rules_kotlin/1.9.6/source.json": "2faa4794364282db7c06600b7e5e34867a564ae91bda7cae7c29c64e9466b7d5", "https://bcr.bazel.build/modules/rules_license/0.0.3/MODULE.bazel": "627e9ab0247f7d1e05736b59dbb1b6871373de5ad31c3011880b4133cafd4bd0", "https://bcr.bazel.build/modules/rules_license/0.0.4/MODULE.bazel": "6a88dd22800cf1f9f79ba32cacad0d3a423ed28efa2c2ed5582eaa78dd3ac1e5", "https://bcr.bazel.build/modules/rules_license/0.0.7/MODULE.bazel": "088fbeb0b6a419005b89cf93fe62d9517c0a2b8bb56af3244af65ecfe37e7d5d", "https://bcr.bazel.build/modules/rules_license/0.0.8/MODULE.bazel": "5669c6fe49b5134dbf534db681ad3d67a2d49cfc197e4a95f1ca2fd7f3aebe96", - "https://bcr.bazel.build/modules/rules_license/0.0.8/source.json": "ccfd3964cd0cd1739202efb8dbf9a06baab490e61e174b2ad4790f9c4e610beb", + "https://bcr.bazel.build/modules/rules_license/1.0.0/MODULE.bazel": "a7fda60eefdf3d8c827262ba499957e4df06f659330bbe6cdbdb975b768bb65c", + "https://bcr.bazel.build/modules/rules_license/1.0.0/source.json": "a52c89e54cc311196e478f8382df91c15f7a2bfdf4c6cd0e2675cc2ff0b56efb", "https://bcr.bazel.build/modules/rules_multitool/0.4.0/MODULE.bazel": "15517987d5c00c9e7faab41fbe22ee67a350b6eabcc1e08baded5c6d9025897f", "https://bcr.bazel.build/modules/rules_multitool/0.4.0/source.json": "d73b450b7c6d9683e400d6cebc463fbc2b870cc5d8e2e75080d6278805aaab08", "https://bcr.bazel.build/modules/rules_pkg/0.7.0/MODULE.bazel": "df99f03fc7934a4737122518bb87e667e62d780b610910f0447665a7e2be62dc", @@ -221,13 +290,18 @@ "https://bcr.bazel.build/modules/rules_proto/6.0.2/source.json": "17a2e195f56cb28d6bbf763e49973d13890487c6945311ed141e196fb660426d", "https://bcr.bazel.build/modules/rules_python/0.10.2/MODULE.bazel": "cc82bc96f2997baa545ab3ce73f196d040ffb8756fd2d66125a530031cd90e5f", "https://bcr.bazel.build/modules/rules_python/0.22.1/MODULE.bazel": "26114f0c0b5e93018c0c066d6673f1a2c3737c7e90af95eff30cfee38d0bbac7", + "https://bcr.bazel.build/modules/rules_python/0.23.1/MODULE.bazel": "49ffccf0511cb8414de28321f5fcf2a31312b47c40cc21577144b7447f2bf300", "https://bcr.bazel.build/modules/rules_python/0.25.0/MODULE.bazel": "72f1506841c920a1afec76975b35312410eea3aa7b63267436bfb1dd91d2d382", + "https://bcr.bazel.build/modules/rules_python/0.28.0/MODULE.bazel": "cba2573d870babc976664a912539b320cbaa7114cd3e8f053c720171cde331ed", "https://bcr.bazel.build/modules/rules_python/0.29.0/MODULE.bazel": "2ac8cd70524b4b9ec49a0b8284c79e4cd86199296f82f6e0d5da3f783d660c82", "https://bcr.bazel.build/modules/rules_python/0.31.0/MODULE.bazel": "93a43dc47ee570e6ec9f5779b2e64c1476a6ce921c48cc9a1678a91dd5f8fd58", + "https://bcr.bazel.build/modules/rules_python/0.33.2/MODULE.bazel": "3e036c4ad8d804a4dad897d333d8dce200d943df4827cb849840055be8d2e937", "https://bcr.bazel.build/modules/rules_python/0.34.0/MODULE.bazel": "1d623d026e075b78c9fde483a889cda7996f5da4f36dffb24c246ab30f06513a", "https://bcr.bazel.build/modules/rules_python/0.37.0/MODULE.bazel": "bd90c62e4c789ea94ed61ab21a5a538dd4145548d1de994192049652d433816e", "https://bcr.bazel.build/modules/rules_python/0.37.0/source.json": "c17b8ca7a2348fd8fa96ad5b414223dd1ce5d6e8265c3134a88d337b0554d53c", "https://bcr.bazel.build/modules/rules_python/0.4.0/MODULE.bazel": "9208ee05fd48bf09ac60ed269791cf17fb343db56c8226a720fbb1cdf467166c", + "https://bcr.bazel.build/modules/rules_shell/0.2.0/MODULE.bazel": "fda8a652ab3c7d8fee214de05e7a9916d8b28082234e8d2c0094505c5268ed3c", + "https://bcr.bazel.build/modules/rules_shell/0.2.0/source.json": "7f27af3c28037d9701487c4744b5448d26537cc66cdef0d8df7ae85411f8de95", "https://bcr.bazel.build/modules/rules_swift/1.15.1/MODULE.bazel": "7031d3e5221b54dfee3901d221f10f54a8b0f2a64d4616de7879bcf83fe8d85d", "https://bcr.bazel.build/modules/rules_swift/1.15.1/source.json": "6472a4607d0a2f39eeb7daae78054b995aba593caad99aa64561f631fcf93a63", "https://bcr.bazel.build/modules/rules_uv/0.34.0/MODULE.bazel": "fb7c2da897786eac4b643d1ed516be715c11566620ee5cf022d7009298ad9590", @@ -236,10 +310,10 @@ "https://bcr.bazel.build/modules/stardoc/0.5.3/MODULE.bazel": "c7f6948dae6999bf0db32c1858ae345f112cacf98f174c7a8bb707e41b974f1c", "https://bcr.bazel.build/modules/stardoc/0.5.4/MODULE.bazel": "6569966df04610b8520957cb8e97cf2e9faac2c0309657c537ab51c16c18a2a4", "https://bcr.bazel.build/modules/stardoc/0.6.2/MODULE.bazel": "7060193196395f5dd668eda046ccbeacebfd98efc77fed418dbe2b82ffaa39fd", - "https://bcr.bazel.build/modules/stardoc/0.6.2/source.json": "d2ff8063b63b4a85e65fe595c4290f99717434fa9f95b4748a79a7d04dfed349", + "https://bcr.bazel.build/modules/stardoc/0.7.0/MODULE.bazel": "05e3d6d30c099b6770e97da986c53bd31844d7f13d41412480ea265ac9e8079c", + "https://bcr.bazel.build/modules/stardoc/0.7.0/source.json": "e3c524bf2ef20992539ce2bc4a2243f4853130209ee831689983e28d05769099", "https://bcr.bazel.build/modules/upb/0.0.0-20220923-a547704/MODULE.bazel": "7298990c00040a0e2f121f6c32544bab27d4452f80d9ce51349b1a28f3005c43", "https://bcr.bazel.build/modules/upb/0.0.0-20230516-61a97ef/MODULE.bazel": "c0df5e35ad55e264160417fd0875932ee3c9dda63d9fccace35ac62f45e1b6f9", - "https://bcr.bazel.build/modules/upb/0.0.0-20230516-61a97ef/source.json": "b2150404947339e8b947c6b16baa39fa75657f4ddec5e37272c7b11c7ab533bc", "https://bcr.bazel.build/modules/with_cfg.bzl/0.5.0/MODULE.bazel": "67fa8ac990536334d99ce6c18d75273e61544f59f1b170c93bf30b9b27be0ab0", "https://bcr.bazel.build/modules/with_cfg.bzl/0.5.0/source.json": "c78e66485e2463cb2f260592793dd67343eb4f5ed44e572749d366a96fc502c1", "https://bcr.bazel.build/modules/zlib/1.2.11/MODULE.bazel": "07b389abc85fdbca459b69e2ec656ae5622873af3f845e1c9d80fe179f3effa0", @@ -247,6 +321,7 @@ "https://bcr.bazel.build/modules/zlib/1.2.13/MODULE.bazel": "aa6deb1b83c18ffecd940c4119aff9567cd0a671d7bba756741cb2ef043a29d5", "https://bcr.bazel.build/modules/zlib/1.3.1.bcr.3/MODULE.bazel": "af322bc08976524477c79d1e45e241b6efbeb918c497e8840b8ab116802dda79", "https://bcr.bazel.build/modules/zlib/1.3.1.bcr.3/source.json": "2be409ac3c7601245958cd4fcdff4288be79ed23bd690b4b951f500d54ee6e7d", + "https://bcr.bazel.build/modules/zlib/1.3.1/MODULE.bazel": "751c9940dcfe869f5f7274e1295422a34623555916eb98c174c1e945594bf198", "https://bcr.bazel.build/modules/zstd/1.5.6/MODULE.bazel": "471ebe7d3cdd8c6469390fcf623eb4779ff55fbee0a87f1dc57a1def468b96d4", "https://bcr.bazel.build/modules/zstd/1.5.6/source.json": "02010c3333fc89b44fe861db049968decb6e688411f7f9d4f6791d74f9adfb51" }, @@ -254,8 +329,8 @@ "moduleExtensions": { "@@apple_support~//crosstool:setup.bzl%apple_cc_configure_extension": { "general": { - "bzlTransitiveDigest": "hDHJiBbKme6a+N8oiSQcVnU1v5B7tHMjJaAzS6GFfPc=", - "usagesDigest": "8MpdqvE6998JkKyqx+txaHjL8YIQGCDb8inyLInqs4w=", + "bzlTransitiveDigest": "7rY6uLsMi3Ma6rwkL3yK4deWcIXKE2ScY4Kt8lA079s=", + "usagesDigest": "2rUj1nIKMIRWTPS0bs9eJAzlNwSbV3APk1f7UNpjXq0=", "recordedFileInputs": {}, "recordedDirentsInputs": {}, "envVariables": {}, @@ -1079,29 +1154,69 @@ "recordedRepoMappingEntries": [] } }, - "@@protobuf~//:non_module_deps.bzl%non_module_deps": { + "@@rules_kotlin~//src/main/starlark/core/repositories:bzlmod_setup.bzl%rules_kotlin_extensions": { "general": { - "bzlTransitiveDigest": "zrC0Xg5rY819dsKgDXDP+eTr1lB/eGewLGy9h4DnUBg=", - "usagesDigest": "1JwsUDre7ljlZoaD2WfcvUlKnXUonmxIKAVBQ82j6Ig=", + "bzlTransitiveDigest": "mjEpMcNvt8O97wimreF4hDPVsJeMJ5KQ4Mrv+yWl4Ps=", + "usagesDigest": "aJF6fLy82rR95Ff5CZPAqxNoFgOMLMN5ImfBS0nhnkg=", "recordedFileInputs": {}, "recordedDirentsInputs": {}, "envVariables": {}, "generatedRepoSpecs": { - "utf8_range": { + "com_github_jetbrains_kotlin_git": { + "bzlFile": "@@rules_kotlin~//src/main/starlark/core/repositories:compiler.bzl", + "ruleClassName": "kotlin_compiler_git_repository", + "attributes": { + "urls": [ + "https://github.com/JetBrains/kotlin/releases/download/v1.9.23/kotlin-compiler-1.9.23.zip" + ], + "sha256": "93137d3aab9afa9b27cb06a824c2324195c6b6f6179d8a8653f440f5bd58be88" + } + }, + "com_github_jetbrains_kotlin": { + "bzlFile": "@@rules_kotlin~//src/main/starlark/core/repositories:compiler.bzl", + "ruleClassName": "kotlin_capabilities_repository", + "attributes": { + "git_repository_name": "com_github_jetbrains_kotlin_git", + "compiler_version": "1.9.23" + } + }, + "com_github_google_ksp": { + "bzlFile": "@@rules_kotlin~//src/main/starlark/core/repositories:ksp.bzl", + "ruleClassName": "ksp_compiler_plugin_repository", + "attributes": { + "urls": [ + "https://github.com/google/ksp/releases/download/1.9.23-1.0.20/artifacts.zip" + ], + "sha256": "ee0618755913ef7fd6511288a232e8fad24838b9af6ea73972a76e81053c8c2d", + "strip_version": "1.9.23-1.0.20" + } + }, + "com_github_pinterest_ktlint": { + "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", + "ruleClassName": "http_file", + "attributes": { + "sha256": "01b2e0ef893383a50dbeb13970fe7fa3be36ca3e83259e01649945b09d736985", + "urls": [ + "https://github.com/pinterest/ktlint/releases/download/1.3.0/ktlint" + ], + "executable": true + } + }, + "rules_android": { "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", "ruleClassName": "http_archive", "attributes": { + "sha256": "cd06d15dd8bb59926e4d65f9003bfc20f9da4b2519985c27e190cddc8b7a7806", + "strip_prefix": "rules_android-0.1.1", "urls": [ - "https://github.com/protocolbuffers/utf8_range/archive/de0b4a8ff9b5d4c98108bdfe723291a33c52c54f.zip" - ], - "strip_prefix": "utf8_range-de0b4a8ff9b5d4c98108bdfe723291a33c52c54f", - "sha256": "5da960e5e5d92394c809629a03af3c7709d2d3d0ca731dacb3a9fb4bf28f7702" + "https://github.com/bazelbuild/rules_android/archive/v0.1.1.zip" + ] } } }, "recordedRepoMappingEntries": [ [ - "protobuf~", + "rules_kotlin~", "bazel_tools", "bazel_tools" ] diff --git a/bazel/swig.bzl b/bazel/swig.bzl new file mode 100644 index 00000000..757e2311 --- /dev/null +++ b/bazel/swig.bzl @@ -0,0 +1,149 @@ +load("@rules_cc//cc:action_names.bzl", "C_COMPILE_ACTION_NAME") +load("@rules_cc//cc:find_cc_toolchain.bzl", "find_cc_toolchain", "use_cc_toolchain") + +def _swig_cc_library_impl(ctx): + args = ctx.actions.args() + + if ctx.attr.cpp: + args.add("-c++") + + args.add("-std=c++17") + args.add("-c") + args.add("-O") + args.add("-module", ctx.attr.module) + args.add_joined("-features", ctx.attr.enabled_features, join_with = ",") + + if ctx.attr.defines: + args.add_all(ctx.attr.defines, format_each = "-D%s") + + cc_toolchain = find_cc_toolchain(ctx) + if (cc_toolchain): + args.add_all(cc_toolchain.built_in_include_directories, format_each = "-I%s") + + feature_configuration = cc_common.configure_features( + ctx = ctx, + cc_toolchain = cc_toolchain, + requested_features = ctx.features, + unsupported_features = ctx.disabled_features, + ) + c_compile_variables = cc_common.create_compile_variables( + feature_configuration = feature_configuration, + cc_toolchain = cc_toolchain, + user_compile_flags = ctx.fragments.cpp.copts + ctx.fragments.cpp.conlyopts, + ) + cc_compile_command_line = cc_common.get_memory_inefficient_command_line( + feature_configuration = feature_configuration, + action_name = C_COMPILE_ACTION_NAME, + variables = c_compile_variables, + ) + for arg in cc_compile_command_line: + if (arg.startswith("-I") or arg.startswith("-D")): + args.add(arg) + + cc_info = cc_common.merge_cc_infos(direct_cc_infos = [dep[CcInfo] for dep in ctx.attr.deps]) + args.add_all(cc_info.compilation_context.defines, format_each = "-D%s") + args.add_all(cc_info.compilation_context.local_defines, format_each = "-D%s") + args.add_all(cc_info.compilation_context.framework_includes, format_each = "-I%s") + args.add_all(cc_info.compilation_context.includes, format_each = "-I%s") + args.add_all(cc_info.compilation_context.quote_includes, format_each = "-I%s") + args.add_all(cc_info.compilation_context.system_includes, format_each = "-I%s") + + output_cpp = ctx.actions.declare_file("%s.cpp" % ctx.attr.module) + output_h = ctx.actions.declare_file("%s.h" % ctx.attr.module) + args.add("-outdir", output_h.dirname) + + outputs = [ + output_cpp, + output_h, + ] + args.add("-o", output_cpp) + args.add("-w-305") + args.add(ctx.file.interface) + + inputs = depset(ctx.attr.srcs, transitive = [ + ctx.attr.interface.files, + cc_info.compilation_context.headers, + ctx.attr._swig_lib.files, + ]) + + ctx.actions.run( + inputs = inputs, + outputs = outputs, + executable = ctx.executable._swig, + arguments = [args], + env = { + "SWIG_LIB": ctx.files._swig_lib[0].dirname, + }, + mnemonic = "SwigC", + ) + + return [ + DefaultInfo( + files = depset(outputs), + ), + OutputGroupInfo( + hdrs = depset([output_h]), + srcs = depset([output_cpp]), + ), + ] + +_swig_cc_library = rule( + _swig_cc_library_impl, + attrs = { + "interface": attr.label( + mandatory = True, + allow_single_file = True, + ), + "srcs": attr.label_list( + allow_files = True, + ), + "deps": attr.label_list( + providers = [CcInfo], + ), + "defines": attr.string_list(), + "enabled_features": attr.string_list(), + "module": attr.string( + mandatory = True, + ), + "cpp": attr.bool( + default = True, + ), + "intgosize": attr.int( + default = 64, + ), + "_swig": attr.label( + default = "@org_swig_swig//:swig", + cfg = "exec", + executable = True, + ), + "_swig_lib": attr.label( + default = "@org_swig_swig//:lib", + allow_files = True, + ), + }, + toolchains = use_cc_toolchain(), + fragments = ["cpp"], +) + +def swig_cc_library(name, deps = [], **kwargs): + _swig_cc_library( + name = "{}.swig".format(name), + deps = deps, + **kwargs + ) + native.filegroup( + name = "{}.hdrs".format(name), + srcs = [":{}.swig".format(name)], + output_group = "hdrs", + ) + native.filegroup( + name = "{}.srcs".format(name), + srcs = [":{}.swig".format(name)], + output_group = "srcs", + ) + native.cc_library( + name = name, + hdrs = [":{}.hdrs".format(name)], + srcs = [":{}.srcs".format(name)], + deps = deps, + ) diff --git a/third_party/com_google_sentencepiece/BUILD.bazel b/third_party/com_google_sentencepiece/BUILD.bazel new file mode 100644 index 00000000..7314ec78 --- /dev/null +++ b/third_party/com_google_sentencepiece/BUILD.bazel @@ -0,0 +1,38 @@ +load(":fwd.bzl", "include_fwd") + +include_fwd( + name = "absl_hdrs", + includes = [ + "absl/container/flat_hash_map.h", + "absl/container/flat_hash_set.h", + "absl/flags/flag.h", + "absl/flags/parse.h", + "absl/flags/usage.h", + "absl/strings/match.h", + "absl/strings/numbers.h", + "absl/strings/str_cat.h", + "absl/strings/str_format.h", + "absl/strings/str_join.h", + "absl/strings/str_replace.h", + "absl/strings/str_split.h", + "absl/strings/string_view.h", + "absl/strings/strip.h", + ], +) + +cc_library( + name = "absl", + hdrs = [":absl_hdrs"], + include_prefix = "third_party", + includes = ["."], + visibility = ["//visibility:public"], + deps = [ + "@abseil-cpp//absl/container:flat_hash_map", + "@abseil-cpp//absl/container:flat_hash_set", + "@abseil-cpp//absl/flags:flag", + "@abseil-cpp//absl/flags:parse", + "@abseil-cpp//absl/flags:usage", + "@abseil-cpp//absl/strings", + "@abseil-cpp//absl/strings:string_view", + ], +) diff --git a/third_party/com_google_sentencepiece/fwd.bzl b/third_party/com_google_sentencepiece/fwd.bzl new file mode 100644 index 00000000..dd4836f5 --- /dev/null +++ b/third_party/com_google_sentencepiece/fwd.bzl @@ -0,0 +1,14 @@ +def _include_fwd_impl(ctx): + files = [] + for include in ctx.attr.includes: + f = ctx.actions.declare_file(include) + ctx.actions.write(f, '#include "{}"'.format(include)) + files.append(f) + return [DefaultInfo(files = depset(files))] + +include_fwd = rule( + implementation = _include_fwd_impl, + attrs = { + "includes": attr.string_list(), + }, +) diff --git a/third_party/com_google_sentencepiece/repo.bzl b/third_party/com_google_sentencepiece/repo.bzl new file mode 100644 index 00000000..4487523d --- /dev/null +++ b/third_party/com_google_sentencepiece/repo.bzl @@ -0,0 +1,9 @@ +load("@bazel_tools//tools/build_defs/repo:git.bzl", "new_git_repository") + +def repo(): + new_git_repository( + name = "com_google_sentencepiece", + remote = "https://github.com/google/sentencepiece.git", + commit = "d8f741853847553169444afc12c00f4bbff3e9ce", + build_file = "//third_party/com_google_sentencepiece:sentencepiece.bazel", + ) diff --git a/third_party/com_google_sentencepiece/sentencepiece.bazel b/third_party/com_google_sentencepiece/sentencepiece.bazel new file mode 100644 index 00000000..f896466f --- /dev/null +++ b/third_party/com_google_sentencepiece/sentencepiece.bazel @@ -0,0 +1,95 @@ +load("@bazel_skylib//rules:copy_file.bzl", "copy_file") +load("@protobuf//bazel:cc_proto_library.bzl", "cc_proto_library") +load("@protobuf//bazel:proto_library.bzl", "proto_library") + +package( + default_visibility = ["//visibility:public"], + features = [ + "layering_check", + "parse_headers", + ], +) + +licenses(["notice"]) # Apache 2, BSD, MIT + +proto_library( + name = "sentencepiece_proto", + srcs = ["src/sentencepiece.proto"], +) + +cc_proto_library( + name = "sentencepiece_cc_proto", + deps = [":sentencepiece_proto"], +) + +proto_library( + name = "sentencepiece_model_proto", + srcs = ["src/sentencepiece_model.proto"], +) + +cc_proto_library( + name = "sentencepiece_model_cc_proto", + deps = [":sentencepiece_model_proto"], +) + +copy_file( + name = "config_h", + src = "config.h.in", + out = "config.h", + allow_symlink = True, +) + +cc_library( + name = "darts_clone", + hdrs = glob([ + "third_party/darts_clone/*.h", + ]), + includes = ["."], +) + +cc_library( + name = "sentencepiece_processor", + srcs = [ + "src/bpe_model.cc", + "src/char_model.cc", + "src/error.cc", + "src/filesystem.cc", + "src/model_factory.cc", + "src/model_interface.cc", + "src/normalizer.cc", + "src/sentencepiece_processor.cc", + "src/unigram_model.cc", + "src/util.cc", + "src/word_model.cc", + ], + hdrs = [ + ":config_h", + "src/common.h", + "src/bpe_model.h", + "src/char_model.h", + "src/filesystem.h", + "src/freelist.h", + "src/init.h", + "src/model_factory.h", + "src/model_interface.h", + "src/normalizer.h", + "src/sentencepiece_processor.h", + "src/trainer_interface.h", + "src/unigram_model.h", + "src/util.h", + "src/word_model.h", + ], + defines = [ + "_USE_EXTERNAL_PROTOBUF", + "_USE_EXTERNAL_ABSL", + ], + includes = [ + "src", + ], + deps = [ + ":darts_clone", + ":sentencepiece_cc_proto", + ":sentencepiece_model_cc_proto", + "@@//third_party/com_google_sentencepiece:absl", + ], +) diff --git a/third_party/non_module_deps.bzl b/third_party/non_module_deps.bzl new file mode 100644 index 00000000..004a45e9 --- /dev/null +++ b/third_party/non_module_deps.bzl @@ -0,0 +1,16 @@ +load("//:third_party/org_swig_swig/repo.bzl", org_swig_swig = "repo") +load("//third_party/com_google_sentencepiece:repo.bzl", com_google_sentencepiece = "repo") + +def _non_module_deps_impl(mctx): + com_google_sentencepiece() + org_swig_swig() + + return mctx.extension_metadata( + reproducible = True, + root_module_direct_deps = "all", + root_module_direct_dev_deps = [], + ) + +non_module_deps = module_extension( + implementation = _non_module_deps_impl, +) diff --git a/third_party/org_swig_swig/repo.bzl b/third_party/org_swig_swig/repo.bzl new file mode 100644 index 00000000..247c9d46 --- /dev/null +++ b/third_party/org_swig_swig/repo.bzl @@ -0,0 +1,10 @@ +load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") + +def repo(): + http_archive( + name = "org_swig_swig", + url = "http://prdownloads.sourceforge.net/swig/swig-4.3.0.tar.gz", + sha256 = "f7203ef796f61af986c70c05816236cbd0d31b7aa9631e5ab53020ab7804aa9e", + strip_prefix = "swig-4.3.0", + build_file = "//:third_party/org_swig_swig/swig.bazel", + ) diff --git a/third_party/org_swig_swig/swig.bazel b/third_party/org_swig_swig/swig.bazel new file mode 100644 index 00000000..44d0f9f1 --- /dev/null +++ b/third_party/org_swig_swig/swig.bazel @@ -0,0 +1,109 @@ +licenses(["restricted"]) # GPLv3 + +exports_files(["LICENSE"]) + +filegroup( + name = "lib", + srcs = glob([ + "Lib/*.*", + "Lib/c/*.*", + "Lib/std/*.*", + "Lib/typemaps/*.*", + ]), + visibility = ["//visibility:public"], +) + +cc_binary( + name = "swig", + srcs = glob([ + "Source/CParse/*.h", + "Source/CParse/*.c", + "Source/DOH/*.h", + "Source/DOH/*.c", + "Source/Include/*.h", + "Source/Preprocessor/*.h", + "Source/Preprocessor/*.c", + "Source/Swig/*.h", + "Source/Swig/*.c", + ]) + [ + "Source/Include/swigconfig.h", + "Source/Modules/allocate.cxx", + "Source/Modules/c.cxx", + "Source/Modules/contract.cxx", + "Source/Modules/directors.cxx", + "Source/Modules/emit.cxx", + "Source/Modules/interface.cxx", + "Source/Modules/lang.cxx", + "Source/Modules/main.cxx", + "Source/Modules/nested.cxx", + "Source/Modules/overload.cxx", + "Source/Modules/swigmain-lite.cxx", + "Source/Modules/swigmod.h", + "Source/Modules/typepass.cxx", + "Source/Modules/utils.cxx", + "Source/Modules/xml.cxx", + ], + includes = [ + "Source/CParse", + "Source/DOH", + "Source/Include", + "Source/Modules", + "Source/Preprocessor", + "Source/Swig", + ], + data = [":lib"], + output_licenses = ["unencumbered"], + visibility = ["//visibility:public"], + deps = ["@pcre2"], +) + +genrule( + name = "swigconfig", + outs = ["Source/Include/swigconfig.h"], + cmd = """\ +cat <$@ +#define HAVE_BOOL +#define HAVE_PCRE +#define HAVE_POPEN +#define PACKAGE_BUGREPORT \"http://www.swig.org\" +#define PACKAGE_VERSION \"4.3.0\" +#define STDC_HEADERS +#define SWIG_CXX \"bazel4lyfe\" +#define SWIG_LIB \"external/org_swig_swig/Lib\" +#define SWIG_LIB_WIN_UNIX \"\" +#define SWIG_PLATFORM \"bazel4lyfe\" +EOF +""", +) + +genrule( + name = "get_rid_of_stuff_we_dont_need_yet", + srcs = ["Source/Modules/swigmain.cxx"], + outs = ["Source/Modules/swigmain-lite.cxx"], + cmd = """\ +sed -e '/swig_allegrocl/d' \ + -e '/swig_chicken/d' \ + -e '/swig_clisp/d' \ + -e '/swig_csharp/d' \ + -e '/swig_d/d' \ + -e '/swig_guile/d' \ + -e '/swig_go/d' \ + -e '/swig_java/d' \ + -e '/swig_lua/d' \ + -e '/swig_modula3/d' \ + -e '/swig_mzscheme/d' \ + -e '/swig_ocaml/d' \ + -e '/swig_octave/d' \ + -e '/swig_perl/d' \ + -e '/swig_php/d' \ + -e '/swig_pike/d' \ + -e '/swig_python/d' \ + -e '/swig_r/d' \ + -e '/swig_ruby/d' \ + -e '/swig_scilab/d' \ + -e '/swig_sexp/d' \ + -e '/swig_tcl/d' \ + -e '/swig_uffi/d' \ + $< >$@ +""", +) diff --git a/zml/tokenizer/hf_tokenizers/BUILD.bazel b/zml/tokenizer/hf_tokenizers/BUILD.bazel new file mode 100644 index 00000000..e69de29b diff --git a/zml/tokenizer/sentencepiece/BUILD.bazel b/zml/tokenizer/sentencepiece/BUILD.bazel new file mode 100644 index 00000000..216b08e2 --- /dev/null +++ b/zml/tokenizer/sentencepiece/BUILD.bazel @@ -0,0 +1,61 @@ +load("@rules_zig//zig:defs.bzl", "zig_library") +load("@zml//bazel:zig.bzl", "zig_cc_binary") +load("//bazel:swig.bzl", "swig_cc_library") + +cc_library( + name = "bridge", + srcs = ["sentencepiece_c.cc"], + hdrs = ["sentencepiece_c.h"], + deps = [ + "//ffi", + "@com_google_sentencepiece//:sentencepiece_processor", + ], +) + +cc_binary( + name = "sentencepiece_playground", + srcs = ["sentencepiece_playground.cc"], + copts = ["-lc"], + visibility = ["//visibility:public"], + deps = [ + "@com_google_sentencepiece//:sentencepiece_processor", + ], +) + +zig_library( + name = "sentencepiece", + import_name = "sentencepiece", + main = "sentencepiece.zig", + visibility = ["//visibility:public"], + deps = [ + ":bridge", + "//ffi:ffi_zig", + ], +) + +cc_library( + name = "zig", + hdrs = ["zig.h"], +) + +swig_cc_library( + name = "sentencepiece_swig", + interface = "sentencepiece.i", + module = "sentencepiece", + visibility = ["//visibility:public"], + deps = [ + ":zig", + "@com_google_sentencepiece//:sentencepiece_processor", + ], +) + +zig_cc_binary( + name = "main", + srcs = ["sentencepiece.zig"], + main = "main.zig", + visibility = ["//visibility:public"], + deps = [ + ":sentencepiece_swig", + ":zig", + ], +) diff --git a/zml/tokenizer/sentencepiece/main.zig b/zml/tokenizer/sentencepiece/main.zig new file mode 100644 index 00000000..51a42e39 --- /dev/null +++ b/zml/tokenizer/sentencepiece/main.zig @@ -0,0 +1,291 @@ +const std = @import("std"); +const c = @import("c"); + +pub const SentencePieceError = error{ + Cancelled, + Unknown, + InvalidArgument, + DeadlineExceeded, + NotFound, + AlreadyExists, + PermissionDenied, + ResourceExhausted, + FailedPrecondition, + Aborted, + OutOfRange, + Unimplemented, + Internal, + Unavailable, + DataLoss, + Unauthenticated, +}; + +pub const DecoderStream = struct { + const TokensSize = 4; + const StringSize = 128; + decoder: SentencePieceProcessor.Decoder, + buffer: [StringSize]u8 = undefined, + last_tokens: []u8 = &.{}, + + pub fn init(decoder: SentencePieceProcessor.Decoder) DecoderStream { + var ret: DecoderStream = .{ + .decoder = decoder, + }; + ret.decoder.reserve_tokens(TokensSize); + ret.decoder.reserve_string(StringSize); + return ret; + } + + pub fn next(self: *DecoderStream, next_token: i32) !?[]const u8 { + if (self.decoder.tokens().len >= TokensSize) { + const tokens = self.decoder.tokens(); + inline for (0..TokensSize - 1) |i| { + tokens[i] = tokens[i + 1]; + } + tokens[TokensSize - 1] = next_token; + } else { + self.decoder.append(next_token); + } + const new_tokens = try self.decoder.decode(); + if (self.last_tokens.len == 0) { + self.last_tokens = self.buffer[0..new_tokens.len]; + @memcpy(self.last_tokens, new_tokens); + return new_tokens; + } + for (1..self.last_tokens.len) |i| { + if (std.mem.startsWith(u8, new_tokens, self.last_tokens[i..])) { + const toks = new_tokens[self.last_tokens.len - i..]; + self.last_tokens = self.buffer[0..new_tokens.len]; + @memcpy(self.last_tokens, new_tokens); + return toks; + } + } + return null; + } +}; + +pub const SentencePieceProcessor = opaque { + pub const Encoder = struct { + inner: *SentencePieceProcessor, + vec: *c.std_vector_int, + + fn init(inner: *SentencePieceProcessor) Encoder { + return .{ + .inner = inner, + .vec = c.std_vector_int_new() orelse unreachable, + }; + } + + pub fn deinit(self: *Encoder) void { + c.std_vector_int_delete(self.vec); + } + + pub fn reserve(self: *Encoder, size: usize) void { + c.std_vector_int_reserve(self.vec, size); + } + + pub fn reset(self: *Encoder) void { + c.std_vector_int_clear(self.vec); + } + + pub fn encode(self: *Encoder, input: []const u8) ![]const i32 { + const str = c.zig_slice{ .ptr = input.ptr, .len = @intCast(input.len), }; + try assertOk(c.SentencePieceProcessor_Encode(@ptrCast(self.inner), str, self.vec)); + return c.std_vector_int_data(self.vec)[0..c.std_vector_int_size(self.vec)]; + } + }; + + pub const Decoder = struct { + inner: *SentencePieceProcessor, + vec: *c.std_vector_int, + str: *c.std_string, + + fn init(inner: *SentencePieceProcessor) Decoder { + return .{ + .inner = inner, + .vec = c.std_vector_int_new() orelse unreachable, + .str = c.std_string_new() orelse unreachable, + }; + } + + pub fn append(self: *Decoder, token: i32) void { + c.std_vector_int_push_back(self.vec, token); + } + + pub fn deinit(self: *Decoder) void { + c.std_vector_int_delete(self.vec); + c.std_string_delete(self.str); + } + + pub fn reserve_tokens(self: *Decoder, size: usize) void { + c.std_vector_int_reserve(self.vec, size); + } + + pub fn reserve_string(self: *Decoder, size: usize) void { + c.std_string_reserve(self.str, size); + } + + pub fn reset(self: *Decoder) void { + c.std_vector_int_clear(self.vec); + c.std_string_clear(self.str); + } + + pub fn decode(self: *Decoder) ![]const u8 { + try assertOk(c.SentencePieceProcessor_Decode(@ptrCast(self.inner), self.vec, self.str)); + return self.string(); + } + + pub fn string(self: *const Decoder) []const u8 { + const res = c.std_string_data(self.str); + return res.ptr[0..res.len]; + } + + pub fn tokens(self: *const Decoder) []i32 { + const ptr: [*c]i32 = @ptrCast(c.std_vector_int_data(self.vec)); + return ptr[0..c.std_vector_int_size(self.vec)]; + } + }; + + fn assertOk(code: c.sentencepiece_util_StatusCode) SentencePieceError!void { + return switch (code) { + c.sentencepiece_util_StatusCode_kOk => {}, + c.sentencepiece_util_StatusCode_kCancelled => error.Cancelled, + c.sentencepiece_util_StatusCode_kUnknown => error.Unknown, + c.sentencepiece_util_StatusCode_kInvalidArgument => error.InvalidArgument, + c.sentencepiece_util_StatusCode_kDeadlineExceeded => error.DeadlineExceeded, + c.sentencepiece_util_StatusCode_kNotFound => error.NotFound, + c.sentencepiece_util_StatusCode_kAlreadyExists => error.AlreadyExists, + c.sentencepiece_util_StatusCode_kPermissionDenied => error.PermissionDenied, + c.sentencepiece_util_StatusCode_kResourceExhausted => error.ResourceExhausted, + c.sentencepiece_util_StatusCode_kFailedPrecondition => error.FailedPrecondition, + c.sentencepiece_util_StatusCode_kAborted => error.Aborted, + c.sentencepiece_util_StatusCode_kOutOfRange => error.OutOfRange, + c.sentencepiece_util_StatusCode_kUnimplemented => error.Unimplemented, + c.sentencepiece_util_StatusCode_kInternal => error.Internal, + c.sentencepiece_util_StatusCode_kUnavailable => error.Unavailable, + c.sentencepiece_util_StatusCode_kDataLoss => error.DataLoss, + c.sentencepiece_util_StatusCode_kUnauthenticated => error.Unauthenticated, + else => unreachable, + }; + } + + + pub fn load(model: []const u8) !*SentencePieceProcessor { + const sp: *SentencePieceProcessor = @ptrCast(c.SentencePieceProcessor_new()); + errdefer sp.deinit(); + try sp.load_from(model); + return sp; + } + + pub fn deinit(self: *SentencePieceProcessor) void { + c.SentencePieceProcessor_delete(@ptrCast(self)); + } + + fn load_from(self: *SentencePieceProcessor, model: []const u8) !void { + try assertOk(c.SentencePieceProcessor_Load(@ptrCast(self), c.zig_slice{ .ptr = @constCast(model.ptr), .len = @intCast(model.len) })); + } + + pub fn encoder(self: *SentencePieceProcessor) Encoder { + return Encoder.init(self); + } + + pub fn decoder(self: *SentencePieceProcessor) Decoder { + return Decoder.init(self); + } +}; + +pub fn as_path(path: []const u8) [std.fs.max_path_bytes:0]u8 { + var result: [std.fs.max_path_bytes:0]u8 = undefined; + @memcpy(result[0..path.len], path); + result[path.len] = 0; + return result; +} + +pub fn main() !void { + const sp = try SentencePieceProcessor.load("/Users/steeve/Downloads/poolside.sp.pb"); + defer sp.deinit(); + + std.debug.print("Loaded model\n", .{}); + + var encoder = sp.encoder(); + defer encoder.deinit(); + + var decoder = sp.decoder(); + defer decoder.deinit(); + + const ss = @embedFile("main.zig"); + // \\String class + // \\Strings are objects that represent sequences of characters. + // \\ + // \\The standard string class provides support for such objects with an interface similar to that of a standard container of bytes, but adding features specifically designed to operate with strings of single-byte characters. + // \\ + // \\The string class is an instantiation of the basic_string class template that uses char (i.e., bytes) as its character type, with its default char_traits and allocator types (see basic_string for more info on the template). + // \\ + // \\Note that this class handles bytes independently of the encoding used: If used to handle sequences of multi-byte or variable-length characters (such as UTF-8), all members of this class (such as length or size), as well as its iterators, will still operate in terms of bytes (not actual encoded characters). + // \\ + // ; + const tokens = try encoder.encode(ss); + + // const ss2 = 128; + // var buf = [_]u8{0} ** ss2; + // // _ = buf; // autofix + // var last_tokens: []u8 = &.{}; + // // _ = last_tokens; // autofix + // decoder.reserve_tokens(4); + // decoder.reserve_string(128); + + var stream = DecoderStream.init(decoder); + + var start = try std.time.Timer.start(); + // _ = start; // autofix + for (tokens) |token| { + if (try stream.next(token)) |chunk| { + // std.debug.print("{s}", .{chunk}); + std.debug.print("{d}us - {s}\n", .{start.lap() / std.time.ns_per_us, chunk}); + } + } + + // var start = try std.time.Timer.start(); + // var it = std.mem.window(i32, tokens, 3, 1); + // while (it.next()) |slice| { + // if (decoder.tokens().len >= 4) { + // const kept_tokens = decoder.tokens()[1..]; + // std.mem.copyForwards(i32, decoder.tokens()[0..kept_tokens.len], kept_tokens); + // kept_tokens[kept_tokens.len - 1] = slice[2]; + // } else { + // for (slice) |token| { + // decoder.append(token); + // } + // } + // const new_tokens = try decoder.decode(); + // for (0..ss2) |i| { + // if (std.mem.startsWith(u8, new_tokens, last_tokens[i..])) { + // const toks = new_tokens[last_tokens.len - i..]; + // // std.debug.print("{s}", .{toks}); + // if (toks.len == 0) { + // // std.debug.print("WESH\n", .{}); + // } + // break; + // } + // } + // last_tokens = buf[0..new_tokens.len]; + // @memcpy(last_tokens, new_tokens); + // std.debug.print("{d}us\n", .{start.lap() / std.time.ns_per_us}); + // } + + // for (tokens) |token| { + // decoder.append(token); + // } + // const decoded = try decoder.decode(); + // std.debug.print("Decoded: {s}\n", .{decoded}); + + + + + // const model = "/Users/steeve/Downloads/poolside.sp.pb"; + + // c.SentencePieceProcessor_LoadOrDie(sp, c.zig_slice{ .ptr = model.ptr, .len = model.len }); + + // const piece = c.SentencePieceProcessor_IdToPiece(sp, 10999); + // std.debug.print("{s}\n", .{piece.ptr[0..piece.len]}); +} diff --git a/zml/tokenizer/sentencepiece/sentencepiece.i b/zml/tokenizer/sentencepiece/sentencepiece.i new file mode 100644 index 00000000..8608f357 --- /dev/null +++ b/zml/tokenizer/sentencepiece/sentencepiece.i @@ -0,0 +1,91 @@ +/* File : example.i */ +%module sentencepiece +%include +%include + +%{ +#include +#include +#include +#include +#include "zml/tokenizer/sentencepiece/zig.h" +%} + +%extend std::vector { + T* data() { + return $self->data(); + }; +} + +%template(std_vector_int) std::vector; + +%typemap(in) absl::string_view { + $1 = absl::string_view($input.ptr, $input.len); +} + +%typemap(out, optimal="1") const std::string& %{ + $result.ptr = (char *)($1->data()); + $result.len = (size_t)($1->length()); +%} +%typemap(ctype) absl::string_view, const std::string& "zig_slice" + +%rename(std_string) std::string; +namespace std { + class string { + public: + void reserve(size_t n); + void clear(); + size_t capacity() const; + }; +} + +%extend std::string { + const std::string& data() const { + return *$self; + }; +} + +%typemap(out) sentencepiece::util::Status %{ + $result = $1.code(); +%} +%typemap(ctype) sentencepiece::util::Status "unsigned int" +%rename(sentencepiece_util_StatusCode, fullname=1) sentencepiece::util::StatusCode; + +namespace sentencepiece { + namespace util { + enum class StatusCode : int { + kOk = 0, + kCancelled = 1, + kUnknown = 2, + kInvalidArgument = 3, + kDeadlineExceeded = 4, + kNotFound = 5, + kAlreadyExists = 6, + kPermissionDenied = 7, + kResourceExhausted = 8, + kFailedPrecondition = 9, + kAborted = 10, + kOutOfRange = 11, + kUnimplemented = 12, + kInternal = 13, + kUnavailable = 14, + kDataLoss = 15, + kUnauthenticated = 16, + }; + } + + class SentencePieceProcessor { + public: + virtual sentencepiece::util::Status Load(absl::string_view filename); + virtual sentencepiece::util::Status Encode(absl::string_view input, std::vector *ids) const; + virtual sentencepiece::util::Status Decode(const std::vector &ids, std::string *detokenized) const; + virtual bool IsUnknown(int id) const; + virtual bool IsControl(int id) const; + virtual bool IsUnused(int id) const; + virtual bool IsByte(int id) const; + virtual int unk_id() const; + virtual int bos_id() const; + virtual int eos_id() const; + virtual int pad_id() const; + }; +} diff --git a/zml/tokenizer/sentencepiece/sentencepiece.zig b/zml/tokenizer/sentencepiece/sentencepiece.zig new file mode 100644 index 00000000..133fce26 --- /dev/null +++ b/zml/tokenizer/sentencepiece/sentencepiece.zig @@ -0,0 +1,12 @@ +pub const std = @import("std"); +pub const c = @import("c"); + +pub const SentencePieceProcessor = opaque { + pub const create() *SentencePieceProcessor { + return @ptrCast(c.SentencePieceProcessor_new()); + } + + pub const deinit(self: *SentencePieceProcessor) { + c.SentencePieceProcessor_delete(@ptrCast(self)); + } +}; diff --git a/zml/tokenizer/sentencepiece/sentencepiece2.zig b/zml/tokenizer/sentencepiece/sentencepiece2.zig new file mode 100644 index 00000000..54574b33 --- /dev/null +++ b/zml/tokenizer/sentencepiece/sentencepiece2.zig @@ -0,0 +1,130 @@ +const std = @import("std"); +const ffi = @import("ffi_zig"); +const c = @import("c"); + +const log = std.log.scoped(.sentencepiece); + +// ref: https://github.com/google/sentencepiece/blob/d8f741853847553169444afc12c00f4bbff3e9ce/src/sentencepiece_processor.h#L34 +pub const SentencePieceError = error{ + Cancelled, + Unknown, + InvalidArgument, + DeadlineExceeded, + NotFound, + AlreadyExists, + PermissionDenied, + ResourceExhausted, + FailedPrecondition, + Aborted, + OutOfRange, + Unimplemented, + Internal, + Unavailable, + DataLoss, + Unauthenticated, +}; + +pub const SentencePieceProcessor = struct { + arena: std.heap.ArenaAllocator, + _sp_processor: *c.SentencePieceProcessor, + + fn assertOk(code: c.sentencepiece_util_StatusCode) SentencePieceError!void { + return switch (code) { + c.kOk => {}, + c.kCancelled => error.Cancelled, + c.kUnknown => error.Unknown, + c.kInvalidArgument => error.InvalidArgument, + c.kDeadlineExceeded => error.DeadlineExceeded, + c.kNotFound => error.NotFound, + c.kAlreadyExists => error.AlreadyExists, + c.kPermissionDenied => error.PermissionDenied, + c.kResourceExhausted => error.ResourceExhausted, + c.kFailedPrecondition => error.FailedPrecondition, + c.kAborted => error.Aborted, + c.kOutOfRange => error.OutOfRange, + c.kUnimplemented => error.Unimplemented, + c.kInternal => error.Internal, + c.kUnavailable => error.Unavailable, + c.kDataLoss => error.DataLoss, + c.kUnauthenticated => error.Unauthenticated, + else => unreachable, + }; + } + + pub fn init(allocator: std.mem.Allocator, model: []const u8) !SentencePieceProcessor { + var arena = std.heap.ArenaAllocator.init(allocator); + + const sp_processor = try (c.SentencePieceProcessor_new(ffi.ZigAllocator.from(arena.allocator())) orelse std.mem.Allocator.Error.OutOfMemory); + errdefer c.SentencePieceProcessor_delete(ffi.ZigAllocator.from(arena.allocator()), sp_processor); + + try assertOk(c.SentencePieceProcessor_Load(sp_processor, ffi.as_path(model)[0..].ptr)); + + return .{ + .arena = arena, + ._sp_processor = sp_processor, + }; + } + + pub fn deinit(self: *const SentencePieceProcessor) void { + c.SentencePieceProcessor_delete(self.arena.allocator(), self._sp_processor); + self.arena.deinit(); + } + + pub fn encode(self: *const SentencePieceProcessor, allocator: std.mem.Allocator, input: []const u8) ![]i32 { + var ids: c.zig_slice = undefined; + try assertOk(c.SentencePieceProcessor_Encode(self._sp_processor, ffi.ZigAllocator.from(allocator), ffi.ZigSlice.from(input), &ids)); + return ffi.ZigSlice.to(i32, ids); + } + + pub fn decode(self: *const SentencePieceProcessor, allocator: std.mem.Allocator, input: []const i32) ![]u8 { + var detokenized: c.zig_slice = undefined; + try assertOk(c.SentencePieceProcessor_Decode(self._sp_processor, ffi.ZigAllocator.from(allocator), ffi.ZigSlice.from(input), &detokenized)); + return ffi.ZigSlice.to(u8, detokenized); + } + + pub fn decode2(self: *const SentencePieceProcessor, allocator: std.mem.Allocator, input: []const i32) ![]const u8 { + var detokenized = try ffi.std_string.ArrayList(u8).init(allocator); + + try assertOk(c.SentencePieceProcessor_Decode2(self._sp_processor, ffi.ZigSlice.from(input), @ptrCast(detokenized.str))); + detokenized.refresh(); + try detokenized.array_list().appendSlice("hello hellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohello"); + + log.debug("detokenized: {d}", .{detokenized.array_list().items.len}); + return detokenized.array_list().items; + } + + pub fn decode3(self: *const SentencePieceProcessor, allocator: std.mem.Allocator, input: []const i32) ![]const u8 { + var pieces = try std.ArrayList(u8).initCapacity(allocator, input.len); + defer pieces.deinit(); + + for (input) |token_id| { + var piece_slice: c.zig_slice = undefined; + try assertOk(c.SentencePieceProcessor_DecodeId(self._sp_processor, token_id, &piece_slice)); + const piece = ffi.ZigSlice.to(u8, piece_slice); + try pieces.appendSlice(piece); + } + return pieces.toOwnedSlice(); + } + + pub fn decodeId(self: *const SentencePieceProcessor, id: i32) ![]u8 { + var buffer: c.zig_slice = undefined; + try assertOk(c.SentencePieceProcessor_DecodeId(self._sp_processor, id, &buffer)); + return ffi.ZigSlice.to(u8, buffer); + } + + pub fn pieceToId(self: *const SentencePieceProcessor, input: []const u8) i32 { + return c.SentencePieceProcessor_PieceToId(self._sp_processor, ffi.ZigSlice.from(input)); + } + + pub fn eosId(self: *const SentencePieceProcessor) i32 { + return c.SentencePieceProcessor_eos_id(self._sp_processor); + } + + pub fn bosId(self: *const SentencePieceProcessor) i32 { + return c.SentencePieceProcessor_bos_id(self._sp_processor); + } + + pub fn unkId(self: *const SentencePieceProcessor) i32 { + return c.SentencePieceProcessor_unk_id(self._sp_processor); + } +}; diff --git a/zml/tokenizer/sentencepiece/zig.h b/zml/tokenizer/sentencepiece/zig.h new file mode 100644 index 00000000..d1bcb0c1 --- /dev/null +++ b/zml/tokenizer/sentencepiece/zig.h @@ -0,0 +1,9 @@ +#pragma once + +#include + +typedef struct +{ + const char *ptr; + size_t len; +} zig_slice; diff --git a/zml/tokenizer/tokenizer.zig b/zml/tokenizer/tokenizer.zig new file mode 100644 index 00000000..09a04511 --- /dev/null +++ b/zml/tokenizer/tokenizer.zig @@ -0,0 +1,27 @@ +pub const Tokenizer = struct { + pub const Decoder = struct { + pub fn step(self: *Decoder, token_id: u32) []const u8 { + return input; + } + + pub fn reset(self: *Decoder) void { + _ = self; // autofix + } + }; + + pub fn init() Tokenizer { + return Tokenizer{}; + } + + pub fn encode(self: *Tokenizer, input: []const u8) []const u32 { + _ = input; // autofix + _ = self; // autofix + return &.{}; + } + + pub fn decode(self: *Tokenizer, input: []const u32) []const u8 { + _ = input; // autofix + _ = self; // autofix + return &.{}; + } +}; From 25d8cf4d3a92339d055b3d4cc26728e5a12ad8ce Mon Sep 17 00:00:00 2001 From: Steeve Morin Date: Wed, 25 Dec 2024 00:39:17 +0100 Subject: [PATCH 02/48] zml/tokenizer: add huggingface tokenizers binding --- MODULE.bazel | 10 + MODULE.bazel.lock | 1067 ++++++++++++++++- zml/tokenizer/hf_tokenizers/BUILD.bazel | 28 + zml/tokenizer/hf_tokenizers/Cargo.lock | 827 +++++++++++++ zml/tokenizer/hf_tokenizers/Cargo.toml | 7 + zml/tokenizer/hf_tokenizers/hf_tokenizers.h | 17 + zml/tokenizer/hf_tokenizers/hf_tokenizers.zig | 0 zml/tokenizer/hf_tokenizers/main.zig | 33 + zml/tokenizer/hf_tokenizers/src/lib.rs | 64 + 9 files changed, 2047 insertions(+), 6 deletions(-) create mode 100644 zml/tokenizer/hf_tokenizers/Cargo.lock create mode 100644 zml/tokenizer/hf_tokenizers/Cargo.toml create mode 100644 zml/tokenizer/hf_tokenizers/hf_tokenizers.h create mode 100644 zml/tokenizer/hf_tokenizers/hf_tokenizers.zig create mode 100644 zml/tokenizer/hf_tokenizers/main.zig create mode 100644 zml/tokenizer/hf_tokenizers/src/lib.rs diff --git a/MODULE.bazel b/MODULE.bazel index 0cba87a3..d5164aaf 100644 --- a/MODULE.bazel +++ b/MODULE.bazel @@ -121,3 +121,13 @@ use_repo(apt, "neuron_bookworm") non_module_deps = use_extension("//:third_party/non_module_deps.bzl", "non_module_deps") use_repo(non_module_deps, "com_google_sentencepiece", "org_swig_swig") + +bazel_dep(name = "rules_rust", version = "0.56.0") + +crate = use_extension("@rules_rust//crate_universe:extensions.bzl", "crate") +crate.from_cargo( + name = "crates", + cargo_lockfile = "//zml/tokenizer/hf_tokenizers:Cargo.lock", + manifests = ["//zml/tokenizer/hf_tokenizers:Cargo.toml"], +) +use_repo(crate, "crates") diff --git a/MODULE.bazel.lock b/MODULE.bazel.lock index 73371244..35629f0d 100644 --- a/MODULE.bazel.lock +++ b/MODULE.bazel.lock @@ -13,6 +13,7 @@ "https://bazel-registry.zml.ai/modules/abseil-cpp/20240722.0.bcr.2/MODULE.bazel": "not found", "https://bazel-registry.zml.ai/modules/apple_support/1.11.1/MODULE.bazel": "not found", "https://bazel-registry.zml.ai/modules/apple_support/1.15.1/MODULE.bazel": "not found", + "https://bazel-registry.zml.ai/modules/apple_support/1.17.1/MODULE.bazel": "not found", "https://bazel-registry.zml.ai/modules/apple_support/1.5.0/MODULE.bazel": "not found", "https://bazel-registry.zml.ai/modules/aspect_bazel_lib/2.7.9/MODULE.bazel": "not found", "https://bazel-registry.zml.ai/modules/aspect_bazel_lib/2.8.1/MODULE.bazel": "not found", @@ -20,11 +21,13 @@ "https://bazel-registry.zml.ai/modules/aspect_bazel_lib/2.9.3/MODULE.bazel": "not found", "https://bazel-registry.zml.ai/modules/aspect_rules_py/1.0.0-rc0/MODULE.bazel": "not found", "https://bazel-registry.zml.ai/modules/bazel_features/1.1.1/MODULE.bazel": "not found", + "https://bazel-registry.zml.ai/modules/bazel_features/1.10.0/MODULE.bazel": "not found", "https://bazel-registry.zml.ai/modules/bazel_features/1.11.0/MODULE.bazel": "not found", "https://bazel-registry.zml.ai/modules/bazel_features/1.15.0/MODULE.bazel": "not found", "https://bazel-registry.zml.ai/modules/bazel_features/1.17.0/MODULE.bazel": "not found", "https://bazel-registry.zml.ai/modules/bazel_features/1.18.0/MODULE.bazel": "not found", "https://bazel-registry.zml.ai/modules/bazel_features/1.19.0/MODULE.bazel": "not found", + "https://bazel-registry.zml.ai/modules/bazel_features/1.21.0/MODULE.bazel": "not found", "https://bazel-registry.zml.ai/modules/bazel_features/1.3.0/MODULE.bazel": "not found", "https://bazel-registry.zml.ai/modules/bazel_features/1.4.1/MODULE.bazel": "not found", "https://bazel-registry.zml.ai/modules/bazel_features/1.9.1/MODULE.bazel": "not found", @@ -79,6 +82,7 @@ "https://bazel-registry.zml.ai/modules/rules_cc/0.0.1/MODULE.bazel": "not found", "https://bazel-registry.zml.ai/modules/rules_cc/0.0.10/MODULE.bazel": "not found", "https://bazel-registry.zml.ai/modules/rules_cc/0.0.16/MODULE.bazel": "not found", + "https://bazel-registry.zml.ai/modules/rules_cc/0.0.17/MODULE.bazel": "not found", "https://bazel-registry.zml.ai/modules/rules_cc/0.0.2/MODULE.bazel": "not found", "https://bazel-registry.zml.ai/modules/rules_cc/0.0.6/MODULE.bazel": "not found", "https://bazel-registry.zml.ai/modules/rules_cc/0.0.8/MODULE.bazel": "not found", @@ -126,7 +130,9 @@ "https://bazel-registry.zml.ai/modules/rules_python/0.34.0/MODULE.bazel": "not found", "https://bazel-registry.zml.ai/modules/rules_python/0.37.0/MODULE.bazel": "not found", "https://bazel-registry.zml.ai/modules/rules_python/0.4.0/MODULE.bazel": "not found", + "https://bazel-registry.zml.ai/modules/rules_rust/0.56.0/MODULE.bazel": "not found", "https://bazel-registry.zml.ai/modules/rules_shell/0.2.0/MODULE.bazel": "not found", + "https://bazel-registry.zml.ai/modules/rules_shell/0.3.0/MODULE.bazel": "not found", "https://bazel-registry.zml.ai/modules/rules_swift/1.15.1/MODULE.bazel": "not found", "https://bazel-registry.zml.ai/modules/rules_uv/0.34.0/MODULE.bazel": "not found", "https://bazel-registry.zml.ai/modules/stardoc/0.5.1/MODULE.bazel": "not found", @@ -157,7 +163,8 @@ "https://bcr.bazel.build/modules/abseil-cpp/20240722.0.bcr.2/source.json": "464f3012c8f40cd51facbfc6962563971c6bd55f45ba16bd98313f2de73340c5", "https://bcr.bazel.build/modules/apple_support/1.11.1/MODULE.bazel": "1843d7cd8a58369a444fc6000e7304425fba600ff641592161d9f15b179fb896", "https://bcr.bazel.build/modules/apple_support/1.15.1/MODULE.bazel": "a0556fefca0b1bb2de8567b8827518f94db6a6e7e7d632b4c48dc5f865bc7c85", - "https://bcr.bazel.build/modules/apple_support/1.15.1/source.json": "517f2b77430084c541bc9be2db63fdcbb7102938c5f64c17ee60ffda2e5cf07b", + "https://bcr.bazel.build/modules/apple_support/1.17.1/MODULE.bazel": "655c922ab1209978a94ef6ca7d9d43e940cd97d9c172fb55f94d91ac53f8610b", + "https://bcr.bazel.build/modules/apple_support/1.17.1/source.json": "6b2b8c74d14e8d485528a938e44bdb72a5ba17632b9e14ef6e68a5ee96c8347f", "https://bcr.bazel.build/modules/apple_support/1.5.0/MODULE.bazel": "50341a62efbc483e8a2a6aec30994a58749bd7b885e18dd96aa8c33031e558ef", "https://bcr.bazel.build/modules/aspect_bazel_lib/2.7.9/MODULE.bazel": "06e54f2b345b8eb7adceed2329b273da00d0368e28a9ebd9dfc75b4a052dac85", "https://bcr.bazel.build/modules/aspect_bazel_lib/2.8.1/MODULE.bazel": "812d2dd42f65dca362152101fbec418029cc8fd34cbad1a2fde905383d705838", @@ -167,12 +174,14 @@ "https://bcr.bazel.build/modules/aspect_rules_py/1.0.0-rc0/MODULE.bazel": "32d7c3fc7dea1aef4a95475e91a9cdd79473c4bd6a198906a306bea2fbc4e601", "https://bcr.bazel.build/modules/aspect_rules_py/1.0.0-rc0/source.json": "b8eaced4b9ab418f3498d9657f98c980e58f6fad397fc17081955dcf3813be3f", "https://bcr.bazel.build/modules/bazel_features/1.1.1/MODULE.bazel": "27b8c79ef57efe08efccbd9dd6ef70d61b4798320b8d3c134fd571f78963dbcd", + "https://bcr.bazel.build/modules/bazel_features/1.10.0/MODULE.bazel": "f75e8807570484a99be90abcd52b5e1f390362c258bcb73106f4544957a48101", "https://bcr.bazel.build/modules/bazel_features/1.11.0/MODULE.bazel": "f9382337dd5a474c3b7d334c2f83e50b6eaedc284253334cf823044a26de03e8", "https://bcr.bazel.build/modules/bazel_features/1.15.0/MODULE.bazel": "d38ff6e517149dc509406aca0db3ad1efdd890a85e049585b7234d04238e2a4d", "https://bcr.bazel.build/modules/bazel_features/1.17.0/MODULE.bazel": "039de32d21b816b47bd42c778e0454217e9c9caac4a3cf8e15c7231ee3ddee4d", "https://bcr.bazel.build/modules/bazel_features/1.18.0/MODULE.bazel": "1be0ae2557ab3a72a57aeb31b29be347bcdc5d2b1eb1e70f39e3851a7e97041a", "https://bcr.bazel.build/modules/bazel_features/1.19.0/MODULE.bazel": "59adcdf28230d220f0067b1f435b8537dd033bfff8db21335ef9217919c7fb58", - "https://bcr.bazel.build/modules/bazel_features/1.19.0/source.json": "d7bf14517c1b25b9d9c580b0f8795fceeae08a7590f507b76aace528e941375d", + "https://bcr.bazel.build/modules/bazel_features/1.21.0/MODULE.bazel": "675642261665d8eea09989aa3b8afb5c37627f1be178382c320d1b46afba5e3b", + "https://bcr.bazel.build/modules/bazel_features/1.21.0/source.json": "3e8379efaaef53ce35b7b8ba419df829315a880cb0a030e5bb45c96d6d5ecb5f", "https://bcr.bazel.build/modules/bazel_features/1.3.0/MODULE.bazel": "cdcafe83ec318cda34e02948e81d790aab8df7a929cec6f6969f13a489ccecd9", "https://bcr.bazel.build/modules/bazel_features/1.4.1/MODULE.bazel": "e45b6bb2350aff3e442ae1111c555e27eac1d915e77775f6fdc4b351b758b5d7", "https://bcr.bazel.build/modules/bazel_features/1.9.1/MODULE.bazel": "8f679097876a9b609ad1f60249c49d68bfab783dd9be012faf9d82547b14815a", @@ -242,7 +251,8 @@ "https://bcr.bazel.build/modules/rules_cc/0.0.1/MODULE.bazel": "cb2aa0747f84c6c3a78dad4e2049c154f08ab9d166b1273835a8174940365647", "https://bcr.bazel.build/modules/rules_cc/0.0.10/MODULE.bazel": "ec1705118f7eaedd6e118508d3d26deba2a4e76476ada7e0e3965211be012002", "https://bcr.bazel.build/modules/rules_cc/0.0.16/MODULE.bazel": "7661303b8fc1b4d7f532e54e9d6565771fea666fbdf839e0a86affcd02defe87", - "https://bcr.bazel.build/modules/rules_cc/0.0.16/source.json": "227e83737046aa4f50015da48e98e0d8ab42fd0ec74d8d653b6cc9f9a357f200", + "https://bcr.bazel.build/modules/rules_cc/0.0.17/MODULE.bazel": "2ae1d8f4238ec67d7185d8861cb0a2cdf4bc608697c331b95bf990e69b62e64a", + "https://bcr.bazel.build/modules/rules_cc/0.0.17/source.json": "4db99b3f55c90ab28d14552aa0632533e3e8e5e9aea0f5c24ac0014282c2a7c5", "https://bcr.bazel.build/modules/rules_cc/0.0.2/MODULE.bazel": "6915987c90970493ab97393024c156ea8fb9f3bea953b2f3ec05c34f19b5695c", "https://bcr.bazel.build/modules/rules_cc/0.0.6/MODULE.bazel": "abf360251023dfe3efcef65ab9d56beefa8394d4176dd29529750e1c57eaa33f", "https://bcr.bazel.build/modules/rules_cc/0.0.8/MODULE.bazel": "964c85c82cfeb6f3855e6a07054fdb159aced38e99a5eecf7bce9d53990afa3e", @@ -300,8 +310,11 @@ "https://bcr.bazel.build/modules/rules_python/0.37.0/MODULE.bazel": "bd90c62e4c789ea94ed61ab21a5a538dd4145548d1de994192049652d433816e", "https://bcr.bazel.build/modules/rules_python/0.37.0/source.json": "c17b8ca7a2348fd8fa96ad5b414223dd1ce5d6e8265c3134a88d337b0554d53c", "https://bcr.bazel.build/modules/rules_python/0.4.0/MODULE.bazel": "9208ee05fd48bf09ac60ed269791cf17fb343db56c8226a720fbb1cdf467166c", + "https://bcr.bazel.build/modules/rules_rust/0.56.0/MODULE.bazel": "3295b00757db397122092322fe1e920be7f5c9fbfb8619138977e820f2cbbbae", + "https://bcr.bazel.build/modules/rules_rust/0.56.0/source.json": "7dc294c3decd40af8f7b83897a5936e764d3ae8584b4056862978fb3870ab8d7", "https://bcr.bazel.build/modules/rules_shell/0.2.0/MODULE.bazel": "fda8a652ab3c7d8fee214de05e7a9916d8b28082234e8d2c0094505c5268ed3c", - "https://bcr.bazel.build/modules/rules_shell/0.2.0/source.json": "7f27af3c28037d9701487c4744b5448d26537cc66cdef0d8df7ae85411f8de95", + "https://bcr.bazel.build/modules/rules_shell/0.3.0/MODULE.bazel": "de4402cd12f4cc8fda2354fce179fdb068c0b9ca1ec2d2b17b3e21b24c1a937b", + "https://bcr.bazel.build/modules/rules_shell/0.3.0/source.json": "c55ed591aa5009401ddf80ded9762ac32c358d2517ee7820be981e2de9756cf3", "https://bcr.bazel.build/modules/rules_swift/1.15.1/MODULE.bazel": "7031d3e5221b54dfee3901d221f10f54a8b0f2a64d4616de7879bcf83fe8d85d", "https://bcr.bazel.build/modules/rules_swift/1.15.1/source.json": "6472a4607d0a2f39eeb7daae78054b995aba593caad99aa64561f631fcf93a63", "https://bcr.bazel.build/modules/rules_uv/0.34.0/MODULE.bazel": "fb7c2da897786eac4b643d1ed516be715c11566620ee5cf022d7009298ad9590", @@ -329,8 +342,8 @@ "moduleExtensions": { "@@apple_support~//crosstool:setup.bzl%apple_cc_configure_extension": { "general": { - "bzlTransitiveDigest": "7rY6uLsMi3Ma6rwkL3yK4deWcIXKE2ScY4Kt8lA079s=", - "usagesDigest": "2rUj1nIKMIRWTPS0bs9eJAzlNwSbV3APk1f7UNpjXq0=", + "bzlTransitiveDigest": "SKth1NgruDWmWTeXDCh0A0NfAgafC4gc2LLGmtsh+xc=", + "usagesDigest": "M6JoVI4x/XU3HC+5Z3XrwK+Q5ctDj3gF34U1L4s7m9o=", "recordedFileInputs": {}, "recordedDirentsInputs": {}, "envVariables": {}, @@ -1154,6 +1167,210 @@ "recordedRepoMappingEntries": [] } }, + "@@rules_distroless~//apt:extensions.bzl%apt": { + "general": { + "bzlTransitiveDigest": "rCfUzSGMSZSoItAWsqjTUC8ki4434a+MaUc8Ar3697c=", + "usagesDigest": "8/uJYwaWKZossA3jGwUl3q4Z/6ztn1xuhLcQjImLkoU=", + "recordedFileInputs": { + "@@//runtimes/neuron/packages.lock.json": "4cf407725dcd905a3334f79302735d5085901f27b34bd402e9678fad58354622" + }, + "recordedDirentsInputs": {}, + "envVariables": {}, + "generatedRepoSpecs": { + "neuron_bookworm_bash_5.2.15-2-p-b7_amd64": { + "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", + "ruleClassName": "http_archive", + "attributes": { + "build_file_content": "\ngenrule(\n name = \"data\",\n srcs = glob([\"data.tar*\"]),\n outs = [\"layer.tar.gz\"],\n cmd = \"\"\"\n # Per the dpkg-dev man page:\n # https://manpages.debian.org/bookworm/dpkg-dev/deb.5.en.html\n #\n # Debian data.tar files can be:\n # - .tar uncompressed, supported since dpkg 1.10.24\n # - .tar compressed with\n # * gzip: .gz\n # * bzip2: .bz2, supported since dpkg 1.10.24\n # * lzma: .lzma, supported since dpkg 1.13.25\n # * xz: .xz, supported since dpkg 1.15.6\n # * zstd: .zst, supported since dpkg 1.21.18\n #\n # ZSTD_BIN can decompress all formats except bzip2\n #\n # The OCI image spec supports .tar and .tar compressed with gzip or zstd.\n # Bazel needs the output filename to be fixed in advanced so we settle for\n # gzip compression.\n\n data_file=\"$$(basename $<)\"\n\n if [[ \"$$data_file\" == \"data.tar.bz2\" ]]; then\n # TODO: support bz2\n echo \"ERROR: unsupported compression: bz2\"\n exit 1\n elif [[ \"$$data_file\" == \"data.tar.gz\" ]]; then\n mv $< $@\n elif [[ \"$$data_file\" == \"data.tar\" ]]; then\n $(ZSTD_BIN) --compress --format=gzip $< >$@\n else\n $(ZSTD_BIN) --force --decompress --stdout $< |\n $(ZSTD_BIN) --compress --format=gzip - >$@\n fi\n \"\"\",\n toolchains = [\"@zstd_toolchains//:resolved_toolchain\"],\n visibility = [\"//visibility:public\"],\n)\n\nfilegroup(\n name = \"control\",\n srcs = glob([\"control.tar.*\"]),\n visibility = [\"//visibility:public\"],\n)\n", + "urls": [ + "https://deb.debian.org/debian/pool/main/b/bash/bash_5.2.15-2+b7_amd64.deb" + ], + "sha256": "d3c65202568384a588ea32017b243fe64ca054943a008cba4e5bd8f9e79975c4" + } + }, + "neuron_bookworm_debianutils_5.7-0.5_deb12u1_amd64": { + "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", + "ruleClassName": "http_archive", + "attributes": { + "build_file_content": "\ngenrule(\n name = \"data\",\n srcs = glob([\"data.tar*\"]),\n outs = [\"layer.tar.gz\"],\n cmd = \"\"\"\n # Per the dpkg-dev man page:\n # https://manpages.debian.org/bookworm/dpkg-dev/deb.5.en.html\n #\n # Debian data.tar files can be:\n # - .tar uncompressed, supported since dpkg 1.10.24\n # - .tar compressed with\n # * gzip: .gz\n # * bzip2: .bz2, supported since dpkg 1.10.24\n # * lzma: .lzma, supported since dpkg 1.13.25\n # * xz: .xz, supported since dpkg 1.15.6\n # * zstd: .zst, supported since dpkg 1.21.18\n #\n # ZSTD_BIN can decompress all formats except bzip2\n #\n # The OCI image spec supports .tar and .tar compressed with gzip or zstd.\n # Bazel needs the output filename to be fixed in advanced so we settle for\n # gzip compression.\n\n data_file=\"$$(basename $<)\"\n\n if [[ \"$$data_file\" == \"data.tar.bz2\" ]]; then\n # TODO: support bz2\n echo \"ERROR: unsupported compression: bz2\"\n exit 1\n elif [[ \"$$data_file\" == \"data.tar.gz\" ]]; then\n mv $< $@\n elif [[ \"$$data_file\" == \"data.tar\" ]]; then\n $(ZSTD_BIN) --compress --format=gzip $< >$@\n else\n $(ZSTD_BIN) --force --decompress --stdout $< |\n $(ZSTD_BIN) --compress --format=gzip - >$@\n fi\n \"\"\",\n toolchains = [\"@zstd_toolchains//:resolved_toolchain\"],\n visibility = [\"//visibility:public\"],\n)\n\nfilegroup(\n name = \"control\",\n srcs = glob([\"control.tar.*\"]),\n visibility = [\"//visibility:public\"],\n)\n", + "urls": [ + "https://deb.debian.org/debian/pool/main/d/debianutils/debianutils_5.7-0.5~deb12u1_amd64.deb" + ], + "sha256": "55f951359670eb3236c9e2ccd5fac9ccb3db734f5a22aff21589e7a30aee48c9" + } + }, + "neuron_bookworm_libc6_2.36-9-p-deb12u9_amd64": { + "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", + "ruleClassName": "http_archive", + "attributes": { + "build_file_content": "\ngenrule(\n name = \"data\",\n srcs = glob([\"data.tar*\"]),\n outs = [\"layer.tar.gz\"],\n cmd = \"\"\"\n # Per the dpkg-dev man page:\n # https://manpages.debian.org/bookworm/dpkg-dev/deb.5.en.html\n #\n # Debian data.tar files can be:\n # - .tar uncompressed, supported since dpkg 1.10.24\n # - .tar compressed with\n # * gzip: .gz\n # * bzip2: .bz2, supported since dpkg 1.10.24\n # * lzma: .lzma, supported since dpkg 1.13.25\n # * xz: .xz, supported since dpkg 1.15.6\n # * zstd: .zst, supported since dpkg 1.21.18\n #\n # ZSTD_BIN can decompress all formats except bzip2\n #\n # The OCI image spec supports .tar and .tar compressed with gzip or zstd.\n # Bazel needs the output filename to be fixed in advanced so we settle for\n # gzip compression.\n\n data_file=\"$$(basename $<)\"\n\n if [[ \"$$data_file\" == \"data.tar.bz2\" ]]; then\n # TODO: support bz2\n echo \"ERROR: unsupported compression: bz2\"\n exit 1\n elif [[ \"$$data_file\" == \"data.tar.gz\" ]]; then\n mv $< $@\n elif [[ \"$$data_file\" == \"data.tar\" ]]; then\n $(ZSTD_BIN) --compress --format=gzip $< >$@\n else\n $(ZSTD_BIN) --force --decompress --stdout $< |\n $(ZSTD_BIN) --compress --format=gzip - >$@\n fi\n \"\"\",\n toolchains = [\"@zstd_toolchains//:resolved_toolchain\"],\n visibility = [\"//visibility:public\"],\n)\n\nfilegroup(\n name = \"control\",\n srcs = glob([\"control.tar.*\"]),\n visibility = [\"//visibility:public\"],\n)\n", + "urls": [ + "https://deb.debian.org/debian/pool/main/g/glibc/libc6_2.36-9+deb12u9_amd64.deb" + ], + "sha256": "3a043b9dbf1a8c8b5a9e2268253e6dca8c7d431bd7a202fea96364abf374fea9" + } + }, + "neuron_bookworm_libgcc-s1_12.2.0-14_amd64": { + "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", + "ruleClassName": "http_archive", + "attributes": { + "build_file_content": "\ngenrule(\n name = \"data\",\n srcs = glob([\"data.tar*\"]),\n outs = [\"layer.tar.gz\"],\n cmd = \"\"\"\n # Per the dpkg-dev man page:\n # https://manpages.debian.org/bookworm/dpkg-dev/deb.5.en.html\n #\n # Debian data.tar files can be:\n # - .tar uncompressed, supported since dpkg 1.10.24\n # - .tar compressed with\n # * gzip: .gz\n # * bzip2: .bz2, supported since dpkg 1.10.24\n # * lzma: .lzma, supported since dpkg 1.13.25\n # * xz: .xz, supported since dpkg 1.15.6\n # * zstd: .zst, supported since dpkg 1.21.18\n #\n # ZSTD_BIN can decompress all formats except bzip2\n #\n # The OCI image spec supports .tar and .tar compressed with gzip or zstd.\n # Bazel needs the output filename to be fixed in advanced so we settle for\n # gzip compression.\n\n data_file=\"$$(basename $<)\"\n\n if [[ \"$$data_file\" == \"data.tar.bz2\" ]]; then\n # TODO: support bz2\n echo \"ERROR: unsupported compression: bz2\"\n exit 1\n elif [[ \"$$data_file\" == \"data.tar.gz\" ]]; then\n mv $< $@\n elif [[ \"$$data_file\" == \"data.tar\" ]]; then\n $(ZSTD_BIN) --compress --format=gzip $< >$@\n else\n $(ZSTD_BIN) --force --decompress --stdout $< |\n $(ZSTD_BIN) --compress --format=gzip - >$@\n fi\n \"\"\",\n toolchains = [\"@zstd_toolchains//:resolved_toolchain\"],\n visibility = [\"//visibility:public\"],\n)\n\nfilegroup(\n name = \"control\",\n srcs = glob([\"control.tar.*\"]),\n visibility = [\"//visibility:public\"],\n)\n", + "urls": [ + "https://deb.debian.org/debian/pool/main/g/gcc-12/libgcc-s1_12.2.0-14_amd64.deb" + ], + "sha256": "f3d1d48c0599aea85b7f2077a01d285badc42998c1a1e7473935d5cf995c8141" + } + }, + "neuron_bookworm_gcc-12-base_12.2.0-14_amd64": { + "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", + "ruleClassName": "http_archive", + "attributes": { + "build_file_content": "\ngenrule(\n name = \"data\",\n srcs = glob([\"data.tar*\"]),\n outs = [\"layer.tar.gz\"],\n cmd = \"\"\"\n # Per the dpkg-dev man page:\n # https://manpages.debian.org/bookworm/dpkg-dev/deb.5.en.html\n #\n # Debian data.tar files can be:\n # - .tar uncompressed, supported since dpkg 1.10.24\n # - .tar compressed with\n # * gzip: .gz\n # * bzip2: .bz2, supported since dpkg 1.10.24\n # * lzma: .lzma, supported since dpkg 1.13.25\n # * xz: .xz, supported since dpkg 1.15.6\n # * zstd: .zst, supported since dpkg 1.21.18\n #\n # ZSTD_BIN can decompress all formats except bzip2\n #\n # The OCI image spec supports .tar and .tar compressed with gzip or zstd.\n # Bazel needs the output filename to be fixed in advanced so we settle for\n # gzip compression.\n\n data_file=\"$$(basename $<)\"\n\n if [[ \"$$data_file\" == \"data.tar.bz2\" ]]; then\n # TODO: support bz2\n echo \"ERROR: unsupported compression: bz2\"\n exit 1\n elif [[ \"$$data_file\" == \"data.tar.gz\" ]]; then\n mv $< $@\n elif [[ \"$$data_file\" == \"data.tar\" ]]; then\n $(ZSTD_BIN) --compress --format=gzip $< >$@\n else\n $(ZSTD_BIN) --force --decompress --stdout $< |\n $(ZSTD_BIN) --compress --format=gzip - >$@\n fi\n \"\"\",\n toolchains = [\"@zstd_toolchains//:resolved_toolchain\"],\n visibility = [\"//visibility:public\"],\n)\n\nfilegroup(\n name = \"control\",\n srcs = glob([\"control.tar.*\"]),\n visibility = [\"//visibility:public\"],\n)\n", + "urls": [ + "https://deb.debian.org/debian/pool/main/g/gcc-12/gcc-12-base_12.2.0-14_amd64.deb" + ], + "sha256": "1a03df5a57833d65b5bb08cfa19d50e76f29088dc9e64fb934af42d9023a0807" + } + }, + "neuron_bookworm_base-files_12.4-p-deb12u8_amd64": { + "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", + "ruleClassName": "http_archive", + "attributes": { + "build_file_content": "\ngenrule(\n name = \"data\",\n srcs = glob([\"data.tar*\"]),\n outs = [\"layer.tar.gz\"],\n cmd = \"\"\"\n # Per the dpkg-dev man page:\n # https://manpages.debian.org/bookworm/dpkg-dev/deb.5.en.html\n #\n # Debian data.tar files can be:\n # - .tar uncompressed, supported since dpkg 1.10.24\n # - .tar compressed with\n # * gzip: .gz\n # * bzip2: .bz2, supported since dpkg 1.10.24\n # * lzma: .lzma, supported since dpkg 1.13.25\n # * xz: .xz, supported since dpkg 1.15.6\n # * zstd: .zst, supported since dpkg 1.21.18\n #\n # ZSTD_BIN can decompress all formats except bzip2\n #\n # The OCI image spec supports .tar and .tar compressed with gzip or zstd.\n # Bazel needs the output filename to be fixed in advanced so we settle for\n # gzip compression.\n\n data_file=\"$$(basename $<)\"\n\n if [[ \"$$data_file\" == \"data.tar.bz2\" ]]; then\n # TODO: support bz2\n echo \"ERROR: unsupported compression: bz2\"\n exit 1\n elif [[ \"$$data_file\" == \"data.tar.gz\" ]]; then\n mv $< $@\n elif [[ \"$$data_file\" == \"data.tar\" ]]; then\n $(ZSTD_BIN) --compress --format=gzip $< >$@\n else\n $(ZSTD_BIN) --force --decompress --stdout $< |\n $(ZSTD_BIN) --compress --format=gzip - >$@\n fi\n \"\"\",\n toolchains = [\"@zstd_toolchains//:resolved_toolchain\"],\n visibility = [\"//visibility:public\"],\n)\n\nfilegroup(\n name = \"control\",\n srcs = glob([\"control.tar.*\"]),\n visibility = [\"//visibility:public\"],\n)\n", + "urls": [ + "https://deb.debian.org/debian/pool/main/b/base-files/base-files_12.4+deb12u8_amd64.deb" + ], + "sha256": "b961a69d1b79f093597d89a96f296ddca17d3bab9d166361c42f07a6beb4f685" + } + }, + "neuron_bookworm_libtinfo6_6.4-4_amd64": { + "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", + "ruleClassName": "http_archive", + "attributes": { + "build_file_content": "\ngenrule(\n name = \"data\",\n srcs = glob([\"data.tar*\"]),\n outs = [\"layer.tar.gz\"],\n cmd = \"\"\"\n # Per the dpkg-dev man page:\n # https://manpages.debian.org/bookworm/dpkg-dev/deb.5.en.html\n #\n # Debian data.tar files can be:\n # - .tar uncompressed, supported since dpkg 1.10.24\n # - .tar compressed with\n # * gzip: .gz\n # * bzip2: .bz2, supported since dpkg 1.10.24\n # * lzma: .lzma, supported since dpkg 1.13.25\n # * xz: .xz, supported since dpkg 1.15.6\n # * zstd: .zst, supported since dpkg 1.21.18\n #\n # ZSTD_BIN can decompress all formats except bzip2\n #\n # The OCI image spec supports .tar and .tar compressed with gzip or zstd.\n # Bazel needs the output filename to be fixed in advanced so we settle for\n # gzip compression.\n\n data_file=\"$$(basename $<)\"\n\n if [[ \"$$data_file\" == \"data.tar.bz2\" ]]; then\n # TODO: support bz2\n echo \"ERROR: unsupported compression: bz2\"\n exit 1\n elif [[ \"$$data_file\" == \"data.tar.gz\" ]]; then\n mv $< $@\n elif [[ \"$$data_file\" == \"data.tar\" ]]; then\n $(ZSTD_BIN) --compress --format=gzip $< >$@\n else\n $(ZSTD_BIN) --force --decompress --stdout $< |\n $(ZSTD_BIN) --compress --format=gzip - >$@\n fi\n \"\"\",\n toolchains = [\"@zstd_toolchains//:resolved_toolchain\"],\n visibility = [\"//visibility:public\"],\n)\n\nfilegroup(\n name = \"control\",\n srcs = glob([\"control.tar.*\"]),\n visibility = [\"//visibility:public\"],\n)\n", + "urls": [ + "https://deb.debian.org/debian/pool/main/n/ncurses/libtinfo6_6.4-4_amd64.deb" + ], + "sha256": "072d908f38f51090ca28ca5afa3b46b2957dc61fe35094c0b851426859a49a51" + } + }, + "neuron_bookworm_zlib1g_1-1.2.13.dfsg-1_amd64": { + "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", + "ruleClassName": "http_archive", + "attributes": { + "build_file_content": "\ngenrule(\n name = \"data\",\n srcs = glob([\"data.tar*\"]),\n outs = [\"layer.tar.gz\"],\n cmd = \"\"\"\n # Per the dpkg-dev man page:\n # https://manpages.debian.org/bookworm/dpkg-dev/deb.5.en.html\n #\n # Debian data.tar files can be:\n # - .tar uncompressed, supported since dpkg 1.10.24\n # - .tar compressed with\n # * gzip: .gz\n # * bzip2: .bz2, supported since dpkg 1.10.24\n # * lzma: .lzma, supported since dpkg 1.13.25\n # * xz: .xz, supported since dpkg 1.15.6\n # * zstd: .zst, supported since dpkg 1.21.18\n #\n # ZSTD_BIN can decompress all formats except bzip2\n #\n # The OCI image spec supports .tar and .tar compressed with gzip or zstd.\n # Bazel needs the output filename to be fixed in advanced so we settle for\n # gzip compression.\n\n data_file=\"$$(basename $<)\"\n\n if [[ \"$$data_file\" == \"data.tar.bz2\" ]]; then\n # TODO: support bz2\n echo \"ERROR: unsupported compression: bz2\"\n exit 1\n elif [[ \"$$data_file\" == \"data.tar.gz\" ]]; then\n mv $< $@\n elif [[ \"$$data_file\" == \"data.tar\" ]]; then\n $(ZSTD_BIN) --compress --format=gzip $< >$@\n else\n $(ZSTD_BIN) --force --decompress --stdout $< |\n $(ZSTD_BIN) --compress --format=gzip - >$@\n fi\n \"\"\",\n toolchains = [\"@zstd_toolchains//:resolved_toolchain\"],\n visibility = [\"//visibility:public\"],\n)\n\nfilegroup(\n name = \"control\",\n srcs = glob([\"control.tar.*\"]),\n visibility = [\"//visibility:public\"],\n)\n", + "urls": [ + "https://deb.debian.org/debian/pool/main/z/zlib/zlib1g_1.2.13.dfsg-1_amd64.deb" + ], + "sha256": "d7dd1d1411fedf27f5e27650a6eff20ef294077b568f4c8c5e51466dc7c08ce4" + } + }, + "neuron_bookworm_libxml2_2.9.14-p-dfsg-1.3_deb12u1_amd64": { + "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", + "ruleClassName": "http_archive", + "attributes": { + "build_file_content": "\ngenrule(\n name = \"data\",\n srcs = glob([\"data.tar*\"]),\n outs = [\"layer.tar.gz\"],\n cmd = \"\"\"\n # Per the dpkg-dev man page:\n # https://manpages.debian.org/bookworm/dpkg-dev/deb.5.en.html\n #\n # Debian data.tar files can be:\n # - .tar uncompressed, supported since dpkg 1.10.24\n # - .tar compressed with\n # * gzip: .gz\n # * bzip2: .bz2, supported since dpkg 1.10.24\n # * lzma: .lzma, supported since dpkg 1.13.25\n # * xz: .xz, supported since dpkg 1.15.6\n # * zstd: .zst, supported since dpkg 1.21.18\n #\n # ZSTD_BIN can decompress all formats except bzip2\n #\n # The OCI image spec supports .tar and .tar compressed with gzip or zstd.\n # Bazel needs the output filename to be fixed in advanced so we settle for\n # gzip compression.\n\n data_file=\"$$(basename $<)\"\n\n if [[ \"$$data_file\" == \"data.tar.bz2\" ]]; then\n # TODO: support bz2\n echo \"ERROR: unsupported compression: bz2\"\n exit 1\n elif [[ \"$$data_file\" == \"data.tar.gz\" ]]; then\n mv $< $@\n elif [[ \"$$data_file\" == \"data.tar\" ]]; then\n $(ZSTD_BIN) --compress --format=gzip $< >$@\n else\n $(ZSTD_BIN) --force --decompress --stdout $< |\n $(ZSTD_BIN) --compress --format=gzip - >$@\n fi\n \"\"\",\n toolchains = [\"@zstd_toolchains//:resolved_toolchain\"],\n visibility = [\"//visibility:public\"],\n)\n\nfilegroup(\n name = \"control\",\n srcs = glob([\"control.tar.*\"]),\n visibility = [\"//visibility:public\"],\n)\n", + "urls": [ + "https://deb.debian.org/debian/pool/main/libx/libxml2/libxml2_2.9.14+dfsg-1.3~deb12u1_amd64.deb" + ], + "sha256": "35b76cb7038fc1c940204a4f05f33ffb79d027353ce469397d9adcf8f9b3e1a7" + } + }, + "neuron_bookworm_liblzma5_5.4.1-0.2_amd64": { + "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", + "ruleClassName": "http_archive", + "attributes": { + "build_file_content": "\ngenrule(\n name = \"data\",\n srcs = glob([\"data.tar*\"]),\n outs = [\"layer.tar.gz\"],\n cmd = \"\"\"\n # Per the dpkg-dev man page:\n # https://manpages.debian.org/bookworm/dpkg-dev/deb.5.en.html\n #\n # Debian data.tar files can be:\n # - .tar uncompressed, supported since dpkg 1.10.24\n # - .tar compressed with\n # * gzip: .gz\n # * bzip2: .bz2, supported since dpkg 1.10.24\n # * lzma: .lzma, supported since dpkg 1.13.25\n # * xz: .xz, supported since dpkg 1.15.6\n # * zstd: .zst, supported since dpkg 1.21.18\n #\n # ZSTD_BIN can decompress all formats except bzip2\n #\n # The OCI image spec supports .tar and .tar compressed with gzip or zstd.\n # Bazel needs the output filename to be fixed in advanced so we settle for\n # gzip compression.\n\n data_file=\"$$(basename $<)\"\n\n if [[ \"$$data_file\" == \"data.tar.bz2\" ]]; then\n # TODO: support bz2\n echo \"ERROR: unsupported compression: bz2\"\n exit 1\n elif [[ \"$$data_file\" == \"data.tar.gz\" ]]; then\n mv $< $@\n elif [[ \"$$data_file\" == \"data.tar\" ]]; then\n $(ZSTD_BIN) --compress --format=gzip $< >$@\n else\n $(ZSTD_BIN) --force --decompress --stdout $< |\n $(ZSTD_BIN) --compress --format=gzip - >$@\n fi\n \"\"\",\n toolchains = [\"@zstd_toolchains//:resolved_toolchain\"],\n visibility = [\"//visibility:public\"],\n)\n\nfilegroup(\n name = \"control\",\n srcs = glob([\"control.tar.*\"]),\n visibility = [\"//visibility:public\"],\n)\n", + "urls": [ + "https://deb.debian.org/debian/pool/main/x/xz-utils/liblzma5_5.4.1-0.2_amd64.deb" + ], + "sha256": "d4b7736e58512a2b047f9cb91b71db5a3cf9d3451192fc6da044c77bf51fe869" + } + }, + "neuron_bookworm_libicu72_72.1-3_amd64": { + "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", + "ruleClassName": "http_archive", + "attributes": { + "build_file_content": "\ngenrule(\n name = \"data\",\n srcs = glob([\"data.tar*\"]),\n outs = [\"layer.tar.gz\"],\n cmd = \"\"\"\n # Per the dpkg-dev man page:\n # https://manpages.debian.org/bookworm/dpkg-dev/deb.5.en.html\n #\n # Debian data.tar files can be:\n # - .tar uncompressed, supported since dpkg 1.10.24\n # - .tar compressed with\n # * gzip: .gz\n # * bzip2: .bz2, supported since dpkg 1.10.24\n # * lzma: .lzma, supported since dpkg 1.13.25\n # * xz: .xz, supported since dpkg 1.15.6\n # * zstd: .zst, supported since dpkg 1.21.18\n #\n # ZSTD_BIN can decompress all formats except bzip2\n #\n # The OCI image spec supports .tar and .tar compressed with gzip or zstd.\n # Bazel needs the output filename to be fixed in advanced so we settle for\n # gzip compression.\n\n data_file=\"$$(basename $<)\"\n\n if [[ \"$$data_file\" == \"data.tar.bz2\" ]]; then\n # TODO: support bz2\n echo \"ERROR: unsupported compression: bz2\"\n exit 1\n elif [[ \"$$data_file\" == \"data.tar.gz\" ]]; then\n mv $< $@\n elif [[ \"$$data_file\" == \"data.tar\" ]]; then\n $(ZSTD_BIN) --compress --format=gzip $< >$@\n else\n $(ZSTD_BIN) --force --decompress --stdout $< |\n $(ZSTD_BIN) --compress --format=gzip - >$@\n fi\n \"\"\",\n toolchains = [\"@zstd_toolchains//:resolved_toolchain\"],\n visibility = [\"//visibility:public\"],\n)\n\nfilegroup(\n name = \"control\",\n srcs = glob([\"control.tar.*\"]),\n visibility = [\"//visibility:public\"],\n)\n", + "urls": [ + "https://deb.debian.org/debian/pool/main/i/icu/libicu72_72.1-3_amd64.deb" + ], + "sha256": "e239c1c9f52bee0ff627f291552d63691b765ec7c5cdf6de7c7ae4dec0275857" + } + }, + "neuron_bookworm_libstdc-p--p-6_12.2.0-14_amd64": { + "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", + "ruleClassName": "http_archive", + "attributes": { + "build_file_content": "\ngenrule(\n name = \"data\",\n srcs = glob([\"data.tar*\"]),\n outs = [\"layer.tar.gz\"],\n cmd = \"\"\"\n # Per the dpkg-dev man page:\n # https://manpages.debian.org/bookworm/dpkg-dev/deb.5.en.html\n #\n # Debian data.tar files can be:\n # - .tar uncompressed, supported since dpkg 1.10.24\n # - .tar compressed with\n # * gzip: .gz\n # * bzip2: .bz2, supported since dpkg 1.10.24\n # * lzma: .lzma, supported since dpkg 1.13.25\n # * xz: .xz, supported since dpkg 1.15.6\n # * zstd: .zst, supported since dpkg 1.21.18\n #\n # ZSTD_BIN can decompress all formats except bzip2\n #\n # The OCI image spec supports .tar and .tar compressed with gzip or zstd.\n # Bazel needs the output filename to be fixed in advanced so we settle for\n # gzip compression.\n\n data_file=\"$$(basename $<)\"\n\n if [[ \"$$data_file\" == \"data.tar.bz2\" ]]; then\n # TODO: support bz2\n echo \"ERROR: unsupported compression: bz2\"\n exit 1\n elif [[ \"$$data_file\" == \"data.tar.gz\" ]]; then\n mv $< $@\n elif [[ \"$$data_file\" == \"data.tar\" ]]; then\n $(ZSTD_BIN) --compress --format=gzip $< >$@\n else\n $(ZSTD_BIN) --force --decompress --stdout $< |\n $(ZSTD_BIN) --compress --format=gzip - >$@\n fi\n \"\"\",\n toolchains = [\"@zstd_toolchains//:resolved_toolchain\"],\n visibility = [\"//visibility:public\"],\n)\n\nfilegroup(\n name = \"control\",\n srcs = glob([\"control.tar.*\"]),\n visibility = [\"//visibility:public\"],\n)\n", + "urls": [ + "https://deb.debian.org/debian/pool/main/g/gcc-12/libstdc++6_12.2.0-14_amd64.deb" + ], + "sha256": "9b1b269020cec6aced3b39f096f7b67edd1f0d4ab24f412cb6506d0800e19cbf" + } + }, + "neuron_bookworm_aws-neuronx-runtime-lib_2.22.19.0-5856c0b42_amd64": { + "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", + "ruleClassName": "http_archive", + "attributes": { + "build_file_content": "\ngenrule(\n name = \"data\",\n srcs = glob([\"data.tar*\"]),\n outs = [\"layer.tar.gz\"],\n cmd = \"\"\"\n # Per the dpkg-dev man page:\n # https://manpages.debian.org/bookworm/dpkg-dev/deb.5.en.html\n #\n # Debian data.tar files can be:\n # - .tar uncompressed, supported since dpkg 1.10.24\n # - .tar compressed with\n # * gzip: .gz\n # * bzip2: .bz2, supported since dpkg 1.10.24\n # * lzma: .lzma, supported since dpkg 1.13.25\n # * xz: .xz, supported since dpkg 1.15.6\n # * zstd: .zst, supported since dpkg 1.21.18\n #\n # ZSTD_BIN can decompress all formats except bzip2\n #\n # The OCI image spec supports .tar and .tar compressed with gzip or zstd.\n # Bazel needs the output filename to be fixed in advanced so we settle for\n # gzip compression.\n\n data_file=\"$$(basename $<)\"\n\n if [[ \"$$data_file\" == \"data.tar.bz2\" ]]; then\n # TODO: support bz2\n echo \"ERROR: unsupported compression: bz2\"\n exit 1\n elif [[ \"$$data_file\" == \"data.tar.gz\" ]]; then\n mv $< $@\n elif [[ \"$$data_file\" == \"data.tar\" ]]; then\n $(ZSTD_BIN) --compress --format=gzip $< >$@\n else\n $(ZSTD_BIN) --force --decompress --stdout $< |\n $(ZSTD_BIN) --compress --format=gzip - >$@\n fi\n \"\"\",\n toolchains = [\"@zstd_toolchains//:resolved_toolchain\"],\n visibility = [\"//visibility:public\"],\n)\n\nfilegroup(\n name = \"control\",\n srcs = glob([\"control.tar.*\"]),\n visibility = [\"//visibility:public\"],\n)\n", + "urls": [ + "https://apt.repos.neuron.amazonaws.com/pool/main/a/aws-neuronx-runtime-lib/aws-neuronx-runtime-lib_2.22.19.0-5856c0b42_amd64.deb" + ], + "sha256": "f952dad4f615f2881a0bf93ba5132d308fdfa697a78a09e2e1653a6c4704222d" + } + }, + "neuron_bookworm_aws-neuronx-collectives_2.22.33.0-d2128d1aa_amd64": { + "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", + "ruleClassName": "http_archive", + "attributes": { + "build_file_content": "\ngenrule(\n name = \"data\",\n srcs = glob([\"data.tar*\"]),\n outs = [\"layer.tar.gz\"],\n cmd = \"\"\"\n # Per the dpkg-dev man page:\n # https://manpages.debian.org/bookworm/dpkg-dev/deb.5.en.html\n #\n # Debian data.tar files can be:\n # - .tar uncompressed, supported since dpkg 1.10.24\n # - .tar compressed with\n # * gzip: .gz\n # * bzip2: .bz2, supported since dpkg 1.10.24\n # * lzma: .lzma, supported since dpkg 1.13.25\n # * xz: .xz, supported since dpkg 1.15.6\n # * zstd: .zst, supported since dpkg 1.21.18\n #\n # ZSTD_BIN can decompress all formats except bzip2\n #\n # The OCI image spec supports .tar and .tar compressed with gzip or zstd.\n # Bazel needs the output filename to be fixed in advanced so we settle for\n # gzip compression.\n\n data_file=\"$$(basename $<)\"\n\n if [[ \"$$data_file\" == \"data.tar.bz2\" ]]; then\n # TODO: support bz2\n echo \"ERROR: unsupported compression: bz2\"\n exit 1\n elif [[ \"$$data_file\" == \"data.tar.gz\" ]]; then\n mv $< $@\n elif [[ \"$$data_file\" == \"data.tar\" ]]; then\n $(ZSTD_BIN) --compress --format=gzip $< >$@\n else\n $(ZSTD_BIN) --force --decompress --stdout $< |\n $(ZSTD_BIN) --compress --format=gzip - >$@\n fi\n \"\"\",\n toolchains = [\"@zstd_toolchains//:resolved_toolchain\"],\n visibility = [\"//visibility:public\"],\n)\n\nfilegroup(\n name = \"control\",\n srcs = glob([\"control.tar.*\"]),\n visibility = [\"//visibility:public\"],\n)\n", + "urls": [ + "https://apt.repos.neuron.amazonaws.com/pool/main/a/aws-neuronx-collectives/aws-neuronx-collectives_2.22.33.0-d2128d1aa_amd64.deb" + ], + "sha256": "1eadead90a7daf6056a10a09d0ac3b72a3e885e6fedacd14b53a11a30d9774b3" + } + }, + "neuron_bookworm_resolve": { + "bzlFile": "@@rules_distroless~//apt/private:resolve.bzl", + "ruleClassName": "deb_resolve", + "attributes": { + "manifest": "@@//runtimes/neuron:packages.yaml", + "resolve_transitive": true + } + }, + "neuron_bookworm": { + "bzlFile": "@@rules_distroless~//apt/private:index.bzl", + "ruleClassName": "deb_package_index", + "attributes": { + "lock": "@@//runtimes/neuron:packages.lock.json", + "lock_content": "{\n\t\"packages\": [\n\t\t{\n\t\t\t\"arch\": \"amd64\",\n\t\t\t\"dependencies\": [\n\t\t\t\t{\n\t\t\t\t\t\"key\": \"debianutils_5.7-0.5_deb12u1_amd64\",\n\t\t\t\t\t\"name\": \"debianutils\",\n\t\t\t\t\t\"version\": \"5.7-0.5~deb12u1\"\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"key\": \"libc6_2.36-9-p-deb12u9_amd64\",\n\t\t\t\t\t\"name\": \"libc6\",\n\t\t\t\t\t\"version\": \"2.36-9+deb12u9\"\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"key\": \"libgcc-s1_12.2.0-14_amd64\",\n\t\t\t\t\t\"name\": \"libgcc-s1\",\n\t\t\t\t\t\"version\": \"12.2.0-14\"\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"key\": \"gcc-12-base_12.2.0-14_amd64\",\n\t\t\t\t\t\"name\": \"gcc-12-base\",\n\t\t\t\t\t\"version\": \"12.2.0-14\"\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"key\": \"base-files_12.4-p-deb12u8_amd64\",\n\t\t\t\t\t\"name\": \"base-files\",\n\t\t\t\t\t\"version\": \"12.4+deb12u8\"\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"key\": \"libtinfo6_6.4-4_amd64\",\n\t\t\t\t\t\"name\": \"libtinfo6\",\n\t\t\t\t\t\"version\": \"6.4-4\"\n\t\t\t\t}\n\t\t\t],\n\t\t\t\"key\": \"bash_5.2.15-2-p-b7_amd64\",\n\t\t\t\"name\": \"bash\",\n\t\t\t\"sha256\": \"d3c65202568384a588ea32017b243fe64ca054943a008cba4e5bd8f9e79975c4\",\n\t\t\t\"url\": \"https://deb.debian.org/debian/pool/main/b/bash/bash_5.2.15-2+b7_amd64.deb\",\n\t\t\t\"version\": \"5.2.15-2+b7\"\n\t\t},\n\t\t{\n\t\t\t\"arch\": \"amd64\",\n\t\t\t\"dependencies\": [],\n\t\t\t\"key\": \"debianutils_5.7-0.5_deb12u1_amd64\",\n\t\t\t\"name\": \"debianutils\",\n\t\t\t\"sha256\": \"55f951359670eb3236c9e2ccd5fac9ccb3db734f5a22aff21589e7a30aee48c9\",\n\t\t\t\"url\": \"https://deb.debian.org/debian/pool/main/d/debianutils/debianutils_5.7-0.5~deb12u1_amd64.deb\",\n\t\t\t\"version\": \"5.7-0.5~deb12u1\"\n\t\t},\n\t\t{\n\t\t\t\"arch\": \"amd64\",\n\t\t\t\"dependencies\": [],\n\t\t\t\"key\": \"libc6_2.36-9-p-deb12u9_amd64\",\n\t\t\t\"name\": \"libc6\",\n\t\t\t\"sha256\": \"3a043b9dbf1a8c8b5a9e2268253e6dca8c7d431bd7a202fea96364abf374fea9\",\n\t\t\t\"url\": \"https://deb.debian.org/debian/pool/main/g/glibc/libc6_2.36-9+deb12u9_amd64.deb\",\n\t\t\t\"version\": \"2.36-9+deb12u9\"\n\t\t},\n\t\t{\n\t\t\t\"arch\": \"amd64\",\n\t\t\t\"dependencies\": [],\n\t\t\t\"key\": \"libgcc-s1_12.2.0-14_amd64\",\n\t\t\t\"name\": \"libgcc-s1\",\n\t\t\t\"sha256\": \"f3d1d48c0599aea85b7f2077a01d285badc42998c1a1e7473935d5cf995c8141\",\n\t\t\t\"url\": \"https://deb.debian.org/debian/pool/main/g/gcc-12/libgcc-s1_12.2.0-14_amd64.deb\",\n\t\t\t\"version\": \"12.2.0-14\"\n\t\t},\n\t\t{\n\t\t\t\"arch\": \"amd64\",\n\t\t\t\"dependencies\": [],\n\t\t\t\"key\": \"gcc-12-base_12.2.0-14_amd64\",\n\t\t\t\"name\": \"gcc-12-base\",\n\t\t\t\"sha256\": \"1a03df5a57833d65b5bb08cfa19d50e76f29088dc9e64fb934af42d9023a0807\",\n\t\t\t\"url\": \"https://deb.debian.org/debian/pool/main/g/gcc-12/gcc-12-base_12.2.0-14_amd64.deb\",\n\t\t\t\"version\": \"12.2.0-14\"\n\t\t},\n\t\t{\n\t\t\t\"arch\": \"amd64\",\n\t\t\t\"dependencies\": [],\n\t\t\t\"key\": \"base-files_12.4-p-deb12u8_amd64\",\n\t\t\t\"name\": \"base-files\",\n\t\t\t\"sha256\": \"b961a69d1b79f093597d89a96f296ddca17d3bab9d166361c42f07a6beb4f685\",\n\t\t\t\"url\": \"https://deb.debian.org/debian/pool/main/b/base-files/base-files_12.4+deb12u8_amd64.deb\",\n\t\t\t\"version\": \"12.4+deb12u8\"\n\t\t},\n\t\t{\n\t\t\t\"arch\": \"amd64\",\n\t\t\t\"dependencies\": [],\n\t\t\t\"key\": \"libtinfo6_6.4-4_amd64\",\n\t\t\t\"name\": \"libtinfo6\",\n\t\t\t\"sha256\": \"072d908f38f51090ca28ca5afa3b46b2957dc61fe35094c0b851426859a49a51\",\n\t\t\t\"url\": \"https://deb.debian.org/debian/pool/main/n/ncurses/libtinfo6_6.4-4_amd64.deb\",\n\t\t\t\"version\": \"6.4-4\"\n\t\t},\n\t\t{\n\t\t\t\"arch\": \"amd64\",\n\t\t\t\"dependencies\": [\n\t\t\t\t{\n\t\t\t\t\t\"key\": \"libc6_2.36-9-p-deb12u9_amd64\",\n\t\t\t\t\t\"name\": \"libc6\",\n\t\t\t\t\t\"version\": \"2.36-9+deb12u9\"\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"key\": \"libgcc-s1_12.2.0-14_amd64\",\n\t\t\t\t\t\"name\": \"libgcc-s1\",\n\t\t\t\t\t\"version\": \"12.2.0-14\"\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"key\": \"gcc-12-base_12.2.0-14_amd64\",\n\t\t\t\t\t\"name\": \"gcc-12-base\",\n\t\t\t\t\t\"version\": \"12.2.0-14\"\n\t\t\t\t}\n\t\t\t],\n\t\t\t\"key\": \"zlib1g_1-1.2.13.dfsg-1_amd64\",\n\t\t\t\"name\": \"zlib1g\",\n\t\t\t\"sha256\": \"d7dd1d1411fedf27f5e27650a6eff20ef294077b568f4c8c5e51466dc7c08ce4\",\n\t\t\t\"url\": \"https://deb.debian.org/debian/pool/main/z/zlib/zlib1g_1.2.13.dfsg-1_amd64.deb\",\n\t\t\t\"version\": \"1:1.2.13.dfsg-1\"\n\t\t},\n\t\t{\n\t\t\t\"arch\": \"amd64\",\n\t\t\t\"dependencies\": [\n\t\t\t\t{\n\t\t\t\t\t\"key\": \"zlib1g_1-1.2.13.dfsg-1_amd64\",\n\t\t\t\t\t\"name\": \"zlib1g\",\n\t\t\t\t\t\"version\": \"1:1.2.13.dfsg-1\"\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"key\": \"libc6_2.36-9-p-deb12u9_amd64\",\n\t\t\t\t\t\"name\": \"libc6\",\n\t\t\t\t\t\"version\": \"2.36-9+deb12u9\"\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"key\": \"libgcc-s1_12.2.0-14_amd64\",\n\t\t\t\t\t\"name\": \"libgcc-s1\",\n\t\t\t\t\t\"version\": \"12.2.0-14\"\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"key\": \"gcc-12-base_12.2.0-14_amd64\",\n\t\t\t\t\t\"name\": \"gcc-12-base\",\n\t\t\t\t\t\"version\": \"12.2.0-14\"\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"key\": \"liblzma5_5.4.1-0.2_amd64\",\n\t\t\t\t\t\"name\": \"liblzma5\",\n\t\t\t\t\t\"version\": \"5.4.1-0.2\"\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"key\": \"libicu72_72.1-3_amd64\",\n\t\t\t\t\t\"name\": \"libicu72\",\n\t\t\t\t\t\"version\": \"72.1-3\"\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"key\": \"libstdc-p--p-6_12.2.0-14_amd64\",\n\t\t\t\t\t\"name\": \"libstdc++6\",\n\t\t\t\t\t\"version\": \"12.2.0-14\"\n\t\t\t\t}\n\t\t\t],\n\t\t\t\"key\": \"libxml2_2.9.14-p-dfsg-1.3_deb12u1_amd64\",\n\t\t\t\"name\": \"libxml2\",\n\t\t\t\"sha256\": \"35b76cb7038fc1c940204a4f05f33ffb79d027353ce469397d9adcf8f9b3e1a7\",\n\t\t\t\"url\": \"https://deb.debian.org/debian/pool/main/libx/libxml2/libxml2_2.9.14+dfsg-1.3~deb12u1_amd64.deb\",\n\t\t\t\"version\": \"2.9.14+dfsg-1.3~deb12u1\"\n\t\t},\n\t\t{\n\t\t\t\"arch\": \"amd64\",\n\t\t\t\"dependencies\": [],\n\t\t\t\"key\": \"liblzma5_5.4.1-0.2_amd64\",\n\t\t\t\"name\": \"liblzma5\",\n\t\t\t\"sha256\": \"d4b7736e58512a2b047f9cb91b71db5a3cf9d3451192fc6da044c77bf51fe869\",\n\t\t\t\"url\": \"https://deb.debian.org/debian/pool/main/x/xz-utils/liblzma5_5.4.1-0.2_amd64.deb\",\n\t\t\t\"version\": \"5.4.1-0.2\"\n\t\t},\n\t\t{\n\t\t\t\"arch\": \"amd64\",\n\t\t\t\"dependencies\": [],\n\t\t\t\"key\": \"libicu72_72.1-3_amd64\",\n\t\t\t\"name\": \"libicu72\",\n\t\t\t\"sha256\": \"e239c1c9f52bee0ff627f291552d63691b765ec7c5cdf6de7c7ae4dec0275857\",\n\t\t\t\"url\": \"https://deb.debian.org/debian/pool/main/i/icu/libicu72_72.1-3_amd64.deb\",\n\t\t\t\"version\": \"72.1-3\"\n\t\t},\n\t\t{\n\t\t\t\"arch\": \"amd64\",\n\t\t\t\"dependencies\": [],\n\t\t\t\"key\": \"libstdc-p--p-6_12.2.0-14_amd64\",\n\t\t\t\"name\": \"libstdc++6\",\n\t\t\t\"sha256\": \"9b1b269020cec6aced3b39f096f7b67edd1f0d4ab24f412cb6506d0800e19cbf\",\n\t\t\t\"url\": \"https://deb.debian.org/debian/pool/main/g/gcc-12/libstdc++6_12.2.0-14_amd64.deb\",\n\t\t\t\"version\": \"12.2.0-14\"\n\t\t},\n\t\t{\n\t\t\t\"arch\": \"amd64\",\n\t\t\t\"dependencies\": [],\n\t\t\t\"key\": \"aws-neuronx-runtime-lib_2.22.19.0-5856c0b42_amd64\",\n\t\t\t\"name\": \"aws-neuronx-runtime-lib\",\n\t\t\t\"sha256\": \"f952dad4f615f2881a0bf93ba5132d308fdfa697a78a09e2e1653a6c4704222d\",\n\t\t\t\"url\": \"https://apt.repos.neuron.amazonaws.com/pool/main/a/aws-neuronx-runtime-lib/aws-neuronx-runtime-lib_2.22.19.0-5856c0b42_amd64.deb\",\n\t\t\t\"version\": \"2.22.19.0-5856c0b42\"\n\t\t},\n\t\t{\n\t\t\t\"arch\": \"amd64\",\n\t\t\t\"dependencies\": [],\n\t\t\t\"key\": \"aws-neuronx-collectives_2.22.33.0-d2128d1aa_amd64\",\n\t\t\t\"name\": \"aws-neuronx-collectives\",\n\t\t\t\"sha256\": \"1eadead90a7daf6056a10a09d0ac3b72a3e885e6fedacd14b53a11a30d9774b3\",\n\t\t\t\"url\": \"https://apt.repos.neuron.amazonaws.com/pool/main/a/aws-neuronx-collectives/aws-neuronx-collectives_2.22.33.0-d2128d1aa_amd64.deb\",\n\t\t\t\"version\": \"2.22.33.0-d2128d1aa\"\n\t\t}\n\t],\n\t\"version\": 1\n}", + "package_template": "@@rules_distroless~//apt/private:package.BUILD.tmpl" + } + } + }, + "moduleExtensionMetadata": { + "explicitRootModuleDirectDeps": [ + "neuron_bookworm" + ], + "explicitRootModuleDirectDevDeps": [], + "useAllRepos": "NO", + "reproducible": false + }, + "recordedRepoMappingEntries": [ + [ + "rules_distroless~", + "aspect_bazel_lib", + "aspect_bazel_lib~" + ], + [ + "rules_distroless~", + "bazel_tools", + "bazel_tools" + ] + ] + } + }, "@@rules_kotlin~//src/main/starlark/core/repositories:bzlmod_setup.bzl%rules_kotlin_extensions": { "general": { "bzlTransitiveDigest": "mjEpMcNvt8O97wimreF4hDPVsJeMJ5KQ4Mrv+yWl4Ps=", @@ -1287,6 +1504,844 @@ }, "recordedRepoMappingEntries": [] } + }, + "@@rules_rust~//rust/private:internal_extensions.bzl%i": { + "general": { + "bzlTransitiveDigest": "QRpfBOgO39qBaMLcLOuXd7asyMSvVqTSgC5Nz5+5438=", + "usagesDigest": "ojUWpdSJ5FsqV5SiidVYsxzvjzgeQ3EB4HmC6u86fCc=", + "recordedFileInputs": {}, + "recordedDirentsInputs": {}, + "envVariables": {}, + "generatedRepoSpecs": { + "rules_rust_tinyjson": { + "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", + "ruleClassName": "http_archive", + "attributes": { + "sha256": "9ab95735ea2c8fd51154d01e39cf13912a78071c2d89abc49a7ef102a7dd725a", + "url": "https://static.crates.io/crates/tinyjson/tinyjson-2.5.1.crate", + "strip_prefix": "tinyjson-2.5.1", + "type": "tar.gz", + "build_file": "@@rules_rust~//util/process_wrapper:BUILD.tinyjson.bazel" + } + }, + "rrra__aho-corasick-1.0.2": { + "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", + "ruleClassName": "http_archive", + "attributes": { + "sha256": "43f6cb1bf222025340178f382c426f13757b2960e89779dfcb319c32542a5a41", + "type": "tar.gz", + "urls": [ + "https://static.crates.io/crates/aho-corasick/1.0.2/download" + ], + "strip_prefix": "aho-corasick-1.0.2", + "build_file": "@@rules_rust~//tools/rust_analyzer/3rdparty/crates:BUILD.aho-corasick-1.0.2.bazel" + } + }, + "rrra__anstream-0.3.2": { + "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", + "ruleClassName": "http_archive", + "attributes": { + "sha256": "0ca84f3628370c59db74ee214b3263d58f9aadd9b4fe7e711fd87dc452b7f163", + "type": "tar.gz", + "urls": [ + "https://static.crates.io/crates/anstream/0.3.2/download" + ], + "strip_prefix": "anstream-0.3.2", + "build_file": "@@rules_rust~//tools/rust_analyzer/3rdparty/crates:BUILD.anstream-0.3.2.bazel" + } + }, + "rrra__anstyle-1.0.1": { + "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", + "ruleClassName": "http_archive", + "attributes": { + "sha256": "3a30da5c5f2d5e72842e00bcb57657162cdabef0931f40e2deb9b4140440cecd", + "type": "tar.gz", + "urls": [ + "https://static.crates.io/crates/anstyle/1.0.1/download" + ], + "strip_prefix": "anstyle-1.0.1", + "build_file": "@@rules_rust~//tools/rust_analyzer/3rdparty/crates:BUILD.anstyle-1.0.1.bazel" + } + }, + "rrra__anstyle-parse-0.2.1": { + "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", + "ruleClassName": "http_archive", + "attributes": { + "sha256": "938874ff5980b03a87c5524b3ae5b59cf99b1d6bc836848df7bc5ada9643c333", + "type": "tar.gz", + "urls": [ + "https://static.crates.io/crates/anstyle-parse/0.2.1/download" + ], + "strip_prefix": "anstyle-parse-0.2.1", + "build_file": "@@rules_rust~//tools/rust_analyzer/3rdparty/crates:BUILD.anstyle-parse-0.2.1.bazel" + } + }, + "rrra__anstyle-query-1.0.0": { + "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", + "ruleClassName": "http_archive", + "attributes": { + "sha256": "5ca11d4be1bab0c8bc8734a9aa7bf4ee8316d462a08c6ac5052f888fef5b494b", + "type": "tar.gz", + "urls": [ + "https://static.crates.io/crates/anstyle-query/1.0.0/download" + ], + "strip_prefix": "anstyle-query-1.0.0", + "build_file": "@@rules_rust~//tools/rust_analyzer/3rdparty/crates:BUILD.anstyle-query-1.0.0.bazel" + } + }, + "rrra__anstyle-wincon-1.0.1": { + "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", + "ruleClassName": "http_archive", + "attributes": { + "sha256": "180abfa45703aebe0093f79badacc01b8fd4ea2e35118747e5811127f926e188", + "type": "tar.gz", + "urls": [ + "https://static.crates.io/crates/anstyle-wincon/1.0.1/download" + ], + "strip_prefix": "anstyle-wincon-1.0.1", + "build_file": "@@rules_rust~//tools/rust_analyzer/3rdparty/crates:BUILD.anstyle-wincon-1.0.1.bazel" + } + }, + "rrra__anyhow-1.0.71": { + "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", + "ruleClassName": "http_archive", + "attributes": { + "sha256": "9c7d0618f0e0b7e8ff11427422b64564d5fb0be1940354bfe2e0529b18a9d9b8", + "type": "tar.gz", + "urls": [ + "https://static.crates.io/crates/anyhow/1.0.71/download" + ], + "strip_prefix": "anyhow-1.0.71", + "build_file": "@@rules_rust~//tools/rust_analyzer/3rdparty/crates:BUILD.anyhow-1.0.71.bazel" + } + }, + "rrra__bitflags-1.3.2": { + "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", + "ruleClassName": "http_archive", + "attributes": { + "sha256": "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a", + "type": "tar.gz", + "urls": [ + "https://static.crates.io/crates/bitflags/1.3.2/download" + ], + "strip_prefix": "bitflags-1.3.2", + "build_file": "@@rules_rust~//tools/rust_analyzer/3rdparty/crates:BUILD.bitflags-1.3.2.bazel" + } + }, + "rrra__cc-1.0.79": { + "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", + "ruleClassName": "http_archive", + "attributes": { + "sha256": "50d30906286121d95be3d479533b458f87493b30a4b5f79a607db8f5d11aa91f", + "type": "tar.gz", + "urls": [ + "https://static.crates.io/crates/cc/1.0.79/download" + ], + "strip_prefix": "cc-1.0.79", + "build_file": "@@rules_rust~//tools/rust_analyzer/3rdparty/crates:BUILD.cc-1.0.79.bazel" + } + }, + "rrra__clap-4.3.11": { + "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", + "ruleClassName": "http_archive", + "attributes": { + "sha256": "1640e5cc7fb47dbb8338fd471b105e7ed6c3cb2aeb00c2e067127ffd3764a05d", + "type": "tar.gz", + "urls": [ + "https://static.crates.io/crates/clap/4.3.11/download" + ], + "strip_prefix": "clap-4.3.11", + "build_file": "@@rules_rust~//tools/rust_analyzer/3rdparty/crates:BUILD.clap-4.3.11.bazel" + } + }, + "rrra__clap_builder-4.3.11": { + "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", + "ruleClassName": "http_archive", + "attributes": { + "sha256": "98c59138d527eeaf9b53f35a77fcc1fad9d883116070c63d5de1c7dc7b00c72b", + "type": "tar.gz", + "urls": [ + "https://static.crates.io/crates/clap_builder/4.3.11/download" + ], + "strip_prefix": "clap_builder-4.3.11", + "build_file": "@@rules_rust~//tools/rust_analyzer/3rdparty/crates:BUILD.clap_builder-4.3.11.bazel" + } + }, + "rrra__clap_derive-4.3.2": { + "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", + "ruleClassName": "http_archive", + "attributes": { + "sha256": "b8cd2b2a819ad6eec39e8f1d6b53001af1e5469f8c177579cdaeb313115b825f", + "type": "tar.gz", + "urls": [ + "https://static.crates.io/crates/clap_derive/4.3.2/download" + ], + "strip_prefix": "clap_derive-4.3.2", + "build_file": "@@rules_rust~//tools/rust_analyzer/3rdparty/crates:BUILD.clap_derive-4.3.2.bazel" + } + }, + "rrra__clap_lex-0.5.0": { + "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", + "ruleClassName": "http_archive", + "attributes": { + "sha256": "2da6da31387c7e4ef160ffab6d5e7f00c42626fe39aea70a7b0f1773f7dd6c1b", + "type": "tar.gz", + "urls": [ + "https://static.crates.io/crates/clap_lex/0.5.0/download" + ], + "strip_prefix": "clap_lex-0.5.0", + "build_file": "@@rules_rust~//tools/rust_analyzer/3rdparty/crates:BUILD.clap_lex-0.5.0.bazel" + } + }, + "rrra__colorchoice-1.0.0": { + "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", + "ruleClassName": "http_archive", + "attributes": { + "sha256": "acbf1af155f9b9ef647e42cdc158db4b64a1b61f743629225fde6f3e0be2a7c7", + "type": "tar.gz", + "urls": [ + "https://static.crates.io/crates/colorchoice/1.0.0/download" + ], + "strip_prefix": "colorchoice-1.0.0", + "build_file": "@@rules_rust~//tools/rust_analyzer/3rdparty/crates:BUILD.colorchoice-1.0.0.bazel" + } + }, + "rrra__either-1.8.1": { + "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", + "ruleClassName": "http_archive", + "attributes": { + "sha256": "7fcaabb2fef8c910e7f4c7ce9f67a1283a1715879a7c230ca9d6d1ae31f16d91", + "type": "tar.gz", + "urls": [ + "https://static.crates.io/crates/either/1.8.1/download" + ], + "strip_prefix": "either-1.8.1", + "build_file": "@@rules_rust~//tools/rust_analyzer/3rdparty/crates:BUILD.either-1.8.1.bazel" + } + }, + "rrra__env_logger-0.10.0": { + "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", + "ruleClassName": "http_archive", + "attributes": { + "sha256": "85cdab6a89accf66733ad5a1693a4dcced6aeff64602b634530dd73c1f3ee9f0", + "type": "tar.gz", + "urls": [ + "https://static.crates.io/crates/env_logger/0.10.0/download" + ], + "strip_prefix": "env_logger-0.10.0", + "build_file": "@@rules_rust~//tools/rust_analyzer/3rdparty/crates:BUILD.env_logger-0.10.0.bazel" + } + }, + "rrra__errno-0.3.1": { + "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", + "ruleClassName": "http_archive", + "attributes": { + "sha256": "4bcfec3a70f97c962c307b2d2c56e358cf1d00b558d74262b5f929ee8cc7e73a", + "type": "tar.gz", + "urls": [ + "https://static.crates.io/crates/errno/0.3.1/download" + ], + "strip_prefix": "errno-0.3.1", + "build_file": "@@rules_rust~//tools/rust_analyzer/3rdparty/crates:BUILD.errno-0.3.1.bazel" + } + }, + "rrra__errno-dragonfly-0.1.2": { + "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", + "ruleClassName": "http_archive", + "attributes": { + "sha256": "aa68f1b12764fab894d2755d2518754e71b4fd80ecfb822714a1206c2aab39bf", + "type": "tar.gz", + "urls": [ + "https://static.crates.io/crates/errno-dragonfly/0.1.2/download" + ], + "strip_prefix": "errno-dragonfly-0.1.2", + "build_file": "@@rules_rust~//tools/rust_analyzer/3rdparty/crates:BUILD.errno-dragonfly-0.1.2.bazel" + } + }, + "rrra__heck-0.4.1": { + "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", + "ruleClassName": "http_archive", + "attributes": { + "sha256": "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8", + "type": "tar.gz", + "urls": [ + "https://static.crates.io/crates/heck/0.4.1/download" + ], + "strip_prefix": "heck-0.4.1", + "build_file": "@@rules_rust~//tools/rust_analyzer/3rdparty/crates:BUILD.heck-0.4.1.bazel" + } + }, + "rrra__hermit-abi-0.3.2": { + "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", + "ruleClassName": "http_archive", + "attributes": { + "sha256": "443144c8cdadd93ebf52ddb4056d257f5b52c04d3c804e657d19eb73fc33668b", + "type": "tar.gz", + "urls": [ + "https://static.crates.io/crates/hermit-abi/0.3.2/download" + ], + "strip_prefix": "hermit-abi-0.3.2", + "build_file": "@@rules_rust~//tools/rust_analyzer/3rdparty/crates:BUILD.hermit-abi-0.3.2.bazel" + } + }, + "rrra__humantime-2.1.0": { + "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", + "ruleClassName": "http_archive", + "attributes": { + "sha256": "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4", + "type": "tar.gz", + "urls": [ + "https://static.crates.io/crates/humantime/2.1.0/download" + ], + "strip_prefix": "humantime-2.1.0", + "build_file": "@@rules_rust~//tools/rust_analyzer/3rdparty/crates:BUILD.humantime-2.1.0.bazel" + } + }, + "rrra__io-lifetimes-1.0.11": { + "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", + "ruleClassName": "http_archive", + "attributes": { + "sha256": "eae7b9aee968036d54dce06cebaefd919e4472e753296daccd6d344e3e2df0c2", + "type": "tar.gz", + "urls": [ + "https://static.crates.io/crates/io-lifetimes/1.0.11/download" + ], + "strip_prefix": "io-lifetimes-1.0.11", + "build_file": "@@rules_rust~//tools/rust_analyzer/3rdparty/crates:BUILD.io-lifetimes-1.0.11.bazel" + } + }, + "rrra__is-terminal-0.4.7": { + "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", + "ruleClassName": "http_archive", + "attributes": { + "sha256": "adcf93614601c8129ddf72e2d5633df827ba6551541c6d8c59520a371475be1f", + "type": "tar.gz", + "urls": [ + "https://static.crates.io/crates/is-terminal/0.4.7/download" + ], + "strip_prefix": "is-terminal-0.4.7", + "build_file": "@@rules_rust~//tools/rust_analyzer/3rdparty/crates:BUILD.is-terminal-0.4.7.bazel" + } + }, + "rrra__itertools-0.11.0": { + "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", + "ruleClassName": "http_archive", + "attributes": { + "sha256": "b1c173a5686ce8bfa551b3563d0c2170bf24ca44da99c7ca4bfdab5418c3fe57", + "type": "tar.gz", + "urls": [ + "https://static.crates.io/crates/itertools/0.11.0/download" + ], + "strip_prefix": "itertools-0.11.0", + "build_file": "@@rules_rust~//tools/rust_analyzer/3rdparty/crates:BUILD.itertools-0.11.0.bazel" + } + }, + "rrra__itoa-1.0.8": { + "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", + "ruleClassName": "http_archive", + "attributes": { + "sha256": "62b02a5381cc465bd3041d84623d0fa3b66738b52b8e2fc3bab8ad63ab032f4a", + "type": "tar.gz", + "urls": [ + "https://static.crates.io/crates/itoa/1.0.8/download" + ], + "strip_prefix": "itoa-1.0.8", + "build_file": "@@rules_rust~//tools/rust_analyzer/3rdparty/crates:BUILD.itoa-1.0.8.bazel" + } + }, + "rrra__libc-0.2.147": { + "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", + "ruleClassName": "http_archive", + "attributes": { + "sha256": "b4668fb0ea861c1df094127ac5f1da3409a82116a4ba74fca2e58ef927159bb3", + "type": "tar.gz", + "urls": [ + "https://static.crates.io/crates/libc/0.2.147/download" + ], + "strip_prefix": "libc-0.2.147", + "build_file": "@@rules_rust~//tools/rust_analyzer/3rdparty/crates:BUILD.libc-0.2.147.bazel" + } + }, + "rrra__linux-raw-sys-0.3.8": { + "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", + "ruleClassName": "http_archive", + "attributes": { + "sha256": "ef53942eb7bf7ff43a617b3e2c1c4a5ecf5944a7c1bc12d7ee39bbb15e5c1519", + "type": "tar.gz", + "urls": [ + "https://static.crates.io/crates/linux-raw-sys/0.3.8/download" + ], + "strip_prefix": "linux-raw-sys-0.3.8", + "build_file": "@@rules_rust~//tools/rust_analyzer/3rdparty/crates:BUILD.linux-raw-sys-0.3.8.bazel" + } + }, + "rrra__log-0.4.19": { + "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", + "ruleClassName": "http_archive", + "attributes": { + "sha256": "b06a4cde4c0f271a446782e3eff8de789548ce57dbc8eca9292c27f4a42004b4", + "type": "tar.gz", + "urls": [ + "https://static.crates.io/crates/log/0.4.19/download" + ], + "strip_prefix": "log-0.4.19", + "build_file": "@@rules_rust~//tools/rust_analyzer/3rdparty/crates:BUILD.log-0.4.19.bazel" + } + }, + "rrra__memchr-2.5.0": { + "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", + "ruleClassName": "http_archive", + "attributes": { + "sha256": "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d", + "type": "tar.gz", + "urls": [ + "https://static.crates.io/crates/memchr/2.5.0/download" + ], + "strip_prefix": "memchr-2.5.0", + "build_file": "@@rules_rust~//tools/rust_analyzer/3rdparty/crates:BUILD.memchr-2.5.0.bazel" + } + }, + "rrra__once_cell-1.18.0": { + "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", + "ruleClassName": "http_archive", + "attributes": { + "sha256": "dd8b5dd2ae5ed71462c540258bedcb51965123ad7e7ccf4b9a8cafaa4a63576d", + "type": "tar.gz", + "urls": [ + "https://static.crates.io/crates/once_cell/1.18.0/download" + ], + "strip_prefix": "once_cell-1.18.0", + "build_file": "@@rules_rust~//tools/rust_analyzer/3rdparty/crates:BUILD.once_cell-1.18.0.bazel" + } + }, + "rrra__proc-macro2-1.0.64": { + "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", + "ruleClassName": "http_archive", + "attributes": { + "sha256": "78803b62cbf1f46fde80d7c0e803111524b9877184cfe7c3033659490ac7a7da", + "type": "tar.gz", + "urls": [ + "https://static.crates.io/crates/proc-macro2/1.0.64/download" + ], + "strip_prefix": "proc-macro2-1.0.64", + "build_file": "@@rules_rust~//tools/rust_analyzer/3rdparty/crates:BUILD.proc-macro2-1.0.64.bazel" + } + }, + "rrra__quote-1.0.29": { + "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", + "ruleClassName": "http_archive", + "attributes": { + "sha256": "573015e8ab27661678357f27dc26460738fd2b6c86e46f386fde94cb5d913105", + "type": "tar.gz", + "urls": [ + "https://static.crates.io/crates/quote/1.0.29/download" + ], + "strip_prefix": "quote-1.0.29", + "build_file": "@@rules_rust~//tools/rust_analyzer/3rdparty/crates:BUILD.quote-1.0.29.bazel" + } + }, + "rrra__regex-1.9.1": { + "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", + "ruleClassName": "http_archive", + "attributes": { + "sha256": "b2eae68fc220f7cf2532e4494aded17545fce192d59cd996e0fe7887f4ceb575", + "type": "tar.gz", + "urls": [ + "https://static.crates.io/crates/regex/1.9.1/download" + ], + "strip_prefix": "regex-1.9.1", + "build_file": "@@rules_rust~//tools/rust_analyzer/3rdparty/crates:BUILD.regex-1.9.1.bazel" + } + }, + "rrra__regex-automata-0.3.3": { + "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", + "ruleClassName": "http_archive", + "attributes": { + "sha256": "39354c10dd07468c2e73926b23bb9c2caca74c5501e38a35da70406f1d923310", + "type": "tar.gz", + "urls": [ + "https://static.crates.io/crates/regex-automata/0.3.3/download" + ], + "strip_prefix": "regex-automata-0.3.3", + "build_file": "@@rules_rust~//tools/rust_analyzer/3rdparty/crates:BUILD.regex-automata-0.3.3.bazel" + } + }, + "rrra__regex-syntax-0.7.4": { + "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", + "ruleClassName": "http_archive", + "attributes": { + "sha256": "e5ea92a5b6195c6ef2a0295ea818b312502c6fc94dde986c5553242e18fd4ce2", + "type": "tar.gz", + "urls": [ + "https://static.crates.io/crates/regex-syntax/0.7.4/download" + ], + "strip_prefix": "regex-syntax-0.7.4", + "build_file": "@@rules_rust~//tools/rust_analyzer/3rdparty/crates:BUILD.regex-syntax-0.7.4.bazel" + } + }, + "rrra__rustix-0.37.23": { + "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", + "ruleClassName": "http_archive", + "attributes": { + "sha256": "4d69718bf81c6127a49dc64e44a742e8bb9213c0ff8869a22c308f84c1d4ab06", + "type": "tar.gz", + "urls": [ + "https://static.crates.io/crates/rustix/0.37.23/download" + ], + "strip_prefix": "rustix-0.37.23", + "build_file": "@@rules_rust~//tools/rust_analyzer/3rdparty/crates:BUILD.rustix-0.37.23.bazel" + } + }, + "rrra__ryu-1.0.14": { + "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", + "ruleClassName": "http_archive", + "attributes": { + "sha256": "fe232bdf6be8c8de797b22184ee71118d63780ea42ac85b61d1baa6d3b782ae9", + "type": "tar.gz", + "urls": [ + "https://static.crates.io/crates/ryu/1.0.14/download" + ], + "strip_prefix": "ryu-1.0.14", + "build_file": "@@rules_rust~//tools/rust_analyzer/3rdparty/crates:BUILD.ryu-1.0.14.bazel" + } + }, + "rrra__serde-1.0.171": { + "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", + "ruleClassName": "http_archive", + "attributes": { + "sha256": "30e27d1e4fd7659406c492fd6cfaf2066ba8773de45ca75e855590f856dc34a9", + "type": "tar.gz", + "urls": [ + "https://static.crates.io/crates/serde/1.0.171/download" + ], + "strip_prefix": "serde-1.0.171", + "build_file": "@@rules_rust~//tools/rust_analyzer/3rdparty/crates:BUILD.serde-1.0.171.bazel" + } + }, + "rrra__serde_derive-1.0.171": { + "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", + "ruleClassName": "http_archive", + "attributes": { + "sha256": "389894603bd18c46fa56231694f8d827779c0951a667087194cf9de94ed24682", + "type": "tar.gz", + "urls": [ + "https://static.crates.io/crates/serde_derive/1.0.171/download" + ], + "strip_prefix": "serde_derive-1.0.171", + "build_file": "@@rules_rust~//tools/rust_analyzer/3rdparty/crates:BUILD.serde_derive-1.0.171.bazel" + } + }, + "rrra__serde_json-1.0.102": { + "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", + "ruleClassName": "http_archive", + "attributes": { + "sha256": "b5062a995d481b2308b6064e9af76011f2921c35f97b0468811ed9f6cd91dfed", + "type": "tar.gz", + "urls": [ + "https://static.crates.io/crates/serde_json/1.0.102/download" + ], + "strip_prefix": "serde_json-1.0.102", + "build_file": "@@rules_rust~//tools/rust_analyzer/3rdparty/crates:BUILD.serde_json-1.0.102.bazel" + } + }, + "rrra__strsim-0.10.0": { + "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", + "ruleClassName": "http_archive", + "attributes": { + "sha256": "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623", + "type": "tar.gz", + "urls": [ + "https://static.crates.io/crates/strsim/0.10.0/download" + ], + "strip_prefix": "strsim-0.10.0", + "build_file": "@@rules_rust~//tools/rust_analyzer/3rdparty/crates:BUILD.strsim-0.10.0.bazel" + } + }, + "rrra__syn-2.0.25": { + "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", + "ruleClassName": "http_archive", + "attributes": { + "sha256": "15e3fc8c0c74267e2df136e5e5fb656a464158aa57624053375eb9c8c6e25ae2", + "type": "tar.gz", + "urls": [ + "https://static.crates.io/crates/syn/2.0.25/download" + ], + "strip_prefix": "syn-2.0.25", + "build_file": "@@rules_rust~//tools/rust_analyzer/3rdparty/crates:BUILD.syn-2.0.25.bazel" + } + }, + "rrra__termcolor-1.2.0": { + "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", + "ruleClassName": "http_archive", + "attributes": { + "sha256": "be55cf8942feac5c765c2c993422806843c9a9a45d4d5c407ad6dd2ea95eb9b6", + "type": "tar.gz", + "urls": [ + "https://static.crates.io/crates/termcolor/1.2.0/download" + ], + "strip_prefix": "termcolor-1.2.0", + "build_file": "@@rules_rust~//tools/rust_analyzer/3rdparty/crates:BUILD.termcolor-1.2.0.bazel" + } + }, + "rrra__unicode-ident-1.0.10": { + "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", + "ruleClassName": "http_archive", + "attributes": { + "sha256": "22049a19f4a68748a168c0fc439f9516686aa045927ff767eca0a85101fb6e73", + "type": "tar.gz", + "urls": [ + "https://static.crates.io/crates/unicode-ident/1.0.10/download" + ], + "strip_prefix": "unicode-ident-1.0.10", + "build_file": "@@rules_rust~//tools/rust_analyzer/3rdparty/crates:BUILD.unicode-ident-1.0.10.bazel" + } + }, + "rrra__utf8parse-0.2.1": { + "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", + "ruleClassName": "http_archive", + "attributes": { + "sha256": "711b9620af191e0cdc7468a8d14e709c3dcdb115b36f838e601583af800a370a", + "type": "tar.gz", + "urls": [ + "https://static.crates.io/crates/utf8parse/0.2.1/download" + ], + "strip_prefix": "utf8parse-0.2.1", + "build_file": "@@rules_rust~//tools/rust_analyzer/3rdparty/crates:BUILD.utf8parse-0.2.1.bazel" + } + }, + "rrra__winapi-0.3.9": { + "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", + "ruleClassName": "http_archive", + "attributes": { + "sha256": "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419", + "type": "tar.gz", + "urls": [ + "https://static.crates.io/crates/winapi/0.3.9/download" + ], + "strip_prefix": "winapi-0.3.9", + "build_file": "@@rules_rust~//tools/rust_analyzer/3rdparty/crates:BUILD.winapi-0.3.9.bazel" + } + }, + "rrra__winapi-i686-pc-windows-gnu-0.4.0": { + "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", + "ruleClassName": "http_archive", + "attributes": { + "sha256": "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6", + "type": "tar.gz", + "urls": [ + "https://static.crates.io/crates/winapi-i686-pc-windows-gnu/0.4.0/download" + ], + "strip_prefix": "winapi-i686-pc-windows-gnu-0.4.0", + "build_file": "@@rules_rust~//tools/rust_analyzer/3rdparty/crates:BUILD.winapi-i686-pc-windows-gnu-0.4.0.bazel" + } + }, + "rrra__winapi-util-0.1.5": { + "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", + "ruleClassName": "http_archive", + "attributes": { + "sha256": "70ec6ce85bb158151cae5e5c87f95a8e97d2c0c4b001223f33a334e3ce5de178", + "type": "tar.gz", + "urls": [ + "https://static.crates.io/crates/winapi-util/0.1.5/download" + ], + "strip_prefix": "winapi-util-0.1.5", + "build_file": "@@rules_rust~//tools/rust_analyzer/3rdparty/crates:BUILD.winapi-util-0.1.5.bazel" + } + }, + "rrra__winapi-x86_64-pc-windows-gnu-0.4.0": { + "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", + "ruleClassName": "http_archive", + "attributes": { + "sha256": "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f", + "type": "tar.gz", + "urls": [ + "https://static.crates.io/crates/winapi-x86_64-pc-windows-gnu/0.4.0/download" + ], + "strip_prefix": "winapi-x86_64-pc-windows-gnu-0.4.0", + "build_file": "@@rules_rust~//tools/rust_analyzer/3rdparty/crates:BUILD.winapi-x86_64-pc-windows-gnu-0.4.0.bazel" + } + }, + "rrra__windows-sys-0.48.0": { + "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", + "ruleClassName": "http_archive", + "attributes": { + "sha256": "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9", + "type": "tar.gz", + "urls": [ + "https://static.crates.io/crates/windows-sys/0.48.0/download" + ], + "strip_prefix": "windows-sys-0.48.0", + "build_file": "@@rules_rust~//tools/rust_analyzer/3rdparty/crates:BUILD.windows-sys-0.48.0.bazel" + } + }, + "rrra__windows-targets-0.48.1": { + "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", + "ruleClassName": "http_archive", + "attributes": { + "sha256": "05d4b17490f70499f20b9e791dcf6a299785ce8af4d709018206dc5b4953e95f", + "type": "tar.gz", + "urls": [ + "https://static.crates.io/crates/windows-targets/0.48.1/download" + ], + "strip_prefix": "windows-targets-0.48.1", + "build_file": "@@rules_rust~//tools/rust_analyzer/3rdparty/crates:BUILD.windows-targets-0.48.1.bazel" + } + }, + "rrra__windows_aarch64_gnullvm-0.48.0": { + "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", + "ruleClassName": "http_archive", + "attributes": { + "sha256": "91ae572e1b79dba883e0d315474df7305d12f569b400fcf90581b06062f7e1bc", + "type": "tar.gz", + "urls": [ + "https://static.crates.io/crates/windows_aarch64_gnullvm/0.48.0/download" + ], + "strip_prefix": "windows_aarch64_gnullvm-0.48.0", + "build_file": "@@rules_rust~//tools/rust_analyzer/3rdparty/crates:BUILD.windows_aarch64_gnullvm-0.48.0.bazel" + } + }, + "rrra__windows_aarch64_msvc-0.48.0": { + "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", + "ruleClassName": "http_archive", + "attributes": { + "sha256": "b2ef27e0d7bdfcfc7b868b317c1d32c641a6fe4629c171b8928c7b08d98d7cf3", + "type": "tar.gz", + "urls": [ + "https://static.crates.io/crates/windows_aarch64_msvc/0.48.0/download" + ], + "strip_prefix": "windows_aarch64_msvc-0.48.0", + "build_file": "@@rules_rust~//tools/rust_analyzer/3rdparty/crates:BUILD.windows_aarch64_msvc-0.48.0.bazel" + } + }, + "rrra__windows_i686_gnu-0.48.0": { + "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", + "ruleClassName": "http_archive", + "attributes": { + "sha256": "622a1962a7db830d6fd0a69683c80a18fda201879f0f447f065a3b7467daa241", + "type": "tar.gz", + "urls": [ + "https://static.crates.io/crates/windows_i686_gnu/0.48.0/download" + ], + "strip_prefix": "windows_i686_gnu-0.48.0", + "build_file": "@@rules_rust~//tools/rust_analyzer/3rdparty/crates:BUILD.windows_i686_gnu-0.48.0.bazel" + } + }, + "rrra__windows_i686_msvc-0.48.0": { + "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", + "ruleClassName": "http_archive", + "attributes": { + "sha256": "4542c6e364ce21bf45d69fdd2a8e455fa38d316158cfd43b3ac1c5b1b19f8e00", + "type": "tar.gz", + "urls": [ + "https://static.crates.io/crates/windows_i686_msvc/0.48.0/download" + ], + "strip_prefix": "windows_i686_msvc-0.48.0", + "build_file": "@@rules_rust~//tools/rust_analyzer/3rdparty/crates:BUILD.windows_i686_msvc-0.48.0.bazel" + } + }, + "rrra__windows_x86_64_gnu-0.48.0": { + "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", + "ruleClassName": "http_archive", + "attributes": { + "sha256": "ca2b8a661f7628cbd23440e50b05d705db3686f894fc9580820623656af974b1", + "type": "tar.gz", + "urls": [ + "https://static.crates.io/crates/windows_x86_64_gnu/0.48.0/download" + ], + "strip_prefix": "windows_x86_64_gnu-0.48.0", + "build_file": "@@rules_rust~//tools/rust_analyzer/3rdparty/crates:BUILD.windows_x86_64_gnu-0.48.0.bazel" + } + }, + "rrra__windows_x86_64_gnullvm-0.48.0": { + "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", + "ruleClassName": "http_archive", + "attributes": { + "sha256": "7896dbc1f41e08872e9d5e8f8baa8fdd2677f29468c4e156210174edc7f7b953", + "type": "tar.gz", + "urls": [ + "https://static.crates.io/crates/windows_x86_64_gnullvm/0.48.0/download" + ], + "strip_prefix": "windows_x86_64_gnullvm-0.48.0", + "build_file": "@@rules_rust~//tools/rust_analyzer/3rdparty/crates:BUILD.windows_x86_64_gnullvm-0.48.0.bazel" + } + }, + "rrra__windows_x86_64_msvc-0.48.0": { + "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", + "ruleClassName": "http_archive", + "attributes": { + "sha256": "1a515f5799fe4961cb532f983ce2b23082366b898e52ffbce459c86f67c8378a", + "type": "tar.gz", + "urls": [ + "https://static.crates.io/crates/windows_x86_64_msvc/0.48.0/download" + ], + "strip_prefix": "windows_x86_64_msvc-0.48.0", + "build_file": "@@rules_rust~//tools/rust_analyzer/3rdparty/crates:BUILD.windows_x86_64_msvc-0.48.0.bazel" + } + } + }, + "moduleExtensionMetadata": { + "explicitRootModuleDirectDeps": [ + "rules_rust_tinyjson", + "rrra__anyhow-1.0.71", + "rrra__clap-4.3.11", + "rrra__env_logger-0.10.0", + "rrra__itertools-0.11.0", + "rrra__log-0.4.19", + "rrra__serde-1.0.171", + "rrra__serde_json-1.0.102" + ], + "explicitRootModuleDirectDevDeps": [], + "useAllRepos": "NO", + "reproducible": false + }, + "recordedRepoMappingEntries": [ + [ + "rules_rust~", + "bazel_skylib", + "bazel_skylib~" + ], + [ + "rules_rust~", + "bazel_tools", + "bazel_tools" + ], + [ + "rules_rust~", + "rrra__anyhow-1.0.71", + "rules_rust~~i~rrra__anyhow-1.0.71" + ], + [ + "rules_rust~", + "rrra__clap-4.3.11", + "rules_rust~~i~rrra__clap-4.3.11" + ], + [ + "rules_rust~", + "rrra__env_logger-0.10.0", + "rules_rust~~i~rrra__env_logger-0.10.0" + ], + [ + "rules_rust~", + "rrra__itertools-0.11.0", + "rules_rust~~i~rrra__itertools-0.11.0" + ], + [ + "rules_rust~", + "rrra__log-0.4.19", + "rules_rust~~i~rrra__log-0.4.19" + ], + [ + "rules_rust~", + "rrra__serde-1.0.171", + "rules_rust~~i~rrra__serde-1.0.171" + ], + [ + "rules_rust~", + "rrra__serde_json-1.0.102", + "rules_rust~~i~rrra__serde_json-1.0.102" + ] + ] + } } } } diff --git a/zml/tokenizer/hf_tokenizers/BUILD.bazel b/zml/tokenizer/hf_tokenizers/BUILD.bazel index e69de29b..51e426bb 100644 --- a/zml/tokenizer/hf_tokenizers/BUILD.bazel +++ b/zml/tokenizer/hf_tokenizers/BUILD.bazel @@ -0,0 +1,28 @@ +load("@rules_rust//rust:defs.bzl", "rust_static_library") +load("@zml//bazel:zig.bzl", "zig_cc_binary") + +rust_static_library( + name = "hf_tokenizers_rs", + srcs = ["src/lib.rs"], + crate_name = "zml_hf_tokenizers", + edition = "2021", + deps = [ + "@crates//:tokenizers", + ], +) + +cc_library( + name = "hf_tokenizers", + hdrs = ["hf_tokenizers.h"], + visibility = ["//visibility:public"], + deps = [ + ":hf_tokenizers_rs", + ], +) + +zig_cc_binary( + name = "main", + main = "main.zig", + visibility = ["//visibility:public"], + deps = [":hf_tokenizers"], +) diff --git a/zml/tokenizer/hf_tokenizers/Cargo.lock b/zml/tokenizer/hf_tokenizers/Cargo.lock new file mode 100644 index 00000000..e9b3047c --- /dev/null +++ b/zml/tokenizer/hf_tokenizers/Cargo.lock @@ -0,0 +1,827 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 4 + +[[package]] +name = "aho-corasick" +version = "1.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e60d3430d3a69478ad0993f19238d2df97c507009a52b3c10addcd7f6bcb916" +dependencies = [ + "memchr", +] + +[[package]] +name = "base64" +version = "0.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9e1b586273c5702936fe7b7d6896644d8be71e6314cfe09d3167c95f712589e8" + +[[package]] +name = "bitflags" +version = "1.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" + +[[package]] +name = "bumpalo" +version = "3.16.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "79296716171880943b8470b5f8d03aa55eb2e645a4874bdbb28adb49162e012c" + +[[package]] +name = "byteorder" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" + +[[package]] +name = "cc" +version = "1.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c31a0499c1dc64f458ad13872de75c0eb7e3fdb0e67964610c914b034fc5956e" +dependencies = [ + "shlex", +] + +[[package]] +name = "cfg-if" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" + +[[package]] +name = "console" +version = "0.15.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ea3c6ecd8059b57859df5c69830340ed3c41d30e3da0c1cbed90a96ac853041b" +dependencies = [ + "encode_unicode", + "libc", + "once_cell", + "unicode-width", + "windows-sys", +] + +[[package]] +name = "crossbeam-deque" +version = "0.8.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9dd111b7b7f7d55b72c0a6ae361660ee5853c9af73f70c3c2ef6858b950e2e51" +dependencies = [ + "crossbeam-epoch", + "crossbeam-utils", +] + +[[package]] +name = "crossbeam-epoch" +version = "0.9.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5b82ac4a3c2ca9c3460964f020e1402edd5753411d7737aa39c3714ad1b5420e" +dependencies = [ + "crossbeam-utils", +] + +[[package]] +name = "crossbeam-utils" +version = "0.8.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d0a5c400df2834b80a4c3327b3aad3a4c4cd4de0629063962b03235697506a28" + +[[package]] +name = "darling" +version = "0.20.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6f63b86c8a8826a49b8c21f08a2d07338eec8d900540f8630dc76284be802989" +dependencies = [ + "darling_core", + "darling_macro", +] + +[[package]] +name = "darling_core" +version = "0.20.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "95133861a8032aaea082871032f5815eb9e98cef03fa916ab4500513994df9e5" +dependencies = [ + "fnv", + "ident_case", + "proc-macro2", + "quote", + "strsim", + "syn", +] + +[[package]] +name = "darling_macro" +version = "0.20.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d336a2a514f6ccccaa3e09b02d41d35330c07ddf03a62165fcec10bb561c7806" +dependencies = [ + "darling_core", + "quote", + "syn", +] + +[[package]] +name = "derive_builder" +version = "0.20.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "507dfb09ea8b7fa618fcf76e953f4f5e192547945816d5358edffe39f6f94947" +dependencies = [ + "derive_builder_macro", +] + +[[package]] +name = "derive_builder_core" +version = "0.20.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2d5bcf7b024d6835cfb3d473887cd966994907effbe9227e8c8219824d06c4e8" +dependencies = [ + "darling", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "derive_builder_macro" +version = "0.20.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ab63b0e2bf4d5928aff72e83a7dace85d7bba5fe12dcc3c5a572d78caffd3f3c" +dependencies = [ + "derive_builder_core", + "syn", +] + +[[package]] +name = "either" +version = "1.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "60b1af1c220855b6ceac025d3f6ecdd2b7c4894bfe9cd9bda4fbb4bc7c0d4cf0" + +[[package]] +name = "encode_unicode" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "34aa73646ffb006b8f5147f3dc182bd4bcb190227ce861fc4a4844bf8e3cb2c0" + +[[package]] +name = "esaxx-rs" +version = "0.1.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d817e038c30374a4bcb22f94d0a8a0e216958d4c3dcde369b1439fec4bdda6e6" +dependencies = [ + "cc", +] + +[[package]] +name = "fnv" +version = "1.0.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" + +[[package]] +name = "getrandom" +version = "0.2.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c4567c8db10ae91089c99af84c68c38da3ec2f087c3f82960bcdbf3656b6f4d7" +dependencies = [ + "cfg-if", + "libc", + "wasi", +] + +[[package]] +name = "hf_tokenizers" +version = "0.1.0" +dependencies = [ + "tokenizers", +] + +[[package]] +name = "ident_case" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39" + +[[package]] +name = "indicatif" +version = "0.17.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cbf675b85ed934d3c67b5c5469701eec7db22689d0a2139d856e0925fa28b281" +dependencies = [ + "console", + "number_prefix", + "portable-atomic", + "unicode-width", + "web-time", +] + +[[package]] +name = "itertools" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b1c173a5686ce8bfa551b3563d0c2170bf24ca44da99c7ca4bfdab5418c3fe57" +dependencies = [ + "either", +] + +[[package]] +name = "itertools" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ba291022dbbd398a455acf126c1e341954079855bc60dfdda641363bd6922569" +dependencies = [ + "either", +] + +[[package]] +name = "itoa" +version = "1.0.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d75a2a4b1b190afb6f5425f10f6a8f959d2ea0b9c2b1d79553551850539e4674" + +[[package]] +name = "js-sys" +version = "0.3.76" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6717b6b5b077764fb5966237269cb3c64edddde4b14ce42647430a78ced9e7b7" +dependencies = [ + "once_cell", + "wasm-bindgen", +] + +[[package]] +name = "lazy_static" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" + +[[package]] +name = "libc" +version = "0.2.169" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b5aba8db14291edd000dfcc4d620c7ebfb122c613afb886ca8803fa4e128a20a" + +[[package]] +name = "log" +version = "0.4.22" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a7a70ba024b9dc04c27ea2f0c0548feb474ec5c54bba33a7f72f873a39d07b24" + +[[package]] +name = "macro_rules_attribute" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8a82271f7bc033d84bbca59a3ce3e4159938cb08a9c3aebbe54d215131518a13" +dependencies = [ + "macro_rules_attribute-proc_macro", + "paste", +] + +[[package]] +name = "macro_rules_attribute-proc_macro" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b8dd856d451cc0da70e2ef2ce95a18e39a93b7558bedf10201ad28503f918568" + +[[package]] +name = "memchr" +version = "2.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3" + +[[package]] +name = "minimal-lexical" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a" + +[[package]] +name = "monostate" +version = "0.1.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0d208407d7552cd041d8cdb69a1bc3303e029c598738177a3d87082004dc0e1e" +dependencies = [ + "monostate-impl", + "serde", +] + +[[package]] +name = "monostate-impl" +version = "0.1.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a7ce64b975ed4f123575d11afd9491f2e37bbd5813fbfbc0f09ae1fbddea74e0" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "nom" +version = "7.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d273983c5a657a70a3e8f2a01329822f3b8c8172b73826411a55751e404a0a4a" +dependencies = [ + "memchr", + "minimal-lexical", +] + +[[package]] +name = "number_prefix" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "830b246a0e5f20af87141b25c173cd1b609bd7779a4617d6ec582abaf90870f3" + +[[package]] +name = "once_cell" +version = "1.20.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1261fe7e33c73b354eab43b1273a57c8f967d0391e80353e51f764ac02cf6775" + +[[package]] +name = "onig" +version = "6.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8c4b31c8722ad9171c6d77d3557db078cab2bd50afcc9d09c8b315c59df8ca4f" +dependencies = [ + "bitflags", + "libc", + "once_cell", + "onig_sys", +] + +[[package]] +name = "onig_sys" +version = "69.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7b829e3d7e9cc74c7e315ee8edb185bf4190da5acde74afd7fc59c35b1f086e7" +dependencies = [ + "cc", + "pkg-config", +] + +[[package]] +name = "paste" +version = "1.0.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "57c0d7b74b563b49d38dae00a0c37d4d6de9b432382b2892f0574ddcae73fd0a" + +[[package]] +name = "pkg-config" +version = "0.3.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "953ec861398dccce10c670dfeaf3ec4911ca479e9c02154b3a215178c5f566f2" + +[[package]] +name = "portable-atomic" +version = "1.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "280dc24453071f1b63954171985a0b0d30058d287960968b9b2aca264c8d4ee6" + +[[package]] +name = "ppv-lite86" +version = "0.2.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "77957b295656769bb8ad2b6a6b09d897d94f05c41b069aede1fcdaa675eaea04" +dependencies = [ + "zerocopy", +] + +[[package]] +name = "proc-macro2" +version = "1.0.92" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "37d3544b3f2748c54e147655edb5025752e2303145b5aefb3c3ea2c78b973bb0" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "quote" +version = "1.0.37" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b5b9d34b8991d19d98081b46eacdd8eb58c6f2b201139f7c5f643cc155a633af" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "rand" +version = "0.8.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" +dependencies = [ + "libc", + "rand_chacha", + "rand_core", +] + +[[package]] +name = "rand_chacha" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" +dependencies = [ + "ppv-lite86", + "rand_core", +] + +[[package]] +name = "rand_core" +version = "0.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" +dependencies = [ + "getrandom", +] + +[[package]] +name = "rayon" +version = "1.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b418a60154510ca1a002a752ca9714984e21e4241e804d32555251faf8b78ffa" +dependencies = [ + "either", + "rayon-core", +] + +[[package]] +name = "rayon-cond" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "059f538b55efd2309c9794130bc149c6a553db90e9d99c2030785c82f0bd7df9" +dependencies = [ + "either", + "itertools 0.11.0", + "rayon", +] + +[[package]] +name = "rayon-core" +version = "1.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1465873a3dfdaa8ae7cb14b4383657caab0b3e8a0aa9ae8e04b044854c8dfce2" +dependencies = [ + "crossbeam-deque", + "crossbeam-utils", +] + +[[package]] +name = "regex" +version = "1.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b544ef1b4eac5dc2db33ea63606ae9ffcfac26c1416a2806ae0bf5f56b201191" +dependencies = [ + "aho-corasick", + "memchr", + "regex-automata", + "regex-syntax", +] + +[[package]] +name = "regex-automata" +version = "0.4.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "809e8dc61f6de73b46c85f4c96486310fe304c434cfa43669d7b40f711150908" +dependencies = [ + "aho-corasick", + "memchr", + "regex-syntax", +] + +[[package]] +name = "regex-syntax" +version = "0.8.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2b15c43186be67a4fd63bee50d0303afffcef381492ebe2c5d87f324e1b8815c" + +[[package]] +name = "ryu" +version = "1.0.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f3cb5ba0dc43242ce17de99c180e96db90b235b8a9fdc9543c96d2209116bd9f" + +[[package]] +name = "serde" +version = "1.0.216" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b9781016e935a97e8beecf0c933758c97a5520d32930e460142b4cd80c6338e" +dependencies = [ + "serde_derive", +] + +[[package]] +name = "serde_derive" +version = "1.0.216" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "46f859dbbf73865c6627ed570e78961cd3ac92407a2d117204c49232485da55e" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "serde_json" +version = "1.0.134" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d00f4175c42ee48b15416f6193a959ba3a0d67fc699a0db9ad12df9f83991c7d" +dependencies = [ + "itoa", + "memchr", + "ryu", + "serde", +] + +[[package]] +name = "shlex" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64" + +[[package]] +name = "smallvec" +version = "1.13.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3c5e1a9a646d36c3599cd173a41282daf47c44583ad367b8e6837255952e5c67" + +[[package]] +name = "spm_precompiled" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5851699c4033c63636f7ea4cf7b7c1f1bf06d0cc03cfb42e711de5a5c46cf326" +dependencies = [ + "base64", + "nom", + "serde", + "unicode-segmentation", +] + +[[package]] +name = "strsim" +version = "0.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f" + +[[package]] +name = "syn" +version = "2.0.91" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d53cbcb5a243bd33b7858b1d7f4aca2153490815872d86d955d6ea29f743c035" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "thiserror" +version = "1.0.69" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6aaf5339b578ea85b50e080feb250a3e8ae8cfcdff9a461c9ec2904bc923f52" +dependencies = [ + "thiserror-impl", +] + +[[package]] +name = "thiserror-impl" +version = "1.0.69" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4fee6c4efc90059e10f81e6d42c60a18f76588c3d74cb83a0b242a2b6c7504c1" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "tokenizers" +version = "0.21.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ecededfed68a69bc657e486510089e255e53c3d38cc7d4d59c8742668ca2cae" +dependencies = [ + "aho-corasick", + "derive_builder", + "esaxx-rs", + "getrandom", + "indicatif", + "itertools 0.12.1", + "lazy_static", + "log", + "macro_rules_attribute", + "monostate", + "onig", + "paste", + "rand", + "rayon", + "rayon-cond", + "regex", + "regex-syntax", + "serde", + "serde_json", + "spm_precompiled", + "thiserror", + "unicode-normalization-alignments", + "unicode-segmentation", + "unicode_categories", +] + +[[package]] +name = "unicode-ident" +version = "1.0.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "adb9e6ca4f869e1180728b7950e35922a7fc6397f7b641499e8f3ef06e50dc83" + +[[package]] +name = "unicode-normalization-alignments" +version = "0.1.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "43f613e4fa046e69818dd287fdc4bc78175ff20331479dab6e1b0f98d57062de" +dependencies = [ + "smallvec", +] + +[[package]] +name = "unicode-segmentation" +version = "1.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f6ccf251212114b54433ec949fd6a7841275f9ada20dddd2f29e9ceea4501493" + +[[package]] +name = "unicode-width" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1fc81956842c57dac11422a97c3b8195a1ff727f06e85c84ed2e8aa277c9a0fd" + +[[package]] +name = "unicode_categories" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "39ec24b3121d976906ece63c9daad25b85969647682eee313cb5779fdd69e14e" + +[[package]] +name = "wasi" +version = "0.11.0+wasi-snapshot-preview1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" + +[[package]] +name = "wasm-bindgen" +version = "0.2.99" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a474f6281d1d70c17ae7aa6a613c87fce69a127e2624002df63dcb39d6cf6396" +dependencies = [ + "cfg-if", + "once_cell", + "wasm-bindgen-macro", +] + +[[package]] +name = "wasm-bindgen-backend" +version = "0.2.99" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5f89bb38646b4f81674e8f5c3fb81b562be1fd936d84320f3264486418519c79" +dependencies = [ + "bumpalo", + "log", + "proc-macro2", + "quote", + "syn", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-macro" +version = "0.2.99" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2cc6181fd9a7492eef6fef1f33961e3695e4579b9872a6f7c83aee556666d4fe" +dependencies = [ + "quote", + "wasm-bindgen-macro-support", +] + +[[package]] +name = "wasm-bindgen-macro-support" +version = "0.2.99" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "30d7a95b763d3c45903ed6c81f156801839e5ee968bb07e534c44df0fcd330c2" +dependencies = [ + "proc-macro2", + "quote", + "syn", + "wasm-bindgen-backend", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-shared" +version = "0.2.99" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "943aab3fdaaa029a6e0271b35ea10b72b943135afe9bffca82384098ad0e06a6" + +[[package]] +name = "web-time" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5a6580f308b1fad9207618087a65c04e7a10bc77e02c8e84e9b00dd4b12fa0bb" +dependencies = [ + "js-sys", + "wasm-bindgen", +] + +[[package]] +name = "windows-sys" +version = "0.59.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e38bc4d79ed67fd075bcc251a1c39b32a1776bbe92e5bef1f0bf1f8c531853b" +dependencies = [ + "windows-targets", +] + +[[package]] +name = "windows-targets" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973" +dependencies = [ + "windows_aarch64_gnullvm", + "windows_aarch64_msvc", + "windows_i686_gnu", + "windows_i686_gnullvm", + "windows_i686_msvc", + "windows_x86_64_gnu", + "windows_x86_64_gnullvm", + "windows_x86_64_msvc", +] + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" + +[[package]] +name = "windows_i686_gnu" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b" + +[[package]] +name = "windows_i686_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" + +[[package]] +name = "windows_i686_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" + +[[package]] +name = "zerocopy" +version = "0.7.35" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1b9b4fd18abc82b8136838da5d50bae7bdea537c574d8dc1a34ed098d6c166f0" +dependencies = [ + "byteorder", + "zerocopy-derive", +] + +[[package]] +name = "zerocopy-derive" +version = "0.7.35" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fa4f8080344d4671fb4e831a13ad1e68092748387dfc4f55e356242fae12ce3e" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] diff --git a/zml/tokenizer/hf_tokenizers/Cargo.toml b/zml/tokenizer/hf_tokenizers/Cargo.toml new file mode 100644 index 00000000..db0132d5 --- /dev/null +++ b/zml/tokenizer/hf_tokenizers/Cargo.toml @@ -0,0 +1,7 @@ +[package] +name = "hf_tokenizers" +version = "0.1.0" +edition = "2021" + +[dependencies] +tokenizers = "0.21.0" diff --git a/zml/tokenizer/hf_tokenizers/hf_tokenizers.h b/zml/tokenizer/hf_tokenizers/hf_tokenizers.h new file mode 100644 index 00000000..7cb56799 --- /dev/null +++ b/zml/tokenizer/hf_tokenizers/hf_tokenizers.h @@ -0,0 +1,17 @@ +#pragma once + +#include + +typedef struct +{ + char *ptr; + size_t len; +} zig_slice; +typedef void hf_tokenizers; + +hf_tokenizers *hf_tokenizers_new(zig_slice); +void hf_tokenizers_drop(void *tokenizer); +zig_slice hf_tokenizers_encode(hf_tokenizers *tokenizer, zig_slice text); +void hf_tokenizers_tokens_drop(zig_slice tokens); +zig_slice hf_tokenizers_decode(hf_tokenizers *tokenizer, zig_slice tokens); +void hf_tokenizers_str_drop(zig_slice text); diff --git a/zml/tokenizer/hf_tokenizers/hf_tokenizers.zig b/zml/tokenizer/hf_tokenizers/hf_tokenizers.zig new file mode 100644 index 00000000..e69de29b diff --git a/zml/tokenizer/hf_tokenizers/main.zig b/zml/tokenizer/hf_tokenizers/main.zig new file mode 100644 index 00000000..c7b7b66d --- /dev/null +++ b/zml/tokenizer/hf_tokenizers/main.zig @@ -0,0 +1,33 @@ +const std = @import("std"); +const c = @import("c"); + +pub const HFTokenizers = opaque { + pub fn init(model: []const u8) *HFTokenizers { + return @ptrCast(c.hf_tokenizers_new(c.zig_slice{ .ptr = @constCast(model.ptr), .len = @intCast(model.len) })); + } + + pub fn deinit(self: *HFTokenizers) void { + return c.hf_tokenizers_drop(self); + } + + pub fn encode(self: *HFTokenizers, input: []const u8) []i32 { + const ret = c.hf_tokenizers_encode(self, c.zig_slice{ .ptr = @constCast(input.ptr), .len = @intCast(input.len) }); + return @as([*c]i32, @alignCast(@ptrCast(ret.ptr)))[0..ret.len]; + } +}; + +pub fn as_path(path: []const u8) [std.fs.max_path_bytes:0]u8 { + var result: [std.fs.max_path_bytes:0]u8 = undefined; + @memcpy(result[0..path.len], path); + result[path.len] = 0; + return result; +} + +pub fn main() !void { + const tokenizer = HFTokenizers.init("/private/var/tmp/_bazel_steeve/a67b810d44f2a673ebbd5bab86ccd5cc/external/zml~~huggingface~Meta-Llama-3.1-8B-Instruct/tokenizer.json"); + defer HFTokenizers.deinit(tokenizer); + + const input = "Hello, world! plane pouet plane"; + const encoded = HFTokenizers.encode(tokenizer, input); + std.debug.print("{any} {any}\n", .{tokenizer, encoded}); +} diff --git a/zml/tokenizer/hf_tokenizers/src/lib.rs b/zml/tokenizer/hf_tokenizers/src/lib.rs new file mode 100644 index 00000000..7bb8d295 --- /dev/null +++ b/zml/tokenizer/hf_tokenizers/src/lib.rs @@ -0,0 +1,64 @@ +#[repr(C)] +struct ZigSlice { + ptr: *mut T, + len: usize, +} + +impl ZigSlice { + fn as_slice(&self) -> &[T] { + unsafe { std::slice::from_raw_parts(self.ptr, self.len) } + } +} + +#[no_mangle] +extern "C" fn hf_tokenizers_new(path: ZigSlice) -> *mut tokenizers::Tokenizer { + return Box::into_raw(Box::new( + tokenizers::Tokenizer::from_file(std::path::Path::new( + std::str::from_utf8(path.as_slice()).unwrap(), + )) + .unwrap() + .into(), + )); +} + +#[no_mangle] +extern "C" fn hf_tokenizers_drop(t: *mut tokenizers::Tokenizer) { + drop(unsafe { Box::from_raw(t) }); +} + +#[no_mangle] +extern "C" fn hf_tokenizers_encode( + t: *mut tokenizers::Tokenizer, + string: ZigSlice, +) -> ZigSlice { + let input_str = std::str::from_utf8(string.as_slice()).unwrap(); + let encoded = unsafe { (*t).encode_fast(input_str, false) }.unwrap(); + let len = encoded.get_ids().len(); + return ZigSlice { + ptr: Box::into_raw(encoded.get_ids().to_vec().into_boxed_slice()), + len: len, + }; +} + +#[no_mangle] +extern "C" fn hf_tokenizers_tokens_drop(tokens: ZigSlice) { + // drop(unsafe { Box::from_raw(tokens.ptr) }); +} + +#[no_mangle] +extern "C" fn hf_tokenizers_decode( + t: *mut tokenizers::Tokenizer, + ids: ZigSlice, +) -> ZigSlice { + let decoded = unsafe { (*t).decode(ids.as_slice(), false).unwrap() }; + let len = decoded.len(); + return ZigSlice { + ptr: decoded.into_boxed_str().as_mut_ptr(), + len: len, + }; +} + +#[no_mangle] +extern "C" fn hf_tokenizers_str_drop(tokens: ZigSlice) { + // drop(unsafe { Box::from_raw(tokens.ptr) }); +} From 63df2e25c9d13bb37784bd9607c3385174dab508 Mon Sep 17 00:00:00 2001 From: Steeve Morin Date: Wed, 25 Dec 2024 23:38:43 +0100 Subject: [PATCH 03/48] WIP --- examples/.bazelrc | 1 + zml/tokenizer/hf_tokenizers/Cargo.lock | 207 ------------------------- zml/tokenizer/hf_tokenizers/Cargo.toml | 2 +- zml/tokenizer/hf_tokenizers/main.zig | 48 +++++- zml/tokenizer/hf_tokenizers/src/lib.rs | 32 ++-- 5 files changed, 68 insertions(+), 222 deletions(-) diff --git a/examples/.bazelrc b/examples/.bazelrc index 6d969ccd..c732aa99 100644 --- a/examples/.bazelrc +++ b/examples/.bazelrc @@ -64,6 +64,7 @@ build --experimental_starlark_cc_import build --compiler=clang +build:macos --action_env=MACOSX_DEPLOYMENT_TARGET=13.0 build:macos --macos_sdk_version=13.0 # Used by the tsl overlay in python_init_repositories for the bazelified xla module 20241025.0-4663f04 diff --git a/zml/tokenizer/hf_tokenizers/Cargo.lock b/zml/tokenizer/hf_tokenizers/Cargo.lock index e9b3047c..526199b5 100644 --- a/zml/tokenizer/hf_tokenizers/Cargo.lock +++ b/zml/tokenizer/hf_tokenizers/Cargo.lock @@ -23,12 +23,6 @@ version = "1.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" -[[package]] -name = "bumpalo" -version = "3.16.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "79296716171880943b8470b5f8d03aa55eb2e645a4874bdbb28adb49162e012c" - [[package]] name = "byteorder" version = "1.5.0" @@ -50,19 +44,6 @@ version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" -[[package]] -name = "console" -version = "0.15.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ea3c6ecd8059b57859df5c69830340ed3c41d30e3da0c1cbed90a96ac853041b" -dependencies = [ - "encode_unicode", - "libc", - "once_cell", - "unicode-width", - "windows-sys", -] - [[package]] name = "crossbeam-deque" version = "0.8.6" @@ -160,20 +141,11 @@ version = "1.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "60b1af1c220855b6ceac025d3f6ecdd2b7c4894bfe9cd9bda4fbb4bc7c0d4cf0" -[[package]] -name = "encode_unicode" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "34aa73646ffb006b8f5147f3dc182bd4bcb190227ce861fc4a4844bf8e3cb2c0" - [[package]] name = "esaxx-rs" version = "0.1.10" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d817e038c30374a4bcb22f94d0a8a0e216958d4c3dcde369b1439fec4bdda6e6" -dependencies = [ - "cc", -] [[package]] name = "fnv" @@ -205,19 +177,6 @@ version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39" -[[package]] -name = "indicatif" -version = "0.17.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cbf675b85ed934d3c67b5c5469701eec7db22689d0a2139d856e0925fa28b281" -dependencies = [ - "console", - "number_prefix", - "portable-atomic", - "unicode-width", - "web-time", -] - [[package]] name = "itertools" version = "0.11.0" @@ -242,16 +201,6 @@ version = "1.0.14" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d75a2a4b1b190afb6f5425f10f6a8f959d2ea0b9c2b1d79553551850539e4674" -[[package]] -name = "js-sys" -version = "0.3.76" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6717b6b5b077764fb5966237269cb3c64edddde4b14ce42647430a78ced9e7b7" -dependencies = [ - "once_cell", - "wasm-bindgen", -] - [[package]] name = "lazy_static" version = "1.5.0" @@ -329,12 +278,6 @@ dependencies = [ "minimal-lexical", ] -[[package]] -name = "number_prefix" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "830b246a0e5f20af87141b25c173cd1b609bd7779a4617d6ec582abaf90870f3" - [[package]] name = "once_cell" version = "1.20.2" @@ -375,12 +318,6 @@ version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "953ec861398dccce10c670dfeaf3ec4911ca479e9c02154b3a215178c5f566f2" -[[package]] -name = "portable-atomic" -version = "1.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "280dc24453071f1b63954171985a0b0d30058d287960968b9b2aca264c8d4ee6" - [[package]] name = "ppv-lite86" version = "0.2.20" @@ -607,7 +544,6 @@ dependencies = [ "derive_builder", "esaxx-rs", "getrandom", - "indicatif", "itertools 0.12.1", "lazy_static", "log", @@ -650,12 +586,6 @@ version = "1.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f6ccf251212114b54433ec949fd6a7841275f9ada20dddd2f29e9ceea4501493" -[[package]] -name = "unicode-width" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1fc81956842c57dac11422a97c3b8195a1ff727f06e85c84ed2e8aa277c9a0fd" - [[package]] name = "unicode_categories" version = "0.1.1" @@ -668,143 +598,6 @@ version = "0.11.0+wasi-snapshot-preview1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" -[[package]] -name = "wasm-bindgen" -version = "0.2.99" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a474f6281d1d70c17ae7aa6a613c87fce69a127e2624002df63dcb39d6cf6396" -dependencies = [ - "cfg-if", - "once_cell", - "wasm-bindgen-macro", -] - -[[package]] -name = "wasm-bindgen-backend" -version = "0.2.99" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f89bb38646b4f81674e8f5c3fb81b562be1fd936d84320f3264486418519c79" -dependencies = [ - "bumpalo", - "log", - "proc-macro2", - "quote", - "syn", - "wasm-bindgen-shared", -] - -[[package]] -name = "wasm-bindgen-macro" -version = "0.2.99" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2cc6181fd9a7492eef6fef1f33961e3695e4579b9872a6f7c83aee556666d4fe" -dependencies = [ - "quote", - "wasm-bindgen-macro-support", -] - -[[package]] -name = "wasm-bindgen-macro-support" -version = "0.2.99" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "30d7a95b763d3c45903ed6c81f156801839e5ee968bb07e534c44df0fcd330c2" -dependencies = [ - "proc-macro2", - "quote", - "syn", - "wasm-bindgen-backend", - "wasm-bindgen-shared", -] - -[[package]] -name = "wasm-bindgen-shared" -version = "0.2.99" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "943aab3fdaaa029a6e0271b35ea10b72b943135afe9bffca82384098ad0e06a6" - -[[package]] -name = "web-time" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5a6580f308b1fad9207618087a65c04e7a10bc77e02c8e84e9b00dd4b12fa0bb" -dependencies = [ - "js-sys", - "wasm-bindgen", -] - -[[package]] -name = "windows-sys" -version = "0.59.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e38bc4d79ed67fd075bcc251a1c39b32a1776bbe92e5bef1f0bf1f8c531853b" -dependencies = [ - "windows-targets", -] - -[[package]] -name = "windows-targets" -version = "0.52.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973" -dependencies = [ - "windows_aarch64_gnullvm", - "windows_aarch64_msvc", - "windows_i686_gnu", - "windows_i686_gnullvm", - "windows_i686_msvc", - "windows_x86_64_gnu", - "windows_x86_64_gnullvm", - "windows_x86_64_msvc", -] - -[[package]] -name = "windows_aarch64_gnullvm" -version = "0.52.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" - -[[package]] -name = "windows_aarch64_msvc" -version = "0.52.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" - -[[package]] -name = "windows_i686_gnu" -version = "0.52.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b" - -[[package]] -name = "windows_i686_gnullvm" -version = "0.52.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" - -[[package]] -name = "windows_i686_msvc" -version = "0.52.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" - -[[package]] -name = "windows_x86_64_gnu" -version = "0.52.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" - -[[package]] -name = "windows_x86_64_gnullvm" -version = "0.52.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" - -[[package]] -name = "windows_x86_64_msvc" -version = "0.52.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" - [[package]] name = "zerocopy" version = "0.7.35" diff --git a/zml/tokenizer/hf_tokenizers/Cargo.toml b/zml/tokenizer/hf_tokenizers/Cargo.toml index db0132d5..36a780f1 100644 --- a/zml/tokenizer/hf_tokenizers/Cargo.toml +++ b/zml/tokenizer/hf_tokenizers/Cargo.toml @@ -4,4 +4,4 @@ version = "0.1.0" edition = "2021" [dependencies] -tokenizers = "0.21.0" +tokenizers = { version = "0.21.0", default-features = false, features = ["onig"] } diff --git a/zml/tokenizer/hf_tokenizers/main.zig b/zml/tokenizer/hf_tokenizers/main.zig index c7b7b66d..40dc1a38 100644 --- a/zml/tokenizer/hf_tokenizers/main.zig +++ b/zml/tokenizer/hf_tokenizers/main.zig @@ -2,6 +2,21 @@ const std = @import("std"); const c = @import("c"); pub const HFTokenizers = opaque { + pub const Encoded = struct { + ids: []const u32, + + pub fn deinit(self: *Encoded) void { + c.hf_tokenizers_tokens_drop(c.zig_slice{ .ptr = @ptrCast(@constCast(self.ids.ptr)), .len = @intCast(self.ids.len) }); + } + }; + + pub const Decoded = struct { + str: []const u8, + + pub fn deinit(self: *Decoded) void { + c.hf_tokenizers_str_drop(c.zig_slice{ .ptr = @ptrCast(@constCast(self.str.ptr)), .len = @intCast(self.str.len) }); + } + }; pub fn init(model: []const u8) *HFTokenizers { return @ptrCast(c.hf_tokenizers_new(c.zig_slice{ .ptr = @constCast(model.ptr), .len = @intCast(model.len) })); } @@ -10,9 +25,18 @@ pub const HFTokenizers = opaque { return c.hf_tokenizers_drop(self); } - pub fn encode(self: *HFTokenizers, input: []const u8) []i32 { + pub fn encode(self: *HFTokenizers, input: []const u8) Encoded { const ret = c.hf_tokenizers_encode(self, c.zig_slice{ .ptr = @constCast(input.ptr), .len = @intCast(input.len) }); - return @as([*c]i32, @alignCast(@ptrCast(ret.ptr)))[0..ret.len]; + return .{ + .ids = @as([*c]const u32, @alignCast(@ptrCast(ret.ptr)))[0..ret.len] + }; + } + + pub fn decode(self: *HFTokenizers, input: []const u32) Decoded { + const ret = c.hf_tokenizers_decode(self, c.zig_slice{ .ptr = @ptrCast(@constCast(input.ptr)), .len = @intCast(input.len) }); + return .{ + .str = @as([*c]const u8, @alignCast(@ptrCast(ret.ptr)))[0..ret.len] + }; } }; @@ -28,6 +52,22 @@ pub fn main() !void { defer HFTokenizers.deinit(tokenizer); const input = "Hello, world! plane pouet plane"; - const encoded = HFTokenizers.encode(tokenizer, input); - std.debug.print("{any} {any}\n", .{tokenizer, encoded}); + var encoded = HFTokenizers.encode(tokenizer, input); + defer encoded.deinit(); + var pouet = std.ArrayList(u32).init(std.heap.c_allocator); + defer pouet.deinit(); + + // try pouet.appendSlice(encoded.ids); + + var t = try std.time.Timer.start(); + for (0..100) |i| { + _ = i; // autofix + try pouet.appendSlice(encoded.ids); + t.reset(); + var decoded = HFTokenizers.decode(tokenizer, pouet.items); + defer decoded.deinit(); + const elapsed = t.lap(); + // std.debug.print("{any} {any} {d}us\n", .{tokenizer, encoded, elapsed / std.time.ns_per_us}); + std.debug.print("{any} {any} {s} {d}ns {d}us\n", .{tokenizer, encoded, decoded.str, elapsed, elapsed / std.time.ns_per_us}); + } } diff --git a/zml/tokenizer/hf_tokenizers/src/lib.rs b/zml/tokenizer/hf_tokenizers/src/lib.rs index 7bb8d295..c22e9f80 100644 --- a/zml/tokenizer/hf_tokenizers/src/lib.rs +++ b/zml/tokenizer/hf_tokenizers/src/lib.rs @@ -32,17 +32,23 @@ extern "C" fn hf_tokenizers_encode( string: ZigSlice, ) -> ZigSlice { let input_str = std::str::from_utf8(string.as_slice()).unwrap(); - let encoded = unsafe { (*t).encode_fast(input_str, false) }.unwrap(); - let len = encoded.get_ids().len(); - return ZigSlice { - ptr: Box::into_raw(encoded.get_ids().to_vec().into_boxed_slice()), + let encoded = unsafe { t.as_ref() } + .unwrap() + .encode_fast(input_str, false) + .unwrap(); + let mut ids = encoded.get_ids().to_owned().into_boxed_slice(); + let len = ids.len(); + let ret = ZigSlice { + ptr: ids.as_mut_ptr(), len: len, }; + std::mem::forget(ids); + return ret; } #[no_mangle] extern "C" fn hf_tokenizers_tokens_drop(tokens: ZigSlice) { - // drop(unsafe { Box::from_raw(tokens.ptr) }); + drop(unsafe { Box::from_raw(tokens.ptr) }); } #[no_mangle] @@ -50,15 +56,21 @@ extern "C" fn hf_tokenizers_decode( t: *mut tokenizers::Tokenizer, ids: ZigSlice, ) -> ZigSlice { - let decoded = unsafe { (*t).decode(ids.as_slice(), false).unwrap() }; + let decoded = unsafe { t.as_ref() } + .unwrap() + .decode(ids.as_slice(), false) + .unwrap(); let len = decoded.len(); - return ZigSlice { - ptr: decoded.into_boxed_str().as_mut_ptr(), - len: len, + let mut dstr = decoded.into_boxed_str(); + let ret = ZigSlice { + ptr: dstr.as_mut_ptr(), + len: dstr.len(), }; + std::mem::forget(dstr); + return ret; } #[no_mangle] extern "C" fn hf_tokenizers_str_drop(tokens: ZigSlice) { - // drop(unsafe { Box::from_raw(tokens.ptr) }); + drop(unsafe { Box::from_raw(tokens.ptr) }); } From cf13fdf638fe6d94ddc69e00dd950a10535d6875 Mon Sep 17 00:00:00 2001 From: Steeve Morin Date: Fri, 27 Dec 2024 16:02:06 +0000 Subject: [PATCH 04/48] WIP --- MODULE.bazel | 4 +- examples/.vscode/settings.json | 3 + zml/tokenizer/BUILD.bazel | 34 ++++ zml/tokenizer/hf_tokenizers/BUILD.bazel | 28 ---- zml/tokenizer/hf_tokenizers/hf_tokenizers.h | 17 -- zml/tokenizer/hf_tokenizers/hf_tokenizers.zig | 0 zml/tokenizer/hf_tokenizers/main.zig | 73 -------- zml/tokenizer/hftokenizers/BUILD.bazel | 38 +++++ .../Cargo.lock | 14 +- .../Cargo.toml | 6 +- zml/tokenizer/hftokenizers/hftokenizers.h | 14 ++ .../lib.rs => hftokenizers/hftokenizers.rs} | 33 ++-- zml/tokenizer/hftokenizers/hftokenizers.zig | 81 +++++++++ zml/tokenizer/hftokenizers/main.zig | 28 ++++ zml/tokenizer/main.zig | 24 +++ zml/tokenizer/sentencepiece/BUILD.bazel | 42 +---- zml/tokenizer/sentencepiece/main.zig | 37 ++-- zml/tokenizer/sentencepiece/sentencepiece.i | 24 +-- zml/tokenizer/sentencepiece/sentencepiece.zig | 158 +++++++++++++++++- zml/tokenizer/sentencepiece/zig.h | 9 - zml/tokenizer/tokenizer.zig | 111 ++++++++++-- 21 files changed, 536 insertions(+), 242 deletions(-) create mode 100644 zml/tokenizer/BUILD.bazel delete mode 100644 zml/tokenizer/hf_tokenizers/BUILD.bazel delete mode 100644 zml/tokenizer/hf_tokenizers/hf_tokenizers.h delete mode 100644 zml/tokenizer/hf_tokenizers/hf_tokenizers.zig delete mode 100644 zml/tokenizer/hf_tokenizers/main.zig create mode 100644 zml/tokenizer/hftokenizers/BUILD.bazel rename zml/tokenizer/{hf_tokenizers => hftokenizers}/Cargo.lock (99%) rename zml/tokenizer/{hf_tokenizers => hftokenizers}/Cargo.toml (58%) create mode 100644 zml/tokenizer/hftokenizers/hftokenizers.h rename zml/tokenizer/{hf_tokenizers/src/lib.rs => hftokenizers/hftokenizers.rs} (59%) create mode 100644 zml/tokenizer/hftokenizers/hftokenizers.zig create mode 100644 zml/tokenizer/hftokenizers/main.zig create mode 100644 zml/tokenizer/main.zig delete mode 100644 zml/tokenizer/sentencepiece/zig.h diff --git a/MODULE.bazel b/MODULE.bazel index d5164aaf..7c08ff98 100644 --- a/MODULE.bazel +++ b/MODULE.bazel @@ -127,7 +127,7 @@ bazel_dep(name = "rules_rust", version = "0.56.0") crate = use_extension("@rules_rust//crate_universe:extensions.bzl", "crate") crate.from_cargo( name = "crates", - cargo_lockfile = "//zml/tokenizer/hf_tokenizers:Cargo.lock", - manifests = ["//zml/tokenizer/hf_tokenizers:Cargo.toml"], + cargo_lockfile = "//zml/tokenizer/hftokenizers:Cargo.lock", + manifests = ["//zml/tokenizer/hftokenizers:Cargo.toml"], ) use_repo(crate, "crates") diff --git a/examples/.vscode/settings.json b/examples/.vscode/settings.json index f9c5f96a..82050af6 100644 --- a/examples/.vscode/settings.json +++ b/examples/.vscode/settings.json @@ -31,4 +31,7 @@ "source.fixAll": "explicit", } }, + "rust-analyzer.linkedProjects": [ + "${workspaceFolder}/zml/tokenizer/hftokenizers/Cargo.toml" + ] } diff --git a/zml/tokenizer/BUILD.bazel b/zml/tokenizer/BUILD.bazel new file mode 100644 index 00000000..170cd8a4 --- /dev/null +++ b/zml/tokenizer/BUILD.bazel @@ -0,0 +1,34 @@ +load("@rules_zig//zig:defs.bzl", "zig_library") +load("@zml//bazel:zig.bzl", "zig_cc_binary") +load("//bazel:swig.bzl", "swig_cc_library") + +swig_cc_library( + name = "sentencepiece_swig", + interface = "sentencepiece.i", + module = "sentencepiece", + deps = [ + "//ffi:cc", + "@com_google_sentencepiece//:sentencepiece_processor", + ], +) + +zig_library( + name = "tokenizer", + import_name = "zml/tokenizer", + main = "tokenizer.zig", + visibility = ["//visibility:public"], + deps = [ + "//ffi:zig", + "//zml/tokenizer/hftokenizers", + "//zml/tokenizer/sentencepiece", + ], +) + +zig_cc_binary( + name = "main", + main = "main.zig", + visibility = ["//visibility:public"], + deps = [ + ":tokenizer", + ], +) diff --git a/zml/tokenizer/hf_tokenizers/BUILD.bazel b/zml/tokenizer/hf_tokenizers/BUILD.bazel deleted file mode 100644 index 51e426bb..00000000 --- a/zml/tokenizer/hf_tokenizers/BUILD.bazel +++ /dev/null @@ -1,28 +0,0 @@ -load("@rules_rust//rust:defs.bzl", "rust_static_library") -load("@zml//bazel:zig.bzl", "zig_cc_binary") - -rust_static_library( - name = "hf_tokenizers_rs", - srcs = ["src/lib.rs"], - crate_name = "zml_hf_tokenizers", - edition = "2021", - deps = [ - "@crates//:tokenizers", - ], -) - -cc_library( - name = "hf_tokenizers", - hdrs = ["hf_tokenizers.h"], - visibility = ["//visibility:public"], - deps = [ - ":hf_tokenizers_rs", - ], -) - -zig_cc_binary( - name = "main", - main = "main.zig", - visibility = ["//visibility:public"], - deps = [":hf_tokenizers"], -) diff --git a/zml/tokenizer/hf_tokenizers/hf_tokenizers.h b/zml/tokenizer/hf_tokenizers/hf_tokenizers.h deleted file mode 100644 index 7cb56799..00000000 --- a/zml/tokenizer/hf_tokenizers/hf_tokenizers.h +++ /dev/null @@ -1,17 +0,0 @@ -#pragma once - -#include - -typedef struct -{ - char *ptr; - size_t len; -} zig_slice; -typedef void hf_tokenizers; - -hf_tokenizers *hf_tokenizers_new(zig_slice); -void hf_tokenizers_drop(void *tokenizer); -zig_slice hf_tokenizers_encode(hf_tokenizers *tokenizer, zig_slice text); -void hf_tokenizers_tokens_drop(zig_slice tokens); -zig_slice hf_tokenizers_decode(hf_tokenizers *tokenizer, zig_slice tokens); -void hf_tokenizers_str_drop(zig_slice text); diff --git a/zml/tokenizer/hf_tokenizers/hf_tokenizers.zig b/zml/tokenizer/hf_tokenizers/hf_tokenizers.zig deleted file mode 100644 index e69de29b..00000000 diff --git a/zml/tokenizer/hf_tokenizers/main.zig b/zml/tokenizer/hf_tokenizers/main.zig deleted file mode 100644 index 40dc1a38..00000000 --- a/zml/tokenizer/hf_tokenizers/main.zig +++ /dev/null @@ -1,73 +0,0 @@ -const std = @import("std"); -const c = @import("c"); - -pub const HFTokenizers = opaque { - pub const Encoded = struct { - ids: []const u32, - - pub fn deinit(self: *Encoded) void { - c.hf_tokenizers_tokens_drop(c.zig_slice{ .ptr = @ptrCast(@constCast(self.ids.ptr)), .len = @intCast(self.ids.len) }); - } - }; - - pub const Decoded = struct { - str: []const u8, - - pub fn deinit(self: *Decoded) void { - c.hf_tokenizers_str_drop(c.zig_slice{ .ptr = @ptrCast(@constCast(self.str.ptr)), .len = @intCast(self.str.len) }); - } - }; - pub fn init(model: []const u8) *HFTokenizers { - return @ptrCast(c.hf_tokenizers_new(c.zig_slice{ .ptr = @constCast(model.ptr), .len = @intCast(model.len) })); - } - - pub fn deinit(self: *HFTokenizers) void { - return c.hf_tokenizers_drop(self); - } - - pub fn encode(self: *HFTokenizers, input: []const u8) Encoded { - const ret = c.hf_tokenizers_encode(self, c.zig_slice{ .ptr = @constCast(input.ptr), .len = @intCast(input.len) }); - return .{ - .ids = @as([*c]const u32, @alignCast(@ptrCast(ret.ptr)))[0..ret.len] - }; - } - - pub fn decode(self: *HFTokenizers, input: []const u32) Decoded { - const ret = c.hf_tokenizers_decode(self, c.zig_slice{ .ptr = @ptrCast(@constCast(input.ptr)), .len = @intCast(input.len) }); - return .{ - .str = @as([*c]const u8, @alignCast(@ptrCast(ret.ptr)))[0..ret.len] - }; - } -}; - -pub fn as_path(path: []const u8) [std.fs.max_path_bytes:0]u8 { - var result: [std.fs.max_path_bytes:0]u8 = undefined; - @memcpy(result[0..path.len], path); - result[path.len] = 0; - return result; -} - -pub fn main() !void { - const tokenizer = HFTokenizers.init("/private/var/tmp/_bazel_steeve/a67b810d44f2a673ebbd5bab86ccd5cc/external/zml~~huggingface~Meta-Llama-3.1-8B-Instruct/tokenizer.json"); - defer HFTokenizers.deinit(tokenizer); - - const input = "Hello, world! plane pouet plane"; - var encoded = HFTokenizers.encode(tokenizer, input); - defer encoded.deinit(); - var pouet = std.ArrayList(u32).init(std.heap.c_allocator); - defer pouet.deinit(); - - // try pouet.appendSlice(encoded.ids); - - var t = try std.time.Timer.start(); - for (0..100) |i| { - _ = i; // autofix - try pouet.appendSlice(encoded.ids); - t.reset(); - var decoded = HFTokenizers.decode(tokenizer, pouet.items); - defer decoded.deinit(); - const elapsed = t.lap(); - // std.debug.print("{any} {any} {d}us\n", .{tokenizer, encoded, elapsed / std.time.ns_per_us}); - std.debug.print("{any} {any} {s} {d}ns {d}us\n", .{tokenizer, encoded, decoded.str, elapsed, elapsed / std.time.ns_per_us}); - } -} diff --git a/zml/tokenizer/hftokenizers/BUILD.bazel b/zml/tokenizer/hftokenizers/BUILD.bazel new file mode 100644 index 00000000..0b87d77b --- /dev/null +++ b/zml/tokenizer/hftokenizers/BUILD.bazel @@ -0,0 +1,38 @@ +load("@rules_rust//rust:defs.bzl", "rust_static_library") +load("@rules_zig//zig:defs.bzl", "zig_library") +load("@zml//bazel:zig.bzl", "zig_cc_binary") + +rust_static_library( + name = "hftokenizers_rs", + srcs = ["hftokenizers.rs"], + crate_name = "zml_tokenizer_hftokenizers", + edition = "2021", + deps = ["@crates//:tokenizers"], +) + +cc_library( + name = "hftokenizers_cc", + hdrs = ["hftokenizers.h"], + visibility = ["//visibility:public"], + deps = [ + ":hftokenizers_rs", + "//ffi:cc", + ], +) + +zig_library( + name = "hftokenizers", + main = "hftokenizers.zig", + visibility = ["//visibility:public"], + deps = [ + ":hftokenizers_cc", + "//ffi:zig", + ], +) + +zig_cc_binary( + name = "main", + main = "main.zig", + visibility = ["//visibility:public"], + deps = [":hftokenizers"], +) diff --git a/zml/tokenizer/hf_tokenizers/Cargo.lock b/zml/tokenizer/hftokenizers/Cargo.lock similarity index 99% rename from zml/tokenizer/hf_tokenizers/Cargo.lock rename to zml/tokenizer/hftokenizers/Cargo.lock index 526199b5..d7c670cb 100644 --- a/zml/tokenizer/hf_tokenizers/Cargo.lock +++ b/zml/tokenizer/hftokenizers/Cargo.lock @@ -164,13 +164,6 @@ dependencies = [ "wasi", ] -[[package]] -name = "hf_tokenizers" -version = "0.1.0" -dependencies = [ - "tokenizers", -] - [[package]] name = "ident_case" version = "1.0.1" @@ -618,3 +611,10 @@ dependencies = [ "quote", "syn", ] + +[[package]] +name = "zml_tokenizer_hftokenizers" +version = "0.1.0" +dependencies = [ + "tokenizers", +] diff --git a/zml/tokenizer/hf_tokenizers/Cargo.toml b/zml/tokenizer/hftokenizers/Cargo.toml similarity index 58% rename from zml/tokenizer/hf_tokenizers/Cargo.toml rename to zml/tokenizer/hftokenizers/Cargo.toml index 36a780f1..e88bad7a 100644 --- a/zml/tokenizer/hf_tokenizers/Cargo.toml +++ b/zml/tokenizer/hftokenizers/Cargo.toml @@ -1,7 +1,11 @@ [package] -name = "hf_tokenizers" +name = "zml_tokenizer_hftokenizers" version = "0.1.0" edition = "2021" [dependencies] tokenizers = { version = "0.21.0", default-features = false, features = ["onig"] } + +[lib] +name = "zml_tokenizer_hftokenizers" +path = "hftokenizers.rs" diff --git a/zml/tokenizer/hftokenizers/hftokenizers.h b/zml/tokenizer/hftokenizers/hftokenizers.h new file mode 100644 index 00000000..dc54d4b5 --- /dev/null +++ b/zml/tokenizer/hftokenizers/hftokenizers.h @@ -0,0 +1,14 @@ +#pragma once + +#include + +#include "ffi/zig_slice.h" + +typedef struct hftokenizers hftokenizers; + +hftokenizers *hftokenizers_new(zig_slice); +void hftokenizers_drop(void *tokenizer); +zig_slice hftokenizers_encode(hftokenizers *tokenizer, zig_slice text); +void hftokenizers_tokens_drop(zig_slice tokens); +zig_slice hftokenizers_decode(hftokenizers *tokenizer, zig_slice tokens); +void hftokenizers_str_drop(zig_slice text); diff --git a/zml/tokenizer/hf_tokenizers/src/lib.rs b/zml/tokenizer/hftokenizers/hftokenizers.rs similarity index 59% rename from zml/tokenizer/hf_tokenizers/src/lib.rs rename to zml/tokenizer/hftokenizers/hftokenizers.rs index c22e9f80..439869e1 100644 --- a/zml/tokenizer/hf_tokenizers/src/lib.rs +++ b/zml/tokenizer/hftokenizers/hftokenizers.rs @@ -11,7 +11,7 @@ impl ZigSlice { } #[no_mangle] -extern "C" fn hf_tokenizers_new(path: ZigSlice) -> *mut tokenizers::Tokenizer { +extern "C" fn hftokenizers_new(path: ZigSlice) -> *mut tokenizers::Tokenizer { return Box::into_raw(Box::new( tokenizers::Tokenizer::from_file(std::path::Path::new( std::str::from_utf8(path.as_slice()).unwrap(), @@ -22,12 +22,12 @@ extern "C" fn hf_tokenizers_new(path: ZigSlice) -> *mut tokenizers::Tokenize } #[no_mangle] -extern "C" fn hf_tokenizers_drop(t: *mut tokenizers::Tokenizer) { +extern "C" fn hftokenizers_drop(t: *mut tokenizers::Tokenizer) { drop(unsafe { Box::from_raw(t) }); } #[no_mangle] -extern "C" fn hf_tokenizers_encode( +extern "C" fn hftokenizers_encode( t: *mut tokenizers::Tokenizer, string: ZigSlice, ) -> ZigSlice { @@ -36,23 +36,20 @@ extern "C" fn hf_tokenizers_encode( .unwrap() .encode_fast(input_str, false) .unwrap(); - let mut ids = encoded.get_ids().to_owned().into_boxed_slice(); - let len = ids.len(); - let ret = ZigSlice { - ptr: ids.as_mut_ptr(), - len: len, + let ids = encoded.get_ids(); + return ZigSlice { + len: ids.len(), + ptr: Box::into_raw(ids.to_owned().into_boxed_slice()) as *mut u32, }; - std::mem::forget(ids); - return ret; } #[no_mangle] -extern "C" fn hf_tokenizers_tokens_drop(tokens: ZigSlice) { +extern "C" fn hftokenizers_tokens_drop(tokens: ZigSlice) { drop(unsafe { Box::from_raw(tokens.ptr) }); } #[no_mangle] -extern "C" fn hf_tokenizers_decode( +extern "C" fn hftokenizers_decode( t: *mut tokenizers::Tokenizer, ids: ZigSlice, ) -> ZigSlice { @@ -60,17 +57,13 @@ extern "C" fn hf_tokenizers_decode( .unwrap() .decode(ids.as_slice(), false) .unwrap(); - let len = decoded.len(); - let mut dstr = decoded.into_boxed_str(); - let ret = ZigSlice { - ptr: dstr.as_mut_ptr(), - len: dstr.len(), + return ZigSlice { + len: decoded.len(), + ptr: Box::into_raw(decoded.into_boxed_str()) as *mut u8, }; - std::mem::forget(dstr); - return ret; } #[no_mangle] -extern "C" fn hf_tokenizers_str_drop(tokens: ZigSlice) { +extern "C" fn hftokenizers_str_drop(tokens: ZigSlice) { drop(unsafe { Box::from_raw(tokens.ptr) }); } diff --git a/zml/tokenizer/hftokenizers/hftokenizers.zig b/zml/tokenizer/hftokenizers/hftokenizers.zig new file mode 100644 index 00000000..d5f80da7 --- /dev/null +++ b/zml/tokenizer/hftokenizers/hftokenizers.zig @@ -0,0 +1,81 @@ +const std = @import("std"); +const c = @import("c"); +const ffi = @import("ffi"); + +pub const Encoder = struct { + inner: *HFTokenizer, + current_ids: ?[]const u32 = null, + + fn init(inner: *HFTokenizer) Encoder { + return .{ .inner = inner }; + } + + pub fn reset(self: *Encoder) void { + if (self.current_ids) |current_ids_| { + c.hftokenizers_tokens_drop(ffi.ZigSlice.from(current_ids_)); + self.current_ids = null; + } + } + + pub fn deinit(self: *Encoder) void { + self.reset(); + } + + pub fn encode(self: *Encoder, input: []const u8) ![]const u32 { + self.reset(); + self.current_ids = ffi.ZigSlice.to(u32, c.hftokenizers_encode(@ptrCast(self.inner), ffi.ZigSlice.from(input))); + return self.ids(); + } + + pub fn ids(self: *const Encoder) []const u32 { + return self.current_ids orelse &.{}; + } +}; + +pub const Decoder = struct { + inner: *HFTokenizer, + current_string: ?[]const u8 = null, + + fn init(inner: *HFTokenizer) Decoder { + return .{ .inner = inner }; + } + + pub fn deinit(self: *Decoder) void { + self.reset(); + } + + pub fn reset(self: *Decoder) void { + if (self.current_string) |current_string_| { + c.hftokenizers_str_drop(ffi.ZigSlice.from(current_string_)); + self.current_string = null; + } + } + + pub fn decode(self: *Decoder, ids: []const u32) ![]const u8 { + self.reset(); + self.current_string = ffi.ZigSlice.to(u8, c.hftokenizers_decode(@ptrCast(self.inner), ffi.ZigSlice.from(ids))); + return self.string(); + } + + pub fn string(self: *const Decoder) []const u8 { + return self.current_string orelse &.{}; + } +}; + +pub const HFTokenizer = opaque { + pub fn from_file(model: []const u8) !*HFTokenizer { + return @ptrCast(c.hftokenizers_new(ffi.ZigSlice.from(model))); + } + + pub fn deinit(self: *HFTokenizer) void { + return c.hftokenizers_drop(self); + } + + pub fn encoder(self: *HFTokenizer) !Encoder { + return Encoder.init(self); + } + + pub fn decoder(self: *HFTokenizer) !Decoder { + return Decoder.init(self); + } +}; diff --git a/zml/tokenizer/hftokenizers/main.zig b/zml/tokenizer/hftokenizers/main.zig new file mode 100644 index 00000000..0356634c --- /dev/null +++ b/zml/tokenizer/hftokenizers/main.zig @@ -0,0 +1,28 @@ +const std = @import("std"); +const c = @import("c"); +const HFTokenizers = @import("hftokenizers").HFTokenizers; + +pub fn main() !void { + const tokenizer = HFTokenizers.init("/private/var/tmp/_bazel_steeve/a67b810d44f2a673ebbd5bab86ccd5cc/external/zml~~huggingface~Meta-Llama-3.1-8B-Instruct/tokenizer.json"); + defer HFTokenizers.deinit(tokenizer); + + const input = "Hello, world! plane pouet plane"; + var encoded = HFTokenizers.encode(tokenizer, input); + defer encoded.deinit(); + var pouet = std.ArrayList(u32).init(std.heap.c_allocator); + defer pouet.deinit(); + + // try pouet.appendSlice(encoded.ids); + + var t = try std.time.Timer.start(); + for (0..100) |i| { + _ = i; // autofix + try pouet.appendSlice(encoded.ids); + t.reset(); + var decoded = HFTokenizers.decode(tokenizer, pouet.items); + defer decoded.deinit(); + const elapsed = t.lap(); + // std.debug.print("{any} {any} {d}us\n", .{tokenizer, encoded, elapsed / std.time.ns_per_us}); + std.debug.print("{any} {any} {s} {d}ns {d}us\n", .{ tokenizer, encoded, decoded.str, elapsed, elapsed / std.time.ns_per_us }); + } +} diff --git a/zml/tokenizer/main.zig b/zml/tokenizer/main.zig new file mode 100644 index 00000000..6b950d77 --- /dev/null +++ b/zml/tokenizer/main.zig @@ -0,0 +1,24 @@ +const std = @import("std"); +const tokenizer = @import("zml/tokenizer"); + +pub fn main() !void { + const model1 = "/Users/steeve/Downloads/poolside.sp.pb"; + _ = model1; // autofix + const model2 = "/private/var/tmp/_bazel_steeve/a67b810d44f2a673ebbd5bab86ccd5cc/external/zml~~huggingface~Meta-Llama-3.1-8B-Instruct/tokenizer.json"; + + var sp = try tokenizer.Tokenizer.from_file(std.heap.c_allocator, model2); + defer sp.deinit(); + + std.debug.print("Loaded model\n", .{}); + + var encoder = try sp.encoder(); + defer encoder.deinit(); + + var decoder = try sp.decoder(); + defer decoder.deinit(); + + const ids = try encoder.encode("Hello, world! plane pouet plane"); + const decoded = try decoder.decode(ids); + + std.debug.print("{d}\n{s}\n", .{ ids, decoded }); +} diff --git a/zml/tokenizer/sentencepiece/BUILD.bazel b/zml/tokenizer/sentencepiece/BUILD.bazel index 216b08e2..a0fb658d 100644 --- a/zml/tokenizer/sentencepiece/BUILD.bazel +++ b/zml/tokenizer/sentencepiece/BUILD.bazel @@ -2,22 +2,12 @@ load("@rules_zig//zig:defs.bzl", "zig_library") load("@zml//bazel:zig.bzl", "zig_cc_binary") load("//bazel:swig.bzl", "swig_cc_library") -cc_library( - name = "bridge", - srcs = ["sentencepiece_c.cc"], - hdrs = ["sentencepiece_c.h"], - deps = [ - "//ffi", - "@com_google_sentencepiece//:sentencepiece_processor", - ], -) - -cc_binary( - name = "sentencepiece_playground", - srcs = ["sentencepiece_playground.cc"], - copts = ["-lc"], - visibility = ["//visibility:public"], +swig_cc_library( + name = "sentencepiece_swig", + interface = "sentencepiece.i", + module = "sentencepiece", deps = [ + "//ffi:cc", "@com_google_sentencepiece//:sentencepiece_processor", ], ) @@ -28,24 +18,8 @@ zig_library( main = "sentencepiece.zig", visibility = ["//visibility:public"], deps = [ - ":bridge", - "//ffi:ffi_zig", - ], -) - -cc_library( - name = "zig", - hdrs = ["zig.h"], -) - -swig_cc_library( - name = "sentencepiece_swig", - interface = "sentencepiece.i", - module = "sentencepiece", - visibility = ["//visibility:public"], - deps = [ - ":zig", - "@com_google_sentencepiece//:sentencepiece_processor", + ":sentencepiece_swig", + "//ffi:zig", ], ) @@ -56,6 +30,6 @@ zig_cc_binary( visibility = ["//visibility:public"], deps = [ ":sentencepiece_swig", - ":zig", + "//ffi:zig", ], ) diff --git a/zml/tokenizer/sentencepiece/main.zig b/zml/tokenizer/sentencepiece/main.zig index 51a42e39..1c9f4e91 100644 --- a/zml/tokenizer/sentencepiece/main.zig +++ b/zml/tokenizer/sentencepiece/main.zig @@ -1,5 +1,6 @@ const std = @import("std"); const c = @import("c"); +const ffi = @import("ffi"); pub const SentencePieceError = error{ Cancelled, @@ -36,7 +37,7 @@ pub const DecoderStream = struct { return ret; } - pub fn next(self: *DecoderStream, next_token: i32) !?[]const u8 { + pub fn next(self: *DecoderStream, next_token: u32) !?[]const u8 { if (self.decoder.tokens().len >= TokensSize) { const tokens = self.decoder.tokens(); inline for (0..TokensSize - 1) |i| { @@ -54,7 +55,7 @@ pub const DecoderStream = struct { } for (1..self.last_tokens.len) |i| { if (std.mem.startsWith(u8, new_tokens, self.last_tokens[i..])) { - const toks = new_tokens[self.last_tokens.len - i..]; + const toks = new_tokens[self.last_tokens.len - i ..]; self.last_tokens = self.buffer[0..new_tokens.len]; @memcpy(self.last_tokens, new_tokens); return toks; @@ -88,10 +89,12 @@ pub const SentencePieceProcessor = opaque { c.std_vector_int_clear(self.vec); } - pub fn encode(self: *Encoder, input: []const u8) ![]const i32 { - const str = c.zig_slice{ .ptr = input.ptr, .len = @intCast(input.len), }; - try assertOk(c.SentencePieceProcessor_Encode(@ptrCast(self.inner), str, self.vec)); - return c.std_vector_int_data(self.vec)[0..c.std_vector_int_size(self.vec)]; + pub fn encode(self: *Encoder, input: []const u8) ![]const u32 { + try assertOk(c.SentencePieceProcessor_Encode(@ptrCast(self.inner), ffi.ZigSlice.from(input), self.vec)); + return ffi.ZigSlice.to(u32, .{ + .ptr = c.std_vector_int_data(self.vec), + .len = c.std_vector_int_size(self.vec), + }); } }; @@ -108,8 +111,8 @@ pub const SentencePieceProcessor = opaque { }; } - pub fn append(self: *Decoder, token: i32) void { - c.std_vector_int_push_back(self.vec, token); + pub fn append(self: *Decoder, token: u32) void { + c.std_vector_int_push_back(self.vec, @intCast(token)); } pub fn deinit(self: *Decoder) void { @@ -137,11 +140,11 @@ pub const SentencePieceProcessor = opaque { pub fn string(self: *const Decoder) []const u8 { const res = c.std_string_data(self.str); - return res.ptr[0..res.len]; + return ffi.ZigSlice.to(u8, res); } - pub fn tokens(self: *const Decoder) []i32 { - const ptr: [*c]i32 = @ptrCast(c.std_vector_int_data(self.vec)); + pub fn tokens(self: *const Decoder) []u32 { + const ptr: [*c]u32 = @ptrCast(c.std_vector_int_data(self.vec)); return ptr[0..c.std_vector_int_size(self.vec)]; } }; @@ -169,7 +172,6 @@ pub const SentencePieceProcessor = opaque { }; } - pub fn load(model: []const u8) !*SentencePieceProcessor { const sp: *SentencePieceProcessor = @ptrCast(c.SentencePieceProcessor_new()); errdefer sp.deinit(); @@ -182,7 +184,7 @@ pub const SentencePieceProcessor = opaque { } fn load_from(self: *SentencePieceProcessor, model: []const u8) !void { - try assertOk(c.SentencePieceProcessor_Load(@ptrCast(self), c.zig_slice{ .ptr = @constCast(model.ptr), .len = @intCast(model.len) })); + try assertOk(c.SentencePieceProcessor_Load(@ptrCast(self), ffi.ZigSlice.from(model))); } pub fn encoder(self: *SentencePieceProcessor) Encoder { @@ -241,16 +243,16 @@ pub fn main() !void { for (tokens) |token| { if (try stream.next(token)) |chunk| { // std.debug.print("{s}", .{chunk}); - std.debug.print("{d}us - {s}\n", .{start.lap() / std.time.ns_per_us, chunk}); + std.debug.print("{d}us - {s}\n", .{ start.lap() / std.time.ns_per_us, chunk }); } } // var start = try std.time.Timer.start(); - // var it = std.mem.window(i32, tokens, 3, 1); + // var it = std.mem.window(u32, tokens, 3, 1); // while (it.next()) |slice| { // if (decoder.tokens().len >= 4) { // const kept_tokens = decoder.tokens()[1..]; - // std.mem.copyForwards(i32, decoder.tokens()[0..kept_tokens.len], kept_tokens); + // std.mem.copyForwards(u32, decoder.tokens()[0..kept_tokens.len], kept_tokens); // kept_tokens[kept_tokens.len - 1] = slice[2]; // } else { // for (slice) |token| { @@ -279,9 +281,6 @@ pub fn main() !void { // const decoded = try decoder.decode(); // std.debug.print("Decoded: {s}\n", .{decoded}); - - - // const model = "/Users/steeve/Downloads/poolside.sp.pb"; // c.SentencePieceProcessor_LoadOrDie(sp, c.zig_slice{ .ptr = model.ptr, .len = model.len }); diff --git a/zml/tokenizer/sentencepiece/sentencepiece.i b/zml/tokenizer/sentencepiece/sentencepiece.i index 8608f357..bf67beb2 100644 --- a/zml/tokenizer/sentencepiece/sentencepiece.i +++ b/zml/tokenizer/sentencepiece/sentencepiece.i @@ -8,23 +8,19 @@ #include #include #include -#include "zml/tokenizer/sentencepiece/zig.h" +#include "ffi/zig_slice.h" %} -%extend std::vector { - T* data() { - return $self->data(); - }; -} - -%template(std_vector_int) std::vector; +%insert("cheader") %{ +#include "ffi/zig_slice.h" +%} %typemap(in) absl::string_view { - $1 = absl::string_view($input.ptr, $input.len); + $1 = absl::string_view((char *)$input.ptr, $input.len); } %typemap(out, optimal="1") const std::string& %{ - $result.ptr = (char *)($1->data()); + $result.ptr = (void *)($1->data()); $result.len = (size_t)($1->length()); %} %typemap(ctype) absl::string_view, const std::string& "zig_slice" @@ -45,6 +41,14 @@ namespace std { }; } +%extend std::vector { + T* data() { + return $self->data(); + }; +} + +%template(std_vector_int) std::vector; + %typemap(out) sentencepiece::util::Status %{ $result = $1.code(); %} diff --git a/zml/tokenizer/sentencepiece/sentencepiece.zig b/zml/tokenizer/sentencepiece/sentencepiece.zig index 133fce26..dadd8999 100644 --- a/zml/tokenizer/sentencepiece/sentencepiece.zig +++ b/zml/tokenizer/sentencepiece/sentencepiece.zig @@ -1,12 +1,158 @@ -pub const std = @import("std"); -pub const c = @import("c"); +const std = @import("std"); +const c = @import("c"); +const ffi = @import("ffi"); -pub const SentencePieceProcessor = opaque { - pub const create() *SentencePieceProcessor { - return @ptrCast(c.SentencePieceProcessor_new()); +const StringToTokenRatio = 3; + +pub const Error = error{ + Cancelled, + Unknown, + InvalidArgument, + DeadlineExceeded, + NotFound, + AlreadyExists, + PermissionDenied, + ResourceExhausted, + FailedPrecondition, + Aborted, + OutOfRange, + Unimplemented, + Internal, + Unavailable, + DataLoss, + Unauthenticated, +}; + +fn assertOk(code: c.sentencepiece_util_StatusCode) Error!void { + return switch (code) { + c.sentencepiece_util_StatusCode_kOk => {}, + c.sentencepiece_util_StatusCode_kCancelled => Error.Cancelled, + c.sentencepiece_util_StatusCode_kUnknown => Error.Unknown, + c.sentencepiece_util_StatusCode_kInvalidArgument => Error.InvalidArgument, + c.sentencepiece_util_StatusCode_kDeadlineExceeded => Error.DeadlineExceeded, + c.sentencepiece_util_StatusCode_kNotFound => Error.NotFound, + c.sentencepiece_util_StatusCode_kAlreadyExists => Error.AlreadyExists, + c.sentencepiece_util_StatusCode_kPermissionDenied => Error.PermissionDenied, + c.sentencepiece_util_StatusCode_kResourceExhausted => Error.ResourceExhausted, + c.sentencepiece_util_StatusCode_kFailedPrecondition => Error.FailedPrecondition, + c.sentencepiece_util_StatusCode_kAborted => Error.Aborted, + c.sentencepiece_util_StatusCode_kOutOfRange => Error.OutOfRange, + c.sentencepiece_util_StatusCode_kUnimplemented => Error.Unimplemented, + c.sentencepiece_util_StatusCode_kInternal => Error.Internal, + c.sentencepiece_util_StatusCode_kUnavailable => Error.Unavailable, + c.sentencepiece_util_StatusCode_kDataLoss => Error.DataLoss, + c.sentencepiece_util_StatusCode_kUnauthenticated => Error.Unauthenticated, + else => unreachable, + }; +} + +pub const Encoder = struct { + inner: *SentencePieceProcessor, + vec: *c.std_vector_int, + + fn init(inner: *SentencePieceProcessor) Encoder { + return .{ + .inner = inner, + .vec = c.std_vector_int_new() orelse unreachable, + }; } - pub const deinit(self: *SentencePieceProcessor) { + pub fn deinit(self: *Encoder) void { + c.std_vector_int_delete(self.vec); + } + + pub fn reset(self: *Encoder) void { + c.std_vector_int_clear(self.vec); + } + + pub fn encode(self: *Encoder, input: []const u8) ![]const u32 { + c.std_vector_int_reserve(self.vec, input.len / StringToTokenRatio); + try assertOk(c.SentencePieceProcessor_Encode(@ptrCast(self.inner), ffi.ZigSlice.from(input), self.vec)); + return self.ids(); + } + + pub fn ids(self: *const Encoder) []const u32 { + return ffi.ZigSlice.to(u32, .{ + .ptr = c.std_vector_int_data(self.vec), + .len = c.std_vector_int_size(self.vec), + }); + } +}; + +pub const Decoder = struct { + const TokensBufferSize = 4; + const StringBufferSize = 128; + + inner: *SentencePieceProcessor, + vec: *c.std_vector_int, + str: *c.std_string, + str_buffer: [StringBufferSize]u8 = undefined, + last_tokens: []u8 = &.{}, + + fn init(inner: *SentencePieceProcessor) !Decoder { + const vec = try (c.std_vector_int_new() orelse std.mem.Allocator.Error.OutOfMemory); + c.std_vector_int_reserve(vec, TokensBufferSize); + errdefer c.std_vector_int_delete(vec); + + const str = try (c.std_string_new() orelse std.mem.Allocator.Error.OutOfMemory); + c.std_string_reserve(str, StringBufferSize); + errdefer c.std_string_delete(str); + + return .{ + .inner = inner, + .vec = vec, + .str = str, + }; + } + + pub fn deinit(self: *Decoder) void { + c.std_vector_int_delete(self.vec); + c.std_string_delete(self.str); + } + + pub fn reset(self: *Decoder) void { + c.std_vector_int_clear(self.vec); + c.std_string_clear(self.str); + } + + pub fn decode(self: *Decoder, ids_: []const u32) ![]const u8 { + c.std_vector_int_reserve(self.vec, ids_.len); + c.std_string_reserve(self.str, ids_.len * StringToTokenRatio); + for (ids_) |id| { + c.std_vector_int_push_back(self.vec, @intCast(id)); + } + try assertOk(c.SentencePieceProcessor_Decode(@ptrCast(self.inner), self.vec, self.str)); + return self.string(); + } + + pub fn string(self: *const Decoder) []const u8 { + const res = c.std_string_data(self.str); + return ffi.ZigSlice.to(u8, res); + } + + fn ids(self: *const Decoder) []u32 { + const ptr: [*c]u32 = @ptrCast(c.std_vector_int_data(self.vec)); + return ptr[0..c.std_vector_int_size(self.vec)]; + } +}; + +pub const SentencePieceProcessor = opaque { + pub fn from_file(model: []const u8) !*SentencePieceProcessor { + const sp: *SentencePieceProcessor = @ptrCast(c.SentencePieceProcessor_new()); + errdefer sp.deinit(); + try assertOk(c.SentencePieceProcessor_Load(@ptrCast(sp), ffi.ZigSlice.from(model))); + return sp; + } + + pub fn deinit(self: *SentencePieceProcessor) void { c.SentencePieceProcessor_delete(@ptrCast(self)); + } + + pub fn encoder(self: *SentencePieceProcessor) !Encoder { + return Encoder.init(self); + } + + pub fn decoder(self: *SentencePieceProcessor) !Decoder { + return try Decoder.init(self); } }; diff --git a/zml/tokenizer/sentencepiece/zig.h b/zml/tokenizer/sentencepiece/zig.h deleted file mode 100644 index d1bcb0c1..00000000 --- a/zml/tokenizer/sentencepiece/zig.h +++ /dev/null @@ -1,9 +0,0 @@ -#pragma once - -#include - -typedef struct -{ - const char *ptr; - size_t len; -} zig_slice; diff --git a/zml/tokenizer/tokenizer.zig b/zml/tokenizer/tokenizer.zig index 09a04511..25e0b577 100644 --- a/zml/tokenizer/tokenizer.zig +++ b/zml/tokenizer/tokenizer.zig @@ -1,27 +1,106 @@ -pub const Tokenizer = struct { - pub const Decoder = struct { - pub fn step(self: *Decoder, token_id: u32) []const u8 { - return input; +const std = @import("std"); +const hftokenizers = @import("hftokenizers"); +const sentencepiece = @import("sentencepiece"); + +const Tokenizers = enum { + hftokenizers, + sentencepiece, +}; + +pub const Tokenizer = union(Tokenizers) { + pub const Encoder = union(Tokenizers) { + hftokenizers: hftokenizers.Encoder, + sentencepiece: sentencepiece.Encoder, + + pub fn deinit(self: *Encoder) void { + switch (self.*) { + inline else => |*v| v.deinit(), + } } - pub fn reset(self: *Decoder) void { - _ = self; // autofix + pub fn reset(self: *Encoder) void { + switch (self.*) { + inline else => |*v| v.reset(), + } + } + + pub fn encode(self: *Encoder, input: []const u8) ![]const u32 { + return switch (self.*) { + inline else => |*v| v.encode(input), + }; + } + + pub fn ids(self: Encoder) []const u32 { + return switch (self) { + inline else => |v| v.ids(), + }; } }; - pub fn init() Tokenizer { - return Tokenizer{}; + pub const Decoder = union(Tokenizers) { + hftokenizers: hftokenizers.Decoder, + sentencepiece: sentencepiece.Decoder, + + pub fn deinit(self: *Decoder) void { + switch (self.*) { + inline else => |*v| v.deinit(), + } + } + + pub fn reset(self: *Decoder) void { + switch (self.*) { + inline else => |*v| v.reset(), + } + } + + pub fn decode(self: *Decoder, ids_: []const u32) ![]const u8 { + return switch (self.*) { + inline else => |*v| v.decode(ids_), + }; + } + + pub fn string(self: Decoder) []const u8 { + return switch (self.*) { + inline else => |v| v.string(), + }; + } + + pub fn ids(self: Decoder) []u32 { + return switch (self.*) { + inline else => |v| v.ids(), + }; + } + }; + + hftokenizers: *hftokenizers.HFTokenizer, + sentencepiece: *sentencepiece.SentencePieceProcessor, + + pub fn from_file(allocator: std.mem.Allocator, model: []const u8) !Tokenizer { + _ = allocator; // autofix + if (std.mem.endsWith(u8, model, ".pb")) { + return .{ .sentencepiece = try sentencepiece.SentencePieceProcessor.from_file(model) }; + } + if (std.mem.endsWith(u8, model, ".json")) { + return .{ .hftokenizers = try hftokenizers.HFTokenizer.from_file(model) }; + } + return error.InvalidArgument; } - pub fn encode(self: *Tokenizer, input: []const u8) []const u32 { - _ = input; // autofix - _ = self; // autofix - return &.{}; + pub fn deinit(self: *Tokenizer) void { + switch (self.*) { + inline else => |t| t.deinit(), + } } - pub fn decode(self: *Tokenizer, input: []const u32) []const u8 { - _ = input; // autofix - _ = self; // autofix - return &.{}; + pub fn encoder(self: Tokenizer) !Encoder { + return switch (self) { + inline else => |v, tag| @unionInit(Encoder, @tagName(tag), try v.encoder()), + }; + } + + pub fn decoder(self: Tokenizer) !Decoder { + return switch (self) { + inline else => |v, tag| @unionInit(Decoder, @tagName(tag), try v.decoder()), + }; } }; From 4a9bdca7aaf8cda4fa1a82fae51606f14f8403a7 Mon Sep 17 00:00:00 2001 From: Steeve Morin Date: Sat, 28 Dec 2024 16:48:40 +0000 Subject: [PATCH 05/48] WIP --- examples/BUILD.bazel | 0 examples/MODULE.bazel.lock | 1065 ++++++++++++++++- examples/llama/main.zig | 102 +- .../sentencepiece.bazel | 2 +- zml/BUILD.bazel | 1 + zml/tokenizer/hftokenizers/hftokenizers.h | 4 +- zml/tokenizer/hftokenizers/hftokenizers.rs | 12 +- zml/tokenizer/hftokenizers/hftokenizers.zig | 34 +- zml/tokenizer/sentencepiece/sentencepiece.i | 5 +- zml/tokenizer/sentencepiece/sentencepiece.zig | 41 +- zml/tokenizer/tokenizer.zig | 12 + zml/zml.zig | 3 +- 12 files changed, 1186 insertions(+), 95 deletions(-) create mode 100644 examples/BUILD.bazel diff --git a/examples/BUILD.bazel b/examples/BUILD.bazel new file mode 100644 index 00000000..e69de29b diff --git a/examples/MODULE.bazel.lock b/examples/MODULE.bazel.lock index 43bf85db..55281f85 100644 --- a/examples/MODULE.bazel.lock +++ b/examples/MODULE.bazel.lock @@ -6,8 +6,14 @@ "https://bazel-registry.zml.ai/modules/abseil-cpp/20230125.1/MODULE.bazel": "not found", "https://bazel-registry.zml.ai/modules/abseil-cpp/20230802.0.bcr.1/MODULE.bazel": "not found", "https://bazel-registry.zml.ai/modules/abseil-cpp/20230802.0/MODULE.bazel": "not found", + "https://bazel-registry.zml.ai/modules/abseil-cpp/20230802.1/MODULE.bazel": "not found", "https://bazel-registry.zml.ai/modules/abseil-cpp/20240116.0/MODULE.bazel": "not found", + "https://bazel-registry.zml.ai/modules/abseil-cpp/20240116.1/MODULE.bazel": "not found", + "https://bazel-registry.zml.ai/modules/abseil-cpp/20240116.2/MODULE.bazel": "not found", + "https://bazel-registry.zml.ai/modules/abseil-cpp/20240722.0.bcr.2/MODULE.bazel": "not found", "https://bazel-registry.zml.ai/modules/apple_support/1.11.1/MODULE.bazel": "not found", + "https://bazel-registry.zml.ai/modules/apple_support/1.15.1/MODULE.bazel": "not found", + "https://bazel-registry.zml.ai/modules/apple_support/1.17.1/MODULE.bazel": "not found", "https://bazel-registry.zml.ai/modules/apple_support/1.5.0/MODULE.bazel": "not found", "https://bazel-registry.zml.ai/modules/aspect_bazel_lib/2.7.2/MODULE.bazel": "not found", "https://bazel-registry.zml.ai/modules/aspect_bazel_lib/2.7.9/MODULE.bazel": "not found", @@ -18,6 +24,11 @@ "https://bazel-registry.zml.ai/modules/bazel_features/1.1.1/MODULE.bazel": "not found", "https://bazel-registry.zml.ai/modules/bazel_features/1.10.0/MODULE.bazel": "not found", "https://bazel-registry.zml.ai/modules/bazel_features/1.11.0/MODULE.bazel": "not found", + "https://bazel-registry.zml.ai/modules/bazel_features/1.15.0/MODULE.bazel": "not found", + "https://bazel-registry.zml.ai/modules/bazel_features/1.17.0/MODULE.bazel": "not found", + "https://bazel-registry.zml.ai/modules/bazel_features/1.18.0/MODULE.bazel": "not found", + "https://bazel-registry.zml.ai/modules/bazel_features/1.19.0/MODULE.bazel": "not found", + "https://bazel-registry.zml.ai/modules/bazel_features/1.21.0/MODULE.bazel": "not found", "https://bazel-registry.zml.ai/modules/bazel_features/1.3.0/MODULE.bazel": "not found", "https://bazel-registry.zml.ai/modules/bazel_features/1.4.1/MODULE.bazel": "not found", "https://bazel-registry.zml.ai/modules/bazel_features/1.9.1/MODULE.bazel": "not found", @@ -30,6 +41,7 @@ "https://bazel-registry.zml.ai/modules/bazel_skylib/1.4.2/MODULE.bazel": "not found", "https://bazel-registry.zml.ai/modules/bazel_skylib/1.5.0/MODULE.bazel": "not found", "https://bazel-registry.zml.ai/modules/bazel_skylib/1.6.1/MODULE.bazel": "not found", + "https://bazel-registry.zml.ai/modules/bazel_skylib/1.7.0/MODULE.bazel": "not found", "https://bazel-registry.zml.ai/modules/bazel_skylib/1.7.1/MODULE.bazel": "not found", "https://bazel-registry.zml.ai/modules/buildifier_prebuilt/6.1.2/MODULE.bazel": "not found", "https://bazel-registry.zml.ai/modules/buildifier_prebuilt/7.3.1/MODULE.bazel": "not found", @@ -38,10 +50,13 @@ "https://bazel-registry.zml.ai/modules/googletest/1.11.0/MODULE.bazel": "not found", "https://bazel-registry.zml.ai/modules/googletest/1.14.0.bcr.1/MODULE.bazel": "not found", "https://bazel-registry.zml.ai/modules/googletest/1.14.0/MODULE.bazel": "not found", + "https://bazel-registry.zml.ai/modules/googletest/1.15.2/MODULE.bazel": "not found", "https://bazel-registry.zml.ai/modules/hermetic_cc_toolchain/3.1.0/MODULE.bazel": "not found", + "https://bazel-registry.zml.ai/modules/jsoncpp/1.9.5/MODULE.bazel": "not found", "https://bazel-registry.zml.ai/modules/libpfm/4.11.0/MODULE.bazel": "not found", "https://bazel-registry.zml.ai/modules/nlohmann_json/3.6.1/MODULE.bazel": "not found", "https://bazel-registry.zml.ai/modules/patchelf/0.18.0/MODULE.bazel": "not found", + "https://bazel-registry.zml.ai/modules/pcre2/10.43/MODULE.bazel": "not found", "https://bazel-registry.zml.ai/modules/platforms/0.0.10/MODULE.bazel": "not found", "https://bazel-registry.zml.ai/modules/platforms/0.0.4/MODULE.bazel": "not found", "https://bazel-registry.zml.ai/modules/platforms/0.0.5/MODULE.bazel": "not found", @@ -52,33 +67,50 @@ "https://bazel-registry.zml.ai/modules/protobuf/21.7/MODULE.bazel": "not found", "https://bazel-registry.zml.ai/modules/protobuf/23.1/MODULE.bazel": "not found", "https://bazel-registry.zml.ai/modules/protobuf/24.4/MODULE.bazel": "not found", + "https://bazel-registry.zml.ai/modules/protobuf/27.0/MODULE.bazel": "not found", + "https://bazel-registry.zml.ai/modules/protobuf/29.2/MODULE.bazel": "not found", "https://bazel-registry.zml.ai/modules/protobuf/3.19.0/MODULE.bazel": "not found", "https://bazel-registry.zml.ai/modules/protobuf/3.19.6/MODULE.bazel": "not found", "https://bazel-registry.zml.ai/modules/pybind11_bazel/2.11.1.bzl.1/MODULE.bazel": "not found", "https://bazel-registry.zml.ai/modules/pybind11_bazel/2.11.1/MODULE.bazel": "not found", + "https://bazel-registry.zml.ai/modules/pybind11_bazel/2.12.0/MODULE.bazel": "not found", "https://bazel-registry.zml.ai/modules/re2/2023-09-01/MODULE.bazel": "not found", "https://bazel-registry.zml.ai/modules/re2/2024-02-01/MODULE.bazel": "not found", + "https://bazel-registry.zml.ai/modules/re2/2024-07-02/MODULE.bazel": "not found", + "https://bazel-registry.zml.ai/modules/rules_android/0.1.1/MODULE.bazel": "not found", "https://bazel-registry.zml.ai/modules/rules_apple/3.2.1/MODULE.bazel": "not found", "https://bazel-registry.zml.ai/modules/rules_cc/0.0.1/MODULE.bazel": "not found", + "https://bazel-registry.zml.ai/modules/rules_cc/0.0.10/MODULE.bazel": "not found", + "https://bazel-registry.zml.ai/modules/rules_cc/0.0.16/MODULE.bazel": "not found", + "https://bazel-registry.zml.ai/modules/rules_cc/0.0.17/MODULE.bazel": "not found", "https://bazel-registry.zml.ai/modules/rules_cc/0.0.2/MODULE.bazel": "not found", "https://bazel-registry.zml.ai/modules/rules_cc/0.0.6/MODULE.bazel": "not found", "https://bazel-registry.zml.ai/modules/rules_cc/0.0.8/MODULE.bazel": "not found", "https://bazel-registry.zml.ai/modules/rules_cc/0.0.9/MODULE.bazel": "not found", "https://bazel-registry.zml.ai/modules/rules_distroless/0.3.8/MODULE.bazel": "not found", "https://bazel-registry.zml.ai/modules/rules_foreign_cc/0.9.0/MODULE.bazel": "not found", + "https://bazel-registry.zml.ai/modules/rules_fuzzing/0.5.2/MODULE.bazel": "not found", "https://bazel-registry.zml.ai/modules/rules_java/4.0.0/MODULE.bazel": "not found", "https://bazel-registry.zml.ai/modules/rules_java/5.3.5/MODULE.bazel": "not found", "https://bazel-registry.zml.ai/modules/rules_java/6.3.0/MODULE.bazel": "not found", + "https://bazel-registry.zml.ai/modules/rules_java/6.5.2/MODULE.bazel": "not found", "https://bazel-registry.zml.ai/modules/rules_java/7.1.0/MODULE.bazel": "not found", + "https://bazel-registry.zml.ai/modules/rules_java/7.10.0/MODULE.bazel": "not found", + "https://bazel-registry.zml.ai/modules/rules_java/7.12.2/MODULE.bazel": "not found", + "https://bazel-registry.zml.ai/modules/rules_java/7.2.0/MODULE.bazel": "not found", "https://bazel-registry.zml.ai/modules/rules_java/7.3.2/MODULE.bazel": "not found", + "https://bazel-registry.zml.ai/modules/rules_java/7.6.1/MODULE.bazel": "not found", "https://bazel-registry.zml.ai/modules/rules_java/7.6.5/MODULE.bazel": "not found", "https://bazel-registry.zml.ai/modules/rules_jvm_external/4.4.2/MODULE.bazel": "not found", "https://bazel-registry.zml.ai/modules/rules_jvm_external/5.1/MODULE.bazel": "not found", "https://bazel-registry.zml.ai/modules/rules_jvm_external/5.2/MODULE.bazel": "not found", + "https://bazel-registry.zml.ai/modules/rules_jvm_external/6.3/MODULE.bazel": "not found", + "https://bazel-registry.zml.ai/modules/rules_kotlin/1.9.6/MODULE.bazel": "not found", "https://bazel-registry.zml.ai/modules/rules_license/0.0.3/MODULE.bazel": "not found", "https://bazel-registry.zml.ai/modules/rules_license/0.0.4/MODULE.bazel": "not found", "https://bazel-registry.zml.ai/modules/rules_license/0.0.7/MODULE.bazel": "not found", "https://bazel-registry.zml.ai/modules/rules_license/0.0.8/MODULE.bazel": "not found", + "https://bazel-registry.zml.ai/modules/rules_license/1.0.0/MODULE.bazel": "not found", "https://bazel-registry.zml.ai/modules/rules_multitool/0.4.0/MODULE.bazel": "not found", "https://bazel-registry.zml.ai/modules/rules_oci/2.0.0/MODULE.bazel": "not found", "https://bazel-registry.zml.ai/modules/rules_pkg/0.7.0/MODULE.bazel": "not found", @@ -90,18 +122,25 @@ "https://bazel-registry.zml.ai/modules/rules_proto/6.0.2/MODULE.bazel": "not found", "https://bazel-registry.zml.ai/modules/rules_python/0.10.2/MODULE.bazel": "not found", "https://bazel-registry.zml.ai/modules/rules_python/0.22.1/MODULE.bazel": "not found", + "https://bazel-registry.zml.ai/modules/rules_python/0.23.1/MODULE.bazel": "not found", "https://bazel-registry.zml.ai/modules/rules_python/0.25.0/MODULE.bazel": "not found", + "https://bazel-registry.zml.ai/modules/rules_python/0.28.0/MODULE.bazel": "not found", "https://bazel-registry.zml.ai/modules/rules_python/0.29.0/MODULE.bazel": "not found", "https://bazel-registry.zml.ai/modules/rules_python/0.31.0/MODULE.bazel": "not found", + "https://bazel-registry.zml.ai/modules/rules_python/0.33.2/MODULE.bazel": "not found", "https://bazel-registry.zml.ai/modules/rules_python/0.34.0/MODULE.bazel": "not found", "https://bazel-registry.zml.ai/modules/rules_python/0.37.0/MODULE.bazel": "not found", "https://bazel-registry.zml.ai/modules/rules_python/0.4.0/MODULE.bazel": "not found", + "https://bazel-registry.zml.ai/modules/rules_rust/0.56.0/MODULE.bazel": "not found", + "https://bazel-registry.zml.ai/modules/rules_shell/0.2.0/MODULE.bazel": "not found", + "https://bazel-registry.zml.ai/modules/rules_shell/0.3.0/MODULE.bazel": "not found", "https://bazel-registry.zml.ai/modules/rules_swift/1.15.1/MODULE.bazel": "not found", "https://bazel-registry.zml.ai/modules/rules_uv/0.34.0/MODULE.bazel": "not found", "https://bazel-registry.zml.ai/modules/stardoc/0.5.1/MODULE.bazel": "not found", "https://bazel-registry.zml.ai/modules/stardoc/0.5.3/MODULE.bazel": "not found", "https://bazel-registry.zml.ai/modules/stardoc/0.5.4/MODULE.bazel": "not found", "https://bazel-registry.zml.ai/modules/stardoc/0.6.2/MODULE.bazel": "not found", + "https://bazel-registry.zml.ai/modules/stardoc/0.7.0/MODULE.bazel": "not found", "https://bazel-registry.zml.ai/modules/upb/0.0.0-20220923-a547704/MODULE.bazel": "not found", "https://bazel-registry.zml.ai/modules/upb/0.0.0-20230516-61a97ef/MODULE.bazel": "not found", "https://bazel-registry.zml.ai/modules/with_cfg.bzl/0.5.0/MODULE.bazel": "not found", @@ -109,6 +148,7 @@ "https://bazel-registry.zml.ai/modules/zlib/1.2.12/MODULE.bazel": "not found", "https://bazel-registry.zml.ai/modules/zlib/1.2.13/MODULE.bazel": "not found", "https://bazel-registry.zml.ai/modules/zlib/1.3.1.bcr.3/MODULE.bazel": "not found", + "https://bazel-registry.zml.ai/modules/zlib/1.3.1/MODULE.bazel": "not found", "https://bazel-registry.zml.ai/modules/zstd/1.5.6/MODULE.bazel": "not found", "https://bcr.bazel.build/bazel_registry.json": "8a28e4aff06ee60aed2a8c281907fb8bcbf3b753c91fb5a5c57da3215d5b3497", "https://bcr.bazel.build/modules/abseil-cpp/20210324.2/MODULE.bazel": "7cd0312e064fde87c8d1cd79ba06c876bd23630c83466e9500321be55c96ace2", @@ -116,10 +156,16 @@ "https://bcr.bazel.build/modules/abseil-cpp/20230125.1/MODULE.bazel": "89047429cb0207707b2dface14ba7f8df85273d484c2572755be4bab7ce9c3a0", "https://bcr.bazel.build/modules/abseil-cpp/20230802.0.bcr.1/MODULE.bazel": "1c8cec495288dccd14fdae6e3f95f772c1c91857047a098fad772034264cc8cb", "https://bcr.bazel.build/modules/abseil-cpp/20230802.0/MODULE.bazel": "d253ae36a8bd9ee3c5955384096ccb6baf16a1b1e93e858370da0a3b94f77c16", + "https://bcr.bazel.build/modules/abseil-cpp/20230802.1/MODULE.bazel": "fa92e2eb41a04df73cdabeec37107316f7e5272650f81d6cc096418fe647b915", "https://bcr.bazel.build/modules/abseil-cpp/20240116.0/MODULE.bazel": "98dc378d64c12a4e4741ad3362f87fb737ee6a0886b2d90c3cdbb4d93ea3e0bf", - "https://bcr.bazel.build/modules/abseil-cpp/20240116.0/source.json": "251927429731bd37831facad38ddfc83b8f6f680f819e1d4d35e811b30479d5b", + "https://bcr.bazel.build/modules/abseil-cpp/20240116.1/MODULE.bazel": "37bcdb4440fbb61df6a1c296ae01b327f19e9bb521f9b8e26ec854b6f97309ed", + "https://bcr.bazel.build/modules/abseil-cpp/20240116.2/MODULE.bazel": "73939767a4686cd9a520d16af5ab440071ed75cec1a876bf2fcfaf1f71987a16", + "https://bcr.bazel.build/modules/abseil-cpp/20240722.0.bcr.2/MODULE.bazel": "c3661b44c9d3f17f0b65ffb544896aaeb89127398ea867537babac18133a002a", + "https://bcr.bazel.build/modules/abseil-cpp/20240722.0.bcr.2/source.json": "464f3012c8f40cd51facbfc6962563971c6bd55f45ba16bd98313f2de73340c5", "https://bcr.bazel.build/modules/apple_support/1.11.1/MODULE.bazel": "1843d7cd8a58369a444fc6000e7304425fba600ff641592161d9f15b179fb896", - "https://bcr.bazel.build/modules/apple_support/1.11.1/source.json": "c797537544f4b76d46d12f488456529d7372b6ccff249c82fca50ce0a665957f", + "https://bcr.bazel.build/modules/apple_support/1.15.1/MODULE.bazel": "a0556fefca0b1bb2de8567b8827518f94db6a6e7e7d632b4c48dc5f865bc7c85", + "https://bcr.bazel.build/modules/apple_support/1.17.1/MODULE.bazel": "655c922ab1209978a94ef6ca7d9d43e940cd97d9c172fb55f94d91ac53f8610b", + "https://bcr.bazel.build/modules/apple_support/1.17.1/source.json": "6b2b8c74d14e8d485528a938e44bdb72a5ba17632b9e14ef6e68a5ee96c8347f", "https://bcr.bazel.build/modules/apple_support/1.5.0/MODULE.bazel": "50341a62efbc483e8a2a6aec30994a58749bd7b885e18dd96aa8c33031e558ef", "https://bcr.bazel.build/modules/aspect_bazel_lib/2.7.2/MODULE.bazel": "780d1a6522b28f5edb7ea09630748720721dfe27690d65a2d33aa7509de77e07", "https://bcr.bazel.build/modules/aspect_bazel_lib/2.7.9/MODULE.bazel": "06e54f2b345b8eb7adceed2329b273da00d0368e28a9ebd9dfc75b4a052dac85", @@ -132,7 +178,12 @@ "https://bcr.bazel.build/modules/bazel_features/1.1.1/MODULE.bazel": "27b8c79ef57efe08efccbd9dd6ef70d61b4798320b8d3c134fd571f78963dbcd", "https://bcr.bazel.build/modules/bazel_features/1.10.0/MODULE.bazel": "f75e8807570484a99be90abcd52b5e1f390362c258bcb73106f4544957a48101", "https://bcr.bazel.build/modules/bazel_features/1.11.0/MODULE.bazel": "f9382337dd5a474c3b7d334c2f83e50b6eaedc284253334cf823044a26de03e8", - "https://bcr.bazel.build/modules/bazel_features/1.11.0/source.json": "c9320aa53cd1c441d24bd6b716da087ad7e4ff0d9742a9884587596edfe53015", + "https://bcr.bazel.build/modules/bazel_features/1.15.0/MODULE.bazel": "d38ff6e517149dc509406aca0db3ad1efdd890a85e049585b7234d04238e2a4d", + "https://bcr.bazel.build/modules/bazel_features/1.17.0/MODULE.bazel": "039de32d21b816b47bd42c778e0454217e9c9caac4a3cf8e15c7231ee3ddee4d", + "https://bcr.bazel.build/modules/bazel_features/1.18.0/MODULE.bazel": "1be0ae2557ab3a72a57aeb31b29be347bcdc5d2b1eb1e70f39e3851a7e97041a", + "https://bcr.bazel.build/modules/bazel_features/1.19.0/MODULE.bazel": "59adcdf28230d220f0067b1f435b8537dd033bfff8db21335ef9217919c7fb58", + "https://bcr.bazel.build/modules/bazel_features/1.21.0/MODULE.bazel": "675642261665d8eea09989aa3b8afb5c37627f1be178382c320d1b46afba5e3b", + "https://bcr.bazel.build/modules/bazel_features/1.21.0/source.json": "3e8379efaaef53ce35b7b8ba419df829315a880cb0a030e5bb45c96d6d5ecb5f", "https://bcr.bazel.build/modules/bazel_features/1.3.0/MODULE.bazel": "cdcafe83ec318cda34e02948e81d790aab8df7a929cec6f6969f13a489ccecd9", "https://bcr.bazel.build/modules/bazel_features/1.4.1/MODULE.bazel": "e45b6bb2350aff3e442ae1111c555e27eac1d915e77775f6fdc4b351b758b5d7", "https://bcr.bazel.build/modules/bazel_features/1.9.1/MODULE.bazel": "8f679097876a9b609ad1f60249c49d68bfab783dd9be012faf9d82547b14815a", @@ -145,6 +196,7 @@ "https://bcr.bazel.build/modules/bazel_skylib/1.4.2/MODULE.bazel": "3bd40978e7a1fac911d5989e6b09d8f64921865a45822d8b09e815eaa726a651", "https://bcr.bazel.build/modules/bazel_skylib/1.5.0/MODULE.bazel": "32880f5e2945ce6a03d1fbd588e9198c0a959bb42297b2cfaf1685b7bc32e138", "https://bcr.bazel.build/modules/bazel_skylib/1.6.1/MODULE.bazel": "8fdee2dbaace6c252131c00e1de4b165dc65af02ea278476187765e1a617b917", + "https://bcr.bazel.build/modules/bazel_skylib/1.7.0/MODULE.bazel": "0db596f4563de7938de764cc8deeabec291f55e8ec15299718b93c4423e9796d", "https://bcr.bazel.build/modules/bazel_skylib/1.7.1/MODULE.bazel": "3120d80c5861aa616222ec015332e5f8d3171e062e3e804a2a0253e1be26e59b", "https://bcr.bazel.build/modules/bazel_skylib/1.7.1/source.json": "f121b43eeefc7c29efbd51b83d08631e2347297c95aac9764a701f2a6a2bb953", "https://bcr.bazel.build/modules/buildifier_prebuilt/6.1.2/MODULE.bazel": "2ef4962c8b0b6d8d21928a89190755619254459bc67f870dc0ccb9ba9952d444", @@ -155,15 +207,20 @@ "https://bcr.bazel.build/modules/google_benchmark/1.8.2/MODULE.bazel": "a70cf1bba851000ba93b58ae2f6d76490a9feb74192e57ab8e8ff13c34ec50cb", "https://bcr.bazel.build/modules/googletest/1.11.0/MODULE.bazel": "3a83f095183f66345ca86aa13c58b59f9f94a2f81999c093d4eeaa2d262d12f4", "https://bcr.bazel.build/modules/googletest/1.14.0.bcr.1/MODULE.bazel": "22c31a561553727960057361aa33bf20fb2e98584bc4fec007906e27053f80c6", - "https://bcr.bazel.build/modules/googletest/1.14.0.bcr.1/source.json": "41e9e129f80d8c8bf103a7acc337b76e54fad1214ac0a7084bf24f4cd924b8b4", "https://bcr.bazel.build/modules/googletest/1.14.0/MODULE.bazel": "cfbcbf3e6eac06ef9d85900f64424708cc08687d1b527f0ef65aa7517af8118f", + "https://bcr.bazel.build/modules/googletest/1.15.2/MODULE.bazel": "6de1edc1d26cafb0ea1a6ab3f4d4192d91a312fd2d360b63adaa213cd00b2108", + "https://bcr.bazel.build/modules/googletest/1.15.2/source.json": "dbdda654dcb3a0d7a8bc5d0ac5fc7e150b58c2a986025ae5bc634bb2cb61f470", "https://bcr.bazel.build/modules/hermetic_cc_toolchain/3.1.0/MODULE.bazel": "ea4b3a25a9417a7db57a8a2f9ebdee91d679823c6274b482b817ed128d81c594", "https://bcr.bazel.build/modules/hermetic_cc_toolchain/3.1.0/source.json": "9d1df0459caefdf41052d360469922a73e219f67c8ce4da0628cc604469822b9", + "https://bcr.bazel.build/modules/jsoncpp/1.9.5/MODULE.bazel": "31271aedc59e815656f5736f282bb7509a97c7ecb43e927ac1a37966e0578075", + "https://bcr.bazel.build/modules/jsoncpp/1.9.5/source.json": "4108ee5085dd2885a341c7fab149429db457b3169b86eb081fa245eadf69169d", "https://bcr.bazel.build/modules/libpfm/4.11.0/MODULE.bazel": "45061ff025b301940f1e30d2c16bea596c25b176c8b6b3087e92615adbd52902", "https://bcr.bazel.build/modules/nlohmann_json/3.6.1/MODULE.bazel": "6f7b417dcc794d9add9e556673ad25cb3ba835224290f4f848f8e2db1e1fca74", "https://bcr.bazel.build/modules/nlohmann_json/3.6.1/source.json": "f448c6e8963fdfa7eb831457df83ad63d3d6355018f6574fb017e8169deb43a9", "https://bcr.bazel.build/modules/patchelf/0.18.0/MODULE.bazel": "15a6beff7e828d585c5bd0f9f93589df117b5594e9d19e43096c77de58b9ae5f", "https://bcr.bazel.build/modules/patchelf/0.18.0/source.json": "57caf6bcaa5ba515c6fb1c2eacee00735afbeb1ffacb34a57553fb139c8e4333", + "https://bcr.bazel.build/modules/pcre2/10.43/MODULE.bazel": "08eaa025111bd0fedc14a8187c2905fa6ee4501fbe558193e9bf6cc3e2cdf23c", + "https://bcr.bazel.build/modules/pcre2/10.43/source.json": "8b4149e707094f1d5b57df7216539c3415226e814085c4d960bd9f3d49581b88", "https://bcr.bazel.build/modules/platforms/0.0.10/MODULE.bazel": "8cb8efaf200bdeb2150d93e162c40f388529a25852b332cec879373771e48ed5", "https://bcr.bazel.build/modules/platforms/0.0.10/source.json": "f22828ff4cf021a6b577f1bf6341cb9dcd7965092a439f64fc1bb3b7a5ae4bd5", "https://bcr.bazel.build/modules/platforms/0.0.4/MODULE.bazel": "9b328e31ee156f53f3c416a64f8491f7eb731742655a47c9eec4703a71644aee", @@ -175,42 +232,62 @@ "https://bcr.bazel.build/modules/protobuf/21.7/MODULE.bazel": "a5a29bb89544f9b97edce05642fac225a808b5b7be74038ea3640fae2f8e66a7", "https://bcr.bazel.build/modules/protobuf/23.1/MODULE.bazel": "88b393b3eb4101d18129e5db51847cd40a5517a53e81216144a8c32dfeeca52a", "https://bcr.bazel.build/modules/protobuf/24.4/MODULE.bazel": "7bc7ce5f2abf36b3b7b7c8218d3acdebb9426aeb35c2257c96445756f970eb12", - "https://bcr.bazel.build/modules/protobuf/24.4/source.json": "ace4b8c65d4cfe64efe544f09fc5e5df77faf3a67fbb29c5341e0d755d9b15d6", + "https://bcr.bazel.build/modules/protobuf/27.0/MODULE.bazel": "7873b60be88844a0a1d8f80b9d5d20cfbd8495a689b8763e76c6372998d3f64c", + "https://bcr.bazel.build/modules/protobuf/29.2/MODULE.bazel": "5435497c190d86f79b0568698c45044df7c8d97692886cda9fe9cf9053aea712", + "https://bcr.bazel.build/modules/protobuf/29.2/source.json": "fe7090cc34072609b26d9beafb122916dabc1d47ba61b242c26c4b06c51384ab", "https://bcr.bazel.build/modules/protobuf/3.19.0/MODULE.bazel": "6b5fbb433f760a99a22b18b6850ed5784ef0e9928a72668b66e4d7ccd47db9b0", "https://bcr.bazel.build/modules/protobuf/3.19.6/MODULE.bazel": "9233edc5e1f2ee276a60de3eaa47ac4132302ef9643238f23128fea53ea12858", "https://bcr.bazel.build/modules/pybind11_bazel/2.11.1.bzl.1/MODULE.bazel": "1ef2994c097ee88f8f7ae8fbf991aaefb0603b2540fe575eca14943bc9f220a6", - "https://bcr.bazel.build/modules/pybind11_bazel/2.11.1.bzl.1/source.json": "d8f5b2ebc186b90c6112f92f43d86359dda2c3649c754d9680fd668f8dd28a79", "https://bcr.bazel.build/modules/pybind11_bazel/2.11.1/MODULE.bazel": "88af1c246226d87e65be78ed49ecd1e6f5e98648558c14ce99176da041dc378e", + "https://bcr.bazel.build/modules/pybind11_bazel/2.12.0/MODULE.bazel": "e6f4c20442eaa7c90d7190d8dc539d0ab422f95c65a57cc59562170c58ae3d34", + "https://bcr.bazel.build/modules/pybind11_bazel/2.12.0/source.json": "6900fdc8a9e95866b8c0d4ad4aba4d4236317b5c1cd04c502df3f0d33afed680", "https://bcr.bazel.build/modules/re2/2023-09-01/MODULE.bazel": "cb3d511531b16cfc78a225a9e2136007a48cf8a677e4264baeab57fe78a80206", "https://bcr.bazel.build/modules/re2/2024-02-01/MODULE.bazel": "5ed922cb8b6c110e30969695e73bd0d3159576bf17ce8ee2443a7d07bf500551", - "https://bcr.bazel.build/modules/re2/2024-02-01/source.json": "0b108d5e9836cb66815fbbb70e4395eab52dc29dd2c39a9785f01d6661a8f37e", + "https://bcr.bazel.build/modules/re2/2024-07-02/MODULE.bazel": "0eadc4395959969297cbcf31a249ff457f2f1d456228c67719480205aa306daa", + "https://bcr.bazel.build/modules/re2/2024-07-02/source.json": "547d0111a9d4f362db32196fef805abbf3676e8d6afbe44d395d87816c1130ca", + "https://bcr.bazel.build/modules/rules_android/0.1.1/MODULE.bazel": "48809ab0091b07ad0182defb787c4c5328bd3a278938415c00a7b69b50c4d3a8", + "https://bcr.bazel.build/modules/rules_android/0.1.1/source.json": "e6986b41626ee10bdc864937ffb6d6bf275bb5b9c65120e6137d56e6331f089e", "https://bcr.bazel.build/modules/rules_apple/3.2.1/MODULE.bazel": "55f19b572fdb4a4bd5a1c2231b60c663f8b4e3146769062b2bdeba72226c74b7", "https://bcr.bazel.build/modules/rules_apple/3.2.1/source.json": "b7e8aa85c5fcd9dfec8ea62642b7e93ca161a03b2c403ae05872813f5dfeb7be", "https://bcr.bazel.build/modules/rules_cc/0.0.1/MODULE.bazel": "cb2aa0747f84c6c3a78dad4e2049c154f08ab9d166b1273835a8174940365647", + "https://bcr.bazel.build/modules/rules_cc/0.0.10/MODULE.bazel": "ec1705118f7eaedd6e118508d3d26deba2a4e76476ada7e0e3965211be012002", + "https://bcr.bazel.build/modules/rules_cc/0.0.16/MODULE.bazel": "7661303b8fc1b4d7f532e54e9d6565771fea666fbdf839e0a86affcd02defe87", + "https://bcr.bazel.build/modules/rules_cc/0.0.17/MODULE.bazel": "2ae1d8f4238ec67d7185d8861cb0a2cdf4bc608697c331b95bf990e69b62e64a", + "https://bcr.bazel.build/modules/rules_cc/0.0.17/source.json": "4db99b3f55c90ab28d14552aa0632533e3e8e5e9aea0f5c24ac0014282c2a7c5", "https://bcr.bazel.build/modules/rules_cc/0.0.2/MODULE.bazel": "6915987c90970493ab97393024c156ea8fb9f3bea953b2f3ec05c34f19b5695c", "https://bcr.bazel.build/modules/rules_cc/0.0.6/MODULE.bazel": "abf360251023dfe3efcef65ab9d56beefa8394d4176dd29529750e1c57eaa33f", "https://bcr.bazel.build/modules/rules_cc/0.0.8/MODULE.bazel": "964c85c82cfeb6f3855e6a07054fdb159aced38e99a5eecf7bce9d53990afa3e", "https://bcr.bazel.build/modules/rules_cc/0.0.9/MODULE.bazel": "836e76439f354b89afe6a911a7adf59a6b2518fafb174483ad78a2a2fde7b1c5", - "https://bcr.bazel.build/modules/rules_cc/0.0.9/source.json": "1f1ba6fea244b616de4a554a0f4983c91a9301640c8fe0dd1d410254115c8430", "https://bcr.bazel.build/modules/rules_distroless/0.3.8/MODULE.bazel": "7d7cf5b71d0f05ea30308c379ee7c3e69caddb2c94878796799333ffcd6aa840", "https://bcr.bazel.build/modules/rules_distroless/0.3.8/source.json": "a2421c594d7685202be9a18e89e88fb0c8e1acfea55d0e0cf0452244cb1bf250", "https://bcr.bazel.build/modules/rules_foreign_cc/0.9.0/MODULE.bazel": "c9e8c682bf75b0e7c704166d79b599f93b72cfca5ad7477df596947891feeef6", + "https://bcr.bazel.build/modules/rules_fuzzing/0.5.2/MODULE.bazel": "40c97d1144356f52905566c55811f13b299453a14ac7769dfba2ac38192337a8", + "https://bcr.bazel.build/modules/rules_fuzzing/0.5.2/source.json": "c8b1e2c717646f1702290959a3302a178fb639d987ab61d548105019f11e527e", "https://bcr.bazel.build/modules/rules_java/4.0.0/MODULE.bazel": "5a78a7ae82cd1a33cef56dc578c7d2a46ed0dca12643ee45edbb8417899e6f74", "https://bcr.bazel.build/modules/rules_java/5.3.5/MODULE.bazel": "a4ec4f2db570171e3e5eb753276ee4b389bae16b96207e9d3230895c99644b86", "https://bcr.bazel.build/modules/rules_java/6.3.0/MODULE.bazel": "a97c7678c19f236a956ad260d59c86e10a463badb7eb2eda787490f4c969b963", + "https://bcr.bazel.build/modules/rules_java/6.5.2/MODULE.bazel": "1d440d262d0e08453fa0c4d8f699ba81609ed0e9a9a0f02cd10b3e7942e61e31", "https://bcr.bazel.build/modules/rules_java/7.1.0/MODULE.bazel": "30d9135a2b6561c761bd67bd4990da591e6bdc128790ce3e7afd6a3558b2fb64", + "https://bcr.bazel.build/modules/rules_java/7.10.0/MODULE.bazel": "530c3beb3067e870561739f1144329a21c851ff771cd752a49e06e3dc9c2e71a", + "https://bcr.bazel.build/modules/rules_java/7.12.2/MODULE.bazel": "579c505165ee757a4280ef83cda0150eea193eed3bef50b1004ba88b99da6de6", + "https://bcr.bazel.build/modules/rules_java/7.12.2/source.json": "b0890f9cda8ff1b8e691a3ac6037b5c14b7fd4134765a3946b89f31ea02e5884", + "https://bcr.bazel.build/modules/rules_java/7.2.0/MODULE.bazel": "06c0334c9be61e6cef2c8c84a7800cef502063269a5af25ceb100b192453d4ab", "https://bcr.bazel.build/modules/rules_java/7.3.2/MODULE.bazel": "50dece891cfdf1741ea230d001aa9c14398062f2b7c066470accace78e412bc2", + "https://bcr.bazel.build/modules/rules_java/7.6.1/MODULE.bazel": "2f14b7e8a1aa2f67ae92bc69d1ec0fa8d9f827c4e17ff5e5f02e91caa3b2d0fe", "https://bcr.bazel.build/modules/rules_java/7.6.5/MODULE.bazel": "481164be5e02e4cab6e77a36927683263be56b7e36fef918b458d7a8a1ebadb1", - "https://bcr.bazel.build/modules/rules_java/7.6.5/source.json": "a805b889531d1690e3c72a7a7e47a870d00323186a9904b36af83aa3d053ee8d", "https://bcr.bazel.build/modules/rules_jvm_external/4.4.2/MODULE.bazel": "a56b85e418c83eb1839819f0b515c431010160383306d13ec21959ac412d2fe7", "https://bcr.bazel.build/modules/rules_jvm_external/5.1/MODULE.bazel": "33f6f999e03183f7d088c9be518a63467dfd0be94a11d0055fe2d210f89aa909", "https://bcr.bazel.build/modules/rules_jvm_external/5.2/MODULE.bazel": "d9351ba35217ad0de03816ef3ed63f89d411349353077348a45348b096615036", - "https://bcr.bazel.build/modules/rules_jvm_external/5.2/source.json": "10572111995bc349ce31c78f74b3c147f6b3233975c7fa5eff9211f6db0d34d9", + "https://bcr.bazel.build/modules/rules_jvm_external/6.3/MODULE.bazel": "c998e060b85f71e00de5ec552019347c8bca255062c990ac02d051bb80a38df0", + "https://bcr.bazel.build/modules/rules_jvm_external/6.3/source.json": "6f5f5a5a4419ae4e37c35a5bb0a6ae657ed40b7abc5a5189111b47fcebe43197", + "https://bcr.bazel.build/modules/rules_kotlin/1.9.6/MODULE.bazel": "d269a01a18ee74d0335450b10f62c9ed81f2321d7958a2934e44272fe82dcef3", + "https://bcr.bazel.build/modules/rules_kotlin/1.9.6/source.json": "2faa4794364282db7c06600b7e5e34867a564ae91bda7cae7c29c64e9466b7d5", "https://bcr.bazel.build/modules/rules_license/0.0.3/MODULE.bazel": "627e9ab0247f7d1e05736b59dbb1b6871373de5ad31c3011880b4133cafd4bd0", "https://bcr.bazel.build/modules/rules_license/0.0.4/MODULE.bazel": "6a88dd22800cf1f9f79ba32cacad0d3a423ed28efa2c2ed5582eaa78dd3ac1e5", "https://bcr.bazel.build/modules/rules_license/0.0.7/MODULE.bazel": "088fbeb0b6a419005b89cf93fe62d9517c0a2b8bb56af3244af65ecfe37e7d5d", "https://bcr.bazel.build/modules/rules_license/0.0.8/MODULE.bazel": "5669c6fe49b5134dbf534db681ad3d67a2d49cfc197e4a95f1ca2fd7f3aebe96", - "https://bcr.bazel.build/modules/rules_license/0.0.8/source.json": "ccfd3964cd0cd1739202efb8dbf9a06baab490e61e174b2ad4790f9c4e610beb", + "https://bcr.bazel.build/modules/rules_license/1.0.0/MODULE.bazel": "a7fda60eefdf3d8c827262ba499957e4df06f659330bbe6cdbdb975b768bb65c", + "https://bcr.bazel.build/modules/rules_license/1.0.0/source.json": "a52c89e54cc311196e478f8382df91c15f7a2bfdf4c6cd0e2675cc2ff0b56efb", "https://bcr.bazel.build/modules/rules_multitool/0.4.0/MODULE.bazel": "15517987d5c00c9e7faab41fbe22ee67a350b6eabcc1e08baded5c6d9025897f", "https://bcr.bazel.build/modules/rules_multitool/0.4.0/source.json": "d73b450b7c6d9683e400d6cebc463fbc2b870cc5d8e2e75080d6278805aaab08", "https://bcr.bazel.build/modules/rules_oci/2.0.0/MODULE.bazel": "5d5cf1932238b009f874d5a9f214bbedf5d8cec8e5028e083f1147726876572f", @@ -226,13 +303,21 @@ "https://bcr.bazel.build/modules/rules_proto/6.0.2/source.json": "17a2e195f56cb28d6bbf763e49973d13890487c6945311ed141e196fb660426d", "https://bcr.bazel.build/modules/rules_python/0.10.2/MODULE.bazel": "cc82bc96f2997baa545ab3ce73f196d040ffb8756fd2d66125a530031cd90e5f", "https://bcr.bazel.build/modules/rules_python/0.22.1/MODULE.bazel": "26114f0c0b5e93018c0c066d6673f1a2c3737c7e90af95eff30cfee38d0bbac7", + "https://bcr.bazel.build/modules/rules_python/0.23.1/MODULE.bazel": "49ffccf0511cb8414de28321f5fcf2a31312b47c40cc21577144b7447f2bf300", "https://bcr.bazel.build/modules/rules_python/0.25.0/MODULE.bazel": "72f1506841c920a1afec76975b35312410eea3aa7b63267436bfb1dd91d2d382", + "https://bcr.bazel.build/modules/rules_python/0.28.0/MODULE.bazel": "cba2573d870babc976664a912539b320cbaa7114cd3e8f053c720171cde331ed", "https://bcr.bazel.build/modules/rules_python/0.29.0/MODULE.bazel": "2ac8cd70524b4b9ec49a0b8284c79e4cd86199296f82f6e0d5da3f783d660c82", "https://bcr.bazel.build/modules/rules_python/0.31.0/MODULE.bazel": "93a43dc47ee570e6ec9f5779b2e64c1476a6ce921c48cc9a1678a91dd5f8fd58", + "https://bcr.bazel.build/modules/rules_python/0.33.2/MODULE.bazel": "3e036c4ad8d804a4dad897d333d8dce200d943df4827cb849840055be8d2e937", "https://bcr.bazel.build/modules/rules_python/0.34.0/MODULE.bazel": "1d623d026e075b78c9fde483a889cda7996f5da4f36dffb24c246ab30f06513a", "https://bcr.bazel.build/modules/rules_python/0.37.0/MODULE.bazel": "bd90c62e4c789ea94ed61ab21a5a538dd4145548d1de994192049652d433816e", "https://bcr.bazel.build/modules/rules_python/0.37.0/source.json": "c17b8ca7a2348fd8fa96ad5b414223dd1ce5d6e8265c3134a88d337b0554d53c", "https://bcr.bazel.build/modules/rules_python/0.4.0/MODULE.bazel": "9208ee05fd48bf09ac60ed269791cf17fb343db56c8226a720fbb1cdf467166c", + "https://bcr.bazel.build/modules/rules_rust/0.56.0/MODULE.bazel": "3295b00757db397122092322fe1e920be7f5c9fbfb8619138977e820f2cbbbae", + "https://bcr.bazel.build/modules/rules_rust/0.56.0/source.json": "7dc294c3decd40af8f7b83897a5936e764d3ae8584b4056862978fb3870ab8d7", + "https://bcr.bazel.build/modules/rules_shell/0.2.0/MODULE.bazel": "fda8a652ab3c7d8fee214de05e7a9916d8b28082234e8d2c0094505c5268ed3c", + "https://bcr.bazel.build/modules/rules_shell/0.3.0/MODULE.bazel": "de4402cd12f4cc8fda2354fce179fdb068c0b9ca1ec2d2b17b3e21b24c1a937b", + "https://bcr.bazel.build/modules/rules_shell/0.3.0/source.json": "c55ed591aa5009401ddf80ded9762ac32c358d2517ee7820be981e2de9756cf3", "https://bcr.bazel.build/modules/rules_swift/1.15.1/MODULE.bazel": "7031d3e5221b54dfee3901d221f10f54a8b0f2a64d4616de7879bcf83fe8d85d", "https://bcr.bazel.build/modules/rules_swift/1.15.1/source.json": "6472a4607d0a2f39eeb7daae78054b995aba593caad99aa64561f631fcf93a63", "https://bcr.bazel.build/modules/rules_uv/0.34.0/MODULE.bazel": "fb7c2da897786eac4b643d1ed516be715c11566620ee5cf022d7009298ad9590", @@ -241,10 +326,10 @@ "https://bcr.bazel.build/modules/stardoc/0.5.3/MODULE.bazel": "c7f6948dae6999bf0db32c1858ae345f112cacf98f174c7a8bb707e41b974f1c", "https://bcr.bazel.build/modules/stardoc/0.5.4/MODULE.bazel": "6569966df04610b8520957cb8e97cf2e9faac2c0309657c537ab51c16c18a2a4", "https://bcr.bazel.build/modules/stardoc/0.6.2/MODULE.bazel": "7060193196395f5dd668eda046ccbeacebfd98efc77fed418dbe2b82ffaa39fd", - "https://bcr.bazel.build/modules/stardoc/0.6.2/source.json": "d2ff8063b63b4a85e65fe595c4290f99717434fa9f95b4748a79a7d04dfed349", + "https://bcr.bazel.build/modules/stardoc/0.7.0/MODULE.bazel": "05e3d6d30c099b6770e97da986c53bd31844d7f13d41412480ea265ac9e8079c", + "https://bcr.bazel.build/modules/stardoc/0.7.0/source.json": "e3c524bf2ef20992539ce2bc4a2243f4853130209ee831689983e28d05769099", "https://bcr.bazel.build/modules/upb/0.0.0-20220923-a547704/MODULE.bazel": "7298990c00040a0e2f121f6c32544bab27d4452f80d9ce51349b1a28f3005c43", "https://bcr.bazel.build/modules/upb/0.0.0-20230516-61a97ef/MODULE.bazel": "c0df5e35ad55e264160417fd0875932ee3c9dda63d9fccace35ac62f45e1b6f9", - "https://bcr.bazel.build/modules/upb/0.0.0-20230516-61a97ef/source.json": "b2150404947339e8b947c6b16baa39fa75657f4ddec5e37272c7b11c7ab533bc", "https://bcr.bazel.build/modules/with_cfg.bzl/0.5.0/MODULE.bazel": "67fa8ac990536334d99ce6c18d75273e61544f59f1b170c93bf30b9b27be0ab0", "https://bcr.bazel.build/modules/with_cfg.bzl/0.5.0/source.json": "c78e66485e2463cb2f260592793dd67343eb4f5ed44e572749d366a96fc502c1", "https://bcr.bazel.build/modules/zlib/1.2.11/MODULE.bazel": "07b389abc85fdbca459b69e2ec656ae5622873af3f845e1c9d80fe179f3effa0", @@ -252,6 +337,7 @@ "https://bcr.bazel.build/modules/zlib/1.2.13/MODULE.bazel": "aa6deb1b83c18ffecd940c4119aff9567cd0a671d7bba756741cb2ef043a29d5", "https://bcr.bazel.build/modules/zlib/1.3.1.bcr.3/MODULE.bazel": "af322bc08976524477c79d1e45e241b6efbeb918c497e8840b8ab116802dda79", "https://bcr.bazel.build/modules/zlib/1.3.1.bcr.3/source.json": "2be409ac3c7601245958cd4fcdff4288be79ed23bd690b4b951f500d54ee6e7d", + "https://bcr.bazel.build/modules/zlib/1.3.1/MODULE.bazel": "751c9940dcfe869f5f7274e1295422a34623555916eb98c174c1e945594bf198", "https://bcr.bazel.build/modules/zstd/1.5.6/MODULE.bazel": "471ebe7d3cdd8c6469390fcf623eb4779ff55fbee0a87f1dc57a1def468b96d4", "https://bcr.bazel.build/modules/zstd/1.5.6/source.json": "02010c3333fc89b44fe861db049968decb6e688411f7f9d4f6791d74f9adfb51" }, @@ -259,8 +345,8 @@ "moduleExtensions": { "@@apple_support~//crosstool:setup.bzl%apple_cc_configure_extension": { "general": { - "bzlTransitiveDigest": "hDHJiBbKme6a+N8oiSQcVnU1v5B7tHMjJaAzS6GFfPc=", - "usagesDigest": "DiWkge8efNy5uEEAC5/apbpitw2TcqXtsuVBlXf3wCw=", + "bzlTransitiveDigest": "SKth1NgruDWmWTeXDCh0A0NfAgafC4gc2LLGmtsh+xc=", + "usagesDigest": "i/gYqPAU9qIGmH0uIqJrlW4YJLsLGlx361J3qXrWIXI=", "recordedFileInputs": {}, "recordedDirentsInputs": {}, "envVariables": {}, @@ -1084,35 +1170,6 @@ "recordedRepoMappingEntries": [] } }, - "@@protobuf~//:non_module_deps.bzl%non_module_deps": { - "general": { - "bzlTransitiveDigest": "zrC0Xg5rY819dsKgDXDP+eTr1lB/eGewLGy9h4DnUBg=", - "usagesDigest": "1JwsUDre7ljlZoaD2WfcvUlKnXUonmxIKAVBQ82j6Ig=", - "recordedFileInputs": {}, - "recordedDirentsInputs": {}, - "envVariables": {}, - "generatedRepoSpecs": { - "utf8_range": { - "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", - "ruleClassName": "http_archive", - "attributes": { - "urls": [ - "https://github.com/protocolbuffers/utf8_range/archive/de0b4a8ff9b5d4c98108bdfe723291a33c52c54f.zip" - ], - "strip_prefix": "utf8_range-de0b4a8ff9b5d4c98108bdfe723291a33c52c54f", - "sha256": "5da960e5e5d92394c809629a03af3c7709d2d3d0ca731dacb3a9fb4bf28f7702" - } - } - }, - "recordedRepoMappingEntries": [ - [ - "protobuf~", - "bazel_tools", - "bazel_tools" - ] - ] - } - }, "@@rules_distroless~//apt:extensions.bzl%apt": { "general": { "bzlTransitiveDigest": "rCfUzSGMSZSoItAWsqjTUC8ki4434a+MaUc8Ar3697c=", @@ -1315,6 +1372,75 @@ ] } }, + "@@rules_kotlin~//src/main/starlark/core/repositories:bzlmod_setup.bzl%rules_kotlin_extensions": { + "general": { + "bzlTransitiveDigest": "mjEpMcNvt8O97wimreF4hDPVsJeMJ5KQ4Mrv+yWl4Ps=", + "usagesDigest": "aJF6fLy82rR95Ff5CZPAqxNoFgOMLMN5ImfBS0nhnkg=", + "recordedFileInputs": {}, + "recordedDirentsInputs": {}, + "envVariables": {}, + "generatedRepoSpecs": { + "com_github_jetbrains_kotlin_git": { + "bzlFile": "@@rules_kotlin~//src/main/starlark/core/repositories:compiler.bzl", + "ruleClassName": "kotlin_compiler_git_repository", + "attributes": { + "urls": [ + "https://github.com/JetBrains/kotlin/releases/download/v1.9.23/kotlin-compiler-1.9.23.zip" + ], + "sha256": "93137d3aab9afa9b27cb06a824c2324195c6b6f6179d8a8653f440f5bd58be88" + } + }, + "com_github_jetbrains_kotlin": { + "bzlFile": "@@rules_kotlin~//src/main/starlark/core/repositories:compiler.bzl", + "ruleClassName": "kotlin_capabilities_repository", + "attributes": { + "git_repository_name": "com_github_jetbrains_kotlin_git", + "compiler_version": "1.9.23" + } + }, + "com_github_google_ksp": { + "bzlFile": "@@rules_kotlin~//src/main/starlark/core/repositories:ksp.bzl", + "ruleClassName": "ksp_compiler_plugin_repository", + "attributes": { + "urls": [ + "https://github.com/google/ksp/releases/download/1.9.23-1.0.20/artifacts.zip" + ], + "sha256": "ee0618755913ef7fd6511288a232e8fad24838b9af6ea73972a76e81053c8c2d", + "strip_version": "1.9.23-1.0.20" + } + }, + "com_github_pinterest_ktlint": { + "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", + "ruleClassName": "http_file", + "attributes": { + "sha256": "01b2e0ef893383a50dbeb13970fe7fa3be36ca3e83259e01649945b09d736985", + "urls": [ + "https://github.com/pinterest/ktlint/releases/download/1.3.0/ktlint" + ], + "executable": true + } + }, + "rules_android": { + "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", + "ruleClassName": "http_archive", + "attributes": { + "sha256": "cd06d15dd8bb59926e4d65f9003bfc20f9da4b2519985c27e190cddc8b7a7806", + "strip_prefix": "rules_android-0.1.1", + "urls": [ + "https://github.com/bazelbuild/rules_android/archive/v0.1.1.zip" + ] + } + } + }, + "recordedRepoMappingEntries": [ + [ + "rules_kotlin~", + "bazel_tools", + "bazel_tools" + ] + ] + } + }, "@@rules_multitool~//multitool:extension.bzl%multitool": { "general": { "bzlTransitiveDigest": "ADJmcFhRAIhS4Pgkog5QSZ/k1997Xgw2IXwBSYnWZyc=", @@ -1382,7 +1508,7 @@ }, "@@rules_oci~//oci:extensions.bzl%oci": { "general": { - "bzlTransitiveDigest": "smvRHVw3bPg82VpqtnHGC6bhJIbGZRCIBgQ7MEUVBS8=", + "bzlTransitiveDigest": "KemImcAw1mSOqG3Jodmn/JNOJLaTPS8/4ziRiDHEMVg=", "usagesDigest": "aFu/3xEVrbVVYR6WqwRslJ9+zQ1lbHP/x6oxyenxxy0=", "recordedFileInputs": {}, "recordedDirentsInputs": {}, @@ -1456,9 +1582,20 @@ "ruleClassName": "globals_repo", "attributes": { "globals": { + "CcSharedLibraryInfo": "6.0.0-pre.20220630.1", + "CcSharedLibraryHintInfo": "7.0.0-pre.20230316.2", + "PackageSpecificationInfo": "6.4.0", "RunEnvironmentInfo": "5.3.0", "DefaultInfo": "0.0.1", "__TestingOnly_NeverAvailable": "1000000000.0.0" + }, + "legacy_globals": { + "JavaInfo": "8.0.0", + "JavaPluginInfo": "8.0.0", + "ProtoInfo": "8.0.0", + "PyCcLinkParamsProvider": "8.0.0", + "PyInfo": "8.0.0", + "PyRuntimeInfo": "8.0.0" } } }, @@ -1889,6 +2026,844 @@ ] ] } + }, + "@@rules_rust~//rust/private:internal_extensions.bzl%i": { + "general": { + "bzlTransitiveDigest": "QRpfBOgO39qBaMLcLOuXd7asyMSvVqTSgC5Nz5+5438=", + "usagesDigest": "ojUWpdSJ5FsqV5SiidVYsxzvjzgeQ3EB4HmC6u86fCc=", + "recordedFileInputs": {}, + "recordedDirentsInputs": {}, + "envVariables": {}, + "generatedRepoSpecs": { + "rules_rust_tinyjson": { + "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", + "ruleClassName": "http_archive", + "attributes": { + "sha256": "9ab95735ea2c8fd51154d01e39cf13912a78071c2d89abc49a7ef102a7dd725a", + "url": "https://static.crates.io/crates/tinyjson/tinyjson-2.5.1.crate", + "strip_prefix": "tinyjson-2.5.1", + "type": "tar.gz", + "build_file": "@@rules_rust~//util/process_wrapper:BUILD.tinyjson.bazel" + } + }, + "rrra__aho-corasick-1.0.2": { + "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", + "ruleClassName": "http_archive", + "attributes": { + "sha256": "43f6cb1bf222025340178f382c426f13757b2960e89779dfcb319c32542a5a41", + "type": "tar.gz", + "urls": [ + "https://static.crates.io/crates/aho-corasick/1.0.2/download" + ], + "strip_prefix": "aho-corasick-1.0.2", + "build_file": "@@rules_rust~//tools/rust_analyzer/3rdparty/crates:BUILD.aho-corasick-1.0.2.bazel" + } + }, + "rrra__anstream-0.3.2": { + "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", + "ruleClassName": "http_archive", + "attributes": { + "sha256": "0ca84f3628370c59db74ee214b3263d58f9aadd9b4fe7e711fd87dc452b7f163", + "type": "tar.gz", + "urls": [ + "https://static.crates.io/crates/anstream/0.3.2/download" + ], + "strip_prefix": "anstream-0.3.2", + "build_file": "@@rules_rust~//tools/rust_analyzer/3rdparty/crates:BUILD.anstream-0.3.2.bazel" + } + }, + "rrra__anstyle-1.0.1": { + "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", + "ruleClassName": "http_archive", + "attributes": { + "sha256": "3a30da5c5f2d5e72842e00bcb57657162cdabef0931f40e2deb9b4140440cecd", + "type": "tar.gz", + "urls": [ + "https://static.crates.io/crates/anstyle/1.0.1/download" + ], + "strip_prefix": "anstyle-1.0.1", + "build_file": "@@rules_rust~//tools/rust_analyzer/3rdparty/crates:BUILD.anstyle-1.0.1.bazel" + } + }, + "rrra__anstyle-parse-0.2.1": { + "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", + "ruleClassName": "http_archive", + "attributes": { + "sha256": "938874ff5980b03a87c5524b3ae5b59cf99b1d6bc836848df7bc5ada9643c333", + "type": "tar.gz", + "urls": [ + "https://static.crates.io/crates/anstyle-parse/0.2.1/download" + ], + "strip_prefix": "anstyle-parse-0.2.1", + "build_file": "@@rules_rust~//tools/rust_analyzer/3rdparty/crates:BUILD.anstyle-parse-0.2.1.bazel" + } + }, + "rrra__anstyle-query-1.0.0": { + "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", + "ruleClassName": "http_archive", + "attributes": { + "sha256": "5ca11d4be1bab0c8bc8734a9aa7bf4ee8316d462a08c6ac5052f888fef5b494b", + "type": "tar.gz", + "urls": [ + "https://static.crates.io/crates/anstyle-query/1.0.0/download" + ], + "strip_prefix": "anstyle-query-1.0.0", + "build_file": "@@rules_rust~//tools/rust_analyzer/3rdparty/crates:BUILD.anstyle-query-1.0.0.bazel" + } + }, + "rrra__anstyle-wincon-1.0.1": { + "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", + "ruleClassName": "http_archive", + "attributes": { + "sha256": "180abfa45703aebe0093f79badacc01b8fd4ea2e35118747e5811127f926e188", + "type": "tar.gz", + "urls": [ + "https://static.crates.io/crates/anstyle-wincon/1.0.1/download" + ], + "strip_prefix": "anstyle-wincon-1.0.1", + "build_file": "@@rules_rust~//tools/rust_analyzer/3rdparty/crates:BUILD.anstyle-wincon-1.0.1.bazel" + } + }, + "rrra__anyhow-1.0.71": { + "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", + "ruleClassName": "http_archive", + "attributes": { + "sha256": "9c7d0618f0e0b7e8ff11427422b64564d5fb0be1940354bfe2e0529b18a9d9b8", + "type": "tar.gz", + "urls": [ + "https://static.crates.io/crates/anyhow/1.0.71/download" + ], + "strip_prefix": "anyhow-1.0.71", + "build_file": "@@rules_rust~//tools/rust_analyzer/3rdparty/crates:BUILD.anyhow-1.0.71.bazel" + } + }, + "rrra__bitflags-1.3.2": { + "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", + "ruleClassName": "http_archive", + "attributes": { + "sha256": "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a", + "type": "tar.gz", + "urls": [ + "https://static.crates.io/crates/bitflags/1.3.2/download" + ], + "strip_prefix": "bitflags-1.3.2", + "build_file": "@@rules_rust~//tools/rust_analyzer/3rdparty/crates:BUILD.bitflags-1.3.2.bazel" + } + }, + "rrra__cc-1.0.79": { + "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", + "ruleClassName": "http_archive", + "attributes": { + "sha256": "50d30906286121d95be3d479533b458f87493b30a4b5f79a607db8f5d11aa91f", + "type": "tar.gz", + "urls": [ + "https://static.crates.io/crates/cc/1.0.79/download" + ], + "strip_prefix": "cc-1.0.79", + "build_file": "@@rules_rust~//tools/rust_analyzer/3rdparty/crates:BUILD.cc-1.0.79.bazel" + } + }, + "rrra__clap-4.3.11": { + "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", + "ruleClassName": "http_archive", + "attributes": { + "sha256": "1640e5cc7fb47dbb8338fd471b105e7ed6c3cb2aeb00c2e067127ffd3764a05d", + "type": "tar.gz", + "urls": [ + "https://static.crates.io/crates/clap/4.3.11/download" + ], + "strip_prefix": "clap-4.3.11", + "build_file": "@@rules_rust~//tools/rust_analyzer/3rdparty/crates:BUILD.clap-4.3.11.bazel" + } + }, + "rrra__clap_builder-4.3.11": { + "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", + "ruleClassName": "http_archive", + "attributes": { + "sha256": "98c59138d527eeaf9b53f35a77fcc1fad9d883116070c63d5de1c7dc7b00c72b", + "type": "tar.gz", + "urls": [ + "https://static.crates.io/crates/clap_builder/4.3.11/download" + ], + "strip_prefix": "clap_builder-4.3.11", + "build_file": "@@rules_rust~//tools/rust_analyzer/3rdparty/crates:BUILD.clap_builder-4.3.11.bazel" + } + }, + "rrra__clap_derive-4.3.2": { + "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", + "ruleClassName": "http_archive", + "attributes": { + "sha256": "b8cd2b2a819ad6eec39e8f1d6b53001af1e5469f8c177579cdaeb313115b825f", + "type": "tar.gz", + "urls": [ + "https://static.crates.io/crates/clap_derive/4.3.2/download" + ], + "strip_prefix": "clap_derive-4.3.2", + "build_file": "@@rules_rust~//tools/rust_analyzer/3rdparty/crates:BUILD.clap_derive-4.3.2.bazel" + } + }, + "rrra__clap_lex-0.5.0": { + "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", + "ruleClassName": "http_archive", + "attributes": { + "sha256": "2da6da31387c7e4ef160ffab6d5e7f00c42626fe39aea70a7b0f1773f7dd6c1b", + "type": "tar.gz", + "urls": [ + "https://static.crates.io/crates/clap_lex/0.5.0/download" + ], + "strip_prefix": "clap_lex-0.5.0", + "build_file": "@@rules_rust~//tools/rust_analyzer/3rdparty/crates:BUILD.clap_lex-0.5.0.bazel" + } + }, + "rrra__colorchoice-1.0.0": { + "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", + "ruleClassName": "http_archive", + "attributes": { + "sha256": "acbf1af155f9b9ef647e42cdc158db4b64a1b61f743629225fde6f3e0be2a7c7", + "type": "tar.gz", + "urls": [ + "https://static.crates.io/crates/colorchoice/1.0.0/download" + ], + "strip_prefix": "colorchoice-1.0.0", + "build_file": "@@rules_rust~//tools/rust_analyzer/3rdparty/crates:BUILD.colorchoice-1.0.0.bazel" + } + }, + "rrra__either-1.8.1": { + "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", + "ruleClassName": "http_archive", + "attributes": { + "sha256": "7fcaabb2fef8c910e7f4c7ce9f67a1283a1715879a7c230ca9d6d1ae31f16d91", + "type": "tar.gz", + "urls": [ + "https://static.crates.io/crates/either/1.8.1/download" + ], + "strip_prefix": "either-1.8.1", + "build_file": "@@rules_rust~//tools/rust_analyzer/3rdparty/crates:BUILD.either-1.8.1.bazel" + } + }, + "rrra__env_logger-0.10.0": { + "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", + "ruleClassName": "http_archive", + "attributes": { + "sha256": "85cdab6a89accf66733ad5a1693a4dcced6aeff64602b634530dd73c1f3ee9f0", + "type": "tar.gz", + "urls": [ + "https://static.crates.io/crates/env_logger/0.10.0/download" + ], + "strip_prefix": "env_logger-0.10.0", + "build_file": "@@rules_rust~//tools/rust_analyzer/3rdparty/crates:BUILD.env_logger-0.10.0.bazel" + } + }, + "rrra__errno-0.3.1": { + "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", + "ruleClassName": "http_archive", + "attributes": { + "sha256": "4bcfec3a70f97c962c307b2d2c56e358cf1d00b558d74262b5f929ee8cc7e73a", + "type": "tar.gz", + "urls": [ + "https://static.crates.io/crates/errno/0.3.1/download" + ], + "strip_prefix": "errno-0.3.1", + "build_file": "@@rules_rust~//tools/rust_analyzer/3rdparty/crates:BUILD.errno-0.3.1.bazel" + } + }, + "rrra__errno-dragonfly-0.1.2": { + "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", + "ruleClassName": "http_archive", + "attributes": { + "sha256": "aa68f1b12764fab894d2755d2518754e71b4fd80ecfb822714a1206c2aab39bf", + "type": "tar.gz", + "urls": [ + "https://static.crates.io/crates/errno-dragonfly/0.1.2/download" + ], + "strip_prefix": "errno-dragonfly-0.1.2", + "build_file": "@@rules_rust~//tools/rust_analyzer/3rdparty/crates:BUILD.errno-dragonfly-0.1.2.bazel" + } + }, + "rrra__heck-0.4.1": { + "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", + "ruleClassName": "http_archive", + "attributes": { + "sha256": "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8", + "type": "tar.gz", + "urls": [ + "https://static.crates.io/crates/heck/0.4.1/download" + ], + "strip_prefix": "heck-0.4.1", + "build_file": "@@rules_rust~//tools/rust_analyzer/3rdparty/crates:BUILD.heck-0.4.1.bazel" + } + }, + "rrra__hermit-abi-0.3.2": { + "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", + "ruleClassName": "http_archive", + "attributes": { + "sha256": "443144c8cdadd93ebf52ddb4056d257f5b52c04d3c804e657d19eb73fc33668b", + "type": "tar.gz", + "urls": [ + "https://static.crates.io/crates/hermit-abi/0.3.2/download" + ], + "strip_prefix": "hermit-abi-0.3.2", + "build_file": "@@rules_rust~//tools/rust_analyzer/3rdparty/crates:BUILD.hermit-abi-0.3.2.bazel" + } + }, + "rrra__humantime-2.1.0": { + "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", + "ruleClassName": "http_archive", + "attributes": { + "sha256": "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4", + "type": "tar.gz", + "urls": [ + "https://static.crates.io/crates/humantime/2.1.0/download" + ], + "strip_prefix": "humantime-2.1.0", + "build_file": "@@rules_rust~//tools/rust_analyzer/3rdparty/crates:BUILD.humantime-2.1.0.bazel" + } + }, + "rrra__io-lifetimes-1.0.11": { + "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", + "ruleClassName": "http_archive", + "attributes": { + "sha256": "eae7b9aee968036d54dce06cebaefd919e4472e753296daccd6d344e3e2df0c2", + "type": "tar.gz", + "urls": [ + "https://static.crates.io/crates/io-lifetimes/1.0.11/download" + ], + "strip_prefix": "io-lifetimes-1.0.11", + "build_file": "@@rules_rust~//tools/rust_analyzer/3rdparty/crates:BUILD.io-lifetimes-1.0.11.bazel" + } + }, + "rrra__is-terminal-0.4.7": { + "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", + "ruleClassName": "http_archive", + "attributes": { + "sha256": "adcf93614601c8129ddf72e2d5633df827ba6551541c6d8c59520a371475be1f", + "type": "tar.gz", + "urls": [ + "https://static.crates.io/crates/is-terminal/0.4.7/download" + ], + "strip_prefix": "is-terminal-0.4.7", + "build_file": "@@rules_rust~//tools/rust_analyzer/3rdparty/crates:BUILD.is-terminal-0.4.7.bazel" + } + }, + "rrra__itertools-0.11.0": { + "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", + "ruleClassName": "http_archive", + "attributes": { + "sha256": "b1c173a5686ce8bfa551b3563d0c2170bf24ca44da99c7ca4bfdab5418c3fe57", + "type": "tar.gz", + "urls": [ + "https://static.crates.io/crates/itertools/0.11.0/download" + ], + "strip_prefix": "itertools-0.11.0", + "build_file": "@@rules_rust~//tools/rust_analyzer/3rdparty/crates:BUILD.itertools-0.11.0.bazel" + } + }, + "rrra__itoa-1.0.8": { + "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", + "ruleClassName": "http_archive", + "attributes": { + "sha256": "62b02a5381cc465bd3041d84623d0fa3b66738b52b8e2fc3bab8ad63ab032f4a", + "type": "tar.gz", + "urls": [ + "https://static.crates.io/crates/itoa/1.0.8/download" + ], + "strip_prefix": "itoa-1.0.8", + "build_file": "@@rules_rust~//tools/rust_analyzer/3rdparty/crates:BUILD.itoa-1.0.8.bazel" + } + }, + "rrra__libc-0.2.147": { + "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", + "ruleClassName": "http_archive", + "attributes": { + "sha256": "b4668fb0ea861c1df094127ac5f1da3409a82116a4ba74fca2e58ef927159bb3", + "type": "tar.gz", + "urls": [ + "https://static.crates.io/crates/libc/0.2.147/download" + ], + "strip_prefix": "libc-0.2.147", + "build_file": "@@rules_rust~//tools/rust_analyzer/3rdparty/crates:BUILD.libc-0.2.147.bazel" + } + }, + "rrra__linux-raw-sys-0.3.8": { + "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", + "ruleClassName": "http_archive", + "attributes": { + "sha256": "ef53942eb7bf7ff43a617b3e2c1c4a5ecf5944a7c1bc12d7ee39bbb15e5c1519", + "type": "tar.gz", + "urls": [ + "https://static.crates.io/crates/linux-raw-sys/0.3.8/download" + ], + "strip_prefix": "linux-raw-sys-0.3.8", + "build_file": "@@rules_rust~//tools/rust_analyzer/3rdparty/crates:BUILD.linux-raw-sys-0.3.8.bazel" + } + }, + "rrra__log-0.4.19": { + "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", + "ruleClassName": "http_archive", + "attributes": { + "sha256": "b06a4cde4c0f271a446782e3eff8de789548ce57dbc8eca9292c27f4a42004b4", + "type": "tar.gz", + "urls": [ + "https://static.crates.io/crates/log/0.4.19/download" + ], + "strip_prefix": "log-0.4.19", + "build_file": "@@rules_rust~//tools/rust_analyzer/3rdparty/crates:BUILD.log-0.4.19.bazel" + } + }, + "rrra__memchr-2.5.0": { + "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", + "ruleClassName": "http_archive", + "attributes": { + "sha256": "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d", + "type": "tar.gz", + "urls": [ + "https://static.crates.io/crates/memchr/2.5.0/download" + ], + "strip_prefix": "memchr-2.5.0", + "build_file": "@@rules_rust~//tools/rust_analyzer/3rdparty/crates:BUILD.memchr-2.5.0.bazel" + } + }, + "rrra__once_cell-1.18.0": { + "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", + "ruleClassName": "http_archive", + "attributes": { + "sha256": "dd8b5dd2ae5ed71462c540258bedcb51965123ad7e7ccf4b9a8cafaa4a63576d", + "type": "tar.gz", + "urls": [ + "https://static.crates.io/crates/once_cell/1.18.0/download" + ], + "strip_prefix": "once_cell-1.18.0", + "build_file": "@@rules_rust~//tools/rust_analyzer/3rdparty/crates:BUILD.once_cell-1.18.0.bazel" + } + }, + "rrra__proc-macro2-1.0.64": { + "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", + "ruleClassName": "http_archive", + "attributes": { + "sha256": "78803b62cbf1f46fde80d7c0e803111524b9877184cfe7c3033659490ac7a7da", + "type": "tar.gz", + "urls": [ + "https://static.crates.io/crates/proc-macro2/1.0.64/download" + ], + "strip_prefix": "proc-macro2-1.0.64", + "build_file": "@@rules_rust~//tools/rust_analyzer/3rdparty/crates:BUILD.proc-macro2-1.0.64.bazel" + } + }, + "rrra__quote-1.0.29": { + "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", + "ruleClassName": "http_archive", + "attributes": { + "sha256": "573015e8ab27661678357f27dc26460738fd2b6c86e46f386fde94cb5d913105", + "type": "tar.gz", + "urls": [ + "https://static.crates.io/crates/quote/1.0.29/download" + ], + "strip_prefix": "quote-1.0.29", + "build_file": "@@rules_rust~//tools/rust_analyzer/3rdparty/crates:BUILD.quote-1.0.29.bazel" + } + }, + "rrra__regex-1.9.1": { + "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", + "ruleClassName": "http_archive", + "attributes": { + "sha256": "b2eae68fc220f7cf2532e4494aded17545fce192d59cd996e0fe7887f4ceb575", + "type": "tar.gz", + "urls": [ + "https://static.crates.io/crates/regex/1.9.1/download" + ], + "strip_prefix": "regex-1.9.1", + "build_file": "@@rules_rust~//tools/rust_analyzer/3rdparty/crates:BUILD.regex-1.9.1.bazel" + } + }, + "rrra__regex-automata-0.3.3": { + "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", + "ruleClassName": "http_archive", + "attributes": { + "sha256": "39354c10dd07468c2e73926b23bb9c2caca74c5501e38a35da70406f1d923310", + "type": "tar.gz", + "urls": [ + "https://static.crates.io/crates/regex-automata/0.3.3/download" + ], + "strip_prefix": "regex-automata-0.3.3", + "build_file": "@@rules_rust~//tools/rust_analyzer/3rdparty/crates:BUILD.regex-automata-0.3.3.bazel" + } + }, + "rrra__regex-syntax-0.7.4": { + "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", + "ruleClassName": "http_archive", + "attributes": { + "sha256": "e5ea92a5b6195c6ef2a0295ea818b312502c6fc94dde986c5553242e18fd4ce2", + "type": "tar.gz", + "urls": [ + "https://static.crates.io/crates/regex-syntax/0.7.4/download" + ], + "strip_prefix": "regex-syntax-0.7.4", + "build_file": "@@rules_rust~//tools/rust_analyzer/3rdparty/crates:BUILD.regex-syntax-0.7.4.bazel" + } + }, + "rrra__rustix-0.37.23": { + "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", + "ruleClassName": "http_archive", + "attributes": { + "sha256": "4d69718bf81c6127a49dc64e44a742e8bb9213c0ff8869a22c308f84c1d4ab06", + "type": "tar.gz", + "urls": [ + "https://static.crates.io/crates/rustix/0.37.23/download" + ], + "strip_prefix": "rustix-0.37.23", + "build_file": "@@rules_rust~//tools/rust_analyzer/3rdparty/crates:BUILD.rustix-0.37.23.bazel" + } + }, + "rrra__ryu-1.0.14": { + "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", + "ruleClassName": "http_archive", + "attributes": { + "sha256": "fe232bdf6be8c8de797b22184ee71118d63780ea42ac85b61d1baa6d3b782ae9", + "type": "tar.gz", + "urls": [ + "https://static.crates.io/crates/ryu/1.0.14/download" + ], + "strip_prefix": "ryu-1.0.14", + "build_file": "@@rules_rust~//tools/rust_analyzer/3rdparty/crates:BUILD.ryu-1.0.14.bazel" + } + }, + "rrra__serde-1.0.171": { + "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", + "ruleClassName": "http_archive", + "attributes": { + "sha256": "30e27d1e4fd7659406c492fd6cfaf2066ba8773de45ca75e855590f856dc34a9", + "type": "tar.gz", + "urls": [ + "https://static.crates.io/crates/serde/1.0.171/download" + ], + "strip_prefix": "serde-1.0.171", + "build_file": "@@rules_rust~//tools/rust_analyzer/3rdparty/crates:BUILD.serde-1.0.171.bazel" + } + }, + "rrra__serde_derive-1.0.171": { + "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", + "ruleClassName": "http_archive", + "attributes": { + "sha256": "389894603bd18c46fa56231694f8d827779c0951a667087194cf9de94ed24682", + "type": "tar.gz", + "urls": [ + "https://static.crates.io/crates/serde_derive/1.0.171/download" + ], + "strip_prefix": "serde_derive-1.0.171", + "build_file": "@@rules_rust~//tools/rust_analyzer/3rdparty/crates:BUILD.serde_derive-1.0.171.bazel" + } + }, + "rrra__serde_json-1.0.102": { + "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", + "ruleClassName": "http_archive", + "attributes": { + "sha256": "b5062a995d481b2308b6064e9af76011f2921c35f97b0468811ed9f6cd91dfed", + "type": "tar.gz", + "urls": [ + "https://static.crates.io/crates/serde_json/1.0.102/download" + ], + "strip_prefix": "serde_json-1.0.102", + "build_file": "@@rules_rust~//tools/rust_analyzer/3rdparty/crates:BUILD.serde_json-1.0.102.bazel" + } + }, + "rrra__strsim-0.10.0": { + "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", + "ruleClassName": "http_archive", + "attributes": { + "sha256": "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623", + "type": "tar.gz", + "urls": [ + "https://static.crates.io/crates/strsim/0.10.0/download" + ], + "strip_prefix": "strsim-0.10.0", + "build_file": "@@rules_rust~//tools/rust_analyzer/3rdparty/crates:BUILD.strsim-0.10.0.bazel" + } + }, + "rrra__syn-2.0.25": { + "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", + "ruleClassName": "http_archive", + "attributes": { + "sha256": "15e3fc8c0c74267e2df136e5e5fb656a464158aa57624053375eb9c8c6e25ae2", + "type": "tar.gz", + "urls": [ + "https://static.crates.io/crates/syn/2.0.25/download" + ], + "strip_prefix": "syn-2.0.25", + "build_file": "@@rules_rust~//tools/rust_analyzer/3rdparty/crates:BUILD.syn-2.0.25.bazel" + } + }, + "rrra__termcolor-1.2.0": { + "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", + "ruleClassName": "http_archive", + "attributes": { + "sha256": "be55cf8942feac5c765c2c993422806843c9a9a45d4d5c407ad6dd2ea95eb9b6", + "type": "tar.gz", + "urls": [ + "https://static.crates.io/crates/termcolor/1.2.0/download" + ], + "strip_prefix": "termcolor-1.2.0", + "build_file": "@@rules_rust~//tools/rust_analyzer/3rdparty/crates:BUILD.termcolor-1.2.0.bazel" + } + }, + "rrra__unicode-ident-1.0.10": { + "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", + "ruleClassName": "http_archive", + "attributes": { + "sha256": "22049a19f4a68748a168c0fc439f9516686aa045927ff767eca0a85101fb6e73", + "type": "tar.gz", + "urls": [ + "https://static.crates.io/crates/unicode-ident/1.0.10/download" + ], + "strip_prefix": "unicode-ident-1.0.10", + "build_file": "@@rules_rust~//tools/rust_analyzer/3rdparty/crates:BUILD.unicode-ident-1.0.10.bazel" + } + }, + "rrra__utf8parse-0.2.1": { + "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", + "ruleClassName": "http_archive", + "attributes": { + "sha256": "711b9620af191e0cdc7468a8d14e709c3dcdb115b36f838e601583af800a370a", + "type": "tar.gz", + "urls": [ + "https://static.crates.io/crates/utf8parse/0.2.1/download" + ], + "strip_prefix": "utf8parse-0.2.1", + "build_file": "@@rules_rust~//tools/rust_analyzer/3rdparty/crates:BUILD.utf8parse-0.2.1.bazel" + } + }, + "rrra__winapi-0.3.9": { + "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", + "ruleClassName": "http_archive", + "attributes": { + "sha256": "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419", + "type": "tar.gz", + "urls": [ + "https://static.crates.io/crates/winapi/0.3.9/download" + ], + "strip_prefix": "winapi-0.3.9", + "build_file": "@@rules_rust~//tools/rust_analyzer/3rdparty/crates:BUILD.winapi-0.3.9.bazel" + } + }, + "rrra__winapi-i686-pc-windows-gnu-0.4.0": { + "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", + "ruleClassName": "http_archive", + "attributes": { + "sha256": "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6", + "type": "tar.gz", + "urls": [ + "https://static.crates.io/crates/winapi-i686-pc-windows-gnu/0.4.0/download" + ], + "strip_prefix": "winapi-i686-pc-windows-gnu-0.4.0", + "build_file": "@@rules_rust~//tools/rust_analyzer/3rdparty/crates:BUILD.winapi-i686-pc-windows-gnu-0.4.0.bazel" + } + }, + "rrra__winapi-util-0.1.5": { + "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", + "ruleClassName": "http_archive", + "attributes": { + "sha256": "70ec6ce85bb158151cae5e5c87f95a8e97d2c0c4b001223f33a334e3ce5de178", + "type": "tar.gz", + "urls": [ + "https://static.crates.io/crates/winapi-util/0.1.5/download" + ], + "strip_prefix": "winapi-util-0.1.5", + "build_file": "@@rules_rust~//tools/rust_analyzer/3rdparty/crates:BUILD.winapi-util-0.1.5.bazel" + } + }, + "rrra__winapi-x86_64-pc-windows-gnu-0.4.0": { + "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", + "ruleClassName": "http_archive", + "attributes": { + "sha256": "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f", + "type": "tar.gz", + "urls": [ + "https://static.crates.io/crates/winapi-x86_64-pc-windows-gnu/0.4.0/download" + ], + "strip_prefix": "winapi-x86_64-pc-windows-gnu-0.4.0", + "build_file": "@@rules_rust~//tools/rust_analyzer/3rdparty/crates:BUILD.winapi-x86_64-pc-windows-gnu-0.4.0.bazel" + } + }, + "rrra__windows-sys-0.48.0": { + "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", + "ruleClassName": "http_archive", + "attributes": { + "sha256": "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9", + "type": "tar.gz", + "urls": [ + "https://static.crates.io/crates/windows-sys/0.48.0/download" + ], + "strip_prefix": "windows-sys-0.48.0", + "build_file": "@@rules_rust~//tools/rust_analyzer/3rdparty/crates:BUILD.windows-sys-0.48.0.bazel" + } + }, + "rrra__windows-targets-0.48.1": { + "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", + "ruleClassName": "http_archive", + "attributes": { + "sha256": "05d4b17490f70499f20b9e791dcf6a299785ce8af4d709018206dc5b4953e95f", + "type": "tar.gz", + "urls": [ + "https://static.crates.io/crates/windows-targets/0.48.1/download" + ], + "strip_prefix": "windows-targets-0.48.1", + "build_file": "@@rules_rust~//tools/rust_analyzer/3rdparty/crates:BUILD.windows-targets-0.48.1.bazel" + } + }, + "rrra__windows_aarch64_gnullvm-0.48.0": { + "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", + "ruleClassName": "http_archive", + "attributes": { + "sha256": "91ae572e1b79dba883e0d315474df7305d12f569b400fcf90581b06062f7e1bc", + "type": "tar.gz", + "urls": [ + "https://static.crates.io/crates/windows_aarch64_gnullvm/0.48.0/download" + ], + "strip_prefix": "windows_aarch64_gnullvm-0.48.0", + "build_file": "@@rules_rust~//tools/rust_analyzer/3rdparty/crates:BUILD.windows_aarch64_gnullvm-0.48.0.bazel" + } + }, + "rrra__windows_aarch64_msvc-0.48.0": { + "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", + "ruleClassName": "http_archive", + "attributes": { + "sha256": "b2ef27e0d7bdfcfc7b868b317c1d32c641a6fe4629c171b8928c7b08d98d7cf3", + "type": "tar.gz", + "urls": [ + "https://static.crates.io/crates/windows_aarch64_msvc/0.48.0/download" + ], + "strip_prefix": "windows_aarch64_msvc-0.48.0", + "build_file": "@@rules_rust~//tools/rust_analyzer/3rdparty/crates:BUILD.windows_aarch64_msvc-0.48.0.bazel" + } + }, + "rrra__windows_i686_gnu-0.48.0": { + "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", + "ruleClassName": "http_archive", + "attributes": { + "sha256": "622a1962a7db830d6fd0a69683c80a18fda201879f0f447f065a3b7467daa241", + "type": "tar.gz", + "urls": [ + "https://static.crates.io/crates/windows_i686_gnu/0.48.0/download" + ], + "strip_prefix": "windows_i686_gnu-0.48.0", + "build_file": "@@rules_rust~//tools/rust_analyzer/3rdparty/crates:BUILD.windows_i686_gnu-0.48.0.bazel" + } + }, + "rrra__windows_i686_msvc-0.48.0": { + "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", + "ruleClassName": "http_archive", + "attributes": { + "sha256": "4542c6e364ce21bf45d69fdd2a8e455fa38d316158cfd43b3ac1c5b1b19f8e00", + "type": "tar.gz", + "urls": [ + "https://static.crates.io/crates/windows_i686_msvc/0.48.0/download" + ], + "strip_prefix": "windows_i686_msvc-0.48.0", + "build_file": "@@rules_rust~//tools/rust_analyzer/3rdparty/crates:BUILD.windows_i686_msvc-0.48.0.bazel" + } + }, + "rrra__windows_x86_64_gnu-0.48.0": { + "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", + "ruleClassName": "http_archive", + "attributes": { + "sha256": "ca2b8a661f7628cbd23440e50b05d705db3686f894fc9580820623656af974b1", + "type": "tar.gz", + "urls": [ + "https://static.crates.io/crates/windows_x86_64_gnu/0.48.0/download" + ], + "strip_prefix": "windows_x86_64_gnu-0.48.0", + "build_file": "@@rules_rust~//tools/rust_analyzer/3rdparty/crates:BUILD.windows_x86_64_gnu-0.48.0.bazel" + } + }, + "rrra__windows_x86_64_gnullvm-0.48.0": { + "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", + "ruleClassName": "http_archive", + "attributes": { + "sha256": "7896dbc1f41e08872e9d5e8f8baa8fdd2677f29468c4e156210174edc7f7b953", + "type": "tar.gz", + "urls": [ + "https://static.crates.io/crates/windows_x86_64_gnullvm/0.48.0/download" + ], + "strip_prefix": "windows_x86_64_gnullvm-0.48.0", + "build_file": "@@rules_rust~//tools/rust_analyzer/3rdparty/crates:BUILD.windows_x86_64_gnullvm-0.48.0.bazel" + } + }, + "rrra__windows_x86_64_msvc-0.48.0": { + "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", + "ruleClassName": "http_archive", + "attributes": { + "sha256": "1a515f5799fe4961cb532f983ce2b23082366b898e52ffbce459c86f67c8378a", + "type": "tar.gz", + "urls": [ + "https://static.crates.io/crates/windows_x86_64_msvc/0.48.0/download" + ], + "strip_prefix": "windows_x86_64_msvc-0.48.0", + "build_file": "@@rules_rust~//tools/rust_analyzer/3rdparty/crates:BUILD.windows_x86_64_msvc-0.48.0.bazel" + } + } + }, + "moduleExtensionMetadata": { + "explicitRootModuleDirectDeps": [ + "rules_rust_tinyjson", + "rrra__anyhow-1.0.71", + "rrra__clap-4.3.11", + "rrra__env_logger-0.10.0", + "rrra__itertools-0.11.0", + "rrra__log-0.4.19", + "rrra__serde-1.0.171", + "rrra__serde_json-1.0.102" + ], + "explicitRootModuleDirectDevDeps": [], + "useAllRepos": "NO", + "reproducible": false + }, + "recordedRepoMappingEntries": [ + [ + "rules_rust~", + "bazel_skylib", + "bazel_skylib~" + ], + [ + "rules_rust~", + "bazel_tools", + "bazel_tools" + ], + [ + "rules_rust~", + "rrra__anyhow-1.0.71", + "rules_rust~~i~rrra__anyhow-1.0.71" + ], + [ + "rules_rust~", + "rrra__clap-4.3.11", + "rules_rust~~i~rrra__clap-4.3.11" + ], + [ + "rules_rust~", + "rrra__env_logger-0.10.0", + "rules_rust~~i~rrra__env_logger-0.10.0" + ], + [ + "rules_rust~", + "rrra__itertools-0.11.0", + "rules_rust~~i~rrra__itertools-0.11.0" + ], + [ + "rules_rust~", + "rrra__log-0.4.19", + "rules_rust~~i~rrra__log-0.4.19" + ], + [ + "rules_rust~", + "rrra__serde-1.0.171", + "rules_rust~~i~rrra__serde-1.0.171" + ], + [ + "rules_rust~", + "rrra__serde_json-1.0.102", + "rules_rust~~i~rrra__serde_json-1.0.102" + ] + ] + } } } } diff --git a/examples/llama/main.zig b/examples/llama/main.zig index d7f82736..4a3f3f22 100644 --- a/examples/llama/main.zig +++ b/examples/llama/main.zig @@ -39,7 +39,13 @@ pub fn generateText( seed: u128, prompt: []const u8, ) ![]const u8 { - const prompt_tok = tokenizer.encode(allocator, prompt, .{}) catch unreachable; + var tokenizer_encoder = try tokenizer.encoder(); + defer tokenizer_encoder.deinit(); + + var tokenizer_decoder = try tokenizer.decoder(); + defer tokenizer_decoder.deinit(); + + const prompt_tok = try tokenizer_encoder.encode(prompt); log.debug("Tokenized Prompt {d}", .{prompt_tok}); const dims = llama.model.shape(); const max_seq_len = dims.s; @@ -69,52 +75,78 @@ pub fn generateText( const tracer = zml.tools.Tracer.init("ai.zml.models.llama"); var decode_progress = prompt_tok.len; + decode_progress = decode_progress; const output_tokens_len = max_seq_len - prompt_tok.len - 1; const start = std.time.microTimestamp(); + _ = start; // autofix const output_freq: u8 = 1; + _ = output_freq; // autofix var eos_index: ?usize = null; - for (0..output_tokens_len) |i| { - //_ = i; + eos_index = eos_index; + + for (0..10) |i| { const frame_id = tracer.frameStart(try std.fmt.bufPrintZ(tracer_buffer, "Generate token {}/{}", .{ i + 1, output_tokens_len })); + _ = frame_id; // autofix tokens, const new_token_index, kv_cache, rng = mod.call(.{ tokens, token_index, kv_cache, rng }); token_index.deinit(); token_index = new_token_index; - if ((i + 1) % output_freq == 0) { - const n = output.items.len; - _ = try tokens.toHost(std.mem.sliceAsBytes(token_buffer)); - try tokenizer.decodeWithOpts(&output, @ptrCast(token_buffer[decode_progress..][0..output_freq]), .{}); - decode_progress += output_freq; - std.debug.print("{s}", .{output.items[n..]}); - tracer.frameEnd(frame_id, try std.fmt.bufPrintZ(tracer_buffer, "Decoded token {}/{} : {s}", .{ i + 1, output_tokens_len, output.items[n..] })); - if (std.mem.indexOfAny(i32, token_buffer[decode_progress - output_freq ..], &eos_tokens)) |index| { - // Handle strange scenarios when eos id isn't the very next token after decode_progress - eos_index = decode_progress - output_freq + index; - break; - } - } else { - tracer.frameEnd(frame_id, try std.fmt.bufPrintZ(tracer_buffer, "Generated token {}/{}", .{ i + 1, output_tokens_len })); - } + + const n = output.items.len; + _ = n; // autofix + _ = try tokens.toHost(std.mem.sliceAsBytes(token_buffer)); + + const chunk = try tokenizer_decoder.next(@intCast(token_buffer[decode_progress])) orelse unreachable; + try output.appendSlice(chunk); + decode_progress += 1; + + std.debug.print("{s}", .{chunk}); } - var total_token_count: usize = max_seq_len; - const n = output.items.len; - if (eos_index) |end_idx| { - // count = eos index + 1 - total_token_count = end_idx + 1; - } - const generated_token_count = total_token_count - prompt_tok.len; - try tokenizer.decodeWithOpts(&output, @ptrCast(token_buffer[decode_progress..total_token_count]), .{}); - std.debug.print("{s}\n", .{output.items[n..]}); - const end = std.time.microTimestamp(); - const duration = stdx.math.divFloat(f64, end - start, std.time.us_per_s); - const speed = @as(f64, @floatFromInt(generated_token_count)) / duration; - log.info("✅ Generated {d} tokens in {:.3}s: {d:.3}tok/s", .{ generated_token_count, duration, speed }); + // for (0..output_tokens_len) |i| { + // //_ = i; + // const frame_id = tracer.frameStart(try std.fmt.bufPrintZ(tracer_buffer, "Generate token {}/{}", .{ i + 1, output_tokens_len })); + // tokens, const new_token_index, kv_cache, rng = mod.call(.{ tokens, token_index, kv_cache, rng }); + // token_index.deinit(); + // token_index = new_token_index; + // if ((i + 1) % output_freq == 0) { + // const n = output.items.len; + // _ = try tokens.toHost(std.mem.sliceAsBytes(token_buffer)); - _ = try tokens.toHost(std.mem.sliceAsBytes(token_buffer)); - output.clearRetainingCapacity(); + // decoder.next() - try tokenizer.decodeWithOpts(&output, @ptrCast(token_buffer[0..total_token_count]), .{}); + // try tokenizer.decodeWithOpts(&output, @ptrCast(token_buffer[decode_progress..][0..output_freq]), .{}); + // decode_progress += output_freq; + // std.debug.print("{s}", .{output.items[n..]}); + // tracer.frameEnd(frame_id, try std.fmt.bufPrintZ(tracer_buffer, "Decoded token {}/{} : {s}", .{ i + 1, output_tokens_len, output.items[n..] })); + // if (std.mem.indexOfAny(i32, token_buffer[decode_progress - output_freq ..], &eos_tokens)) |index| { + // // Handle strange scenarios when eos id isn't the very next token after decode_progress + // eos_index = decode_progress - output_freq + index; + // break; + // } + // } else { + // tracer.frameEnd(frame_id, try std.fmt.bufPrintZ(tracer_buffer, "Generated token {}/{}", .{ i + 1, output_tokens_len })); + // } + // } + // var total_token_count: usize = max_seq_len; + // const n = output.items.len; + // if (eos_index) |end_idx| { + // // count = eos index + 1 + // total_token_count = end_idx + 1; + // } + // const generated_token_count = total_token_count - prompt_tok.len; + // try tokenizer.decodeWithOpts(&output, @ptrCast(token_buffer[decode_progress..total_token_count]), .{}); + // std.debug.print("{s}\n", .{output.items[n..]}); + // const end = std.time.microTimestamp(); + + // const duration = stdx.math.divFloat(f64, end - start, std.time.us_per_s); + // const speed = @as(f64, @floatFromInt(generated_token_count)) / duration; + // log.info("✅ Generated {d} tokens in {:.3}s: {d:.3}tok/s", .{ generated_token_count, duration, speed }); + + // _ = try tokens.toHost(std.mem.sliceAsBytes(token_buffer)); + // output.clearRetainingCapacity(); + + // try tokenizer.decodeWithOpts(&output, @ptrCast(token_buffer[0..total_token_count]), .{}); return output.toOwnedSlice(); } @@ -207,7 +239,7 @@ pub fn asyncMain() !void { } const tokenizer_path = cli_args.tokenizer orelse cli_args.model; log.info("\tLoading tokenizer from {s}", .{tokenizer_path}); - var tokenizer = try zml.aio.detectFormatAndLoadTokenizer(allocator, tokenizer_path); + var tokenizer = try zml.tokenizer.Tokenizer.from_file(allocator, tokenizer_path); log.info("✅\tLoaded tokenizer from {s}", .{tokenizer_path}); defer tokenizer.deinit(); diff --git a/third_party/com_google_sentencepiece/sentencepiece.bazel b/third_party/com_google_sentencepiece/sentencepiece.bazel index f896466f..e5378b1d 100644 --- a/third_party/com_google_sentencepiece/sentencepiece.bazel +++ b/third_party/com_google_sentencepiece/sentencepiece.bazel @@ -90,6 +90,6 @@ cc_library( ":darts_clone", ":sentencepiece_cc_proto", ":sentencepiece_model_cc_proto", - "@@//third_party/com_google_sentencepiece:absl", + "@zml//third_party/com_google_sentencepiece:absl", ], ) diff --git a/zml/BUILD.bazel b/zml/BUILD.bazel index 39a8fd78..33f840e4 100644 --- a/zml/BUILD.bazel +++ b/zml/BUILD.bazel @@ -33,6 +33,7 @@ zig_library( "//pjrt", "//runtimes", "//stdx", + "//zml/tokenizer", "//zml/tools", "@rules_zig//zig/lib:libc", "@rules_zig//zig/runfiles", diff --git a/zml/tokenizer/hftokenizers/hftokenizers.h b/zml/tokenizer/hftokenizers/hftokenizers.h index dc54d4b5..7bc8790c 100644 --- a/zml/tokenizer/hftokenizers/hftokenizers.h +++ b/zml/tokenizer/hftokenizers/hftokenizers.h @@ -1,5 +1,6 @@ #pragma once +#include #include #include "ffi/zig_slice.h" @@ -7,8 +8,9 @@ typedef struct hftokenizers hftokenizers; hftokenizers *hftokenizers_new(zig_slice); -void hftokenizers_drop(void *tokenizer); +void hftokenizers_drop(hftokenizers *tokenizer); zig_slice hftokenizers_encode(hftokenizers *tokenizer, zig_slice text); void hftokenizers_tokens_drop(zig_slice tokens); zig_slice hftokenizers_decode(hftokenizers *tokenizer, zig_slice tokens); void hftokenizers_str_drop(zig_slice text); +uint32_t hftokenizers_token_to_id(hftokenizers *tokenizer, zig_slice token); diff --git a/zml/tokenizer/hftokenizers/hftokenizers.rs b/zml/tokenizer/hftokenizers/hftokenizers.rs index 439869e1..28f96e78 100644 --- a/zml/tokenizer/hftokenizers/hftokenizers.rs +++ b/zml/tokenizer/hftokenizers/hftokenizers.rs @@ -16,8 +16,7 @@ extern "C" fn hftokenizers_new(path: ZigSlice) -> *mut tokenizers::Tokenizer tokenizers::Tokenizer::from_file(std::path::Path::new( std::str::from_utf8(path.as_slice()).unwrap(), )) - .unwrap() - .into(), + .unwrap(), )); } @@ -67,3 +66,12 @@ extern "C" fn hftokenizers_decode( extern "C" fn hftokenizers_str_drop(tokens: ZigSlice) { drop(unsafe { Box::from_raw(tokens.ptr) }); } + +#[no_mangle] +extern "C" fn hftokenizers_token_to_id(t: *mut tokenizers::Tokenizer, token: ZigSlice) -> u32 { + let id = unsafe { t.as_ref() } + .unwrap() + .token_to_id(std::str::from_utf8(token.as_slice()).unwrap()) + .unwrap(); + return id; +} diff --git a/zml/tokenizer/hftokenizers/hftokenizers.zig b/zml/tokenizer/hftokenizers/hftokenizers.zig index d5f80da7..a3be46bf 100644 --- a/zml/tokenizer/hftokenizers/hftokenizers.zig +++ b/zml/tokenizer/hftokenizers/hftokenizers.zig @@ -33,8 +33,13 @@ pub const Encoder = struct { }; pub const Decoder = struct { + const StringBuffer = std.BoundedArray(u8, 128); + const TokensIdsBuffer = std.BoundedArray(u32, 4); + inner: *HFTokenizer, current_string: ?[]const u8 = null, + last_string: StringBuffer = .{ .len = 0 }, + last_token_ids: TokensIdsBuffer = .{ .len = 0 }, fn init(inner: *HFTokenizer) Decoder { return .{ .inner = inner }; @@ -60,6 +65,29 @@ pub const Decoder = struct { pub fn string(self: *const Decoder) []const u8 { return self.current_string orelse &.{}; } + + pub fn next(self: *Decoder, token_id: u32) !?[]const u8 { + if (self.last_token_ids.len >= self.last_token_ids.capacity()) { + _ = self.last_token_ids.orderedRemove(0); + } + self.last_token_ids.appendAssumeCapacity(token_id); + const new_string = try self.decode(self.last_token_ids.constSlice()); + if (self.last_string.len == 0) { + self.last_string = try StringBuffer.fromSlice(new_string); + return new_string; + } + var view = try std.unicode.Utf8View.init(self.last_string.constSlice()); + var it = view.iterator(); + while (it.nextCodepointSlice()) |cp| { + const start = it.i - cp.len; + if (std.mem.startsWith(u8, new_string, self.last_string.constSlice()[start..])) { + const chunk = new_string[self.last_string.len - start ..]; + self.last_string = try StringBuffer.fromSlice(new_string); + return chunk; + } + } + return null; + } }; pub const HFTokenizer = opaque { @@ -68,7 +96,7 @@ pub const HFTokenizer = opaque { } pub fn deinit(self: *HFTokenizer) void { - return c.hftokenizers_drop(self); + return c.hftokenizers_drop(@ptrCast(self)); } pub fn encoder(self: *HFTokenizer) !Encoder { @@ -78,4 +106,8 @@ pub const HFTokenizer = opaque { pub fn decoder(self: *HFTokenizer) !Decoder { return Decoder.init(self); } + + pub fn token_to_id(self: *HFTokenizer, token: []const u8) u32 { + return c.hftokenizers_token_to_id(@ptrCast(self), ffi.ZigSlice.from(token)); + } }; diff --git a/zml/tokenizer/sentencepiece/sentencepiece.i b/zml/tokenizer/sentencepiece/sentencepiece.i index bf67beb2..f2413dc3 100644 --- a/zml/tokenizer/sentencepiece/sentencepiece.i +++ b/zml/tokenizer/sentencepiece/sentencepiece.i @@ -83,10 +83,7 @@ namespace sentencepiece { virtual sentencepiece::util::Status Load(absl::string_view filename); virtual sentencepiece::util::Status Encode(absl::string_view input, std::vector *ids) const; virtual sentencepiece::util::Status Decode(const std::vector &ids, std::string *detokenized) const; - virtual bool IsUnknown(int id) const; - virtual bool IsControl(int id) const; - virtual bool IsUnused(int id) const; - virtual bool IsByte(int id) const; + virtual int PieceToId(absl::string_view piece) const; virtual int unk_id() const; virtual int bos_id() const; virtual int eos_id() const; diff --git a/zml/tokenizer/sentencepiece/sentencepiece.zig b/zml/tokenizer/sentencepiece/sentencepiece.zig index dadd8999..a5ce8d47 100644 --- a/zml/tokenizer/sentencepiece/sentencepiece.zig +++ b/zml/tokenizer/sentencepiece/sentencepiece.zig @@ -80,18 +80,18 @@ pub const Encoder = struct { }; pub const Decoder = struct { - const TokensBufferSize = 4; - const StringBufferSize = 128; + const StringBufferSize = 64; + const StringBuffer = std.BoundedArray(u8, StringBufferSize); + const TokenIdsBufferSize = 4; inner: *SentencePieceProcessor, vec: *c.std_vector_int, str: *c.std_string, - str_buffer: [StringBufferSize]u8 = undefined, - last_tokens: []u8 = &.{}, + last_string: StringBuffer = .{ .len = 0 }, fn init(inner: *SentencePieceProcessor) !Decoder { const vec = try (c.std_vector_int_new() orelse std.mem.Allocator.Error.OutOfMemory); - c.std_vector_int_reserve(vec, TokensBufferSize); + c.std_vector_int_reserve(vec, TokenIdsBufferSize); errdefer c.std_vector_int_delete(vec); const str = try (c.std_string_new() orelse std.mem.Allocator.Error.OutOfMemory); @@ -134,6 +134,33 @@ pub const Decoder = struct { const ptr: [*c]u32 = @ptrCast(c.std_vector_int_data(self.vec)); return ptr[0..c.std_vector_int_size(self.vec)]; } + + pub fn next(self: *Decoder, token_id: u32) !?[]const u8 { + const current_ids = self.ids(); + if (current_ids.len >= c.std_vector_int_capacity(self.vec)) { + std.mem.copyForwards(u32, current_ids[0 .. current_ids.len - 1], current_ids[1..]); + current_ids[current_ids.len - 1] = token_id; + } else { + c.std_vector_int_push_back(self.vec, @intCast(token_id)); + } + try assertOk(c.SentencePieceProcessor_Decode(@ptrCast(self.inner), self.vec, self.str)); + const new_string = self.string(); + if (self.last_string.len == 0) { + self.last_string = try StringBuffer.fromSlice(new_string); + return new_string; + } + var view = try std.unicode.Utf8View.init(self.last_string.constSlice()); + var it = view.iterator(); + while (it.nextCodepointSlice()) |cp| { + const start = it.i - cp.len; + if (std.mem.startsWith(u8, new_string, self.last_string.constSlice()[start..])) { + const chunk = new_string[self.last_string.len - start ..]; + self.last_string = try StringBuffer.fromSlice(new_string); + return chunk; + } + } + return &.{}; + } }; pub const SentencePieceProcessor = opaque { @@ -155,4 +182,8 @@ pub const SentencePieceProcessor = opaque { pub fn decoder(self: *SentencePieceProcessor) !Decoder { return try Decoder.init(self); } + + pub fn token_to_id(self: *SentencePieceProcessor, token: []const u8) u32 { + return @intCast(c.SentencePieceProcessor_PieceToId(@ptrCast(self), ffi.ZigSlice.from(token))); + } }; diff --git a/zml/tokenizer/tokenizer.zig b/zml/tokenizer/tokenizer.zig index 25e0b577..66a8366d 100644 --- a/zml/tokenizer/tokenizer.zig +++ b/zml/tokenizer/tokenizer.zig @@ -70,6 +70,12 @@ pub const Tokenizer = union(Tokenizers) { inline else => |v| v.ids(), }; } + + pub fn next(self: *Decoder, token_id: u32) !?[]const u8 { + return switch (self.*) { + inline else => |*v| v.next(token_id), + }; + } }; hftokenizers: *hftokenizers.HFTokenizer, @@ -103,4 +109,10 @@ pub const Tokenizer = union(Tokenizers) { inline else => |v, tag| @unionInit(Decoder, @tagName(tag), try v.decoder()), }; } + + pub fn token_to_id(self: Tokenizer, token: []const u8) u32 { + return switch (self) { + inline else => |v| v.token_to_id(token), + }; + } }; diff --git a/zml/zml.zig b/zml/zml.zig index 292708eb..406389e2 100644 --- a/zml/zml.zig +++ b/zml/zml.zig @@ -28,7 +28,8 @@ pub const platform = @import("platform.zig"); pub const testing = @import("testing.zig"); pub const torch = @import("torch.zig"); -pub const tokenizer = @import("tokenizer.zig"); +// pub const tokenizer = @import("tokenizer.zig"); +pub const tokenizer = @import("zml/tokenizer"); pub const call = ops.call; pub const compile = exe.compile; From 5f430bd77fd1972117c61126fe9b56ac4f9bbe82 Mon Sep 17 00:00:00 2001 From: Steeve Morin Date: Sun, 29 Dec 2024 16:22:27 +0000 Subject: [PATCH 06/48] WIP --- MODULE.bazel | 18 ++++ examples/MODULE.bazel.lock | 202 ------------------------------------- 2 files changed, 18 insertions(+), 202 deletions(-) diff --git a/MODULE.bazel b/MODULE.bazel index 7c08ff98..506636af 100644 --- a/MODULE.bazel +++ b/MODULE.bazel @@ -124,10 +124,28 @@ use_repo(non_module_deps, "com_google_sentencepiece", "org_swig_swig") bazel_dep(name = "rules_rust", version = "0.56.0") +rust = use_extension("@rules_rust//rust:extensions.bzl", "rust") +rust.toolchain( + edition = "2021", + versions = ["1.83.0"], + extra_target_triples = [ + "aarch64-apple-darwin", + "aarch64-unknown-linux-gnu", + "x86_64-unknown-linux-gnu", + ], +) +use_repo(rust, "rust_toolchains") +register_toolchains("@rust_toolchains//:all") + crate = use_extension("@rules_rust//crate_universe:extensions.bzl", "crate") crate.from_cargo( name = "crates", cargo_lockfile = "//zml/tokenizer/hftokenizers:Cargo.lock", manifests = ["//zml/tokenizer/hftokenizers:Cargo.toml"], + supported_platform_triples = [ + "aarch64-apple-darwin", + "aarch64-unknown-linux-gnu", + "x86_64-unknown-linux-gnu", + ], ) use_repo(crate, "crates") diff --git a/examples/MODULE.bazel.lock b/examples/MODULE.bazel.lock index 55281f85..4f64424d 100644 --- a/examples/MODULE.bazel.lock +++ b/examples/MODULE.bazel.lock @@ -1170,208 +1170,6 @@ "recordedRepoMappingEntries": [] } }, - "@@rules_distroless~//apt:extensions.bzl%apt": { - "general": { - "bzlTransitiveDigest": "rCfUzSGMSZSoItAWsqjTUC8ki4434a+MaUc8Ar3697c=", - "usagesDigest": "rdFW9P8nZY8u3k0GlK387r5yKrNYZkN6oPdK/H8SD40=", - "recordedFileInputs": { - "@@zml~//runtimes/neuron/packages.lock.json": "4cf407725dcd905a3334f79302735d5085901f27b34bd402e9678fad58354622" - }, - "recordedDirentsInputs": {}, - "envVariables": {}, - "generatedRepoSpecs": { - "neuron_bookworm_bash_5.2.15-2-p-b7_amd64": { - "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", - "ruleClassName": "http_archive", - "attributes": { - "build_file_content": "\ngenrule(\n name = \"data\",\n srcs = glob([\"data.tar*\"]),\n outs = [\"layer.tar.gz\"],\n cmd = \"\"\"\n # Per the dpkg-dev man page:\n # https://manpages.debian.org/bookworm/dpkg-dev/deb.5.en.html\n #\n # Debian data.tar files can be:\n # - .tar uncompressed, supported since dpkg 1.10.24\n # - .tar compressed with\n # * gzip: .gz\n # * bzip2: .bz2, supported since dpkg 1.10.24\n # * lzma: .lzma, supported since dpkg 1.13.25\n # * xz: .xz, supported since dpkg 1.15.6\n # * zstd: .zst, supported since dpkg 1.21.18\n #\n # ZSTD_BIN can decompress all formats except bzip2\n #\n # The OCI image spec supports .tar and .tar compressed with gzip or zstd.\n # Bazel needs the output filename to be fixed in advanced so we settle for\n # gzip compression.\n\n data_file=\"$$(basename $<)\"\n\n if [[ \"$$data_file\" == \"data.tar.bz2\" ]]; then\n # TODO: support bz2\n echo \"ERROR: unsupported compression: bz2\"\n exit 1\n elif [[ \"$$data_file\" == \"data.tar.gz\" ]]; then\n mv $< $@\n elif [[ \"$$data_file\" == \"data.tar\" ]]; then\n $(ZSTD_BIN) --compress --format=gzip $< >$@\n else\n $(ZSTD_BIN) --force --decompress --stdout $< |\n $(ZSTD_BIN) --compress --format=gzip - >$@\n fi\n \"\"\",\n toolchains = [\"@zstd_toolchains//:resolved_toolchain\"],\n visibility = [\"//visibility:public\"],\n)\n\nfilegroup(\n name = \"control\",\n srcs = glob([\"control.tar.*\"]),\n visibility = [\"//visibility:public\"],\n)\n", - "urls": [ - "https://deb.debian.org/debian/pool/main/b/bash/bash_5.2.15-2+b7_amd64.deb" - ], - "sha256": "d3c65202568384a588ea32017b243fe64ca054943a008cba4e5bd8f9e79975c4" - } - }, - "neuron_bookworm_debianutils_5.7-0.5_deb12u1_amd64": { - "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", - "ruleClassName": "http_archive", - "attributes": { - "build_file_content": "\ngenrule(\n name = \"data\",\n srcs = glob([\"data.tar*\"]),\n outs = [\"layer.tar.gz\"],\n cmd = \"\"\"\n # Per the dpkg-dev man page:\n # https://manpages.debian.org/bookworm/dpkg-dev/deb.5.en.html\n #\n # Debian data.tar files can be:\n # - .tar uncompressed, supported since dpkg 1.10.24\n # - .tar compressed with\n # * gzip: .gz\n # * bzip2: .bz2, supported since dpkg 1.10.24\n # * lzma: .lzma, supported since dpkg 1.13.25\n # * xz: .xz, supported since dpkg 1.15.6\n # * zstd: .zst, supported since dpkg 1.21.18\n #\n # ZSTD_BIN can decompress all formats except bzip2\n #\n # The OCI image spec supports .tar and .tar compressed with gzip or zstd.\n # Bazel needs the output filename to be fixed in advanced so we settle for\n # gzip compression.\n\n data_file=\"$$(basename $<)\"\n\n if [[ \"$$data_file\" == \"data.tar.bz2\" ]]; then\n # TODO: support bz2\n echo \"ERROR: unsupported compression: bz2\"\n exit 1\n elif [[ \"$$data_file\" == \"data.tar.gz\" ]]; then\n mv $< $@\n elif [[ \"$$data_file\" == \"data.tar\" ]]; then\n $(ZSTD_BIN) --compress --format=gzip $< >$@\n else\n $(ZSTD_BIN) --force --decompress --stdout $< |\n $(ZSTD_BIN) --compress --format=gzip - >$@\n fi\n \"\"\",\n toolchains = [\"@zstd_toolchains//:resolved_toolchain\"],\n visibility = [\"//visibility:public\"],\n)\n\nfilegroup(\n name = \"control\",\n srcs = glob([\"control.tar.*\"]),\n visibility = [\"//visibility:public\"],\n)\n", - "urls": [ - "https://deb.debian.org/debian/pool/main/d/debianutils/debianutils_5.7-0.5~deb12u1_amd64.deb" - ], - "sha256": "55f951359670eb3236c9e2ccd5fac9ccb3db734f5a22aff21589e7a30aee48c9" - } - }, - "neuron_bookworm_libc6_2.36-9-p-deb12u9_amd64": { - "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", - "ruleClassName": "http_archive", - "attributes": { - "build_file_content": "\ngenrule(\n name = \"data\",\n srcs = glob([\"data.tar*\"]),\n outs = [\"layer.tar.gz\"],\n cmd = \"\"\"\n # Per the dpkg-dev man page:\n # https://manpages.debian.org/bookworm/dpkg-dev/deb.5.en.html\n #\n # Debian data.tar files can be:\n # - .tar uncompressed, supported since dpkg 1.10.24\n # - .tar compressed with\n # * gzip: .gz\n # * bzip2: .bz2, supported since dpkg 1.10.24\n # * lzma: .lzma, supported since dpkg 1.13.25\n # * xz: .xz, supported since dpkg 1.15.6\n # * zstd: .zst, supported since dpkg 1.21.18\n #\n # ZSTD_BIN can decompress all formats except bzip2\n #\n # The OCI image spec supports .tar and .tar compressed with gzip or zstd.\n # Bazel needs the output filename to be fixed in advanced so we settle for\n # gzip compression.\n\n data_file=\"$$(basename $<)\"\n\n if [[ \"$$data_file\" == \"data.tar.bz2\" ]]; then\n # TODO: support bz2\n echo \"ERROR: unsupported compression: bz2\"\n exit 1\n elif [[ \"$$data_file\" == \"data.tar.gz\" ]]; then\n mv $< $@\n elif [[ \"$$data_file\" == \"data.tar\" ]]; then\n $(ZSTD_BIN) --compress --format=gzip $< >$@\n else\n $(ZSTD_BIN) --force --decompress --stdout $< |\n $(ZSTD_BIN) --compress --format=gzip - >$@\n fi\n \"\"\",\n toolchains = [\"@zstd_toolchains//:resolved_toolchain\"],\n visibility = [\"//visibility:public\"],\n)\n\nfilegroup(\n name = \"control\",\n srcs = glob([\"control.tar.*\"]),\n visibility = [\"//visibility:public\"],\n)\n", - "urls": [ - "https://deb.debian.org/debian/pool/main/g/glibc/libc6_2.36-9+deb12u9_amd64.deb" - ], - "sha256": "3a043b9dbf1a8c8b5a9e2268253e6dca8c7d431bd7a202fea96364abf374fea9" - } - }, - "neuron_bookworm_libgcc-s1_12.2.0-14_amd64": { - "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", - "ruleClassName": "http_archive", - "attributes": { - "build_file_content": "\ngenrule(\n name = \"data\",\n srcs = glob([\"data.tar*\"]),\n outs = [\"layer.tar.gz\"],\n cmd = \"\"\"\n # Per the dpkg-dev man page:\n # https://manpages.debian.org/bookworm/dpkg-dev/deb.5.en.html\n #\n # Debian data.tar files can be:\n # - .tar uncompressed, supported since dpkg 1.10.24\n # - .tar compressed with\n # * gzip: .gz\n # * bzip2: .bz2, supported since dpkg 1.10.24\n # * lzma: .lzma, supported since dpkg 1.13.25\n # * xz: .xz, supported since dpkg 1.15.6\n # * zstd: .zst, supported since dpkg 1.21.18\n #\n # ZSTD_BIN can decompress all formats except bzip2\n #\n # The OCI image spec supports .tar and .tar compressed with gzip or zstd.\n # Bazel needs the output filename to be fixed in advanced so we settle for\n # gzip compression.\n\n data_file=\"$$(basename $<)\"\n\n if [[ \"$$data_file\" == \"data.tar.bz2\" ]]; then\n # TODO: support bz2\n echo \"ERROR: unsupported compression: bz2\"\n exit 1\n elif [[ \"$$data_file\" == \"data.tar.gz\" ]]; then\n mv $< $@\n elif [[ \"$$data_file\" == \"data.tar\" ]]; then\n $(ZSTD_BIN) --compress --format=gzip $< >$@\n else\n $(ZSTD_BIN) --force --decompress --stdout $< |\n $(ZSTD_BIN) --compress --format=gzip - >$@\n fi\n \"\"\",\n toolchains = [\"@zstd_toolchains//:resolved_toolchain\"],\n visibility = [\"//visibility:public\"],\n)\n\nfilegroup(\n name = \"control\",\n srcs = glob([\"control.tar.*\"]),\n visibility = [\"//visibility:public\"],\n)\n", - "urls": [ - "https://deb.debian.org/debian/pool/main/g/gcc-12/libgcc-s1_12.2.0-14_amd64.deb" - ], - "sha256": "f3d1d48c0599aea85b7f2077a01d285badc42998c1a1e7473935d5cf995c8141" - } - }, - "neuron_bookworm_gcc-12-base_12.2.0-14_amd64": { - "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", - "ruleClassName": "http_archive", - "attributes": { - "build_file_content": "\ngenrule(\n name = \"data\",\n srcs = glob([\"data.tar*\"]),\n outs = [\"layer.tar.gz\"],\n cmd = \"\"\"\n # Per the dpkg-dev man page:\n # https://manpages.debian.org/bookworm/dpkg-dev/deb.5.en.html\n #\n # Debian data.tar files can be:\n # - .tar uncompressed, supported since dpkg 1.10.24\n # - .tar compressed with\n # * gzip: .gz\n # * bzip2: .bz2, supported since dpkg 1.10.24\n # * lzma: .lzma, supported since dpkg 1.13.25\n # * xz: .xz, supported since dpkg 1.15.6\n # * zstd: .zst, supported since dpkg 1.21.18\n #\n # ZSTD_BIN can decompress all formats except bzip2\n #\n # The OCI image spec supports .tar and .tar compressed with gzip or zstd.\n # Bazel needs the output filename to be fixed in advanced so we settle for\n # gzip compression.\n\n data_file=\"$$(basename $<)\"\n\n if [[ \"$$data_file\" == \"data.tar.bz2\" ]]; then\n # TODO: support bz2\n echo \"ERROR: unsupported compression: bz2\"\n exit 1\n elif [[ \"$$data_file\" == \"data.tar.gz\" ]]; then\n mv $< $@\n elif [[ \"$$data_file\" == \"data.tar\" ]]; then\n $(ZSTD_BIN) --compress --format=gzip $< >$@\n else\n $(ZSTD_BIN) --force --decompress --stdout $< |\n $(ZSTD_BIN) --compress --format=gzip - >$@\n fi\n \"\"\",\n toolchains = [\"@zstd_toolchains//:resolved_toolchain\"],\n visibility = [\"//visibility:public\"],\n)\n\nfilegroup(\n name = \"control\",\n srcs = glob([\"control.tar.*\"]),\n visibility = [\"//visibility:public\"],\n)\n", - "urls": [ - "https://deb.debian.org/debian/pool/main/g/gcc-12/gcc-12-base_12.2.0-14_amd64.deb" - ], - "sha256": "1a03df5a57833d65b5bb08cfa19d50e76f29088dc9e64fb934af42d9023a0807" - } - }, - "neuron_bookworm_base-files_12.4-p-deb12u8_amd64": { - "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", - "ruleClassName": "http_archive", - "attributes": { - "build_file_content": "\ngenrule(\n name = \"data\",\n srcs = glob([\"data.tar*\"]),\n outs = [\"layer.tar.gz\"],\n cmd = \"\"\"\n # Per the dpkg-dev man page:\n # https://manpages.debian.org/bookworm/dpkg-dev/deb.5.en.html\n #\n # Debian data.tar files can be:\n # - .tar uncompressed, supported since dpkg 1.10.24\n # - .tar compressed with\n # * gzip: .gz\n # * bzip2: .bz2, supported since dpkg 1.10.24\n # * lzma: .lzma, supported since dpkg 1.13.25\n # * xz: .xz, supported since dpkg 1.15.6\n # * zstd: .zst, supported since dpkg 1.21.18\n #\n # ZSTD_BIN can decompress all formats except bzip2\n #\n # The OCI image spec supports .tar and .tar compressed with gzip or zstd.\n # Bazel needs the output filename to be fixed in advanced so we settle for\n # gzip compression.\n\n data_file=\"$$(basename $<)\"\n\n if [[ \"$$data_file\" == \"data.tar.bz2\" ]]; then\n # TODO: support bz2\n echo \"ERROR: unsupported compression: bz2\"\n exit 1\n elif [[ \"$$data_file\" == \"data.tar.gz\" ]]; then\n mv $< $@\n elif [[ \"$$data_file\" == \"data.tar\" ]]; then\n $(ZSTD_BIN) --compress --format=gzip $< >$@\n else\n $(ZSTD_BIN) --force --decompress --stdout $< |\n $(ZSTD_BIN) --compress --format=gzip - >$@\n fi\n \"\"\",\n toolchains = [\"@zstd_toolchains//:resolved_toolchain\"],\n visibility = [\"//visibility:public\"],\n)\n\nfilegroup(\n name = \"control\",\n srcs = glob([\"control.tar.*\"]),\n visibility = [\"//visibility:public\"],\n)\n", - "urls": [ - "https://deb.debian.org/debian/pool/main/b/base-files/base-files_12.4+deb12u8_amd64.deb" - ], - "sha256": "b961a69d1b79f093597d89a96f296ddca17d3bab9d166361c42f07a6beb4f685" - } - }, - "neuron_bookworm_libtinfo6_6.4-4_amd64": { - "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", - "ruleClassName": "http_archive", - "attributes": { - "build_file_content": "\ngenrule(\n name = \"data\",\n srcs = glob([\"data.tar*\"]),\n outs = [\"layer.tar.gz\"],\n cmd = \"\"\"\n # Per the dpkg-dev man page:\n # https://manpages.debian.org/bookworm/dpkg-dev/deb.5.en.html\n #\n # Debian data.tar files can be:\n # - .tar uncompressed, supported since dpkg 1.10.24\n # - .tar compressed with\n # * gzip: .gz\n # * bzip2: .bz2, supported since dpkg 1.10.24\n # * lzma: .lzma, supported since dpkg 1.13.25\n # * xz: .xz, supported since dpkg 1.15.6\n # * zstd: .zst, supported since dpkg 1.21.18\n #\n # ZSTD_BIN can decompress all formats except bzip2\n #\n # The OCI image spec supports .tar and .tar compressed with gzip or zstd.\n # Bazel needs the output filename to be fixed in advanced so we settle for\n # gzip compression.\n\n data_file=\"$$(basename $<)\"\n\n if [[ \"$$data_file\" == \"data.tar.bz2\" ]]; then\n # TODO: support bz2\n echo \"ERROR: unsupported compression: bz2\"\n exit 1\n elif [[ \"$$data_file\" == \"data.tar.gz\" ]]; then\n mv $< $@\n elif [[ \"$$data_file\" == \"data.tar\" ]]; then\n $(ZSTD_BIN) --compress --format=gzip $< >$@\n else\n $(ZSTD_BIN) --force --decompress --stdout $< |\n $(ZSTD_BIN) --compress --format=gzip - >$@\n fi\n \"\"\",\n toolchains = [\"@zstd_toolchains//:resolved_toolchain\"],\n visibility = [\"//visibility:public\"],\n)\n\nfilegroup(\n name = \"control\",\n srcs = glob([\"control.tar.*\"]),\n visibility = [\"//visibility:public\"],\n)\n", - "urls": [ - "https://deb.debian.org/debian/pool/main/n/ncurses/libtinfo6_6.4-4_amd64.deb" - ], - "sha256": "072d908f38f51090ca28ca5afa3b46b2957dc61fe35094c0b851426859a49a51" - } - }, - "neuron_bookworm_zlib1g_1-1.2.13.dfsg-1_amd64": { - "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", - "ruleClassName": "http_archive", - "attributes": { - "build_file_content": "\ngenrule(\n name = \"data\",\n srcs = glob([\"data.tar*\"]),\n outs = [\"layer.tar.gz\"],\n cmd = \"\"\"\n # Per the dpkg-dev man page:\n # https://manpages.debian.org/bookworm/dpkg-dev/deb.5.en.html\n #\n # Debian data.tar files can be:\n # - .tar uncompressed, supported since dpkg 1.10.24\n # - .tar compressed with\n # * gzip: .gz\n # * bzip2: .bz2, supported since dpkg 1.10.24\n # * lzma: .lzma, supported since dpkg 1.13.25\n # * xz: .xz, supported since dpkg 1.15.6\n # * zstd: .zst, supported since dpkg 1.21.18\n #\n # ZSTD_BIN can decompress all formats except bzip2\n #\n # The OCI image spec supports .tar and .tar compressed with gzip or zstd.\n # Bazel needs the output filename to be fixed in advanced so we settle for\n # gzip compression.\n\n data_file=\"$$(basename $<)\"\n\n if [[ \"$$data_file\" == \"data.tar.bz2\" ]]; then\n # TODO: support bz2\n echo \"ERROR: unsupported compression: bz2\"\n exit 1\n elif [[ \"$$data_file\" == \"data.tar.gz\" ]]; then\n mv $< $@\n elif [[ \"$$data_file\" == \"data.tar\" ]]; then\n $(ZSTD_BIN) --compress --format=gzip $< >$@\n else\n $(ZSTD_BIN) --force --decompress --stdout $< |\n $(ZSTD_BIN) --compress --format=gzip - >$@\n fi\n \"\"\",\n toolchains = [\"@zstd_toolchains//:resolved_toolchain\"],\n visibility = [\"//visibility:public\"],\n)\n\nfilegroup(\n name = \"control\",\n srcs = glob([\"control.tar.*\"]),\n visibility = [\"//visibility:public\"],\n)\n", - "urls": [ - "https://deb.debian.org/debian/pool/main/z/zlib/zlib1g_1.2.13.dfsg-1_amd64.deb" - ], - "sha256": "d7dd1d1411fedf27f5e27650a6eff20ef294077b568f4c8c5e51466dc7c08ce4" - } - }, - "neuron_bookworm_libxml2_2.9.14-p-dfsg-1.3_deb12u1_amd64": { - "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", - "ruleClassName": "http_archive", - "attributes": { - "build_file_content": "\ngenrule(\n name = \"data\",\n srcs = glob([\"data.tar*\"]),\n outs = [\"layer.tar.gz\"],\n cmd = \"\"\"\n # Per the dpkg-dev man page:\n # https://manpages.debian.org/bookworm/dpkg-dev/deb.5.en.html\n #\n # Debian data.tar files can be:\n # - .tar uncompressed, supported since dpkg 1.10.24\n # - .tar compressed with\n # * gzip: .gz\n # * bzip2: .bz2, supported since dpkg 1.10.24\n # * lzma: .lzma, supported since dpkg 1.13.25\n # * xz: .xz, supported since dpkg 1.15.6\n # * zstd: .zst, supported since dpkg 1.21.18\n #\n # ZSTD_BIN can decompress all formats except bzip2\n #\n # The OCI image spec supports .tar and .tar compressed with gzip or zstd.\n # Bazel needs the output filename to be fixed in advanced so we settle for\n # gzip compression.\n\n data_file=\"$$(basename $<)\"\n\n if [[ \"$$data_file\" == \"data.tar.bz2\" ]]; then\n # TODO: support bz2\n echo \"ERROR: unsupported compression: bz2\"\n exit 1\n elif [[ \"$$data_file\" == \"data.tar.gz\" ]]; then\n mv $< $@\n elif [[ \"$$data_file\" == \"data.tar\" ]]; then\n $(ZSTD_BIN) --compress --format=gzip $< >$@\n else\n $(ZSTD_BIN) --force --decompress --stdout $< |\n $(ZSTD_BIN) --compress --format=gzip - >$@\n fi\n \"\"\",\n toolchains = [\"@zstd_toolchains//:resolved_toolchain\"],\n visibility = [\"//visibility:public\"],\n)\n\nfilegroup(\n name = \"control\",\n srcs = glob([\"control.tar.*\"]),\n visibility = [\"//visibility:public\"],\n)\n", - "urls": [ - "https://deb.debian.org/debian/pool/main/libx/libxml2/libxml2_2.9.14+dfsg-1.3~deb12u1_amd64.deb" - ], - "sha256": "35b76cb7038fc1c940204a4f05f33ffb79d027353ce469397d9adcf8f9b3e1a7" - } - }, - "neuron_bookworm_liblzma5_5.4.1-0.2_amd64": { - "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", - "ruleClassName": "http_archive", - "attributes": { - "build_file_content": "\ngenrule(\n name = \"data\",\n srcs = glob([\"data.tar*\"]),\n outs = [\"layer.tar.gz\"],\n cmd = \"\"\"\n # Per the dpkg-dev man page:\n # https://manpages.debian.org/bookworm/dpkg-dev/deb.5.en.html\n #\n # Debian data.tar files can be:\n # - .tar uncompressed, supported since dpkg 1.10.24\n # - .tar compressed with\n # * gzip: .gz\n # * bzip2: .bz2, supported since dpkg 1.10.24\n # * lzma: .lzma, supported since dpkg 1.13.25\n # * xz: .xz, supported since dpkg 1.15.6\n # * zstd: .zst, supported since dpkg 1.21.18\n #\n # ZSTD_BIN can decompress all formats except bzip2\n #\n # The OCI image spec supports .tar and .tar compressed with gzip or zstd.\n # Bazel needs the output filename to be fixed in advanced so we settle for\n # gzip compression.\n\n data_file=\"$$(basename $<)\"\n\n if [[ \"$$data_file\" == \"data.tar.bz2\" ]]; then\n # TODO: support bz2\n echo \"ERROR: unsupported compression: bz2\"\n exit 1\n elif [[ \"$$data_file\" == \"data.tar.gz\" ]]; then\n mv $< $@\n elif [[ \"$$data_file\" == \"data.tar\" ]]; then\n $(ZSTD_BIN) --compress --format=gzip $< >$@\n else\n $(ZSTD_BIN) --force --decompress --stdout $< |\n $(ZSTD_BIN) --compress --format=gzip - >$@\n fi\n \"\"\",\n toolchains = [\"@zstd_toolchains//:resolved_toolchain\"],\n visibility = [\"//visibility:public\"],\n)\n\nfilegroup(\n name = \"control\",\n srcs = glob([\"control.tar.*\"]),\n visibility = [\"//visibility:public\"],\n)\n", - "urls": [ - "https://deb.debian.org/debian/pool/main/x/xz-utils/liblzma5_5.4.1-0.2_amd64.deb" - ], - "sha256": "d4b7736e58512a2b047f9cb91b71db5a3cf9d3451192fc6da044c77bf51fe869" - } - }, - "neuron_bookworm_libicu72_72.1-3_amd64": { - "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", - "ruleClassName": "http_archive", - "attributes": { - "build_file_content": "\ngenrule(\n name = \"data\",\n srcs = glob([\"data.tar*\"]),\n outs = [\"layer.tar.gz\"],\n cmd = \"\"\"\n # Per the dpkg-dev man page:\n # https://manpages.debian.org/bookworm/dpkg-dev/deb.5.en.html\n #\n # Debian data.tar files can be:\n # - .tar uncompressed, supported since dpkg 1.10.24\n # - .tar compressed with\n # * gzip: .gz\n # * bzip2: .bz2, supported since dpkg 1.10.24\n # * lzma: .lzma, supported since dpkg 1.13.25\n # * xz: .xz, supported since dpkg 1.15.6\n # * zstd: .zst, supported since dpkg 1.21.18\n #\n # ZSTD_BIN can decompress all formats except bzip2\n #\n # The OCI image spec supports .tar and .tar compressed with gzip or zstd.\n # Bazel needs the output filename to be fixed in advanced so we settle for\n # gzip compression.\n\n data_file=\"$$(basename $<)\"\n\n if [[ \"$$data_file\" == \"data.tar.bz2\" ]]; then\n # TODO: support bz2\n echo \"ERROR: unsupported compression: bz2\"\n exit 1\n elif [[ \"$$data_file\" == \"data.tar.gz\" ]]; then\n mv $< $@\n elif [[ \"$$data_file\" == \"data.tar\" ]]; then\n $(ZSTD_BIN) --compress --format=gzip $< >$@\n else\n $(ZSTD_BIN) --force --decompress --stdout $< |\n $(ZSTD_BIN) --compress --format=gzip - >$@\n fi\n \"\"\",\n toolchains = [\"@zstd_toolchains//:resolved_toolchain\"],\n visibility = [\"//visibility:public\"],\n)\n\nfilegroup(\n name = \"control\",\n srcs = glob([\"control.tar.*\"]),\n visibility = [\"//visibility:public\"],\n)\n", - "urls": [ - "https://deb.debian.org/debian/pool/main/i/icu/libicu72_72.1-3_amd64.deb" - ], - "sha256": "e239c1c9f52bee0ff627f291552d63691b765ec7c5cdf6de7c7ae4dec0275857" - } - }, - "neuron_bookworm_libstdc-p--p-6_12.2.0-14_amd64": { - "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", - "ruleClassName": "http_archive", - "attributes": { - "build_file_content": "\ngenrule(\n name = \"data\",\n srcs = glob([\"data.tar*\"]),\n outs = [\"layer.tar.gz\"],\n cmd = \"\"\"\n # Per the dpkg-dev man page:\n # https://manpages.debian.org/bookworm/dpkg-dev/deb.5.en.html\n #\n # Debian data.tar files can be:\n # - .tar uncompressed, supported since dpkg 1.10.24\n # - .tar compressed with\n # * gzip: .gz\n # * bzip2: .bz2, supported since dpkg 1.10.24\n # * lzma: .lzma, supported since dpkg 1.13.25\n # * xz: .xz, supported since dpkg 1.15.6\n # * zstd: .zst, supported since dpkg 1.21.18\n #\n # ZSTD_BIN can decompress all formats except bzip2\n #\n # The OCI image spec supports .tar and .tar compressed with gzip or zstd.\n # Bazel needs the output filename to be fixed in advanced so we settle for\n # gzip compression.\n\n data_file=\"$$(basename $<)\"\n\n if [[ \"$$data_file\" == \"data.tar.bz2\" ]]; then\n # TODO: support bz2\n echo \"ERROR: unsupported compression: bz2\"\n exit 1\n elif [[ \"$$data_file\" == \"data.tar.gz\" ]]; then\n mv $< $@\n elif [[ \"$$data_file\" == \"data.tar\" ]]; then\n $(ZSTD_BIN) --compress --format=gzip $< >$@\n else\n $(ZSTD_BIN) --force --decompress --stdout $< |\n $(ZSTD_BIN) --compress --format=gzip - >$@\n fi\n \"\"\",\n toolchains = [\"@zstd_toolchains//:resolved_toolchain\"],\n visibility = [\"//visibility:public\"],\n)\n\nfilegroup(\n name = \"control\",\n srcs = glob([\"control.tar.*\"]),\n visibility = [\"//visibility:public\"],\n)\n", - "urls": [ - "https://deb.debian.org/debian/pool/main/g/gcc-12/libstdc++6_12.2.0-14_amd64.deb" - ], - "sha256": "9b1b269020cec6aced3b39f096f7b67edd1f0d4ab24f412cb6506d0800e19cbf" - } - }, - "neuron_bookworm_aws-neuronx-runtime-lib_2.22.19.0-5856c0b42_amd64": { - "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", - "ruleClassName": "http_archive", - "attributes": { - "build_file_content": "\ngenrule(\n name = \"data\",\n srcs = glob([\"data.tar*\"]),\n outs = [\"layer.tar.gz\"],\n cmd = \"\"\"\n # Per the dpkg-dev man page:\n # https://manpages.debian.org/bookworm/dpkg-dev/deb.5.en.html\n #\n # Debian data.tar files can be:\n # - .tar uncompressed, supported since dpkg 1.10.24\n # - .tar compressed with\n # * gzip: .gz\n # * bzip2: .bz2, supported since dpkg 1.10.24\n # * lzma: .lzma, supported since dpkg 1.13.25\n # * xz: .xz, supported since dpkg 1.15.6\n # * zstd: .zst, supported since dpkg 1.21.18\n #\n # ZSTD_BIN can decompress all formats except bzip2\n #\n # The OCI image spec supports .tar and .tar compressed with gzip or zstd.\n # Bazel needs the output filename to be fixed in advanced so we settle for\n # gzip compression.\n\n data_file=\"$$(basename $<)\"\n\n if [[ \"$$data_file\" == \"data.tar.bz2\" ]]; then\n # TODO: support bz2\n echo \"ERROR: unsupported compression: bz2\"\n exit 1\n elif [[ \"$$data_file\" == \"data.tar.gz\" ]]; then\n mv $< $@\n elif [[ \"$$data_file\" == \"data.tar\" ]]; then\n $(ZSTD_BIN) --compress --format=gzip $< >$@\n else\n $(ZSTD_BIN) --force --decompress --stdout $< |\n $(ZSTD_BIN) --compress --format=gzip - >$@\n fi\n \"\"\",\n toolchains = [\"@zstd_toolchains//:resolved_toolchain\"],\n visibility = [\"//visibility:public\"],\n)\n\nfilegroup(\n name = \"control\",\n srcs = glob([\"control.tar.*\"]),\n visibility = [\"//visibility:public\"],\n)\n", - "urls": [ - "https://apt.repos.neuron.amazonaws.com/pool/main/a/aws-neuronx-runtime-lib/aws-neuronx-runtime-lib_2.22.19.0-5856c0b42_amd64.deb" - ], - "sha256": "f952dad4f615f2881a0bf93ba5132d308fdfa697a78a09e2e1653a6c4704222d" - } - }, - "neuron_bookworm_aws-neuronx-collectives_2.22.33.0-d2128d1aa_amd64": { - "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", - "ruleClassName": "http_archive", - "attributes": { - "build_file_content": "\ngenrule(\n name = \"data\",\n srcs = glob([\"data.tar*\"]),\n outs = [\"layer.tar.gz\"],\n cmd = \"\"\"\n # Per the dpkg-dev man page:\n # https://manpages.debian.org/bookworm/dpkg-dev/deb.5.en.html\n #\n # Debian data.tar files can be:\n # - .tar uncompressed, supported since dpkg 1.10.24\n # - .tar compressed with\n # * gzip: .gz\n # * bzip2: .bz2, supported since dpkg 1.10.24\n # * lzma: .lzma, supported since dpkg 1.13.25\n # * xz: .xz, supported since dpkg 1.15.6\n # * zstd: .zst, supported since dpkg 1.21.18\n #\n # ZSTD_BIN can decompress all formats except bzip2\n #\n # The OCI image spec supports .tar and .tar compressed with gzip or zstd.\n # Bazel needs the output filename to be fixed in advanced so we settle for\n # gzip compression.\n\n data_file=\"$$(basename $<)\"\n\n if [[ \"$$data_file\" == \"data.tar.bz2\" ]]; then\n # TODO: support bz2\n echo \"ERROR: unsupported compression: bz2\"\n exit 1\n elif [[ \"$$data_file\" == \"data.tar.gz\" ]]; then\n mv $< $@\n elif [[ \"$$data_file\" == \"data.tar\" ]]; then\n $(ZSTD_BIN) --compress --format=gzip $< >$@\n else\n $(ZSTD_BIN) --force --decompress --stdout $< |\n $(ZSTD_BIN) --compress --format=gzip - >$@\n fi\n \"\"\",\n toolchains = [\"@zstd_toolchains//:resolved_toolchain\"],\n visibility = [\"//visibility:public\"],\n)\n\nfilegroup(\n name = \"control\",\n srcs = glob([\"control.tar.*\"]),\n visibility = [\"//visibility:public\"],\n)\n", - "urls": [ - "https://apt.repos.neuron.amazonaws.com/pool/main/a/aws-neuronx-collectives/aws-neuronx-collectives_2.22.33.0-d2128d1aa_amd64.deb" - ], - "sha256": "1eadead90a7daf6056a10a09d0ac3b72a3e885e6fedacd14b53a11a30d9774b3" - } - }, - "neuron_bookworm_resolve": { - "bzlFile": "@@rules_distroless~//apt/private:resolve.bzl", - "ruleClassName": "deb_resolve", - "attributes": { - "manifest": "@@zml~//runtimes/neuron:packages.yaml", - "resolve_transitive": true - } - }, - "neuron_bookworm": { - "bzlFile": "@@rules_distroless~//apt/private:index.bzl", - "ruleClassName": "deb_package_index", - "attributes": { - "lock": "@@zml~//runtimes/neuron:packages.lock.json", - "lock_content": "{\n\t\"packages\": [\n\t\t{\n\t\t\t\"arch\": \"amd64\",\n\t\t\t\"dependencies\": [\n\t\t\t\t{\n\t\t\t\t\t\"key\": \"debianutils_5.7-0.5_deb12u1_amd64\",\n\t\t\t\t\t\"name\": \"debianutils\",\n\t\t\t\t\t\"version\": \"5.7-0.5~deb12u1\"\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"key\": \"libc6_2.36-9-p-deb12u9_amd64\",\n\t\t\t\t\t\"name\": \"libc6\",\n\t\t\t\t\t\"version\": \"2.36-9+deb12u9\"\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"key\": \"libgcc-s1_12.2.0-14_amd64\",\n\t\t\t\t\t\"name\": \"libgcc-s1\",\n\t\t\t\t\t\"version\": \"12.2.0-14\"\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"key\": \"gcc-12-base_12.2.0-14_amd64\",\n\t\t\t\t\t\"name\": \"gcc-12-base\",\n\t\t\t\t\t\"version\": \"12.2.0-14\"\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"key\": \"base-files_12.4-p-deb12u8_amd64\",\n\t\t\t\t\t\"name\": \"base-files\",\n\t\t\t\t\t\"version\": \"12.4+deb12u8\"\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"key\": \"libtinfo6_6.4-4_amd64\",\n\t\t\t\t\t\"name\": \"libtinfo6\",\n\t\t\t\t\t\"version\": \"6.4-4\"\n\t\t\t\t}\n\t\t\t],\n\t\t\t\"key\": \"bash_5.2.15-2-p-b7_amd64\",\n\t\t\t\"name\": \"bash\",\n\t\t\t\"sha256\": \"d3c65202568384a588ea32017b243fe64ca054943a008cba4e5bd8f9e79975c4\",\n\t\t\t\"url\": \"https://deb.debian.org/debian/pool/main/b/bash/bash_5.2.15-2+b7_amd64.deb\",\n\t\t\t\"version\": \"5.2.15-2+b7\"\n\t\t},\n\t\t{\n\t\t\t\"arch\": \"amd64\",\n\t\t\t\"dependencies\": [],\n\t\t\t\"key\": \"debianutils_5.7-0.5_deb12u1_amd64\",\n\t\t\t\"name\": \"debianutils\",\n\t\t\t\"sha256\": \"55f951359670eb3236c9e2ccd5fac9ccb3db734f5a22aff21589e7a30aee48c9\",\n\t\t\t\"url\": \"https://deb.debian.org/debian/pool/main/d/debianutils/debianutils_5.7-0.5~deb12u1_amd64.deb\",\n\t\t\t\"version\": \"5.7-0.5~deb12u1\"\n\t\t},\n\t\t{\n\t\t\t\"arch\": \"amd64\",\n\t\t\t\"dependencies\": [],\n\t\t\t\"key\": \"libc6_2.36-9-p-deb12u9_amd64\",\n\t\t\t\"name\": \"libc6\",\n\t\t\t\"sha256\": \"3a043b9dbf1a8c8b5a9e2268253e6dca8c7d431bd7a202fea96364abf374fea9\",\n\t\t\t\"url\": \"https://deb.debian.org/debian/pool/main/g/glibc/libc6_2.36-9+deb12u9_amd64.deb\",\n\t\t\t\"version\": \"2.36-9+deb12u9\"\n\t\t},\n\t\t{\n\t\t\t\"arch\": \"amd64\",\n\t\t\t\"dependencies\": [],\n\t\t\t\"key\": \"libgcc-s1_12.2.0-14_amd64\",\n\t\t\t\"name\": \"libgcc-s1\",\n\t\t\t\"sha256\": \"f3d1d48c0599aea85b7f2077a01d285badc42998c1a1e7473935d5cf995c8141\",\n\t\t\t\"url\": \"https://deb.debian.org/debian/pool/main/g/gcc-12/libgcc-s1_12.2.0-14_amd64.deb\",\n\t\t\t\"version\": \"12.2.0-14\"\n\t\t},\n\t\t{\n\t\t\t\"arch\": \"amd64\",\n\t\t\t\"dependencies\": [],\n\t\t\t\"key\": \"gcc-12-base_12.2.0-14_amd64\",\n\t\t\t\"name\": \"gcc-12-base\",\n\t\t\t\"sha256\": \"1a03df5a57833d65b5bb08cfa19d50e76f29088dc9e64fb934af42d9023a0807\",\n\t\t\t\"url\": \"https://deb.debian.org/debian/pool/main/g/gcc-12/gcc-12-base_12.2.0-14_amd64.deb\",\n\t\t\t\"version\": \"12.2.0-14\"\n\t\t},\n\t\t{\n\t\t\t\"arch\": \"amd64\",\n\t\t\t\"dependencies\": [],\n\t\t\t\"key\": \"base-files_12.4-p-deb12u8_amd64\",\n\t\t\t\"name\": \"base-files\",\n\t\t\t\"sha256\": \"b961a69d1b79f093597d89a96f296ddca17d3bab9d166361c42f07a6beb4f685\",\n\t\t\t\"url\": \"https://deb.debian.org/debian/pool/main/b/base-files/base-files_12.4+deb12u8_amd64.deb\",\n\t\t\t\"version\": \"12.4+deb12u8\"\n\t\t},\n\t\t{\n\t\t\t\"arch\": \"amd64\",\n\t\t\t\"dependencies\": [],\n\t\t\t\"key\": \"libtinfo6_6.4-4_amd64\",\n\t\t\t\"name\": \"libtinfo6\",\n\t\t\t\"sha256\": \"072d908f38f51090ca28ca5afa3b46b2957dc61fe35094c0b851426859a49a51\",\n\t\t\t\"url\": \"https://deb.debian.org/debian/pool/main/n/ncurses/libtinfo6_6.4-4_amd64.deb\",\n\t\t\t\"version\": \"6.4-4\"\n\t\t},\n\t\t{\n\t\t\t\"arch\": \"amd64\",\n\t\t\t\"dependencies\": [\n\t\t\t\t{\n\t\t\t\t\t\"key\": \"libc6_2.36-9-p-deb12u9_amd64\",\n\t\t\t\t\t\"name\": \"libc6\",\n\t\t\t\t\t\"version\": \"2.36-9+deb12u9\"\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"key\": \"libgcc-s1_12.2.0-14_amd64\",\n\t\t\t\t\t\"name\": \"libgcc-s1\",\n\t\t\t\t\t\"version\": \"12.2.0-14\"\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"key\": \"gcc-12-base_12.2.0-14_amd64\",\n\t\t\t\t\t\"name\": \"gcc-12-base\",\n\t\t\t\t\t\"version\": \"12.2.0-14\"\n\t\t\t\t}\n\t\t\t],\n\t\t\t\"key\": \"zlib1g_1-1.2.13.dfsg-1_amd64\",\n\t\t\t\"name\": \"zlib1g\",\n\t\t\t\"sha256\": \"d7dd1d1411fedf27f5e27650a6eff20ef294077b568f4c8c5e51466dc7c08ce4\",\n\t\t\t\"url\": \"https://deb.debian.org/debian/pool/main/z/zlib/zlib1g_1.2.13.dfsg-1_amd64.deb\",\n\t\t\t\"version\": \"1:1.2.13.dfsg-1\"\n\t\t},\n\t\t{\n\t\t\t\"arch\": \"amd64\",\n\t\t\t\"dependencies\": [\n\t\t\t\t{\n\t\t\t\t\t\"key\": \"zlib1g_1-1.2.13.dfsg-1_amd64\",\n\t\t\t\t\t\"name\": \"zlib1g\",\n\t\t\t\t\t\"version\": \"1:1.2.13.dfsg-1\"\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"key\": \"libc6_2.36-9-p-deb12u9_amd64\",\n\t\t\t\t\t\"name\": \"libc6\",\n\t\t\t\t\t\"version\": \"2.36-9+deb12u9\"\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"key\": \"libgcc-s1_12.2.0-14_amd64\",\n\t\t\t\t\t\"name\": \"libgcc-s1\",\n\t\t\t\t\t\"version\": \"12.2.0-14\"\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"key\": \"gcc-12-base_12.2.0-14_amd64\",\n\t\t\t\t\t\"name\": \"gcc-12-base\",\n\t\t\t\t\t\"version\": \"12.2.0-14\"\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"key\": \"liblzma5_5.4.1-0.2_amd64\",\n\t\t\t\t\t\"name\": \"liblzma5\",\n\t\t\t\t\t\"version\": \"5.4.1-0.2\"\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"key\": \"libicu72_72.1-3_amd64\",\n\t\t\t\t\t\"name\": \"libicu72\",\n\t\t\t\t\t\"version\": \"72.1-3\"\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"key\": \"libstdc-p--p-6_12.2.0-14_amd64\",\n\t\t\t\t\t\"name\": \"libstdc++6\",\n\t\t\t\t\t\"version\": \"12.2.0-14\"\n\t\t\t\t}\n\t\t\t],\n\t\t\t\"key\": \"libxml2_2.9.14-p-dfsg-1.3_deb12u1_amd64\",\n\t\t\t\"name\": \"libxml2\",\n\t\t\t\"sha256\": \"35b76cb7038fc1c940204a4f05f33ffb79d027353ce469397d9adcf8f9b3e1a7\",\n\t\t\t\"url\": \"https://deb.debian.org/debian/pool/main/libx/libxml2/libxml2_2.9.14+dfsg-1.3~deb12u1_amd64.deb\",\n\t\t\t\"version\": \"2.9.14+dfsg-1.3~deb12u1\"\n\t\t},\n\t\t{\n\t\t\t\"arch\": \"amd64\",\n\t\t\t\"dependencies\": [],\n\t\t\t\"key\": \"liblzma5_5.4.1-0.2_amd64\",\n\t\t\t\"name\": \"liblzma5\",\n\t\t\t\"sha256\": \"d4b7736e58512a2b047f9cb91b71db5a3cf9d3451192fc6da044c77bf51fe869\",\n\t\t\t\"url\": \"https://deb.debian.org/debian/pool/main/x/xz-utils/liblzma5_5.4.1-0.2_amd64.deb\",\n\t\t\t\"version\": \"5.4.1-0.2\"\n\t\t},\n\t\t{\n\t\t\t\"arch\": \"amd64\",\n\t\t\t\"dependencies\": [],\n\t\t\t\"key\": \"libicu72_72.1-3_amd64\",\n\t\t\t\"name\": \"libicu72\",\n\t\t\t\"sha256\": \"e239c1c9f52bee0ff627f291552d63691b765ec7c5cdf6de7c7ae4dec0275857\",\n\t\t\t\"url\": \"https://deb.debian.org/debian/pool/main/i/icu/libicu72_72.1-3_amd64.deb\",\n\t\t\t\"version\": \"72.1-3\"\n\t\t},\n\t\t{\n\t\t\t\"arch\": \"amd64\",\n\t\t\t\"dependencies\": [],\n\t\t\t\"key\": \"libstdc-p--p-6_12.2.0-14_amd64\",\n\t\t\t\"name\": \"libstdc++6\",\n\t\t\t\"sha256\": \"9b1b269020cec6aced3b39f096f7b67edd1f0d4ab24f412cb6506d0800e19cbf\",\n\t\t\t\"url\": \"https://deb.debian.org/debian/pool/main/g/gcc-12/libstdc++6_12.2.0-14_amd64.deb\",\n\t\t\t\"version\": \"12.2.0-14\"\n\t\t},\n\t\t{\n\t\t\t\"arch\": \"amd64\",\n\t\t\t\"dependencies\": [],\n\t\t\t\"key\": \"aws-neuronx-runtime-lib_2.22.19.0-5856c0b42_amd64\",\n\t\t\t\"name\": \"aws-neuronx-runtime-lib\",\n\t\t\t\"sha256\": \"f952dad4f615f2881a0bf93ba5132d308fdfa697a78a09e2e1653a6c4704222d\",\n\t\t\t\"url\": \"https://apt.repos.neuron.amazonaws.com/pool/main/a/aws-neuronx-runtime-lib/aws-neuronx-runtime-lib_2.22.19.0-5856c0b42_amd64.deb\",\n\t\t\t\"version\": \"2.22.19.0-5856c0b42\"\n\t\t},\n\t\t{\n\t\t\t\"arch\": \"amd64\",\n\t\t\t\"dependencies\": [],\n\t\t\t\"key\": \"aws-neuronx-collectives_2.22.33.0-d2128d1aa_amd64\",\n\t\t\t\"name\": \"aws-neuronx-collectives\",\n\t\t\t\"sha256\": \"1eadead90a7daf6056a10a09d0ac3b72a3e885e6fedacd14b53a11a30d9774b3\",\n\t\t\t\"url\": \"https://apt.repos.neuron.amazonaws.com/pool/main/a/aws-neuronx-collectives/aws-neuronx-collectives_2.22.33.0-d2128d1aa_amd64.deb\",\n\t\t\t\"version\": \"2.22.33.0-d2128d1aa\"\n\t\t}\n\t],\n\t\"version\": 1\n}", - "package_template": "@@rules_distroless~//apt/private:package.BUILD.tmpl" - } - } - }, - "moduleExtensionMetadata": { - "explicitRootModuleDirectDeps": [], - "explicitRootModuleDirectDevDeps": [], - "useAllRepos": "NO", - "reproducible": false - }, - "recordedRepoMappingEntries": [ - [ - "rules_distroless~", - "aspect_bazel_lib", - "aspect_bazel_lib~" - ], - [ - "rules_distroless~", - "bazel_tools", - "bazel_tools" - ] - ] - } - }, "@@rules_kotlin~//src/main/starlark/core/repositories:bzlmod_setup.bzl%rules_kotlin_extensions": { "general": { "bzlTransitiveDigest": "mjEpMcNvt8O97wimreF4hDPVsJeMJ5KQ4Mrv+yWl4Ps=", From 5864c7c122a311003988fbe69b93af55b485b9eb Mon Sep 17 00:00:00 2001 From: Steeve Morin Date: Sun, 29 Dec 2024 16:29:54 +0000 Subject: [PATCH 07/48] WIP --- ffi/BUILD.bazel | 22 ++++++++++++++++++++++ ffi/ffi.zig | 12 ++++++++++++ ffi/zig_allocator.h | 22 ++++++++++++++++++++++ ffi/zig_allocator.zig | 25 +++++++++++++++++++++++++ ffi/zig_slice.h | 9 +++++++++ ffi/zig_slice.zig | 15 +++++++++++++++ 6 files changed, 105 insertions(+) create mode 100644 ffi/BUILD.bazel create mode 100644 ffi/ffi.zig create mode 100644 ffi/zig_allocator.h create mode 100644 ffi/zig_allocator.zig create mode 100644 ffi/zig_slice.h create mode 100644 ffi/zig_slice.zig diff --git a/ffi/BUILD.bazel b/ffi/BUILD.bazel new file mode 100644 index 00000000..ed5f95bf --- /dev/null +++ b/ffi/BUILD.bazel @@ -0,0 +1,22 @@ +load("@rules_zig//zig:defs.bzl", "zig_library") + +cc_library( + name = "cc", + hdrs = [ + "zig_allocator.h", + "zig_slice.h", + ], + visibility = ["//visibility:public"], +) + +zig_library( + name = "zig", + srcs = [ + "zig_allocator.zig", + "zig_slice.zig", + ], + import_name = "ffi", + main = "ffi.zig", + visibility = ["//visibility:public"], + deps = [":cc"], +) diff --git a/ffi/ffi.zig b/ffi/ffi.zig new file mode 100644 index 00000000..ad3c09a9 --- /dev/null +++ b/ffi/ffi.zig @@ -0,0 +1,12 @@ +const std = @import("std"); +const c = @import("c"); + +pub const ZigAllocator = @import("zig_allocator.zig").ZigAllocator; +pub const ZigSlice = @import("zig_slice.zig").ZigSlice; + +pub fn as_path(path: []const u8) [std.fs.max_path_bytes:0]u8 { + var result: [std.fs.max_path_bytes:0]u8 = undefined; + @memcpy(result[0..path.len], path); + result[path.len] = 0; + return result; +} diff --git a/ffi/zig_allocator.h b/ffi/zig_allocator.h new file mode 100644 index 00000000..04e6885c --- /dev/null +++ b/ffi/zig_allocator.h @@ -0,0 +1,22 @@ +#pragma once + +#include + +typedef struct +{ + const void *ctx; + void *(*alloc)(const void *ctx, size_t elem, size_t nelems, size_t alignment); + void (*free)(const void *ctx, void *ptr, size_t elem, size_t nelems, size_t alignment); + +#ifdef __cplusplus + template [[nodiscard]] T *allocate(size_t n) + { + return static_cast(this->alloc(this->ctx, sizeof(T), n, _Alignof(T))); + } + + template [[nodiscard]] void deallocate(T *p, size_t n) + { + this->free(this->ctx, static_cast(p), sizeof(T), n, _Alignof(T)); + } +#endif +} zig_allocator; diff --git a/ffi/zig_allocator.zig b/ffi/zig_allocator.zig new file mode 100644 index 00000000..412dcd1e --- /dev/null +++ b/ffi/zig_allocator.zig @@ -0,0 +1,25 @@ +const std = @import("std"); +const c = @import("c"); + +pub const ZigAllocator = struct { + pub inline fn from(allocator: std.mem.Allocator) c.zig_allocator { + return .{ + .ctx = @ptrCast(@alignCast(&allocator)), + .alloc = &alloc, + .free = &free, + }; + } + + pub fn alloc(ctx: ?*const anyopaque, elem: usize, nelems: usize, alignment: usize) callconv(.C) ?*anyopaque { + const self: *const std.mem.Allocator = @ptrCast(@alignCast(ctx)); + const ret = self.rawAlloc(elem * nelems, std.math.log2_int(usize, alignment), @returnAddress()) orelse return null; + return @ptrCast(ret); + } + + pub fn free(ctx: ?*const anyopaque, ptr: ?*anyopaque, elem: usize, nelems: usize, alignment: usize) callconv(.C) void { + const self: *const std.mem.Allocator = @ptrCast(@alignCast(ctx)); + const memory: [*c]u8 = @ptrCast(ptr); + const size = elem * nelems; + self.rawFree(memory[0..size], std.math.log2_int(usize, alignment), @returnAddress()); + } +}; diff --git a/ffi/zig_slice.h b/ffi/zig_slice.h new file mode 100644 index 00000000..e0a6ed30 --- /dev/null +++ b/ffi/zig_slice.h @@ -0,0 +1,9 @@ +#pragma once + +#include + +typedef struct +{ + void *ptr; + size_t len; +} zig_slice; diff --git a/ffi/zig_slice.zig b/ffi/zig_slice.zig new file mode 100644 index 00000000..c7360465 --- /dev/null +++ b/ffi/zig_slice.zig @@ -0,0 +1,15 @@ +const std = @import("std"); +const c = @import("c"); + +pub const ZigSlice = struct { + pub fn from(slice: anytype) c.zig_slice { + return .{ + .ptr = @ptrCast(@constCast(slice.ptr)), + .len = slice.len, + }; + } + + pub fn to(comptime T: type, slice: c.zig_slice) []T { + return @as([*c]T, @ptrCast(@alignCast(slice.ptr)))[0..slice.len]; + } +}; From 309c8a88d220bdcecdd6ce73a1c12cdb96b4b858 Mon Sep 17 00:00:00 2001 From: Steeve Morin Date: Mon, 6 Jan 2025 10:48:57 +0100 Subject: [PATCH 08/48] async: broadcasting on a Condition forces a reactor tick This is way way more intuitive. --- async/zigcoro.zig | 1 + 1 file changed, 1 insertion(+) diff --git a/async/zigcoro.zig b/async/zigcoro.zig index 1f8fe93f..0a27c6ab 100644 --- a/async/zigcoro.zig +++ b/async/zigcoro.zig @@ -36,6 +36,7 @@ pub const Condition = struct { while (self.waiters.pop()) |waiter| { self.exec.runSoon(waiter); } + _ = self.exec.tick(); } pub fn signal(self: *Condition) void { From 50d00f4db4b6832440acff39f568201f014f9973 Mon Sep 17 00:00:00 2001 From: Steeve Morin Date: Mon, 6 Jan 2025 10:50:37 +0100 Subject: [PATCH 09/48] WIP --- stdx/BUILD.bazel | 1 + stdx/stdx.zig | 1 + zml/tokenizer/BUILD.bazel | 1 + zml/tokenizer/tokenizer.zig | 5 +++-- 4 files changed, 6 insertions(+), 2 deletions(-) diff --git a/stdx/BUILD.bazel b/stdx/BUILD.bazel index 56b9683d..33c87e06 100644 --- a/stdx/BUILD.bazel +++ b/stdx/BUILD.bazel @@ -8,6 +8,7 @@ zig_library( "math.zig", "meta.zig", "signature.zig", + "time.zig", ], main = "stdx.zig", visibility = ["//visibility:public"], diff --git a/stdx/stdx.zig b/stdx/stdx.zig index 820e7aa2..9a8cc323 100644 --- a/stdx/stdx.zig +++ b/stdx/stdx.zig @@ -2,3 +2,4 @@ pub const debug = @import("debug.zig"); pub const io = @import("io.zig"); pub const math = @import("math.zig"); pub const meta = @import("meta.zig"); +pub const time = @import("time.zig"); diff --git a/zml/tokenizer/BUILD.bazel b/zml/tokenizer/BUILD.bazel index 170cd8a4..2e0a71f1 100644 --- a/zml/tokenizer/BUILD.bazel +++ b/zml/tokenizer/BUILD.bazel @@ -18,6 +18,7 @@ zig_library( main = "tokenizer.zig", visibility = ["//visibility:public"], deps = [ + "//async", "//ffi:zig", "//zml/tokenizer/hftokenizers", "//zml/tokenizer/sentencepiece", diff --git a/zml/tokenizer/tokenizer.zig b/zml/tokenizer/tokenizer.zig index 66a8366d..81527946 100644 --- a/zml/tokenizer/tokenizer.zig +++ b/zml/tokenizer/tokenizer.zig @@ -1,6 +1,7 @@ const std = @import("std"); const hftokenizers = @import("hftokenizers"); const sentencepiece = @import("sentencepiece"); +const asynk = @import("async"); const Tokenizers = enum { hftokenizers, @@ -84,10 +85,10 @@ pub const Tokenizer = union(Tokenizers) { pub fn from_file(allocator: std.mem.Allocator, model: []const u8) !Tokenizer { _ = allocator; // autofix if (std.mem.endsWith(u8, model, ".pb")) { - return .{ .sentencepiece = try sentencepiece.SentencePieceProcessor.from_file(model) }; + return .{ .sentencepiece = try asynk.callBlocking(sentencepiece.SentencePieceProcessor.from_file, .{model}) }; } if (std.mem.endsWith(u8, model, ".json")) { - return .{ .hftokenizers = try hftokenizers.HFTokenizer.from_file(model) }; + return .{ .hftokenizers = try asynk.callBlocking(hftokenizers.HFTokenizer.from_file, .{model}) }; } return error.InvalidArgument; } From f220fbfa54367fcac56ff34f0ddcc93051073fa8 Mon Sep 17 00:00:00 2001 From: Steeve Morin Date: Mon, 6 Jan 2025 13:27:03 +0100 Subject: [PATCH 10/48] WIP --- stdx/time.zig | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 stdx/time.zig diff --git a/stdx/time.zig b/stdx/time.zig new file mode 100644 index 00000000..149be741 --- /dev/null +++ b/stdx/time.zig @@ -0,0 +1,34 @@ +const std = @import("std"); + +pub const Duration = struct { + ns: u64, + + pub fn format( + self: Duration, + comptime fmt: []const u8, + options: std.fmt.FormatOptions, + writer: anytype, + ) @TypeOf(writer).Error!void { + return try std.fmt.fmtDuration(self.ns).format(fmt, options, writer); + } +}; + +pub const Timer = struct { + inner: std.time.Timer, + + pub fn start() !Timer { + return .{ .inner = try std.time.Timer.start() }; + } + + pub fn lap(self: *Timer) Duration { + return .{ .ns = try self.inner.lap() }; + } + + pub fn read(self: *Timer) Duration { + return .{ .ns = self.inner.read() }; + } + + pub fn reset(self: *Timer) void { + self.inner.reset(); + } +}; From d9a716b4fdd3c2ca128a54742631d3646a366469 Mon Sep 17 00:00:00 2001 From: Steeve Morin Date: Mon, 6 Jan 2025 15:58:56 +0100 Subject: [PATCH 11/48] WIP --- zml/tokenizer/hftokenizers/Cargo.toml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/zml/tokenizer/hftokenizers/Cargo.toml b/zml/tokenizer/hftokenizers/Cargo.toml index e88bad7a..71671833 100644 --- a/zml/tokenizer/hftokenizers/Cargo.toml +++ b/zml/tokenizer/hftokenizers/Cargo.toml @@ -4,7 +4,9 @@ version = "0.1.0" edition = "2021" [dependencies] -tokenizers = { version = "0.21.0", default-features = false, features = ["onig"] } +# onig-sys fails to build with zig cc, disable it via the unstable_wasm feature, which switches +# the regex library to using fancy. +tokenizers = { version = "0.21.0", default-features = false, features = ["unstable_wasm"] } [lib] name = "zml_tokenizer_hftokenizers" From 8956b567f76dca6ba9c86d8632248175b1fa998f Mon Sep 17 00:00:00 2001 From: Steeve Morin Date: Mon, 6 Jan 2025 16:33:26 +0100 Subject: [PATCH 12/48] WIP --- async/zigcoro.zig | 3 + zml/hostbuffer.zig | 2 +- zml/tensor.zig | 2 +- zml/tokenizer/hftokenizers/Cargo.lock | 143 +++++++++++++++++--------- 4 files changed, 101 insertions(+), 49 deletions(-) diff --git a/async/zigcoro.zig b/async/zigcoro.zig index 0a27c6ab..05b35eec 100644 --- a/async/zigcoro.zig +++ b/async/zigcoro.zig @@ -33,6 +33,9 @@ pub const Condition = struct { } pub fn broadcast(self: *Condition) void { + if (self.waiters.empty()) { + return; + } while (self.waiters.pop()) |waiter| { self.exec.runSoon(waiter); } diff --git a/zml/hostbuffer.zig b/zml/hostbuffer.zig index aed629e5..ecb0efba 100644 --- a/zml/hostbuffer.zig +++ b/zml/hostbuffer.zig @@ -38,7 +38,7 @@ pub const HostBuffer = struct { /// The returned HostBuffer doesn't take ownership of the slice /// that will still need to be deallocated. pub fn fromBytes(shape_: Shape, data_: []const u8) HostBuffer { - std.debug.assert(shape_.byteSize() == data_.len); + stdx.debug.assert(shape_.byteSize() == data_.len, "shape {} and data {} don't match", .{ shape_.byteSize(), data_.len }); return .{ ._shape = shape_, .data = data_, diff --git a/zml/tensor.zig b/zml/tensor.zig index 00ae1d38..39892e8f 100644 --- a/zml/tensor.zig +++ b/zml/tensor.zig @@ -2004,7 +2004,7 @@ pub const Tensor = struct { /// Appends a 1-dim axis, with the given tag. pub fn appendAxes(self: Tensor, t: anytype) Tensor { - stdx.debug.assert(self.rank() < Tensor.MAX_RANK - t.len, "appendAxis expects tensor rank to be small enough in order to extend it, got {} and {} (max is {})", .{ self.rank(), t.len, Tensor.MAX_RANK }); + // stdx.debug.assert(self.rank() < Tensor.MAX_RANK - t.len, "appendAxis expects tensor rank to be small enough in order to extend it, got {} and {} (max is {})", .{ self.rank(), t.len, Tensor.MAX_RANK }); return self.insertAxes(.last, t); } diff --git a/zml/tokenizer/hftokenizers/Cargo.lock b/zml/tokenizer/hftokenizers/Cargo.lock index d7c670cb..b896c1fd 100644 --- a/zml/tokenizer/hftokenizers/Cargo.lock +++ b/zml/tokenizer/hftokenizers/Cargo.lock @@ -18,10 +18,25 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9e1b586273c5702936fe7b7d6896644d8be71e6314cfe09d3167c95f712589e8" [[package]] -name = "bitflags" -version = "1.3.2" +name = "bit-set" +version = "0.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" +checksum = "0700ddab506f33b20a03b13996eccd309a48e5ff77d0d95926aa0210fb4e95f1" +dependencies = [ + "bit-vec", +] + +[[package]] +name = "bit-vec" +version = "0.6.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "349f9b6a179ed607305526ca489b34ad0a41aed5f7980fa90eb03160b69598fb" + +[[package]] +name = "bumpalo" +version = "3.16.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "79296716171880943b8470b5f8d03aa55eb2e645a4874bdbb28adb49162e012c" [[package]] name = "byteorder" @@ -29,15 +44,6 @@ version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" -[[package]] -name = "cc" -version = "1.2.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c31a0499c1dc64f458ad13872de75c0eb7e3fdb0e67964610c914b034fc5956e" -dependencies = [ - "shlex", -] - [[package]] name = "cfg-if" version = "1.0.0" @@ -147,6 +153,17 @@ version = "0.1.10" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d817e038c30374a4bcb22f94d0a8a0e216958d4c3dcde369b1439fec4bdda6e6" +[[package]] +name = "fancy-regex" +version = "0.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "531e46835a22af56d1e3b66f04844bed63158bc094a628bec1d321d9b4c44bf2" +dependencies = [ + "bit-set", + "regex-automata", + "regex-syntax", +] + [[package]] name = "fnv" version = "1.0.7" @@ -160,8 +177,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c4567c8db10ae91089c99af84c68c38da3ec2f087c3f82960bcdbf3656b6f4d7" dependencies = [ "cfg-if", + "js-sys", "libc", "wasi", + "wasm-bindgen", ] [[package]] @@ -194,6 +213,16 @@ version = "1.0.14" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d75a2a4b1b190afb6f5425f10f6a8f959d2ea0b9c2b1d79553551850539e4674" +[[package]] +name = "js-sys" +version = "0.3.76" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6717b6b5b077764fb5966237269cb3c64edddde4b14ce42647430a78ced9e7b7" +dependencies = [ + "once_cell", + "wasm-bindgen", +] + [[package]] name = "lazy_static" version = "1.5.0" @@ -277,40 +306,12 @@ version = "1.20.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1261fe7e33c73b354eab43b1273a57c8f967d0391e80353e51f764ac02cf6775" -[[package]] -name = "onig" -version = "6.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8c4b31c8722ad9171c6d77d3557db078cab2bd50afcc9d09c8b315c59df8ca4f" -dependencies = [ - "bitflags", - "libc", - "once_cell", - "onig_sys", -] - -[[package]] -name = "onig_sys" -version = "69.8.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7b829e3d7e9cc74c7e315ee8edb185bf4190da5acde74afd7fc59c35b1f086e7" -dependencies = [ - "cc", - "pkg-config", -] - [[package]] name = "paste" version = "1.0.15" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "57c0d7b74b563b49d38dae00a0c37d4d6de9b432382b2892f0574ddcae73fd0a" -[[package]] -name = "pkg-config" -version = "0.3.31" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "953ec861398dccce10c670dfeaf3ec4911ca479e9c02154b3a215178c5f566f2" - [[package]] name = "ppv-lite86" version = "0.2.20" @@ -466,12 +467,6 @@ dependencies = [ "serde", ] -[[package]] -name = "shlex" -version = "1.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64" - [[package]] name = "smallvec" version = "1.13.2" @@ -536,13 +531,13 @@ dependencies = [ "aho-corasick", "derive_builder", "esaxx-rs", + "fancy-regex", "getrandom", "itertools 0.12.1", "lazy_static", "log", "macro_rules_attribute", "monostate", - "onig", "paste", "rand", "rayon", @@ -591,6 +586,60 @@ version = "0.11.0+wasi-snapshot-preview1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" +[[package]] +name = "wasm-bindgen" +version = "0.2.99" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a474f6281d1d70c17ae7aa6a613c87fce69a127e2624002df63dcb39d6cf6396" +dependencies = [ + "cfg-if", + "once_cell", + "wasm-bindgen-macro", +] + +[[package]] +name = "wasm-bindgen-backend" +version = "0.2.99" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5f89bb38646b4f81674e8f5c3fb81b562be1fd936d84320f3264486418519c79" +dependencies = [ + "bumpalo", + "log", + "proc-macro2", + "quote", + "syn", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-macro" +version = "0.2.99" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2cc6181fd9a7492eef6fef1f33961e3695e4579b9872a6f7c83aee556666d4fe" +dependencies = [ + "quote", + "wasm-bindgen-macro-support", +] + +[[package]] +name = "wasm-bindgen-macro-support" +version = "0.2.99" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "30d7a95b763d3c45903ed6c81f156801839e5ee968bb07e534c44df0fcd330c2" +dependencies = [ + "proc-macro2", + "quote", + "syn", + "wasm-bindgen-backend", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-shared" +version = "0.2.99" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "943aab3fdaaa029a6e0271b35ea10b72b943135afe9bffca82384098ad0e06a6" + [[package]] name = "zerocopy" version = "0.7.35" From e782b574d1e0fc3f7135cb1ba619bc9ad5653610 Mon Sep 17 00:00:00 2001 From: Guillaume Wenzek Date: Thu, 12 Dec 2024 09:48:24 +0100 Subject: [PATCH 13/48] zml: dynSlice1d should use DynSlice too --- zml/tensor.zig | 36 +++++++++++++++++++----------------- 1 file changed, 19 insertions(+), 17 deletions(-) diff --git a/zml/tensor.zig b/zml/tensor.zig index 00ae1d38..a0e75d2c 100644 --- a/zml/tensor.zig +++ b/zml/tensor.zig @@ -127,8 +127,8 @@ pub const Tensor = struct { /// Returns the dimension of axis 'axis_'. /// /// 'axis_' can be an integer or a tag. - pub fn dim(self: Tensor, axis_: anytype) i64 { - return self._shape.dim(axis_); + pub fn dim(self: Tensor, axis_: anytype) u63 { + return @intCast(self._shape.dim(axis_)); } /// Returns the dimensions of a Tensor as a slice. @@ -1772,7 +1772,7 @@ pub const Tensor = struct { const dt: DataType = if (sh.dim(a) <= std.math.maxInt(i32)) .i32 else .i64; const res_shape = sh.withDtype(dt); const mlir_ctx = CompilationContext.current().mlirCtx(); - const loc = mlir_ctx.location(@src()).namedFmt(mlir_ctx, "iota({}, {})", .{ res_shape, axis_ }); + const loc = mlir_ctx.location(@src()).namedFmt(mlir_ctx, "iota({_}, {})", .{ res_shape, axis_ }); var op = dialect.stablehlo.iota(mlir_ctx, a, mlir.ext.RankedTensorType.fromShape(mlir_ctx, res_shape).asType(), loc); return _result(res_shape, op.result(0)); @@ -1808,7 +1808,7 @@ pub const Tensor = struct { return res; } - /// Returns a 0d Tensor with the given value. + /// Returns a 0-rank Tensor with the given value. pub fn scalar(val: anytype, dt: DataType) Tensor { return Tensor.constant(.{}, Data.init(dt, val)); } @@ -1944,6 +1944,12 @@ pub const Tensor = struct { return _result(output_shape, reshape_value.result(0)); } + /// Converts the given 1 element Tensor into a 0-rank Tensor. + pub fn asScalar(self: Tensor) Tensor { + stdx.debug.assert(self.count() == 1, "Tensor.asScalar expects an input with exactly 1-element got {}", .{self}); + return self.reshape(.{}); + } + pub const Pad = struct { low: i64 = 0, high: i64 = 0, @@ -2129,7 +2135,7 @@ pub const Tensor = struct { // Sometimes the backend recognize this pattern, but not always. // So let us handle that. if (indices.count() == 1) { - return self.dynamicSlice1d(coord_axes_.get(0), 1, indices.flattenAll().squeeze(0)).reshape(res_shape); + return self.dynamicSlice1d(coord_axes_.get(0), .{ .start = indices.flattenAll().squeeze(0), .len = 1 }).reshape(res_shape); } var slice_dims: Shape.DimsArray = .{}; @@ -3066,25 +3072,21 @@ pub const Tensor = struct { /// Slices the input Tensor along a specific axis, with a start offset known at runtime. /// Note: this doesn't support tagging, if you have tags, /// you should use `dynamicSlice` directly. - pub fn dynamicSlice1d(self: Tensor, axis_: i8, len: u63, start_indices: Tensor) Tensor { - stdx.debug.assert(start_indices.rank() == 0, "dynamicSlice1d expects 'start_indices' tensor rank to be equal to 0, got {}", .{start_indices.rank()}); + pub fn dynamicSlice1d(self: Tensor, axis_: i8, slice_: DynSlice) Tensor { + stdx.debug.assert(slice_.start.rank() == 0, "dynamicSlice1d expects 'slice_.start' tensor rank to be a scalar, got {}", .{slice_.start}); const a = self.axis(axis_); - const new_shape = self._shape.set(a, len); - const loc = self.getContext().mlirCtx().location(@src()).namedFmt(self.getContext().mlirCtx(), "axis={}, len={}", .{ axis_, len }); - var indices: [Tensor.MAX_RANK]mlir.Value = undefined; - for (0..self.rank()) |i| { - indices[i] = if (i == a) - start_indices.value() - else - constant(.{}, start_indices.dtype().zero()).value(); - } + const new_shape = self._shape.set(a, slice_.len); + const loc = self.getContext().mlirCtx().location(@src()).namedFmt(self.getContext().mlirCtx(), "dynSlice({}, len={})", .{ axis_, slice_.len }); + + var start_indices = [_]mlir.Value{constant(.{}, slice_.start.dtype().zero()).value()} ** MAX_RANK; + start_indices[a] = slice_.start.value(); const op = dialect.stablehlo.dynamicSlice( self.getContext().mlirCtx(), self.value(), new_shape.dims(), - indices[0..self.rank()], + start_indices[0..self.rank()], loc, ); From ee4b8aa8239b38530cec243c25fd0d2679094332 Mon Sep 17 00:00:00 2001 From: Guillaume Wenzek Date: Fri, 13 Dec 2024 12:01:35 +0100 Subject: [PATCH 14/48] transposeIsJustAReshape --- zml/module.zig | 10 ++++++++-- zml/platform.zig | 1 + zml/tensor.zig | 43 +++++++++++++++++++++++++++++++++++++++---- 3 files changed, 48 insertions(+), 6 deletions(-) diff --git a/zml/module.zig b/zml/module.zig index 3b7e67c8..f7e69304 100644 --- a/zml/module.zig +++ b/zml/module.zig @@ -177,6 +177,10 @@ pub const CompilationContext = struct { return self._mlir_ctx; } + pub fn location(self: *const CompilationContext, src: std.builtin.SourceLocation, comptime name: [:0]const u8, args: anytype) mlir.Location { + return self._mlir_ctx.location(src).namedFmt(self._mlir_ctx, name, args); + } + /// Compiles the given function with the given arguments. /// This is the untyped API and is not meant to be use directly. /// @@ -883,11 +887,13 @@ fn compileModuleToPjrtExecutable(arena: std.mem.Allocator, platform: Platform, m try options.env_option_overrides.ensureUnusedCapacity(arena, 16); if (xla_dump_to_ orelse platform.compilation_options.xla_dump_to) |xla_dump_to| { setFlag(&options, "xla_dump_to", xla_dump_to); + setFlag(&options, "xla_dump_hlo_as_dot", true); if (platform.compilation_options.xla_dump_fusion_visualization) { - setFlag(&options, "xla_dump_hlo_as_html", true); - setFlag(&options, "xla_dump_hlo_as_dot", true); setFlag(&options, "xla_dump_fusion_visualization", true); } + if (platform.compilation_options.xla_dump_hlo_pass_re) |re| { + setFlag(&options, "xla_dump_hlo_pass_re", re); + } } switch (platform.target) { .cuda => cuda_dir: { diff --git a/zml/platform.zig b/zml/platform.zig index 6c135971..ec4ae4c6 100644 --- a/zml/platform.zig +++ b/zml/platform.zig @@ -17,6 +17,7 @@ pub const available_targets = std.enums.values(Target); pub const CompilationOptions = struct { xla_dump_to: ?[]const u8 = null, xla_dump_fusion_visualization: bool = false, + xla_dump_hlo_pass_re: ?[]const u8 = null, sharding_enabled: bool = false, sharding_axes: std.BoundedArray([*:0]const u8, 8) = .{}, }; diff --git a/zml/tensor.zig b/zml/tensor.zig index a0e75d2c..097c297f 100644 --- a/zml/tensor.zig +++ b/zml/tensor.zig @@ -1371,7 +1371,12 @@ pub const Tensor = struct { } const res_shape = self._shape.transpose(permutation); - const loc = self.getContext().mlirCtx().location(@src()).namedFmt(self.getContext().mlirCtx(), "tr({any})", .{axes_}); + if (transposeIsJustAReshape(self.shape(), permutation)) { + scoped_log.warn("Rewriting transpose({}, {d}) as a reshape({}, {})", .{ self, permutation, self, res_shape }); + return self.reshape(res_shape); + } + + const loc = self.getContext().location(@src(), "transpose({_}, {d})", .{ self.shape(), permutation }); const op = dialect.stablehlo.transpose( self.getContext().mlirCtx(), self.value(), @@ -3117,7 +3122,7 @@ pub const Tensor = struct { // TODO use slices and slices_tags for the format. // Currently this prints: "dynSlice(struct{q: struct{start: tensor.Tensor, comptime len: comptime_int = 1}}{ .q = struct{start: tensor.Tensor, comptime len: comptime_int = 1}{ .start = Tensor({1,10}, dtype=.i64), .len = 1 } })" // which is kinda ugly. - const loc = self.getContext().mlirCtx().location(@src()).namedFmt(self.getContext().mlirCtx(), "dynSlice({any})", .{slices_}); + const loc = self.getContext().location(@src(), "dynSlice({any})", .{slices_}); const idx_dtype = if (slices.len > 0) slices.get(0).start.dtype() else .i32; const zero = Tensor.scalar(0, idx_dtype).value(); @@ -3155,7 +3160,7 @@ pub const Tensor = struct { { const x = try zml.Buffer.fromArray(platform, [10]T{ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }); const z = try zml.Buffer.scalar(platform, 4, .i32); - const res = try zml.testing.compileAndCall(platform, Tensor.dynamicSlice1d, .{ x, 0, 2, z }); + const res = try zml.testing.compileAndCall(platform, Tensor.dynamicSlice1d, .{ x, 0, .{ .len = 2, .start = z } }); try testing.expectEqual([2]T{ 4, 5 }, try res.getValue([2]T)); } @@ -3165,7 +3170,7 @@ pub const Tensor = struct { const x = try zml.Buffer.fromArray(platform, [2][5]T{ .{ 0, 1, 2, 3, 4 }, .{ 5, 6, 7, 8, 9 } }); const z = try zml.Buffer.scalar(platform, 3, .i32); - const res = try zml.testing.compileAndCall(platform, Tensor.dynamicSlice1d, .{ x, 1, 2, z }); + const res = try zml.testing.compileAndCall(platform, Tensor.dynamicSlice1d, .{ x, 1, .{ .len = 2, .start = z } }); try testing.expectEqual([4]T{ 3, 4, 8, 9 }, res.getValue([4]T)); } } @@ -3978,3 +3983,33 @@ inline fn toI64(values: anytype) []i64 { for (values, 0..) |val, i| res[i] = @intCast(val); return res[0..values.len]; } + +fn transposeIsJustAReshape(x: Shape, permutation: []const i64) bool { + var perm: std.BoundedArray(u8, Tensor.MAX_RANK) = .{}; + for (permutation) |ax| { + perm.appendAssumeCapacity(@intCast(ax)); + } + + for (0..permutation.len) |i| { + if (x.dim(i) != 1) continue; + + const squeezed_ax = perm.orderedRemove(i); + for (0..perm.len) |j| { + const ax = perm.get(j); + if (ax > squeezed_ax) perm.set(j, ax - 1); + } + } + + const no_op = [Tensor.MAX_RANK]u8{ 0, 1, 2, 3, 4, 5, 6, 7 }; + return std.mem.eql(u8, perm.constSlice(), no_op[0..perm.len]); +} + +test transposeIsJustAReshape { + try std.testing.expect(transposeIsJustAReshape(Shape.init(.{ 5, 1, 3 }, .i32), &.{ 0, 1, 2 })); + try std.testing.expect(transposeIsJustAReshape(Shape.init(.{ 5, 1, 3 }, .i32), &.{ 1, 0, 2 })); + try std.testing.expect(!transposeIsJustAReshape(Shape.init(.{ 5, 1, 3 }, .i32), &.{ 2, 1, 0 })); + try std.testing.expect(transposeIsJustAReshape(Shape.init(.{ 64, 8, 1, 128 }, .bf16), &.{ 0, 2, 1, 3 })); + try std.testing.expect(!transposeIsJustAReshape(Shape.init(.{ 64, 8, 155, 128 }, .bf16), &.{ 0, 2, 1, 3 })); + try std.testing.expect(transposeIsJustAReshape(Shape.init(.{ 64, 1, 1, 128 }, .bf16), &.{ 1, 2, 0, 3 })); + try std.testing.expect(!transposeIsJustAReshape(Shape.init(.{ 64, 1, 155, 128 }, .bf16), &.{ 1, 2, 0, 3 })); +} From 3450096f800f70b5f6d1be881ba4bbfc07941cb1 Mon Sep 17 00:00:00 2001 From: Guillaume Wenzek Date: Mon, 16 Dec 2024 11:12:25 +0100 Subject: [PATCH 15/48] simplify transposeIsAReshape --- zml/tensor.zig | 35 +++++++++++++++++++++++------------ 1 file changed, 23 insertions(+), 12 deletions(-) diff --git a/zml/tensor.zig b/zml/tensor.zig index 097c297f..902ace66 100644 --- a/zml/tensor.zig +++ b/zml/tensor.zig @@ -3985,23 +3985,32 @@ inline fn toI64(values: anytype) []i64 { } fn transposeIsJustAReshape(x: Shape, permutation: []const i64) bool { - var perm: std.BoundedArray(u8, Tensor.MAX_RANK) = .{}; + var perm: std.BoundedArray(struct { u8, bool }, Tensor.MAX_RANK) = .{}; + // Don't rewrite on invalid inputs. + if (permutation.len > x.rank()) return false; for (permutation) |ax| { - perm.appendAssumeCapacity(@intCast(ax)); + const squeezable = x.dim(ax) == 1; + perm.appendAssumeCapacity(.{ @intCast(ax), squeezable }); } - for (0..permutation.len) |i| { - if (x.dim(i) != 1) continue; - - const squeezed_ax = perm.orderedRemove(i); - for (0..perm.len) |j| { - const ax = perm.get(j); - if (ax > squeezed_ax) perm.set(j, ax - 1); + var effective_ax: u8 = 0; + for (0..perm.len) |i| { + const ax, const squeezable = perm.get(i); + if (squeezable) { + // Effectively squeeze this axis by decrementing axes coming after by 1. + for (i..perm.len) |j| { + if (perm.buffer[j][0] > ax) { + perm.buffer[j][0] -= 1; + } + } + continue; } + + if (ax != effective_ax) return false; + effective_ax += 1; } - const no_op = [Tensor.MAX_RANK]u8{ 0, 1, 2, 3, 4, 5, 6, 7 }; - return std.mem.eql(u8, perm.constSlice(), no_op[0..perm.len]); + return true; } test transposeIsJustAReshape { @@ -4011,5 +4020,7 @@ test transposeIsJustAReshape { try std.testing.expect(transposeIsJustAReshape(Shape.init(.{ 64, 8, 1, 128 }, .bf16), &.{ 0, 2, 1, 3 })); try std.testing.expect(!transposeIsJustAReshape(Shape.init(.{ 64, 8, 155, 128 }, .bf16), &.{ 0, 2, 1, 3 })); try std.testing.expect(transposeIsJustAReshape(Shape.init(.{ 64, 1, 1, 128 }, .bf16), &.{ 1, 2, 0, 3 })); - try std.testing.expect(!transposeIsJustAReshape(Shape.init(.{ 64, 1, 155, 128 }, .bf16), &.{ 1, 2, 0, 3 })); + try std.testing.expect(!transposeIsJustAReshape(Shape.init(.{ .b = 1, .h = 10, .q = 155, .hd = 1 }, .f32), &.{ 0, 2, 1, 3 })); + try std.testing.expect(!transposeIsJustAReshape(Shape.init(.{ 1, 10, 155, 1 }, .f32), &.{ 0, 2, 3, 1 })); + try std.testing.expect(transposeIsJustAReshape(Shape.init(.{ 1, 10, 155, 1 }, .f32), &.{ 0, 1, 3, 2 })); } From e594dd2e67ac2409803a272a92fe5e440e10a6d1 Mon Sep 17 00:00:00 2001 From: Guillaume Wenzek Date: Mon, 16 Dec 2024 11:17:37 +0100 Subject: [PATCH 16/48] compacter shape printing --- zml/shape.zig | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/zml/shape.zig b/zml/shape.zig index f9643e90..c032ba25 100644 --- a/zml/shape.zig +++ b/zml/shape.zig @@ -391,20 +391,23 @@ pub const Shape = struct { const bare_fmt = fmt.len == 1 and fmt[0] == '_'; _ = try writer.write(if (bare_fmt) "{" else "Shape({"); + var need_comma = false; for (self.dims(), 0..) |d, i| { - const prefix = if (i == 0) "" else ","; + if (need_comma) try writer.writeByte(','); const t = self.tag(i); if (t != TagUnknown) { - try writer.print("{s}.{s}={d}", .{ prefix, t, d }); + try writer.print("{s}={d}", .{ t, d }); } else { - try writer.print("{s}{d}", .{ prefix, d }); + try writer.print("{d}", .{d}); } if (self._sharding_info[i]) { try writer.writeByte('!'); } + need_comma = true; } - _ = try writer.print("}}, dtype=.{s}", .{@tagName(self.dtype())}); - if (!bare_fmt) _ = try writer.write(")"); + if (need_comma) try writer.writeByte(','); + _ = try writer.write(@tagName(self.dtype())); + _ = try writer.write(if (bare_fmt) "}" else "})"); } pub fn reshape(self: Shape, new_shape_: anytype) Shape { From fab89aa2fbdc84eb915375cb6973c80eb37c2393 Mon Sep 17 00:00:00 2001 From: Guillaume Wenzek Date: Mon, 16 Dec 2024 11:51:02 +0100 Subject: [PATCH 17/48] better location info --- zml/tensor.zig | 111 +++++++++++++++++++++++++------------------------ 1 file changed, 57 insertions(+), 54 deletions(-) diff --git a/zml/tensor.zig b/zml/tensor.zig index 902ace66..214867fe 100644 --- a/zml/tensor.zig +++ b/zml/tensor.zig @@ -58,9 +58,9 @@ pub const Tensor = struct { options: std.fmt.FormatOptions, writer: anytype, ) !void { - _ = fmt; _ = options; - try writer.print("Tensor({_})", .{self._shape}); + const bare_fmt = fmt.len == 1 and fmt[0] == '_'; + try writer.print(if (bare_fmt) "{_}" else "Tensor({_})", .{self._shape}); } /// Returns the shape of a Tensor. @@ -277,7 +277,7 @@ pub const Tensor = struct { res_shape = res_shape.withDtype(dt); - const loc = self.getContext().mlirCtx().location(@src()).namedFmt(self.getContext().mlirCtx(), "bitCast({})", .{dt}); + const loc = self.getContext().location(@src(), "bitCast({s})", .{@tagName(dt)}); const op = dialect.stablehlo.bitcast_convert( self.getContext().mlirCtx(), self.value(), @@ -349,17 +349,17 @@ pub const Tensor = struct { /// Returns a Tensor containing the element-wise left-shift operation of 'self' by 'other'. pub fn shiftLeft(self: Tensor, other: Tensor) Tensor { - return binaryOp("shiftLeft", dialect.stablehlo.shift_left)(self, other); + return binaryOp(@src(), "shiftLeft", dialect.stablehlo.shift_left)(self, other); } /// Returns a Tensor containing the element-wise arithmetic right-shift operation of 'self' by 'other'. pub fn shiftRightArithmetic(self: Tensor, other: Tensor) Tensor { - return binaryOp("shiftRightArithmetic", dialect.stablehlo.shift_right_arithmetic)(self, other); + return binaryOp(@src(), "shiftRightArithmetic", dialect.stablehlo.shift_right_arithmetic)(self, other); } /// Returns a Tensor containing the element-wise logical right-shift operation of 'self' by 'other'. pub fn shiftRightLogical(self: Tensor, other: Tensor) Tensor { - return binaryOp("shiftRightLogical", dialect.stablehlo.shift_right_logical)(self, other); + return binaryOp(@src(), "shiftRightLogical", dialect.stablehlo.shift_right_logical)(self, other); } /// Returns the Cholesky decomposition of the input Tensor. @@ -369,7 +369,7 @@ pub const Tensor = struct { pub fn cholesky(self: Tensor, lower: bool) Tensor { stdx.debug.assert(self.rank() <= 2, "cholesky expects tensor rank to be <= 2, got {}", .{self.rank()}); - const loc = self.getContext().mlirCtx().location(@src()).namedFmt(self.getContext().mlirCtx(), "lower={}", .{lower}); + const loc = self.getContext().location(@src(), "lower={}", .{lower}); const op = dialect.stablehlo.cholesky(self.getContext().mlirCtx(), self.value(), lower, loc); return _result(self._shape, op.result(0)); } @@ -379,7 +379,7 @@ pub const Tensor = struct { stdx.debug.assert(self.dtype() == other.dtype(), "triangularSolve expects tensors to be of the same type, got {} and {}", .{ self.dtype(), other.dtype() }); stdx.debug.assert(self.rank() <= 2 and self.rank() == other.rank(), "triangularSolve expects tensors to have the same rank and be <= 2, got {} and {}", .{ self.rank(), other.rank() }); - const loc = self.getContext().mlirCtx().location(@src()).namedFmt(self.getContext().mlirCtx(), "opts={}", .{opts}); + const loc = self.getContext().location(@src(), "triangularSolve({_}, {})", .{ self, opts }); const op = dialect.stablehlo.triangular_solve(self.getContext().mlirCtx(), self.value(), other.value(), loc, opts); return _result(self._shape, op.result(0)); } @@ -492,7 +492,7 @@ pub const Tensor = struct { }, }; - const loc = self.getContext().mlirCtx().location(@src()).namedFmt(self.getContext().mlirCtx(), "opts={}", .{opts}); + const loc = self.getContext().location(@src(), "fft({_},{})", .{ self, opts }); const op = dialect.stablehlo.fft(self.getContext().mlirCtx(), self.value(), loc, opts); return _result(sh, op.result(0)); } @@ -522,7 +522,7 @@ pub const Tensor = struct { /// but it is not guaranteed to be deterministic between implementations. pub fn bitGenerator(self: Rng, sh: Shape) struct { Rng, Tensor } { const ctx = CompilationContext.current(); - const loc = ctx.mlirCtx().location(@src()).namedFmt(ctx.mlirCtx(), "rand.bitGen({})", .{sh}); + const loc = ctx.location(@src(), "rand.bitGen({_})", .{sh}); const op = dialect.stablehlo.rng_bit_generator( ctx.mlirCtx(), self.algorithm, @@ -646,12 +646,12 @@ pub const Tensor = struct { pub fn normal(sh: Shape, opts: struct { mean: f64 = 0, stddev: f64 = 1 }) Tensor { stdx.debug.assert(sh.dtype().isFloat(), "normal expects tensor type to be a float, got {}", .{sh.dtype()}); - const ctx = CompilationContext.current().mlirCtx(); - const loc = ctx.location(@src()).namedFmt(ctx, "rand.normal({}, opts={})", .{ sh, opts }); + const ctx = CompilationContext.current(); + const loc = ctx.location(@src(), "rand.normal({_}, mean={},stddev={})", .{ sh, opts.mean, opts.stddev }); const a = Tensor.constant(.{}, Data.init(sh.dtype(), opts.mean)); const b = Tensor.constant(.{}, Data.init(sh.dtype(), opts.stddev)); const res_shape = Tensor.constantTensor(HostBuffer.fromSlice(.{sh.rank()}, sh.dims())); - const op = dialect.stablehlo.rng(ctx, a.value(), b.value(), res_shape.value(), .NORMAL, loc); + const op = dialect.stablehlo.rng(ctx.mlirCtx(), a.value(), b.value(), res_shape.value(), .NORMAL, loc); return _result(sh, op.result(0)); } @@ -744,7 +744,7 @@ pub const Tensor = struct { stdx.debug.assert(1 <= exponent_bits, "reducePrecision expects 'exponent_bits' to be >= 1, got {}", .{exponent_bits}); stdx.debug.assert(0 <= mantissa_bits, "reducePrecision expects 'mantissa_bits' to be positive, got {}", .{mantissa_bits}); - const loc = self.getContext().mlirCtx().location(@src()).namedFmt(self.getContext().mlirCtx(), "reducePrecision(exponent_bits={}, mantissa_bits={})", .{ exponent_bits, mantissa_bits }); + const loc = self.getContext().location(@src(), "reducePrecision(exponent_bits={}, mantissa_bits={})", .{ exponent_bits, mantissa_bits }); const op = dialect.stablehlo.reduce_precision(self.getContext().mlirCtx(), self.value(), exponent_bits, mantissa_bits, loc); return _result(self._shape, op.result(0)); } @@ -867,7 +867,7 @@ pub const Tensor = struct { batch_group_count: i64 = 1, }, ) Tensor { - const loc = input.getContext().mlirCtx().location(@src()).namedFmt(input.getContext().mlirCtx(), "opts={}", .{opts}); + const loc = input.getContext().location(@src(), "opts={}", .{opts}); return input.convolution(kernel, .{ .window_strides = &.{opts.window_strides}, .pad_value = opts.padding, @@ -912,7 +912,7 @@ pub const Tensor = struct { batch_group_count: i64 = 1, }, ) Tensor { - const loc = input.getContext().mlirCtx().location(@src()).namedFmt(input.getContext().mlirCtx(), "opts={}", .{opts}); + const loc = input.getContext().location(@src(), "opts={}", .{opts}); return input.convolution(kernel, .{ .window_strides = opts.window_strides, .pad_value = opts.padding, @@ -935,37 +935,37 @@ pub const Tensor = struct { /// Returns a Tensor containing the element-wise addition of the input Tensors. pub fn add(self: Tensor, other: Tensor) Tensor { - return binaryOp("add", dialect.stablehlo.add)(self, other); + return binaryOp(@src(), "add", dialect.stablehlo.add)(self, other); } /// Returns a Tensor containing the element-wise subtraction of the input Tensors. pub fn sub(self: Tensor, other: Tensor) Tensor { - return binaryOp("subtract", dialect.stablehlo.subtract)(self, other); + return binaryOp(@src(), "subtract", dialect.stablehlo.subtract)(self, other); } /// Returns a Tensor containing the element-wise multiplication of the input Tensors. pub fn mul(self: Tensor, other: Tensor) Tensor { - return binaryOp("mul", dialect.stablehlo.multiply)(self, other); + return binaryOp(@src(), "mul", dialect.stablehlo.multiply)(self, other); } /// Returns a Tensor containing the element-wise division of the input Tensors. pub fn div(self: Tensor, other: Tensor) Tensor { - return binaryOp("div", dialect.stablehlo.divide)(self, other); + return binaryOp(@src(), "div", dialect.stablehlo.divide)(self, other); } /// Returns a Tensor containing the element-wise exponentiation of the input Tensors. pub fn pow(self: Tensor, other: Tensor) Tensor { - return binaryOp("pow", dialect.stablehlo.power)(self, other); + return binaryOp(@src(), "pow", dialect.stablehlo.power)(self, other); } /// Returns a Tensor containing the element-wise maximum operation of the input Tensors. pub fn maximum(self: Tensor, other: Tensor) Tensor { - return binaryOp("maximum", dialect.stablehlo.maximum)(self, other); + return binaryOp(@src(), "maximum", dialect.stablehlo.maximum)(self, other); } /// Returns a Tensor containing the element-wise minimum operation of the input Tensors. pub fn minimum(self: Tensor, other: Tensor) Tensor { - return binaryOp("minimum", dialect.stablehlo.minimum)(self, other); + return binaryOp(@src(), "minimum", dialect.stablehlo.minimum)(self, other); } /// Returns a Tensor containing the element-wise addition of the input Tensor with a constant. @@ -988,9 +988,9 @@ pub const Tensor = struct { /// Returns a Tensor containing the element-wise logical operation of the input Tensors. pub fn logical(self: Tensor, comptime logical_op: LogicalOp, other: Tensor) Tensor { return switch (logical_op) { - .OR => binaryOp("or", dialect.stablehlo.or_)(self, other), - .XOR => binaryOp("xor", dialect.stablehlo.xor)(self, other), - .AND => binaryOp("and", dialect.stablehlo.and_)(self, other), + .OR => binaryOp(@src(), "or", dialect.stablehlo.or_)(self, other), + .XOR => binaryOp(@src(), "xor", dialect.stablehlo.xor)(self, other), + .AND => binaryOp(@src(), "and", dialect.stablehlo.and_)(self, other), }; } @@ -1007,16 +1007,16 @@ pub const Tensor = struct { } /// Returns a Tensor containing the element-wise conversion to another type. - pub fn convert(self: Tensor, dt: DataType) Tensor { - if (dt == self.dtype()) { + pub fn convert(self: Tensor, to: DataType) Tensor { + if (to == self.dtype()) { return self; } - const res_type = mlir.RankedTensorType.init(self.dims(), mlir.ext.Type.fromDType(self.getContext().mlirCtx(), dt)).as(mlir.Type).?; - const loc = self.getContext().mlirCtx().location(@src()).namedFmt(self.getContext().mlirCtx(), "dtype={}", .{dt}); + const res_type = mlir.RankedTensorType.init(self.dims(), mlir.ext.Type.fromDType(self.getContext().mlirCtx(), to)).as(mlir.Type).?; + const loc = self.getContext().location(@src(), "convert({_},to={s})", .{ self, @tagName(to) }); const op = dialect.stablehlo.convert(self.getContext().mlirCtx(), self.value(), res_type, loc); - return _result(self._shape.withDtype(dt), op.result(0)); + return _result(self._shape.withDtype(to), op.result(0)); } /// Returns a Tensor containing the element-wise rounding operation of the input Tensor. @@ -1174,7 +1174,7 @@ pub const Tensor = struct { } const mlir_ctx = lhs.getContext().mlirCtx(); - const loc = mlir_ctx.location(@src()); + const loc = lhs.getContext().location(@src(), "dot({_},{_},contracting={any},batching={any}", .{ lhs, rhs, contracting_axes, batching_axes }); const op = dialect.stablehlo.dot_general( mlir_ctx, lhs.value(), @@ -1376,7 +1376,7 @@ pub const Tensor = struct { return self.reshape(res_shape); } - const loc = self.getContext().location(@src(), "transpose({_}, {d})", .{ self.shape(), permutation }); + const loc = self.getContext().location(@src(), "transpose({_}, {d})", .{ self, permutation }); const op = dialect.stablehlo.transpose( self.getContext().mlirCtx(), self.value(), @@ -1409,7 +1409,7 @@ pub const Tensor = struct { const new_dim = std.math.divExact(i64, self.dim(a), n) catch std.debug.panic("unflatten expects chosen dimension to be divisible by 'n' but {} is not divisible by {}", .{ self.dim(a), n }); const new_shape = self._shape.set(a, n).insert(a + 1, .{ ._ = new_dim }); - const loc = self.getContext().mlirCtx().location(@src()).namedFmt(self.getContext().mlirCtx(), "axis={}, n={}", .{ axis_, n }); + const loc = self.getContext().location(@src(), "axis={}, n={}", .{ axis_, n }); const reshaped_val = dialect.stablehlo.reshape( self.getContext().mlirCtx(), self.value(), @@ -1426,7 +1426,7 @@ pub const Tensor = struct { pub fn splitAxis(self: Tensor, ax: anytype, split_shape: anytype) Tensor { const new_shape = self._shape.splitAxis(ax, split_shape); - const loc = self.getContext().mlirCtx().location(@src()).namedFmt(self.getContext().mlirCtx(), "splitAxis({}, {any})", .{ ax, split_shape }); + const loc = self.getContext().location(@src(), "splitAxis({}, {any})", .{ ax, split_shape }); const reshaped_val = dialect.stablehlo.reshape( self.getContext().mlirCtx(), self.value(), @@ -1464,8 +1464,7 @@ pub const Tensor = struct { // stdx.debug.assert(a + 1 < self.rank(), "Can't flatten {} on the last axis {}.", .{ self, axis }); const new_shape = old_shape.remove(a + 1).set(a, old_shape.dim(a) * old_shape.dim(a + 1)); - const loc = self.getContext().mlirCtx().location(@src()).namedFmt(self.getContext().mlirCtx(), "axis={}", .{axis_}); - + const loc = self.getContext().location(@src(), "flatten({_},{})", .{ self, axis_ }); const reshaped_val = dialect.stablehlo.reshape( self.getContext().mlirCtx(), self.value(), @@ -1583,8 +1582,9 @@ pub const Tensor = struct { } const res_shape = tensors[0]._shape.set(a, concatenated_dim); - const loc = tensors[0].getContext().mlirCtx().location(@src()).namedFmt(tensors[0].getContext().mlirCtx(), "axis={}", .{axis_}); - const op = dialect.stablehlo.concatenate(tensors[0].getContext().mlirCtx(), buffer[0..tensors.len], a, loc); + const ctx = tensors[0].getContext(); + const loc = ctx.location(@src(), "axis={}", .{axis_}); + const op = dialect.stablehlo.concatenate(ctx.mlirCtx(), buffer[0..tensors.len], a, loc); // log.debug("concatenate({}, {}, {d}) -> {d}", .{ tensors[0], tensors[1], a, res_shape }); return _result(res_shape, op.result(0)); } @@ -1749,7 +1749,7 @@ pub const Tensor = struct { stdx.debug.assert(args.step > 0, "arange expects 'args.step' to be positive, got {}", .{args.step}); const ctx = CompilationContext.current(); - const loc = ctx.mlirCtx().location(@src()).namedFmt(ctx.mlirCtx(), "{}, dtype={}", .{ args, dt }); + const loc = ctx.location(@src(), "arange({}, dtype={})", .{ args, dt }); const n_steps = std.math.divCeil(i64, args.end - args.start, args.step) catch unreachable; const sh = Shape.init(.{n_steps}, dt); @@ -1776,9 +1776,10 @@ pub const Tensor = struct { const a = sh.axis(axis_); const dt: DataType = if (sh.dim(a) <= std.math.maxInt(i32)) .i32 else .i64; const res_shape = sh.withDtype(dt); - const mlir_ctx = CompilationContext.current().mlirCtx(); - const loc = mlir_ctx.location(@src()).namedFmt(mlir_ctx, "iota({_}, {})", .{ res_shape, axis_ }); + const ctx = CompilationContext.current(); + const loc = ctx.location(@src(), "iota({_}, {})", .{ res_shape, axis_ }); + const mlir_ctx = ctx.mlirCtx(); var op = dialect.stablehlo.iota(mlir_ctx, a, mlir.ext.RankedTensorType.fromShape(mlir_ctx, res_shape).asType(), loc); return _result(res_shape, op.result(0)); } @@ -1796,7 +1797,7 @@ pub const Tensor = struct { stdx.debug.assert(dt.isFloat(), "linspace expects type to be a float, got {} (hint: use arange instead)", .{dt}); const ctx = CompilationContext.current(); - const loc = ctx.mlirCtx().location(@src()).namedFmt(ctx.mlirCtx(), "linspace({}, dtype={})", .{ args, dt }); + const loc = ctx.location(@src(), "linspace({}, dtype={})", .{ args, dt }); const sh = Shape.init(.{args.steps}, dt); var iota_op = dialect.stablehlo.iota(ctx.mlirCtx(), 0, mlir.ext.mlirType(ctx.mlirCtx(), sh), loc); @@ -1823,7 +1824,7 @@ pub const Tensor = struct { const sh = Shape.init(dimz, val.dtype()); const singleton_sh = Shape.init(.{}, val.dtype()); const ctx = CompilationContext.current().mlirCtx(); - const loc = ctx.location(@src()).namedFmt(ctx, "dims={d}, value={}", .{ sh, val }); + const loc = CompilationContext.current().location(@src(), "dims={d}, value={}", .{ sh, val }); const res_type = mlir.ext.RankedTensorType.fromShape(ctx, singleton_sh); var constant_op = if (mlir.ext.denseElementAttrType(val.dtype())) |elem_type| @@ -1889,9 +1890,10 @@ pub const Tensor = struct { const d = self.dim(self_ax); stdx.debug.assert(d == 1 or d == output_shape.dim(other_ax), "broadcast expects shape axes to either be 1-sized or to match the target size. got broadcast({}, {}, {d}), error on self axis {} mapping to other axis {}", .{ self, output_shape, axes_, self_ax, other_ax }); } - const result_type = mlir.ext.RankedTensorType.fromShape(self.getContext().mlirCtx(), res_shape).as(mlir.Type).?; - const loc = self.getContext().mlirCtx().location(@src()).namedFmt(self.getContext().mlirCtx(), "broadcast({}, {any}, axes={d})", .{ self, res_shape, axes_ }); - const broadcast_op = dialect.stablehlo.broadcast_in_dim(self.getContext().mlirCtx(), self.value(), axes_, result_type, loc); + const ctx = self.getContext(); + const result_type = mlir.ext.RankedTensorType.fromShape(ctx.mlirCtx(), res_shape).as(mlir.Type).?; + const loc = ctx.location(@src(), "broadcast({_}, {_}, axes={d})", .{ self, res_shape, axes_ }); + const broadcast_op = dialect.stablehlo.broadcast_in_dim(ctx.mlirCtx(), self.value(), axes_, result_type, loc); return _result(res_shape, broadcast_op.result(0)); } @@ -1944,7 +1946,7 @@ pub const Tensor = struct { pub fn reshape(self: Tensor, output_shape_: anytype) Tensor { const output_shape = self._shape.reshape(output_shape_); const tensor_type = mlir.ext.RankedTensorType.fromShape(self.getContext().mlirCtx(), output_shape); - const loc = self.getContext().mlirCtx().location(@src()).namedFmt(self.getContext().mlirCtx(), "reshape({any})", .{output_shape}); + const loc = self.getContext().location(@src(), "reshape({any})", .{output_shape}); const reshape_value = dialect.stablehlo.reshape(self.getContext().mlirCtx(), self.value(), tensor_type, loc); return _result(output_shape, reshape_value.result(0)); } @@ -2035,7 +2037,7 @@ pub const Tensor = struct { pub fn reverse(self: Tensor, axes_: anytype) Tensor { const actual_axes = self._shape.axes(axes_); - const loc = self.getContext().mlirCtx().location(@src()).namedFmt(self.getContext().mlirCtx(), "reverse({any})", .{axes_}); + const loc = self.getContext().location(@src(), "reverse({any})", .{axes_}); const reverse_op = dialect.stablehlo.reverse(self.getContext().mlirCtx(), self.value(), toI64(actual_axes.constSlice()), loc); return _result(self._shape, reverse_op.result(0)); } @@ -3082,7 +3084,7 @@ pub const Tensor = struct { const a = self.axis(axis_); const new_shape = self._shape.set(a, slice_.len); - const loc = self.getContext().mlirCtx().location(@src()).namedFmt(self.getContext().mlirCtx(), "dynSlice({}, len={})", .{ axis_, slice_.len }); + const loc = self.getContext().location(@src(), "dynSlice({}, len={})", .{ axis_, slice_.len }); var start_indices = [_]mlir.Value{constant(.{}, slice_.start.dtype().zero()).value()} ** MAX_RANK; start_indices[a] = slice_.start.value(); @@ -3382,7 +3384,7 @@ pub const Tensor = struct { stdx.debug.assert(self._shape.eql(other._shape), "cmp expects input tensor shapes to match, got {} and {}", .{ self._shape, other._shape }); - const loc = self.getContext().mlirCtx().location(@src()).namedFmt(self.getContext().mlirCtx(), "cmp(.{s})", .{@tagName(direction)}); + const loc = self.getContext().location(@src(), "cmp(.{s})", .{@tagName(direction)}); const op = dialect.stablehlo.compare( self.getContext().mlirCtx(), self.value(), @@ -3686,6 +3688,7 @@ pub const Tensor = struct { } fn binaryOp( + src: std.builtin.SourceLocation, op_name: []const u8, op_fn: fn (mlir.Context, mlir.Value, mlir.Value, mlir.Location) mlir.Operation, ) fn (Tensor, Tensor) Tensor { @@ -3703,9 +3706,9 @@ pub const Tensor = struct { stdx.debug.assert(self._shape.eql(other._shape), "{s} expects tensor shapes to match, got {} and {}", .{ op_name, self._shape, other._shape }); - const mlirCtx = self.getContext().mlirCtx(); - const location = mlirCtx.location(@src()); - const ret = @call(.auto, op_fn, .{ mlirCtx, self.value(), other.value(), location }); + const ctx = self.getContext(); + const location = ctx.location(src, "{s}({_}, {_})", .{ op_name, self, other }); + const ret = @call(.auto, op_fn, .{ ctx.mlirCtx(), self.value(), other.value(), location }); return _result(self._shape, ret.result(0)); } }.binaryOpHelper; From ec336ac72ad5f6ef2b53e14b5616023e4152d01c Mon Sep 17 00:00:00 2001 From: Guillaume Wenzek Date: Mon, 16 Dec 2024 14:59:56 +0100 Subject: [PATCH 18/48] scatter handle several inputs --- zml/meta.zig | 20 +++++++ zml/module.zig | 4 +- zml/ops.zig | 140 +++++++++++++++++++++++++++++++++++++++++++++++++ zml/tensor.zig | 103 +++++------------------------------- 4 files changed, 174 insertions(+), 93 deletions(-) diff --git a/zml/meta.zig b/zml/meta.zig index 2e626058..82b25d76 100644 --- a/zml/meta.zig +++ b/zml/meta.zig @@ -392,6 +392,26 @@ test visit { } } +pub fn count(T: type, value: anytype) u32 { + var counter: u32 = 0; + visit(struct { + pub fn cb(res: *u32, _: *const T) void { + res.* += 1; + } + }.cb, &counter, value); + return counter; +} + +pub fn first(T: type, value: anytype) T { + var res: ?T = null; + visit(struct { + pub fn cb(res_ptr: *?T, x: *const T) void { + if (res_ptr.* == null) res_ptr.* = x.*; + } + }.cb, &res, &value); + return res.?; +} + /// Given a `fn([]const T, Args) T` and a slice of values, /// will combine all values in one value. /// Only T elements of values will be looked at. diff --git a/zml/module.zig b/zml/module.zig index f7e69304..74df746d 100644 --- a/zml/module.zig +++ b/zml/module.zig @@ -365,7 +365,7 @@ pub const CompilationContext = struct { defer arena_state.deinit(); const arena = arena_state.allocator(); - const tensor_count = countTensors(args); + const tensor_count = meta.count(Tensor, args); const mlir_ctx = self.mlirCtx(); const loc = mlir_ctx.location(@src()); @@ -795,7 +795,7 @@ pub const CompilationContext = struct { }; } - fn getValue(self: *const CompilationContext, tensor: Tensor) mlir.Value { + pub fn getValue(self: *const CompilationContext, tensor: Tensor) mlir.Value { return self.getValueAndDonation(tensor)[0]; } diff --git a/zml/ops.zig b/zml/ops.zig index 78091434..608b3b8b 100644 --- a/zml/ops.zig +++ b/zml/ops.zig @@ -753,3 +753,143 @@ pub fn addHostCallback( ); return Tensor._result(input.shape(), op.result(0)); } + +pub fn scatter( + comptime T: type, + comptime BlkCtx: type, + comptime update_fn: fn (BlkCtx, T, T) T, + inputs: T, + blkctx: BlkCtx, + coord_axes: anytype, + indices: Tensor, + updates: T, + opts: Tensor.ScatterOpts, +) T { + const loc = @src(); + const ctx = CompilationContext.current(); + + const _parseGatherCoord = @import("tensor.zig")._parseGatherCoord; + const _collectAxes = @import("tensor.zig")._collectAxes; + + const n_inputs = meta.count(Tensor, &inputs); + const n_updates = meta.count(Tensor, &updates); + stdx.debug.assert(n_inputs == n_updates, "zml.ops.scatter expects the same number of tensors in inputs and updates, got {} and {}", .{ n_inputs, n_updates }); + + // Note: I was a bit lazy here, and I only look at tags on the first tensor. + // we probably should check all of them. + const self = meta.first(Tensor, inputs); + const update = meta.first(Tensor, updates); + log.warn("{_}.scatterSlices({any}, {}, {})", .{ self, coord_axes, indices, update }); + const single_coord, const coord_axes_ = _parseGatherCoord(self, coord_axes); + const AxisKind = enum { batching, update_window, inserted_window, window_id }; + var self_kind: std.BoundedArray(AxisKind, Tensor.MAX_RANK) = .{}; + var indices_batch_axes: Shape.DimsArray = .{}; + for (self._shape.tags()) |t| { + if (update._shape.hasTag(t)) |_| { + if (indices._shape.hasTag(t)) |id_ax| { + // tag is in self, indices and updates -> it's a batching dim + self_kind.appendAssumeCapacity(.batching); + indices_batch_axes.appendAssumeCapacity(id_ax); + } else { + self_kind.appendAssumeCapacity(.update_window); + } + } else { + self_kind.appendAssumeCapacity(.inserted_window); + } + } + // scoped_log.warn(" self_kind -> {any}", .{self_kind.constSlice()}); + + const index_coord_axis = if (single_coord) + indices.rank() + else blk: { + const ax = indices._shape.hasTag(.coord) orelse indices._shape.axis(-1); + stdx.debug.assert(indices.dim(ax) == coord_axes_.len, "scatter({}, coord_axes={any}, indices, updates) expects 'indices' to be a tensor [..., {}], got {}", .{ self, coord_axes, coord_axes_.len, indices }); + + break :blk ax; + }; + if (T == Tensor and indices.count() == 1 and !single_coord) { + return self.dynamicUpdateSlice1d(updates, coord_axes_.get(0), indices.reshape(.{})); + } + + var up_kind: std.BoundedArray(AxisKind, Tensor.MAX_RANK) = .{}; + // Note: we assume the scatter_dims appear in the same order inside indices and inside self. + for (update._shape.tags(), 0..) |t, up_ax| { + if (self._shape.hasTag(t)) |self_ax| { + if (self_kind.get(self_ax) == .batching) { + up_kind.appendAssumeCapacity(.batching); + } else { + stdx.debug.assert(update.dim(up_ax) <= self.dim(self_ax), "scatter expects the slices described in 'updates' to fit inside 'self', but along axis .{s} it doesn't. Got self={}, updates={}.", .{ t, self, update }); + up_kind.appendAssumeCapacity(.update_window); + } + } else if (t == Shape.TagUnknown or indices._shape.hasTag(t) != null) { + up_kind.appendAssumeCapacity(.window_id); + } else { + std.debug.panic("scatter expects 'updates' to be made of axes from self={} and from indices={}, got unknown tag {s} in {}", .{ self, indices, t, update }); + } + } + const n_indices_axes = update.rank() - _collectAxes(AxisKind, up_kind, .update_window).len; + if (single_coord) { + stdx.debug.assert(n_indices_axes == indices.rank(), "scatter({}, {any}) expects 'updates' to contain all axes from 'indices', got indices={}, updates={}", .{ self, coord_axes, indices, update }); + } else { + stdx.debug.assert(n_indices_axes == indices.rank() - 1, "scatter({}, {any}) expects 'updates' to contain all-but-last axes from 'indices', got indices={}, updates={}", .{ self, coord_axes, indices, update }); + } + + const mlir_ctx = ctx.mlirCtx(); + var _scalar: T = inputs; + meta.visit(struct { + pub fn cb(_: void, x: *Tensor) void { + x.* = .{ ._shape = Shape.init(.{}, x.dtype()), ._id = undefined }; + } + }.cb, {}, &_scalar); + + const UpdateS = BlockSign(update_fn); + const update_block, _ = ctx.makeBlock(.hermetic, UpdateS, update_fn, blkctx, .{ _scalar, _scalar }); + + var input_values = std.ArrayList(mlir.Value).initCapacity(ctx.allocator(), n_inputs) catch @panic("OOM"); + defer input_values.deinit(); + meta.collect(CompilationContext.getValue, ctx, &input_values, &inputs) catch unreachable; + var updates_values = std.ArrayList(mlir.Value).initCapacity(ctx.allocator(), n_updates) catch @panic("OOM"); + meta.collect(CompilationContext.getValue, ctx, &updates_values, &updates) catch unreachable; + defer updates_values.deinit(); + + const op = dialect.stablehlo.scatter( + mlir_ctx, + input_values.items, + &.{indices.value()}, + updates_values.items, + update_block, + .{ + .update_window_dims = _collectAxes(AxisKind, up_kind, .update_window).constSlice(), + .inserted_window_dims = _collectAxes(AxisKind, self_kind, .inserted_window).constSlice(), + .input_batching_dims = _collectAxes(AxisKind, self_kind, .batching).constSlice(), + .scatter_indices_batching_dims = indices_batch_axes.constSlice(), + .scatter_dims_to_operand_dims = toI64(coord_axes_.constSlice()), + .index_vector_dim = index_coord_axis, + .indices_are_sorted = opts.indices_are_sorted, + .unique_indices = opts.indices_are_unique, + }, + mlir_ctx.location(loc), + ); + + var res: T = inputs; + const LocalContext = struct { + op: mlir.Operation, + index: usize = 0, + }; + var local_context = LocalContext{ .op = op }; + meta.visit((struct { + fn cb(inner_ctx: *LocalContext, tensor: *Tensor) void { + const val = inner_ctx.op.result(inner_ctx.index); + tensor.* = Tensor._result(tensor.shape(), val); + inner_ctx.index += 1; + } + }).cb, &local_context, &res); + assert(local_context.index == op.numResults()); + return res; +} + +inline fn toI64(values: anytype) []i64 { + var res: [Tensor.MAX_RANK]i64 = undefined; + for (values, 0..) |val, i| res[i] = @intCast(val); + return res[0..values.len]; +} diff --git a/zml/tensor.zig b/zml/tensor.zig index 214867fe..1790a0d5 100644 --- a/zml/tensor.zig +++ b/zml/tensor.zig @@ -2399,19 +2399,14 @@ pub const Tensor = struct { /// then you should make sure the slices don't overlap, /// otherwise the result will depend on the runtime scheduling /// of the operator which is backend specific. - update_fn: *const fn (*const anyopaque, Tensor, Tensor) Tensor = increment, + update_fn: *const fn (Tensor, Tensor) Tensor = increment, - /// Extra data that may be needed for a custom update function. - /// `override` and `increment` don't need it, leaving it to undefined works. - update_fn_ctx: *const anyopaque = undefined, - - pub fn increment(_: *const anyopaque, old_value: Tensor, new_value: Tensor) Tensor { - return old_value.add(new_value); + pub fn increment(old_value: Tensor, new_value: Tensor) Tensor { + return old_value.add(new_value.convert(old_value.dtype())); } - pub fn override(_: *const anyopaque, old_value: Tensor, new_value: Tensor) Tensor { - _ = old_value; - return new_value; + pub fn override(old_value: Tensor, new_value: Tensor) Tensor { + return new_value.convert(old_value.dtype()); } }; @@ -2440,91 +2435,17 @@ pub const Tensor = struct { /// In particular if you scatter overlapping slices, with `zml.Tensor.ScatterOpts.override`, /// then the result will depend on the execution order that you don't control. pub fn scatterSlices(self: Tensor, coord_axes: anytype, indices: Tensor, updates: Tensor, opts: ScatterOpts) Tensor { - const loc = @src(); // scoped_log.debug("scatterSlices({}, {any}, {}, {})", .{ self, coord_axes, indices, updates }); - stdx.debug.assert(self.dtype() == updates.dtype(), "scatterSlices expects input and 'updates' tensors to be of the same type, got {} and {}", .{ self.dtype(), updates.dtype() }); + const UpdateType = @TypeOf(ScatterOpts.increment); - const single_coord, const coord_axes_ = _parseGatherCoord(self, coord_axes); - const AxisKind = enum { batching, update_window, inserted_window, window_id }; - var self_kind: std.BoundedArray(AxisKind, MAX_RANK) = .{}; - var indices_batch_axes: Shape.DimsArray = .{}; - for (self._shape.tags()) |t| { - if (updates._shape.hasTag(t)) |_| { - if (indices._shape.hasTag(t)) |id_ax| { - // tag is in self, indices and updates -> it's a batching dim - self_kind.appendAssumeCapacity(.batching); - indices_batch_axes.appendAssumeCapacity(id_ax); - } else { - self_kind.appendAssumeCapacity(.update_window); - } - } else { - self_kind.appendAssumeCapacity(.inserted_window); + const Custom = struct { + pub fn inc(custom: *const UpdateType, old_value: Tensor, new_value: Tensor) Tensor { + return @call(.auto, custom, .{ old_value, new_value }); } - } - // scoped_log.warn(" self_kind -> {any}", .{self_kind.constSlice()}); - - const index_coord_axis = if (single_coord) - indices.rank() - else blk: { - const ax = indices._shape.hasTag(.coord) orelse indices._shape.axis(-1); - stdx.debug.assert(indices.dim(ax) == coord_axes_.len, "scatterSlices({}, coord_axes={any}, indices, updates) expects 'indices' to be a tensor [..., {}], got {}", .{ self, coord_axes, coord_axes_.len, indices }); - - break :blk ax; }; - if (indices.count() == 1 and !single_coord) { - return self.dynamicUpdateSlice1d(updates, coord_axes_.get(0), indices.reshape(.{})); - } - var up_kind: std.BoundedArray(AxisKind, MAX_RANK) = .{}; - // Note: we assume the scatter_dims appear in the same order inside indices and inside self. - for (updates._shape.tags(), 0..) |t, up_ax| { - if (self._shape.hasTag(t)) |self_ax| { - if (self_kind.get(self_ax) == .batching) { - up_kind.appendAssumeCapacity(.batching); - } else { - stdx.debug.assert(updates.dim(up_ax) <= self.dim(self_ax), "scatterSlices expects the slices described in 'updates' to fit inside 'self', but along axis .{s} it doesn't. Got self={}, updates={}.", .{ t, self, updates }); - up_kind.appendAssumeCapacity(.update_window); - } - } else if (t == Shape.TagUnknown or indices._shape.hasTag(t) != null) { - up_kind.appendAssumeCapacity(.window_id); - } else { - std.debug.panic("scatterSlices expects 'updates' to be made of axes from 'self={}' and from 'indices={}', got unknown tag {s} in {}", .{ self, indices, t, updates }); - } - } - const n_indices_axes = updates.rank() - _collectAxes(AxisKind, up_kind, .update_window).len; - if (single_coord) { - stdx.debug.assert(n_indices_axes == indices.rank(), "scatterSlices({}, {any}) expects 'updates' to contain all axes from 'indices', got indices={}, updates={}", .{ self, coord_axes, indices, updates }); - } else { - stdx.debug.assert(n_indices_axes == indices.rank() - 1, "scatterSlices({}, {any}) expects 'updates' to contain all-but-last axes from 'indices', got indices={}, updates={}", .{ self, coord_axes, indices, updates }); - } - - const ctx = self.getContext(); - const mlir_ctx = ctx.mlirCtx(); - - const _scalar: Tensor = .{ ._shape = Shape.init(.{}, self.dtype()), ._id = undefined }; - const UpdateS = ops.BlockSign(ScatterOpts.increment); - const update_block, _ = ctx.makeBlock(.hermetic, UpdateS, opts.update_fn, opts.update_fn_ctx, .{ _scalar, _scalar }); - - const op = dialect.stablehlo.scatter( - mlir_ctx, - &.{self.value()}, - &.{indices.value()}, - &.{updates.value()}, - update_block, - .{ - .update_window_dims = _collectAxes(AxisKind, up_kind, .update_window).constSlice(), - .inserted_window_dims = _collectAxes(AxisKind, self_kind, .inserted_window).constSlice(), - .input_batching_dims = _collectAxes(AxisKind, self_kind, .batching).constSlice(), - .scatter_indices_batching_dims = indices_batch_axes.constSlice(), - .scatter_dims_to_operand_dims = toI64(coord_axes_.constSlice()), - .index_vector_dim = index_coord_axis, - .indices_are_sorted = opts.indices_are_sorted, - .unique_indices = opts.indices_are_unique, - }, - mlir_ctx.location(loc), - ); - return _result(self._shape, op.result(0)); + return ops.scatter(Tensor, *const UpdateType, Custom.inc, self, opts.update_fn, coord_axes, indices, updates, opts); } test scatterSlices { @@ -3949,7 +3870,7 @@ test shapesOf { } } -fn _collectAxes(T: type, bounded_array: std.BoundedArray(T, Tensor.MAX_RANK), value: T) std.BoundedArray(i64, Tensor.MAX_RANK) { +pub fn _collectAxes(T: type, bounded_array: std.BoundedArray(T, Tensor.MAX_RANK), value: T) std.BoundedArray(i64, Tensor.MAX_RANK) { var res: std.BoundedArray(i64, Tensor.MAX_RANK) = .{}; for (bounded_array.constSlice(), 0..) |v, ax| { if (v == value) { @@ -3959,7 +3880,7 @@ fn _collectAxes(T: type, bounded_array: std.BoundedArray(T, Tensor.MAX_RANK), va return res; } -fn _parseGatherCoord(self: Tensor, axes_: anytype) struct { bool, std.BoundedArray(u3, Tensor.MAX_RANK) } { +pub fn _parseGatherCoord(self: Tensor, axes_: anytype) struct { bool, std.BoundedArray(u3, Tensor.MAX_RANK) } { const AxesT = @TypeOf(axes_); const axes_is_scalar = AxesT == EnumLiteral or AxesT == comptime_int or @typeInfo(AxesT) == .Int; From f0a16409ff729216cfbae037d47bca888746945e Mon Sep 17 00:00:00 2001 From: Guillaume Wenzek Date: Tue, 17 Dec 2024 16:06:35 +0100 Subject: [PATCH 19/48] HostBuffer.prettyPrint --- zml/hostbuffer.zig | 61 ++++++++++++++++++++++++++++++++++++++++++++++ zml/tensor.zig | 14 +++++------ 2 files changed, 67 insertions(+), 8 deletions(-) diff --git a/zml/hostbuffer.zig b/zml/hostbuffer.zig index aed629e5..bd88338c 100644 --- a/zml/hostbuffer.zig +++ b/zml/hostbuffer.zig @@ -235,6 +235,22 @@ pub const HostBuffer = struct { }; } + pub fn squeeze(self: HostBuffer, axis_: anytype) HostBuffer { + const ax = self._shape.axis(axis_); + stdx.debug.assert(self.dim(ax) == 1, "squeeze expects a 1-d axis got {} in {}", .{ ax, self }); + + var _strides: ?[Shape.MAX_RANK]i64 = self._strides; + if (self._strides) |strydes| { + std.mem.copyForwards(i64, _strides.?[0 .. Shape.MAX_RANK - 1], strydes[1..]); + } + return .{ + ._shape = self.shape().drop(ax), + .data = self.data, + ._strides = _strides, + ._memory = self._memory, + }; + } + pub fn format( self: HostBuffer, comptime fmt: []const u8, @@ -245,6 +261,51 @@ pub const HostBuffer = struct { _ = options; try writer.print("HostBuffer(.{_})", .{self._shape}); } + + pub fn prettyPrint(self: HostBuffer, writer: anytype) !void { + return self.prettyPrintIndented(4, 0, writer); + } + + fn prettyPrintIndented(self: HostBuffer, num_rows: u8, indent_level: u8, writer: anytype) !void { + if (self.rank() == 1) { + try writer.writeByteNTimes(' ', indent_level); + switch (self.dtype()) { + inline else => |dt| { + const values = self.items(dt.toZigType()); + const n = @min(values.len, 1024); + try writer.print("{any},\n", .{values[0..n]}); + }, + } + return; + } + try writer.writeByteNTimes(' ', indent_level); + _ = try writer.write("{\n"); + defer { + writer.writeByteNTimes(' ', indent_level) catch {}; + _ = writer.write("},\n") catch {}; + } + + // Write first rows + const n: u64 = @intCast(self.dim(0)); + for (0..@min(num_rows, n)) |d| { + const di: i64 = @intCast(d); + const sliced_self = self.slice1d(0, .{ .start = di, .end = di + 1 }).squeeze(0); + try sliced_self.prettyPrintIndented(num_rows, indent_level + 2, writer); + } + + if (n < num_rows) return; + // Skip middle rows + if (n > 2 * num_rows) { + try writer.writeByteNTimes(' ', indent_level + 2); + _ = try writer.write("...\n"); + } + // Write last rows + for (@max(n - num_rows, num_rows)..n) |d| { + const di: i64 = @intCast(d); + const sliced_self = self.slice1d(0, .{ .start = di, .end = di + 1 }).squeeze(0); + try sliced_self.prettyPrintIndented(num_rows, indent_level + 2, writer); + } + } }; fn parseArrayInfo(T: type) Shape { diff --git a/zml/tensor.zig b/zml/tensor.zig index 1790a0d5..9d87cfaf 100644 --- a/zml/tensor.zig +++ b/zml/tensor.zig @@ -1364,7 +1364,7 @@ pub const Tensor = struct { else toI64(axes__); - stdx.debug.assert(permutation.len == self.rank(), "transpose expects input tensor rank and 'axes_' length to be equal, got {} and {}", .{ self.rank(), permutation.len }); + stdx.debug.assert(permutation.len == self.rank(), "transpose expects input tensor rank and 'axes_' length to be equal, got {_} and {d}", .{ self, permutation[0..@min(permutation.len, MAX_RANK + 2)] }); if (std.mem.eql(i64, permutation, no_op[0..self.rank()])) { return self; @@ -3647,13 +3647,11 @@ pub const Tensor = struct { } fn printCallback(host_buffer: HostBuffer) void { - switch (host_buffer.dtype()) { - inline else => |dt| { - const items = host_buffer.items(dt.toZigType()); - const n = @min(items.len, 1024); - std.debug.print("Device buffer: {}: {any}\n", .{ host_buffer.shape(), items[0..n] }); - }, - } + std.debug.lockStdErr(); + defer std.debug.unlockStdErr(); + const stderr = std.io.getStdErr().writer(); + stderr.print("Device buffer: {}:", .{host_buffer.shape()}) catch return; + host_buffer.prettyPrint(stderr) catch return; } }; From 22f31106a2c43e55092db87aeb3d13668ca48280 Mon Sep 17 00:00:00 2001 From: Guillaume Wenzek Date: Tue, 17 Dec 2024 16:47:34 +0100 Subject: [PATCH 20/48] use just shape in error message should this be the default formatting ? --- zml/ops.zig | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/zml/ops.zig b/zml/ops.zig index 608b3b8b..1c172cf4 100644 --- a/zml/ops.zig +++ b/zml/ops.zig @@ -803,7 +803,7 @@ pub fn scatter( indices.rank() else blk: { const ax = indices._shape.hasTag(.coord) orelse indices._shape.axis(-1); - stdx.debug.assert(indices.dim(ax) == coord_axes_.len, "scatter({}, coord_axes={any}, indices, updates) expects 'indices' to be a tensor [..., {}], got {}", .{ self, coord_axes, coord_axes_.len, indices }); + stdx.debug.assert(indices.dim(ax) == coord_axes_.len, "scatter({_}, coord_axes={any}, indices, updates) expects 'indices' to be a tensor [..., {}], got {_}", .{ self, coord_axes, coord_axes_.len, indices }); break :blk ax; }; @@ -818,20 +818,20 @@ pub fn scatter( if (self_kind.get(self_ax) == .batching) { up_kind.appendAssumeCapacity(.batching); } else { - stdx.debug.assert(update.dim(up_ax) <= self.dim(self_ax), "scatter expects the slices described in 'updates' to fit inside 'self', but along axis .{s} it doesn't. Got self={}, updates={}.", .{ t, self, update }); + stdx.debug.assert(update.dim(up_ax) <= self.dim(self_ax), "scatter expects the slices described in 'updates' to fit inside 'self', but along axis .{s} it doesn't. Got self={_}, updates={_}.", .{ t, self, update }); up_kind.appendAssumeCapacity(.update_window); } } else if (t == Shape.TagUnknown or indices._shape.hasTag(t) != null) { up_kind.appendAssumeCapacity(.window_id); } else { - std.debug.panic("scatter expects 'updates' to be made of axes from self={} and from indices={}, got unknown tag {s} in {}", .{ self, indices, t, update }); + std.debug.panic("scatter expects 'updates' to be made of axes from self={_} and from indices={_}, got unknown tag {s} in {_}", .{ self, indices, t, update }); } } const n_indices_axes = update.rank() - _collectAxes(AxisKind, up_kind, .update_window).len; if (single_coord) { - stdx.debug.assert(n_indices_axes == indices.rank(), "scatter({}, {any}) expects 'updates' to contain all axes from 'indices', got indices={}, updates={}", .{ self, coord_axes, indices, update }); + stdx.debug.assert(n_indices_axes == indices.rank(), "scatter({_}, {any}) expects 'updates' to contain all axes from 'indices', got indices={_}, updates={_}", .{ self, coord_axes, indices, update }); } else { - stdx.debug.assert(n_indices_axes == indices.rank() - 1, "scatter({}, {any}) expects 'updates' to contain all-but-last axes from 'indices', got indices={}, updates={}", .{ self, coord_axes, indices, update }); + stdx.debug.assert(n_indices_axes == indices.rank() - 1, "scatter({_}, {any}) expects 'updates' to contain all-but-last axes from 'indices', got indices={_}, updates={_}", .{ self, coord_axes, indices, update }); } const mlir_ctx = ctx.mlirCtx(); From f054492aa74939ae9f70c5ce94c6caa95f0ca182 Mon Sep 17 00:00:00 2001 From: Guillaume Wenzek Date: Wed, 18 Dec 2024 09:37:05 +0100 Subject: [PATCH 21/48] sdpa: drop bias term you can use the attn_mask, they play the same role --- zml/nn.zig | 24 +++++++----------------- zml/nn/cuda.zig | 3 --- 2 files changed, 7 insertions(+), 20 deletions(-) diff --git a/zml/nn.zig b/zml/nn.zig index 7ab11374..97589b5d 100644 --- a/zml/nn.zig +++ b/zml/nn.zig @@ -716,7 +716,6 @@ pub fn causalAttnMask( pub const SdpaOpts = struct { attn_mask: ?Tensor = null, scale: ?Tensor = null, - bias: ?Tensor = null, allow_cudnn: bool = true, // TODO: put a callback instead of all this field, // so that @@ -769,12 +768,7 @@ pub fn sdpa(q_: Tensor, k_: Tensor, v_: Tensor, opts: SdpaOpts) Tensor { // log.debug("attn_weights : {}", .{attn_weights}); // log.debug("attn_mask : {?}", .{attn_mask}); if (attn_mask) |mask| attn_weights = attn_weights.add(mask.broad(attn_weights.shape())); - - attn_weights = attn_weights.convert(.f32); - if (opts.bias) |bias| { - attn_weights = attn_weights.add(bias); - } - attn_weights = attn_weights.softmax(.k).convert(q.dtype()); + attn_weights = attn_weights.convert(.f32).softmax(.k).convert(q.dtype()); var attn = attn_weights.dot(v, .{.k}); return attn.transpose(q.shape()); @@ -983,10 +977,6 @@ pub fn sdpaChunk(q_: Tensor, k_: Tensor, v_: Tensor, opts: SdpaOpts) PartialSoft // log.debug("attn_mask : {?}", .{attn_mask}); if (attn_mask) |mask| attn_weights = attn_weights.add(mask.broad(attn_weights.shape())); - if (opts.bias) |bias| { - attn_weights = attn_weights.add(bias); - } - const partial = partialSoftmax(attn_weights, .k); const attn = partial.values.dot(v, .{.k}).transpose(q.shape()); @@ -1021,7 +1011,7 @@ test sdpaMemEfficient { const ref_res = try zml.testing.compileAndCall( platform, sdpa, - .{ q, k, v, .{ .attn_mask = mask, .scale = null, .bias = null } }, + .{ q, k, v, .{ .attn_mask = mask, .scale = null } }, ); try std.testing.expectEqualSlices(i64, q.shape().dims(), ref_res.shape().dims()); { @@ -1033,7 +1023,7 @@ test sdpaMemEfficient { q, k, v, - .{ .attn_mask = mask, .scale = null, .bias = null }, + .{ .attn_mask = mask, .scale = null }, .{ .q_chunk_size = 256, .k_chunk_size = @divExact(512, 4) }, }, ); @@ -1049,7 +1039,7 @@ test sdpaMemEfficient { q, k, v, - .{ .attn_mask = mask, .scale = null, .bias = null }, + .{ .attn_mask = mask, .scale = null }, .{ .q_chunk_size = 256, .k_chunk_size = @divExact(512, 16) }, }, ); @@ -1079,7 +1069,7 @@ test "sdpaMemEfficient transposed" { const ref_res = try zml.testing.compileAndCall( platform, sdpa, - .{ q, k, v, .{ .attn_mask = mask, .scale = null, .bias = null } }, + .{ q, k, v, .{ .attn_mask = mask, .scale = null } }, ); try std.testing.expectEqualSlices(i64, q.shape().dims(), ref_res.shape().dims()); @@ -1091,7 +1081,7 @@ test "sdpaMemEfficient transposed" { q, k, v, - .{ .attn_mask = mask, .scale = null, .bias = null }, + .{ .attn_mask = mask, .scale = null }, .{ .q_chunk_size = @divExact(512, 2), .k_chunk_size = @divExact(512, 4) }, }, ); @@ -1107,7 +1097,7 @@ test "sdpaMemEfficient transposed" { q, k, v, - .{ .attn_mask = mask, .scale = null, .bias = null }, + .{ .attn_mask = mask, .scale = null }, .{ .q_chunk_size = 512, .k_chunk_size = @divExact(512, 4) }, }, ); diff --git a/zml/nn/cuda.zig b/zml/nn/cuda.zig index 4c840cb5..854da729 100644 --- a/zml/nn/cuda.zig +++ b/zml/nn/cuda.zig @@ -118,9 +118,6 @@ pub fn sdpa(q_: Tensor, k_: Tensor, v_: Tensor, opts: SdpaOpts) Tensor { if (opts.attn_mask) |attn_mask| { bias = bias.add(attn_mask.broad(bias.shape())); } - if (opts.bias) |b| { - bias = bias.add(b); - } const mlir_ctx = ctx.mlirCtx(); const loc = mlir_ctx.location(@src()); From fc51164f01c6db3387ab9e9bc5082444d30f7872 Mon Sep 17 00:00:00 2001 From: Guillaume Wenzek Date: Wed, 18 Dec 2024 11:20:38 +0100 Subject: [PATCH 22/48] gatherSlices should accept a shape literal --- zml/tensor.zig | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/zml/tensor.zig b/zml/tensor.zig index 9d87cfaf..29d948f8 100644 --- a/zml/tensor.zig +++ b/zml/tensor.zig @@ -2244,7 +2244,8 @@ pub const Tensor = struct { /// while gatherValues, always copy values one by one, and as such don't have the same issues. /// In our example the contiguous dimension .d is not sliced /// and gatherSlices can copy data by group of C'*D elements. - pub fn gatherSlices(self: Tensor, slice_shape: Shape, indices: Tensor, opts: GatherOpts) Tensor { + pub fn gatherSlices(self: Tensor, slice_shape_: anytype, indices: Tensor, opts: GatherOpts) Tensor { + const slice_shape = if (@TypeOf(slice_shape_) == Shape) slice_shape_ else Shape.init(slice_shape_, .i32); // scoped_log.debug("gatherSlice({}, {_}, {})", .{ self, slice_shape, indices }); const tagged_api = slice_shape.isFullyTagged(); @@ -2294,7 +2295,7 @@ pub const Tensor = struct { } } - const loc = self.getContext().mlirCtx().location(@src()); + const loc = self.getContext().location(@src(), "gatherSlices({_}, slice_shape={_}, idx={_})", .{ self, slice_shape, indices }); const gather_op = dialect.stablehlo.gather( self.getContext().mlirCtx(), self.value(), @@ -2318,6 +2319,12 @@ pub const Tensor = struct { const zml = @import("zml.zig"); const platform = zml.testing.env(); + const Local = struct { + pub fn _gatherSlices(self: Tensor, slice_shape: Shape, indices: Tensor, opts: GatherOpts) Tensor { + return self.gatherSlices(slice_shape, indices, opts); + } + }; + { // Only test shapes var comp = try zml.module.CompilationContext.init(std.testing.allocator, "test", platform); @@ -2354,7 +2361,7 @@ pub const Tensor = struct { const mod = try zml.compileFn( std.testing.allocator, - gatherSlices, + Local._gatherSlices, .{ x.shape(), slice_shape, idx.shape(), .{ .indices_are_sorted = true } }, platform, ); @@ -2370,7 +2377,7 @@ pub const Tensor = struct { const start_indices = (try zml.Buffer.fromArray(platform, [2][2]i32{ .{ 2, 1 }, .{ 0, 3 } })).withTags(.{ .n, ._ }); defer start_indices.deinit(); - const result = try zml.testing.compileAndCall(platform, gatherSlices, .{ operand, Shape.init(.{ .b = 2, .c = 3 }, .u16), start_indices, .{} }); + const result = try zml.testing.compileAndCall(platform, Local._gatherSlices, .{ operand, Shape.init(.{ .b = 2, .c = 3 }, .u16), start_indices, .{} }); const expected = zml.HostBuffer.fromArray(&[2][2][2][3]u16{ .{ From d68155de1eb3a69c13aaa2660415649fe4b3a285 Mon Sep 17 00:00:00 2001 From: Guillaume Wenzek Date: Wed, 18 Dec 2024 16:59:06 +0100 Subject: [PATCH 23/48] fix scalar of bool --- mlir/mlir.zig | 2 +- zml/tensor.zig | 16 ++++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/mlir/mlir.zig b/mlir/mlir.zig index fd6bdb88..2dc2b9f3 100644 --- a/mlir/mlir.zig +++ b/mlir/mlir.zig @@ -619,7 +619,7 @@ pub const DenseElementsAttributeTypes = enum { pub fn DenseIntOrFPElementsAttribute(comptime dt: DenseElementsAttributeTypes) type { const ZigInDataType, const ZigOutDataType, const initFn, const getValue = switch (dt) { - .bool => .{ i32, bool, c.mlirDenseElementsAttrBoolGet, c.mlirDenseElementsAttrGetBoolValue }, + .bool => .{ bool, bool, c.mlirDenseElementsAttrBoolGet, c.mlirDenseElementsAttrGetBoolValue }, .i8 => .{ i8, i8, c.mlirDenseElementsAttrInt8Get, c.mlirDenseElementsAttrGetInt8Value }, .i16 => .{ i16, i16, c.mlirDenseElementsAttrInt16Get, c.mlirDenseElementsAttrGetInt16Value }, .i32 => .{ i32, i32, c.mlirDenseElementsAttrInt32Get, c.mlirDenseElementsAttrGetInt32Value }, diff --git a/zml/tensor.zig b/zml/tensor.zig index 29d948f8..9534e6da 100644 --- a/zml/tensor.zig +++ b/zml/tensor.zig @@ -1819,6 +1819,22 @@ pub const Tensor = struct { return Tensor.constant(.{}, Data.init(dt, val)); } + test scalar { + const zml = @import("zml.zig"); + const platform = zml.testing.env(); + + const Local = struct { + pub fn _fwd() [6]Tensor { + var res: [6]Tensor = undefined; + const dtypes = .{ .bool, .u8, .i32, .f32, .bf16, .u64 }; + inline for (0..6) |i| res[i] = scalar(0, dtypes[i]); + return res; + } + }; + + _ = try zml.testing.compileAndCall(platform, Local._fwd, .{}); + } + /// Returns a constant Tensor with the given value. pub fn constant(dimz: anytype, val: Data) Tensor { const sh = Shape.init(dimz, val.dtype()); From ac0c6f83da25337ae2fb6570c45c2c716f8a0f9c Mon Sep 17 00:00:00 2001 From: Guillaume Wenzek Date: Wed, 18 Dec 2024 16:59:52 +0100 Subject: [PATCH 24/48] remainder should leverage binop --- zml/tensor.zig | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/zml/tensor.zig b/zml/tensor.zig index 9534e6da..cd59adc7 100644 --- a/zml/tensor.zig +++ b/zml/tensor.zig @@ -317,13 +317,6 @@ pub const Tensor = struct { return _result(self._shape, op.result(0)); } - /// Returns a Tensor containing the element-wise remainder of dividend 'self' and divisor 'other'. - pub fn remainder(self: Tensor, other: Tensor) Tensor { - const loc = self.getContext().mlirCtx().location(@src()); - const op = dialect.stablehlo.remainder(self.getContext().mlirCtx(), self.value(), other.value(), loc); - return _result(self._shape, op.result(0)); - } - /// Returns a Tensor containing the element-wise remainder of dividend 'self' and divisor 'other'. /// /// See https://pytorch.org/docs/stable/generated/torch.fmod.html for more details. @@ -968,6 +961,11 @@ pub const Tensor = struct { return binaryOp(@src(), "minimum", dialect.stablehlo.minimum)(self, other); } + /// Returns a Tensor containing the element-wise remainder of dividend 'self' and divisor 'other'. + pub fn remainder(self: Tensor, other: Tensor) Tensor { + return binaryOp(@src(), "remainder", dialect.stablehlo.remainder)(self, other); + } + /// Returns a Tensor containing the element-wise addition of the input Tensor with a constant. pub fn addConstant(self: Tensor, b: anytype) Tensor { return self.add(Tensor.scalar(b, self.dtype())); From cbc6a6449018dd8b46adb3781df3b0447542bfc2 Mon Sep 17 00:00:00 2001 From: Guillaume Wenzek Date: Wed, 18 Dec 2024 17:00:46 +0100 Subject: [PATCH 25/48] add outer on the shape --- zml/shape.zig | 16 ++++++++++++++++ zml/tensor.zig | 20 +++----------------- 2 files changed, 19 insertions(+), 17 deletions(-) diff --git a/zml/shape.zig b/zml/shape.zig index c032ba25..54fa3a98 100644 --- a/zml/shape.zig +++ b/zml/shape.zig @@ -1008,4 +1008,20 @@ pub const Shape = struct { try std.testing.expectEqual(1, s.axis(.b)); } } + + pub fn outer(self: Shape, other: Shape) Shape { + var res_shape = self; + var batching_axes: u8 = 0; + for (0..other.rank()) |ax| { + if (other.tag(ax) != Shape.TagUnknown) { + if (self.hasTag(other.tag(ax))) |batching_ax| { + stdx.debug.assert(batching_ax == batching_axes and batching_ax == ax, "outer expects batching dims to be the first dims in both tensors, got outer({}, {})", .{ self, other }); + batching_axes += 1; + } + } + + res_shape = res_shape.appendDim(other.dim(ax), other.tag(ax)); + } + return res_shape; + } }; diff --git a/zml/tensor.zig b/zml/tensor.zig index cd59adc7..07479d76 100644 --- a/zml/tensor.zig +++ b/zml/tensor.zig @@ -1600,7 +1600,7 @@ pub const Tensor = struct { const res_shape = shape0.insertTag(axis_, 1, tag); for (tensors[1..]) |tensor| { - stdx.debug.assert(shape0.eqlWithTags(tensor._shape), "stack expects tensor shapes to match, got {} and {}", .{ tensor._shape, shape0 }); + stdx.debug.assert(shape0.eqlWithTags(tensor._shape), "stack expects tensor shapes to match, got {} and {}", .{ shape0, tensor._shape }); } var reshaped: [32]Tensor = undefined; @@ -1871,22 +1871,8 @@ pub const Tensor = struct { return self.mul(other); } - const other_shape = other.shape(); - var res_shape = self.shape(); - var batching_axes: u8 = 0; - for (0..other.rank()) |ax| { - if (other_shape.tag(ax) != Shape.TagUnknown) { - if (self.shape().hasTag(other_shape.tag(ax))) |batching_ax| { - stdx.debug.assert(batching_ax == batching_axes and batching_ax == ax, "outer expects batching dims to be the first dims in both tensors, got outer({}, {})", .{ self, other }); - batching_axes += 1; - } - } - - res_shape = res_shape.appendDim(other_shape.dim(ax), other_shape.tag(ax)); - } - const left = self.broad(res_shape); - const right = other.broad(res_shape); - return left.mul(right); + const res_shape = self.shape().outer(other.shape()); + return self.broad(res_shape).mul(other.broad(res_shape)); } /// Given a tensor and a shape of the same rank, From 62024ec847ed22d386db79807e54746428393596 Mon Sep 17 00:00:00 2001 From: Guillaume Wenzek Date: Wed, 18 Dec 2024 17:01:33 +0100 Subject: [PATCH 26/48] Tensor.all --- zml/tensor.zig | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/zml/tensor.zig b/zml/tensor.zig index 07479d76..14db2b58 100644 --- a/zml/tensor.zig +++ b/zml/tensor.zig @@ -3483,17 +3483,31 @@ pub const Tensor = struct { /// Returns a Tensor containing boolean indicating if there is a non-zero value over the given axis. pub fn any(self: Tensor, axis_: anytype) Tensor { const pred = self.cmp(.NE, Tensor.constant(self.dims(), self.dtype().zero())); - const red = ops.reduce( + return ops.reduce( struct { pub fn acc(x: Tensor, res: Tensor) Tensor { return res.logical(.OR, x); } }.acc, pred, - Tensor.scalar(0, pred.dtype()), + Tensor.scalar(false, .bool), + &.{self.axis(axis_)}, + ); + } + + /// Returns a Tensor containing boolean indicating if there is a non-zero value over the given axis. + pub fn all(self: Tensor, axis_: anytype) Tensor { + const pred = if (self.dtype() == .bool) self else self.cmp(.NE, Tensor.scalar(0, self.dtype())); + return ops.reduce( + struct { + pub fn acc(x: Tensor, res: Tensor) Tensor { + return res.logical(.AND, x); + } + }.acc, + pred, + Tensor.scalar(true, .bool), &.{self.axis(axis_)}, ); - return red; } /// Given a set of N vectors of lengths A, B, C, D, From bdfa99023704aa13ccd85ebc08d8e21d0e2ca58d Mon Sep 17 00:00:00 2001 From: Guillaume Wenzek Date: Wed, 18 Dec 2024 17:02:38 +0100 Subject: [PATCH 27/48] argMax can automatically chose the index dtype --- zml/nn.zig | 6 +++--- zml/tensor.zig | 13 ++++++------- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/zml/nn.zig b/zml/nn.zig index 97589b5d..6f756e99 100644 --- a/zml/nn.zig +++ b/zml/nn.zig @@ -1117,7 +1117,7 @@ pub const SamplingStrategy = struct { /// Returns an integer tensor with a shape similar to the input, but without the .voc axis. pub fn sampleTokens(activations: Tensor, opts: SamplingStrategy, rng: Tensor.Rng) struct { Tensor, Tensor.Rng } { if (opts.topk <= 1) { - const next_tokens = activations.argMax(.voc, .i32).indices.squeeze(.voc); + const next_tokens = activations.argMax(.voc).indices.squeeze(.voc); return .{ next_tokens, rng }; } @@ -1134,7 +1134,7 @@ pub fn sampleTokens(activations: Tensor, opts: SamplingStrategy, rng: Tensor.Rng // https://en.wikipedia.org/wiki/Gumbel_distribution#Gumbel_reparametrization_tricks const next_rng, const gumbel_noise = rng.gumbel(x.shape()); x = x.add(gumbel_noise); - const topk_idx = x.argMax(.topk, .i32).indices; + const topk_idx = x.argMax(.topk).indices; // topk_idx is indices into topk.values ! so in the range [0, topk] // Convert for the original indices from the full [0, voc] range. @@ -1224,7 +1224,7 @@ pub fn sampleTokensDynamic(logits: Tensor, opts: DynamicSamplingStrategy, rng: T const next_rng, const gumbel_noise = rng.gumbel(x.shape()); x = x.add(gumbel_noise); - const topk_idx = x.argMax(.topk, .i32).indices; + const topk_idx = x.argMax(.topk).indices; const next_tokens = topk_indices.gatherValues(.voc, topk_idx.squeeze(.topk), .{}); return .{ next_tokens, next_rng }; } diff --git a/zml/tensor.zig b/zml/tensor.zig index 14db2b58..7853497f 100644 --- a/zml/tensor.zig +++ b/zml/tensor.zig @@ -685,7 +685,7 @@ pub const Tensor = struct { // Test out the gumbel reparametrization trick var x = target_dist.log().withTags(.{.d}).broad(s); x = x.add(data); - const samples = x.argMax(.d, .i32).indices.squeeze(.d); + const samples = x.argMax(.d).indices.squeeze(.d); // count 0, 1, 2 and 3 in samples: // - map 0 to 1, 1 to 2**16, 2 to 2**32, 3 to N**58 @@ -2645,15 +2645,14 @@ pub const Tensor = struct { /// Stable argmax: /// * bubbles up Nan /// * in case of equality the smallest index matching the maximum - pub fn argMax(x: Tensor, axis_: anytype, index_dtype: DataType) ArgMaxRes { - stdx.debug.assert(index_dtype.isInteger(), "argMax expect index type to be an integer, got {}", .{index_dtype}); - + pub fn argMax(x: Tensor, axis_: anytype) ArgMaxRes { const a = x.axis(axis_); + const dt: DataType = if (x.dim(a) <= std.math.maxInt(i32)) .i32 else .i64; return ops.reduce( ArgMaxRes.cmp, - .{ .values = x, .indices = Tensor.arange(.{ .end = x.dim(a) }, index_dtype).broadcast(x.shape(), &.{a}) }, - .{ .values = Tensor.constant(&.{}, x.dtype().minValue()), .indices = Tensor.scalar(0, index_dtype) }, + .{ .values = x, .indices = Tensor.arange(.{ .end = x.dim(a) }, dt).broadcast(x.shape(), &.{a}) }, + .{ .values = Tensor.constant(&.{}, x.dtype().minValue()), .indices = Tensor.scalar(0, dt) }, &.{a}, ); } @@ -2664,7 +2663,7 @@ pub const Tensor = struct { const allocator = std.testing.allocator; const ArgMaxTest = struct { pub fn forward(x: Tensor) Tensor.ArgMaxRes { - return x.argMax(1, .i32); + return x.argMax(1); } }; From cb1513d8bdee435cfabc31b7f3d8e37b4795539c Mon Sep 17 00:00:00 2001 From: Guillaume Wenzek Date: Thu, 19 Dec 2024 17:33:22 +0100 Subject: [PATCH 28/48] lockStderr --- mlir/mlir.zig | 2 ++ 1 file changed, 2 insertions(+) diff --git a/mlir/mlir.zig b/mlir/mlir.zig index 2dc2b9f3..4a704a55 100644 --- a/mlir/mlir.zig +++ b/mlir/mlir.zig @@ -853,6 +853,8 @@ pub const Operation = struct { @panic("Failed to create MLIR operation"); }; if (args.verify and new_op.verify() == false) { + std.debug.lockStdErr(); + defer std.debug.unlockStdErr(); log.err("Failed to verify MLIR operation:\n{}", .{new_op.mlirFormatter(.{ .debug_info = true })}); @panic("Failed to verify MLIR operation"); } From d635c1a7b3d2dd32f103cec2055432423dd6b92b Mon Sep 17 00:00:00 2001 From: Guillaume Wenzek Date: Tue, 31 Dec 2024 12:43:31 +0100 Subject: [PATCH 29/48] limit profiler output to a size that can be handled by the UI --- pjrt/profiler.zig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pjrt/profiler.zig b/pjrt/profiler.zig index 93883b2b..1e6e2f00 100644 --- a/pjrt/profiler.zig +++ b/pjrt/profiler.zig @@ -135,7 +135,7 @@ pub const Profiler = struct { return; } - var converter = try TraceContainer.init(allocator, profile_data.items(), null); + var converter = try TraceContainer.init(allocator, profile_data.items(), 1_000_000); defer converter.deinit(); var output_file = try dir.createFile(file_name, .{}); From dc41aadcd753f7ac999567dff799b3ffdcc0af92 Mon Sep 17 00:00:00 2001 From: Guillaume Wenzek Date: Tue, 31 Dec 2024 12:44:14 +0100 Subject: [PATCH 30/48] HostBuffer.pretty --- zml/hostbuffer.zig | 14 ++++++++++++++ zml/tensor.zig | 8 ++------ 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/zml/hostbuffer.zig b/zml/hostbuffer.zig index bd88338c..b0840581 100644 --- a/zml/hostbuffer.zig +++ b/zml/hostbuffer.zig @@ -262,6 +262,20 @@ pub const HostBuffer = struct { try writer.print("HostBuffer(.{_})", .{self._shape}); } + pub fn pretty(self: HostBuffer) PrettyPrinter { + return .{ .x = self }; + } + + pub const PrettyPrinter = struct { + x: HostBuffer, + + pub fn format(self: PrettyPrinter, comptime fmt: []const u8, options: std.fmt.FormatOptions, writer: anytype) !void { + _ = fmt; + _ = options; + try prettyPrint(self.x, writer); + } + }; + pub fn prettyPrint(self: HostBuffer, writer: anytype) !void { return self.prettyPrintIndented(4, 0, writer); } diff --git a/zml/tensor.zig b/zml/tensor.zig index 7853497f..75b244dc 100644 --- a/zml/tensor.zig +++ b/zml/tensor.zig @@ -1620,7 +1620,7 @@ pub const Tensor = struct { /// Repeats a Tensor several times along the given axis. /// - /// * repeat1d(x, concat(&.{x, x, x, x}, axis); + /// * repeat1d(x, axis, 4) = concat(&.{x, x, x, x}, axis); /// * repeat1d([0, 1, 2, 3], 0, 2) = [0, 1, 2, 3, 0, 1, 2, 3] pub fn repeat1d(self: Tensor, axis_: anytype, n_rep: u63) Tensor { if (n_rep == 1) { @@ -3667,11 +3667,7 @@ pub const Tensor = struct { } fn printCallback(host_buffer: HostBuffer) void { - std.debug.lockStdErr(); - defer std.debug.unlockStdErr(); - const stderr = std.io.getStdErr().writer(); - stderr.print("Device buffer: {}:", .{host_buffer.shape()}) catch return; - host_buffer.prettyPrint(stderr) catch return; + std.debug.print("Device buffer: {}: {}", .{ host_buffer.shape(), host_buffer.pretty() }); } }; From 4ecfa16867891e2e938d87e1774bca10e362c028 Mon Sep 17 00:00:00 2001 From: Guillaume Wenzek Date: Tue, 31 Dec 2024 12:45:27 +0100 Subject: [PATCH 31/48] meta.edit --- zml/meta.zig | 62 +++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 61 insertions(+), 1 deletion(-) diff --git a/zml/meta.zig b/zml/meta.zig index 82b25d76..b176f572 100644 --- a/zml/meta.zig +++ b/zml/meta.zig @@ -235,7 +235,6 @@ test mapAlloc { try testing.expectEqual(12, bb.static_slice[1].b); } -/// Recursively visit the given struct and calls the callback for each K found. /// The `v` parameter must me a pointer, and tensor data need to be mutable if callbacks needs it. pub fn visit(comptime cb: anytype, ctx: FnParam(cb, 0), v: anytype) void { const T = @TypeOf(v); @@ -269,6 +268,7 @@ pub fn visit(comptime cb: anytype, ctx: FnParam(cb, 0), v: anytype) void { } else switch (@typeInfo(ptr_info.child)) { .Struct => |s| inline for (s.fields) |field_info| { if (field_info.is_comptime) continue; + if (@sizeOf(field_info.type) == 0) continue; const field_type_info = @typeInfo(field_info.type); // If the field is already a pointer, we recurse with it directly, otherwise, we recurse with a pointer to the field. switch (field_type_info) { @@ -392,6 +392,66 @@ test visit { } } +pub fn edit(comptime cb: anytype, ctx: _CollectCtx(cb), from: anytype) @TypeOf(from) { + const T = _CollectArg(cb); + stdx.debug.assertComptime(stdx.meta.FnResult(cb) == T, "edit expects a `fn(T) T` or a `fn(Ctx, T) T callback got {}", .{@TypeOf(cb)}); + + var res = from; + if (@TypeOf(ctx) == void) { + visit(struct { + pub fn _cb(_: void, x: *T) void { + x.* = cb(x.*); + } + }._cb, ctx, &res); + } else { + visit(struct { + pub fn _cb(_ctx: _CollectCtx(cb), x: *T) void { + x.* = cb(_ctx, x.*); + } + }._cb, ctx, &res); + } + + return res; +} + +test edit { + const A = struct { + a: i8, + pub fn increment(offset: u8, a: @This()) @This() { + return .{ .a = a.a + offset }; + } + + pub fn negate(a: @This()) @This() { + return .{ .a = -a.a }; + } + }; + + const Empty = struct {}; + + const AA = struct { + field: A, + array: [2]A, + other: u8, + // We want to allow conversion from comptime to runtime, because Zig type inference works like this. + field_with_empty: struct { A, Empty }, + }; + + const aa: AA = .{ + .field = .{ .a = 4 }, + .array = .{ .{ .a = 5 }, .{ .a = 6 } }, + .other = 7, + .field_with_empty = .{ .{ .a = 9 }, .{} }, + }; + + const bb = edit(A.negate, {}, aa); + try testing.expectEqual(bb, AA{ + .field = .{ .a = -4 }, + .array = .{ .{ .a = -5 }, .{ .a = -6 } }, + .other = 7, + .field_with_empty = .{ .{ .a = -9 }, .{} }, + }); +} + pub fn count(T: type, value: anytype) u32 { var counter: u32 = 0; visit(struct { From b3239bc0c334fc52f9a5e2087a26cf74a4662cb4 Mon Sep 17 00:00:00 2001 From: Guillaume Wenzek Date: Tue, 31 Dec 2024 12:45:39 +0100 Subject: [PATCH 32/48] expose zml.pjrt --- zml/zml.zig | 1 + 1 file changed, 1 insertion(+) diff --git a/zml/zml.zig b/zml/zml.zig index 292708eb..d4e6992f 100644 --- a/zml/zml.zig +++ b/zml/zml.zig @@ -25,6 +25,7 @@ pub const nn = @import("nn.zig"); pub const module = @import("module.zig"); pub const meta = @import("meta.zig"); pub const platform = @import("platform.zig"); +pub const pjrt = @import("pjrtx.zig"); pub const testing = @import("testing.zig"); pub const torch = @import("torch.zig"); From 261ce1b77c176817ceed23bc344d757b08186d43 Mon Sep 17 00:00:00 2001 From: Guillaume Wenzek Date: Tue, 31 Dec 2024 12:46:11 +0100 Subject: [PATCH 33/48] more verbose error for expectClose --- zml/testing.zig | 1 + 1 file changed, 1 insertion(+) diff --git a/zml/testing.zig b/zml/testing.zig index 9d7a47e0..2c0cc4c6 100644 --- a/zml/testing.zig +++ b/zml/testing.zig @@ -53,6 +53,7 @@ pub fn expectClose(left_: anytype, right_: anytype, tolerance: f32) !void { if (should_free_left) left.deinit(allocator); if (should_free_right) right.deinit(allocator); } + errdefer log.err("--> Left: {}\n--> Right: {}", .{ left.pretty(), right.pretty() }); if (!std.mem.eql(i64, left.shape().dims(), right.shape().dims())) { log.err("left.shape() {} != right.shape() {}", .{ left.shape(), right.shape() }); From 6476e053b171a107c549940e430cf0b4230bb835 Mon Sep 17 00:00:00 2001 From: Guillaume Wenzek Date: Fri, 3 Jan 2025 13:30:07 +0100 Subject: [PATCH 34/48] add scatter todos --- zml/ops.zig | 6 +++++- zml/tensor.zig | 3 +++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/zml/ops.zig b/zml/ops.zig index 1c172cf4..02d71c39 100644 --- a/zml/ops.zig +++ b/zml/ops.zig @@ -774,6 +774,7 @@ pub fn scatter( const n_inputs = meta.count(Tensor, &inputs); const n_updates = meta.count(Tensor, &updates); stdx.debug.assert(n_inputs == n_updates, "zml.ops.scatter expects the same number of tensors in inputs and updates, got {} and {}", .{ n_inputs, n_updates }); + // TODO: check all dtypes are the same, this is currently an XLA limitation on scatter // Note: I was a bit lazy here, and I only look at tags on the first tensor. // we probably should check all of them. @@ -849,8 +850,8 @@ pub fn scatter( defer input_values.deinit(); meta.collect(CompilationContext.getValue, ctx, &input_values, &inputs) catch unreachable; var updates_values = std.ArrayList(mlir.Value).initCapacity(ctx.allocator(), n_updates) catch @panic("OOM"); - meta.collect(CompilationContext.getValue, ctx, &updates_values, &updates) catch unreachable; defer updates_values.deinit(); + meta.collect(CompilationContext.getValue, ctx, &updates_values, &updates) catch unreachable; const op = dialect.stablehlo.scatter( mlir_ctx, @@ -861,6 +862,9 @@ pub fn scatter( .{ .update_window_dims = _collectAxes(AxisKind, up_kind, .update_window).constSlice(), .inserted_window_dims = _collectAxes(AxisKind, self_kind, .inserted_window).constSlice(), + // TODO: the batching_dims is a lie + // although they are in stablehlo, they aren't handled well by "scatter_simplifier" pass that insert extra transposes when it sees them, + // while they act as extra coordinates. we should rewrite them .input_batching_dims = _collectAxes(AxisKind, self_kind, .batching).constSlice(), .scatter_indices_batching_dims = indices_batch_axes.constSlice(), .scatter_dims_to_operand_dims = toI64(coord_axes_.constSlice()), diff --git a/zml/tensor.zig b/zml/tensor.zig index 75b244dc..d6c0b66c 100644 --- a/zml/tensor.zig +++ b/zml/tensor.zig @@ -2408,6 +2408,9 @@ pub const Tensor = struct { /// of the operator which is backend specific. update_fn: *const fn (Tensor, Tensor) Tensor = increment, + allow_double_transpose: bool = false, + allow_while_loop: bool = false, + pub fn increment(old_value: Tensor, new_value: Tensor) Tensor { return old_value.add(new_value.convert(old_value.dtype())); } From 5ef822be3f47a1763aa9ecee49c089d8021fdcb1 Mon Sep 17 00:00:00 2001 From: Guillaume Wenzek Date: Fri, 3 Jan 2025 15:15:19 +0100 Subject: [PATCH 35/48] change scatter syntax --- zml/ops.zig | 55 +++++++-------- zml/tensor.zig | 179 +++++++++++++++++++++++++------------------------ 2 files changed, 118 insertions(+), 116 deletions(-) diff --git a/zml/ops.zig b/zml/ops.zig index 02d71c39..645af1eb 100644 --- a/zml/ops.zig +++ b/zml/ops.zig @@ -760,15 +760,13 @@ pub fn scatter( comptime update_fn: fn (BlkCtx, T, T) T, inputs: T, blkctx: BlkCtx, - coord_axes: anytype, - indices: Tensor, + index_tensors: anytype, updates: T, opts: Tensor.ScatterOpts, ) T { const loc = @src(); const ctx = CompilationContext.current(); - const _parseGatherCoord = @import("tensor.zig")._parseGatherCoord; const _collectAxes = @import("tensor.zig")._collectAxes; const n_inputs = meta.count(Tensor, &inputs); @@ -780,17 +778,24 @@ pub fn scatter( // we probably should check all of them. const self = meta.first(Tensor, inputs); const update = meta.first(Tensor, updates); - log.warn("{_}.scatterSlices({any}, {}, {})", .{ self, coord_axes, indices, update }); - const single_coord, const coord_axes_ = _parseGatherCoord(self, coord_axes); + log.warn("{_}.scatterSlices({any}, {})", .{ self, index_tensors, update }); + const indices_per_axis, const coord_axes_ = Shape.parseStruct(Tensor, index_tensors); + if (indices_per_axis.len == 0) return inputs; + const indices_shape = indices_per_axis.get(0).shape(); + // TODO: validate indices_shape: all tensors should have the same shape + // TODO: validate coord axes: all coord_axes should exist inside self + const AxisKind = enum { batching, update_window, inserted_window, window_id }; var self_kind: std.BoundedArray(AxisKind, Tensor.MAX_RANK) = .{}; var indices_batch_axes: Shape.DimsArray = .{}; for (self._shape.tags()) |t| { if (update._shape.hasTag(t)) |_| { - if (indices._shape.hasTag(t)) |id_ax| { + if (std.mem.indexOfScalar(Shape.Tag, coord_axes_.constSlice(), t)) |_| { + self_kind.appendAssumeCapacity(.update_window); + } else if (indices_shape.hasTag(t)) |id_ax| { // tag is in self, indices and updates -> it's a batching dim self_kind.appendAssumeCapacity(.batching); - indices_batch_axes.appendAssumeCapacity(id_ax); + indices_batch_axes.appendAssumeCapacity(@intCast(id_ax)); } else { self_kind.appendAssumeCapacity(.update_window); } @@ -798,42 +803,31 @@ pub fn scatter( self_kind.appendAssumeCapacity(.inserted_window); } } - // scoped_log.warn(" self_kind -> {any}", .{self_kind.constSlice()}); + log.warn(" * self_kind -> {any}", .{self_kind.constSlice()}); - const index_coord_axis = if (single_coord) - indices.rank() - else blk: { - const ax = indices._shape.hasTag(.coord) orelse indices._shape.axis(-1); - stdx.debug.assert(indices.dim(ax) == coord_axes_.len, "scatter({_}, coord_axes={any}, indices, updates) expects 'indices' to be a tensor [..., {}], got {_}", .{ self, coord_axes, coord_axes_.len, indices }); - - break :blk ax; - }; - if (T == Tensor and indices.count() == 1 and !single_coord) { - return self.dynamicUpdateSlice1d(updates, coord_axes_.get(0), indices.reshape(.{})); + if (T == Tensor and indices_per_axis.len == 1 and indices_per_axis.get(0).count() == 1) { + return self.dynamicUpdateSlice1d(updates, self.axis(coord_axes_.get(0)), indices_per_axis.get(0).reshape(.{})); } var up_kind: std.BoundedArray(AxisKind, Tensor.MAX_RANK) = .{}; // Note: we assume the scatter_dims appear in the same order inside indices and inside self. for (update._shape.tags(), 0..) |t, up_ax| { - if (self._shape.hasTag(t)) |self_ax| { + if (t == Shape.TagUnknown or indices_shape.hasTag(t) != null) { + up_kind.appendAssumeCapacity(.window_id); + } else if (self._shape.hasTag(t)) |self_ax| { if (self_kind.get(self_ax) == .batching) { up_kind.appendAssumeCapacity(.batching); } else { stdx.debug.assert(update.dim(up_ax) <= self.dim(self_ax), "scatter expects the slices described in 'updates' to fit inside 'self', but along axis .{s} it doesn't. Got self={_}, updates={_}.", .{ t, self, update }); up_kind.appendAssumeCapacity(.update_window); } - } else if (t == Shape.TagUnknown or indices._shape.hasTag(t) != null) { - up_kind.appendAssumeCapacity(.window_id); } else { - std.debug.panic("scatter expects 'updates' to be made of axes from self={_} and from indices={_}, got unknown tag {s} in {_}", .{ self, indices, t, update }); + std.debug.panic("scatter expects 'updates' to be made of axes from self={_} and from indices={s}, got unknown tag {s} in {_}", .{ self, coord_axes_.constSlice(), t, update }); } } - const n_indices_axes = update.rank() - _collectAxes(AxisKind, up_kind, .update_window).len; - if (single_coord) { - stdx.debug.assert(n_indices_axes == indices.rank(), "scatter({_}, {any}) expects 'updates' to contain all axes from 'indices', got indices={_}, updates={_}", .{ self, coord_axes, indices, update }); - } else { - stdx.debug.assert(n_indices_axes == indices.rank() - 1, "scatter({_}, {any}) expects 'updates' to contain all-but-last axes from 'indices', got indices={_}, updates={_}", .{ self, coord_axes, indices, update }); - } + log.warn(" * up_kind -> {any}", .{up_kind.constSlice()}); + // const n_indices_axes = update.rank() - _collectAxes(AxisKind, up_kind, .update_window).len; + // stdx.debug.assert(n_indices_axes == coord_axes_.len, "scatter({_}, {any}) expects 'updates' to contain all axes from 'indices', got indices={s}, updates={_}", .{ self, index_tensors, coord_axes_.constSlice(), update }); const mlir_ctx = ctx.mlirCtx(); var _scalar: T = inputs; @@ -853,6 +847,7 @@ pub fn scatter( defer updates_values.deinit(); meta.collect(CompilationContext.getValue, ctx, &updates_values, &updates) catch unreachable; + const indices = Tensor.stack(indices_per_axis.constSlice(), .last, .coord); const op = dialect.stablehlo.scatter( mlir_ctx, input_values.items, @@ -867,8 +862,8 @@ pub fn scatter( // while they act as extra coordinates. we should rewrite them .input_batching_dims = _collectAxes(AxisKind, self_kind, .batching).constSlice(), .scatter_indices_batching_dims = indices_batch_axes.constSlice(), - .scatter_dims_to_operand_dims = toI64(coord_axes_.constSlice()), - .index_vector_dim = index_coord_axis, + .scatter_dims_to_operand_dims = toI64(self.axes(coord_axes_.constSlice()).constSlice()), + .index_vector_dim = indices.rank() - 1, .indices_are_sorted = opts.indices_are_sorted, .unique_indices = opts.indices_are_unique, }, diff --git a/zml/tensor.zig b/zml/tensor.zig index d6c0b66c..1d38fc6e 100644 --- a/zml/tensor.zig +++ b/zml/tensor.zig @@ -2444,7 +2444,7 @@ pub const Tensor = struct { /// **Warning**: if `opts.update_fn` is not associative not all calls to `scatterSlices` are sound. /// In particular if you scatter overlapping slices, with `zml.Tensor.ScatterOpts.override`, /// then the result will depend on the execution order that you don't control. - pub fn scatterSlices(self: Tensor, coord_axes: anytype, indices: Tensor, updates: Tensor, opts: ScatterOpts) Tensor { + pub fn scatterSlices(self: Tensor, indices: anytype, updates: Tensor, opts: ScatterOpts) Tensor { // scoped_log.debug("scatterSlices({}, {any}, {}, {})", .{ self, coord_axes, indices, updates }); const UpdateType = @TypeOf(ScatterOpts.increment); @@ -2455,7 +2455,7 @@ pub const Tensor = struct { } }; - return ops.scatter(Tensor, *const UpdateType, Custom.inc, self, opts.update_fn, coord_axes, indices, updates, opts); + return ops.scatter(Tensor, *const UpdateType, Custom.inc, self, opts.update_fn, indices, updates, opts); } test scatterSlices { @@ -2471,6 +2471,10 @@ pub const Tensor = struct { .{ .update_fn = ScatterOpts.increment }, ); } + + pub fn idx(idx_shape: anytype) Tensor { + return Tensor.constant(idx_shape, .{ .i32 = 0 }); + } }; { @@ -2479,111 +2483,114 @@ pub const Tensor = struct { defer comp.deinit(); comp.activate(); defer comp.deactivate(); + const idx = Local.idx; inline for (.{ - .{ .{ .a = 10 }, .a, .{}, .{ .a = 3 } }, - .{ .{ .a = 10, .b = 20 }, .b, .{ .a = 10, .n = 8 }, .{ .a = 10, .n = 8, .b = 2 } }, + // This is equivalent to a dynamic update slice, update 3 values at given offset of axis .a: + .{ .{ .a = 10 }, .{ .a = idx(.{}) }, .{ .a = 3 } }, + // Use .a as a batching axis with .a=10 x .n=8 updates of 2 elements of .b + .{ .{ .a = 10, .b = 20 }, .{ .b = idx(.{ .a = 10, .n = 8 }) }, .{ .a = 10, .n = 8, .b = 2 } }, + // similar, but use the normalized form where a is no longer an explicit batching axis. + .{ .{ .a = 10, .b = 20 }, .{ .a = idx(.{ .a2 = 10, .n = 8 }), .b = idx(.{ .a2 = 10, .n = 8 }) }, .{ .a2 = 10, .n = 8, .b = 2 } }, // I'm not sure I like this variant, cause `b` is not mentionned in updates. // So 'stablehlo.scatter' is implicitly broadcasting the updates along `b` axis. // OTOH asking the user to do the broadcasting isn't trivial cause they will need to do shape wrangling and that's annoying. - .{ .{ .a = 10, .b = 20 }, .a, .{ .n = 8 }, .{ .n = 8, .a = 2 } }, - .{ .{ .a = 10, .b = 20 }, .{ .b, .a }, .{ .n = 8, ._ = 2 }, .{ .n = 8, .a = 3, .b = 2 } }, - .{ .{ .a = 10, .b = 20 }, .{ .a, .b }, .{ .n = 8, ._ = 2 }, .{ .a = 3, .n = 8, .b = 2 } }, + .{ .{ .a = 10, .b = 20 }, .{ .a = idx(.{ .n = 8 }) }, .{ .n = 8, .a = 2 } }, + .{ .{ .a = 10, .b = 20 }, .{ .b = idx(.{ .n = 8 }), .a = idx(.{ .n = 8 }) }, .{ .n = 8, .a = 3, .b = 2 } }, + .{ .{ .a = 10, .b = 20 }, .{ .a = idx(.{ .n = 8 }), .b = idx(.{ .n = 8 }) }, .{ .a = 3, .n = 8, .b = 2 } }, }) |testcase| { - const x_shape, const axes_, const idx_shape, const updates_shapes = testcase; + const x_shape, const indices, const updates_shapes = testcase; const x = Tensor.constant(x_shape, .{ .f16 = 0 }); - const idx = Tensor.constant(idx_shape, .{ .i32 = 0 }); const updates = Tensor.constant(updates_shapes, .{ .f16 = 0 }); - const y = scatterSlices(x, axes_, idx, updates, .{}); + const y = scatterSlices(x, indices, updates, .{}); // Shape doesn't change with scatterSlices try zml.testing.expectEqualShapes(x.shape(), y.shape()); try std.testing.expect(y.value().owner().verify()); } } - // Test with actual values, no batching. - { - const a_host = try zml.HostBuffer.arange(std.testing.allocator, .{ .end = 9 }, .i32); - const a = (try zml.Buffer.from(platform, a_host.reshape(.{ 3, 3 }))).withTags(.{ .a, .b }); - defer a.deinit(); - a_host.deinit(std.testing.allocator); + // // Test with actual values, no batching. + // { + // const a_host = try zml.HostBuffer.arange(std.testing.allocator, .{ .end = 9 }, .i32); + // const a = (try zml.Buffer.from(platform, a_host.reshape(.{ 3, 3 }))).withTags(.{ .a, .b }); + // defer a.deinit(); + // a_host.deinit(std.testing.allocator); - const scatter_indices = try zml.Buffer.fromArray(platform, [2][1]i32{ .{0}, .{2} }); - const updates = try zml.Buffer.fromArray(platform, [2][3]i32{ .{ 10, 20, 30 }, .{ 70, 80, 90 } }); + // const scatter_indices = try zml.Buffer.fromArray(platform, [2][1]i32{ .{0}, .{2} }); + // const updates = try zml.Buffer.fromArray(platform, [2][3]i32{ .{ 10, 20, 30 }, .{ 70, 80, 90 } }); - const expected = [3][3]i32{ .{ 10, 21, 32 }, .{ 3, 4, 5 }, .{ 76, 87, 98 } }; - const result = try zml.testing.compileAndCall(platform, Local.scatter, .{ - a, - a.shape().axes(.{.a}), - scatter_indices.withTags(.{ .n, .coord }), - updates.withTags(.{ .n, .b }), - }); - try std.testing.expect(a.shape().eql(result.shape())); - try std.testing.expectEqual(expected, result.getValue(@TypeOf(expected))); - } - // Test with setting individual values (no batching) - { - const a_host = try zml.HostBuffer.arange(std.testing.allocator, .{ .end = 9 }, .i32); - const a = try zml.Buffer.from(platform, a_host); - defer a.deinit(); - a_host.deinit(std.testing.allocator); + // const expected = [3][3]i32{ .{ 10, 21, 32 }, .{ 3, 4, 5 }, .{ 76, 87, 98 } }; + // const result = try zml.testing.compileAndCall(platform, Local.scatter, .{ + // a, + // &.{ scatter_indices.withTags(.{ .n, .coord }), + // updates.withTags(.{ .n, .b }), + // }); + // try std.testing.expect(a.shape().eql(result.shape())); + // try std.testing.expectEqual(expected, result.getValue(@TypeOf(expected))); + // } + // // Test with setting individual values (no batching) + // { + // const a_host = try zml.HostBuffer.arange(std.testing.allocator, .{ .end = 9 }, .i32); + // const a = try zml.Buffer.from(platform, a_host); + // defer a.deinit(); + // a_host.deinit(std.testing.allocator); - const scatter_indices = try zml.Buffer.fromArray(platform, [2][1]i32{ .{2}, .{7} }); - const updates = try zml.Buffer.fromArray(platform, [2]i32{ 20, 70 }); + // const scatter_indices = try zml.Buffer.fromArray(platform, [2][1]i32{ .{2}, .{7} }); + // const updates = try zml.Buffer.fromArray(platform, [2]i32{ 20, 70 }); - const expected = [9]i32{ 0, 1, 22, 3, 4, 5, 6, 77, 8 }; - const result = try zml.testing.compileAndCall(platform, Local.scatter, .{ - a, - a.shape().axes(.{0}), - scatter_indices.withTags(.{ .n, .coord }), - updates.withTags(.{.n}), - }); - try std.testing.expect(a.shape().eql(result.shape())); - try std.testing.expectEqual(expected, result.getValue(@TypeOf(expected))); - } - { - // Test with actual values and batching along axis .a - const operand = try zml.Buffer.constant(platform, Shape.init(.{ .a = 2, .b = 3, .c = 4, .d = 2 }, .u16), 0); - defer operand.deinit(); - const start_indices = (try zml.Buffer.fromArray( - platform, - [2][2][3][2]i32{ - .{ - .{ .{ 0, 0 }, .{ 1, 0 }, .{ 2, 1 } }, - .{ .{ 0, 1 }, .{ 1, 1 }, .{ 0, 9 } }, - }, - .{ - .{ .{ 0, 0 }, .{ 2, 1 }, .{ 2, 2 } }, - .{ .{ 1, 2 }, .{ 0, 1 }, .{ 1, 0 } }, - }, - }, - )).withTags(.{ .n, .a, .m, .coord }); - defer start_indices.deinit(); + // const expected = [9]i32{ 0, 1, 22, 3, 4, 5, 6, 77, 8 }; + // const result = try zml.testing.compileAndCall(platform, Local.scatter, .{ + // a, + // a.shape().axes(.{0}), + // scatter_indices.withTags(.{ .n, .coord }), + // updates.withTags(.{.n}), + // }); + // try std.testing.expect(a.shape().eql(result.shape())); + // try std.testing.expectEqual(expected, result.getValue(@TypeOf(expected))); + // } + // { + // // Test with actual values and batching along axis .a + // const operand = try zml.Buffer.constant(platform, Shape.init(.{ .a = 2, .b = 3, .c = 4, .d = 2 }, .u16), 0); + // defer operand.deinit(); + // const start_indices = (try zml.Buffer.fromArray( + // platform, + // [2][2][3][2]i32{ + // .{ + // .{ .{ 0, 0 }, .{ 1, 0 }, .{ 2, 1 } }, + // .{ .{ 0, 1 }, .{ 1, 1 }, .{ 0, 9 } }, + // }, + // .{ + // .{ .{ 0, 0 }, .{ 2, 1 }, .{ 2, 2 } }, + // .{ .{ 1, 2 }, .{ 0, 1 }, .{ 1, 0 } }, + // }, + // }, + // )).withTags(.{ .n, .a, .m, .coord }); + // defer start_indices.deinit(); - const values = try zml.Buffer.constant( - platform, - Shape.init(.{ .n = 2, .a = 2, .m = 3, .c = 2, .d = 2 }, .u16), - 1, - ); - defer values.deinit(); + // const values = try zml.Buffer.constant( + // platform, + // Shape.init(.{ .n = 2, .a = 2, .m = 3, .c = 2, .d = 2 }, .u16), + // 1, + // ); + // defer values.deinit(); - const result = try zml.testing.compileAndCall(platform, Local.scatter, .{ operand, operand.shape().axes(.{ .c, .b }), start_indices, values }); + // const result = try zml.testing.compileAndCall(platform, Local.scatter, .{ operand, operand.shape().axes(.{ .c, .b }), start_indices, values }); - const expected = [2][3][4][2]u16{ - .{ - .{ .{ 2, 2 }, .{ 3, 3 }, .{ 1, 1 }, .{ 0, 0 } }, - .{ .{ 0, 0 }, .{ 0, 0 }, .{ 2, 2 }, .{ 2, 2 } }, - .{ .{ 0, 0 }, .{ 0, 0 }, .{ 1, 1 }, .{ 1, 1 } }, - }, - .{ - .{ .{ 0, 0 }, .{ 1, 1 }, .{ 1, 1 }, .{ 0, 0 } }, - .{ .{ 2, 2 }, .{ 3, 3 }, .{ 1, 1 }, .{ 0, 0 } }, - .{ .{ 0, 0 }, .{ 1, 1 }, .{ 1, 1 }, .{ 0, 0 } }, - }, - }; - try std.testing.expect(operand.shape().eql(result.shape())); - try std.testing.expectEqual(expected, result.getValue(@TypeOf(expected))); - } + // const expected = [2][3][4][2]u16{ + // .{ + // .{ .{ 2, 2 }, .{ 3, 3 }, .{ 1, 1 }, .{ 0, 0 } }, + // .{ .{ 0, 0 }, .{ 0, 0 }, .{ 2, 2 }, .{ 2, 2 } }, + // .{ .{ 0, 0 }, .{ 0, 0 }, .{ 1, 1 }, .{ 1, 1 } }, + // }, + // .{ + // .{ .{ 0, 0 }, .{ 1, 1 }, .{ 1, 1 }, .{ 0, 0 } }, + // .{ .{ 2, 2 }, .{ 3, 3 }, .{ 1, 1 }, .{ 0, 0 } }, + // .{ .{ 0, 0 }, .{ 1, 1 }, .{ 1, 1 }, .{ 0, 0 } }, + // }, + // }; + // try std.testing.expect(operand.shape().eql(result.shape())); + // try std.testing.expectEqual(expected, result.getValue(@TypeOf(expected))); + // } } /// Returns a Tensor containing the maximum over a given axis. From d668e3a869a5137ea048469e447b242aecf3ae2e Mon Sep 17 00:00:00 2001 From: Guillaume Wenzek Date: Mon, 6 Jan 2025 07:24:25 +0100 Subject: [PATCH 36/48] scatter: handle simplified batching syntax --- zml/ops.zig | 15 +++++++++------ zml/tensor.zig | 1 + 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/zml/ops.zig b/zml/ops.zig index 645af1eb..1381933d 100644 --- a/zml/ops.zig +++ b/zml/ops.zig @@ -790,12 +790,15 @@ pub fn scatter( var indices_batch_axes: Shape.DimsArray = .{}; for (self._shape.tags()) |t| { if (update._shape.hasTag(t)) |_| { - if (std.mem.indexOfScalar(Shape.Tag, coord_axes_.constSlice(), t)) |_| { - self_kind.appendAssumeCapacity(.update_window); - } else if (indices_shape.hasTag(t)) |id_ax| { - // tag is in self, indices and updates -> it's a batching dim - self_kind.appendAssumeCapacity(.batching); - indices_batch_axes.appendAssumeCapacity(@intCast(id_ax)); + if (indices_shape.hasTag(t)) |id_ax| { + if (std.mem.indexOfScalar(Shape.Tag, coord_axes_.constSlice(), t) != null) { + // tag is in indices AND in coords -> it's a batching dim that has been rewritten to a regular insertion dim + self_kind.appendAssumeCapacity(.inserted_window); + } else { + // tag is in self, indices and updates -> it's a batching dim + self_kind.appendAssumeCapacity(.batching); + indices_batch_axes.appendAssumeCapacity(@intCast(id_ax)); + } } else { self_kind.appendAssumeCapacity(.update_window); } diff --git a/zml/tensor.zig b/zml/tensor.zig index 1d38fc6e..e2db3bc5 100644 --- a/zml/tensor.zig +++ b/zml/tensor.zig @@ -2492,6 +2492,7 @@ pub const Tensor = struct { .{ .{ .a = 10, .b = 20 }, .{ .b = idx(.{ .a = 10, .n = 8 }) }, .{ .a = 10, .n = 8, .b = 2 } }, // similar, but use the normalized form where a is no longer an explicit batching axis. .{ .{ .a = 10, .b = 20 }, .{ .a = idx(.{ .a2 = 10, .n = 8 }), .b = idx(.{ .a2 = 10, .n = 8 }) }, .{ .a2 = 10, .n = 8, .b = 2 } }, + .{ .{ .a = 10, .b = 20 }, .{ .a = idx(.{ .a = 10, .n = 8 }), .b = idx(.{ .a = 10, .n = 8 }) }, .{ .a = 10, .n = 8, .b = 2 } }, // I'm not sure I like this variant, cause `b` is not mentionned in updates. // So 'stablehlo.scatter' is implicitly broadcasting the updates along `b` axis. // OTOH asking the user to do the broadcasting isn't trivial cause they will need to do shape wrangling and that's annoying. From b36e8ce2958cb4e2cbfcd66828ae9ed1bbb13a12 Mon Sep 17 00:00:00 2001 From: Guillaume Wenzek Date: Mon, 6 Jan 2025 07:53:24 +0100 Subject: [PATCH 37/48] scatter: restore some tests --- zml/ops.zig | 96 +++++++++++++++++++++++++++++++++----------------- zml/tensor.zig | 72 ++++++++++++++++++------------------- 2 files changed, 98 insertions(+), 70 deletions(-) diff --git a/zml/ops.zig b/zml/ops.zig index 1381933d..f2d8eb98 100644 --- a/zml/ops.zig +++ b/zml/ops.zig @@ -780,55 +780,85 @@ pub fn scatter( const update = meta.first(Tensor, updates); log.warn("{_}.scatterSlices({any}, {})", .{ self, index_tensors, update }); const indices_per_axis, const coord_axes_ = Shape.parseStruct(Tensor, index_tensors); + log.warn(" * indices_per_axis -> {any}", .{indices_per_axis.constSlice()}); + log.warn(" * coord_axes_ -> {any}", .{coord_axes_.constSlice()}); + if (indices_per_axis.len == 0) return inputs; const indices_shape = indices_per_axis.get(0).shape(); + const tagged_api = coord_axes_.len > 0; + if (T == Tensor and indices_per_axis.len == 1 and indices_shape.count() == 1) { + return self.dynamicUpdateSlice1d( + updates, + if (tagged_api) self.axis(coord_axes_.get(0)) else 0, + indices_per_axis.get(0).reshape(.{}), + ); + } + // TODO: validate indices_shape: all tensors should have the same shape // TODO: validate coord axes: all coord_axes should exist inside self const AxisKind = enum { batching, update_window, inserted_window, window_id }; + var self_kind: std.BoundedArray(AxisKind, Tensor.MAX_RANK) = .{}; + var up_kind: std.BoundedArray(AxisKind, Tensor.MAX_RANK) = .{}; var indices_batch_axes: Shape.DimsArray = .{}; - for (self._shape.tags()) |t| { - if (update._shape.hasTag(t)) |_| { - if (indices_shape.hasTag(t)) |id_ax| { - if (std.mem.indexOfScalar(Shape.Tag, coord_axes_.constSlice(), t) != null) { - // tag is in indices AND in coords -> it's a batching dim that has been rewritten to a regular insertion dim - self_kind.appendAssumeCapacity(.inserted_window); + var scatter_to_operand_axes: Shape.DimsArray = .{}; + + if (tagged_api) { + for (coord_axes_.constSlice()) |t| { + scatter_to_operand_axes.appendAssumeCapacity(self.axis(t)); + } + + for (self._shape.tags()) |t| { + if (update._shape.hasTag(t)) |_| { + if (indices_shape.hasTag(t)) |id_ax| { + if (std.mem.indexOfScalar(Shape.Tag, coord_axes_.constSlice(), t) != null) { + // tag is in indices AND in coords -> it's a batching dim that has been rewritten to a regular insertion dim + self_kind.appendAssumeCapacity(.inserted_window); + } else { + // tag is in self, indices and updates -> it's a batching dim + self_kind.appendAssumeCapacity(.batching); + indices_batch_axes.appendAssumeCapacity(@intCast(id_ax)); + } } else { - // tag is in self, indices and updates -> it's a batching dim - self_kind.appendAssumeCapacity(.batching); - indices_batch_axes.appendAssumeCapacity(@intCast(id_ax)); + self_kind.appendAssumeCapacity(.update_window); } } else { - self_kind.appendAssumeCapacity(.update_window); + self_kind.appendAssumeCapacity(.inserted_window); } - } else { + } + + // Note: we assume the scatter_dims appear in the same order inside indices and inside self. + for (update._shape.tags(), 0..) |t, up_ax| { + if (t == Shape.TagUnknown or indices_shape.hasTag(t) != null) { + up_kind.appendAssumeCapacity(.window_id); + } else if (self._shape.hasTag(t)) |self_ax| { + if (self_kind.get(self_ax) == .batching) { + up_kind.appendAssumeCapacity(.batching); + } else { + stdx.debug.assert(update.dim(up_ax) <= self.dim(self_ax), "scatter expects the slices described in 'updates' to fit inside 'self', but along axis .{s} it doesn't. Got self={_}, updates={_}.", .{ t, self, update }); + up_kind.appendAssumeCapacity(.update_window); + } + } else { + std.debug.panic("scatter expects 'updates' to be made of axes from self={_} and from indices={s}, got unknown tag {s} in {_}", .{ self, coord_axes_.constSlice(), t, update }); + } + } + } else { + for (0..indices_per_axis.len) |i| { self_kind.appendAssumeCapacity(.inserted_window); + scatter_to_operand_axes.appendAssumeCapacity(@intCast(i)); + up_kind.appendAssumeCapacity(.window_id); + } + for (indices_per_axis.len..self.rank()) |_| { + self_kind.appendAssumeCapacity(.update_window); + } + for (indices_per_axis.len..updates.rank()) |_| { + up_kind.appendAssumeCapacity(.update_window); } } log.warn(" * self_kind -> {any}", .{self_kind.constSlice()}); - - if (T == Tensor and indices_per_axis.len == 1 and indices_per_axis.get(0).count() == 1) { - return self.dynamicUpdateSlice1d(updates, self.axis(coord_axes_.get(0)), indices_per_axis.get(0).reshape(.{})); - } - - var up_kind: std.BoundedArray(AxisKind, Tensor.MAX_RANK) = .{}; - // Note: we assume the scatter_dims appear in the same order inside indices and inside self. - for (update._shape.tags(), 0..) |t, up_ax| { - if (t == Shape.TagUnknown or indices_shape.hasTag(t) != null) { - up_kind.appendAssumeCapacity(.window_id); - } else if (self._shape.hasTag(t)) |self_ax| { - if (self_kind.get(self_ax) == .batching) { - up_kind.appendAssumeCapacity(.batching); - } else { - stdx.debug.assert(update.dim(up_ax) <= self.dim(self_ax), "scatter expects the slices described in 'updates' to fit inside 'self', but along axis .{s} it doesn't. Got self={_}, updates={_}.", .{ t, self, update }); - up_kind.appendAssumeCapacity(.update_window); - } - } else { - std.debug.panic("scatter expects 'updates' to be made of axes from self={_} and from indices={s}, got unknown tag {s} in {_}", .{ self, coord_axes_.constSlice(), t, update }); - } - } log.warn(" * up_kind -> {any}", .{up_kind.constSlice()}); + // const n_indices_axes = update.rank() - _collectAxes(AxisKind, up_kind, .update_window).len; // stdx.debug.assert(n_indices_axes == coord_axes_.len, "scatter({_}, {any}) expects 'updates' to contain all axes from 'indices', got indices={s}, updates={_}", .{ self, index_tensors, coord_axes_.constSlice(), update }); @@ -865,7 +895,7 @@ pub fn scatter( // while they act as extra coordinates. we should rewrite them .input_batching_dims = _collectAxes(AxisKind, self_kind, .batching).constSlice(), .scatter_indices_batching_dims = indices_batch_axes.constSlice(), - .scatter_dims_to_operand_dims = toI64(self.axes(coord_axes_.constSlice()).constSlice()), + .scatter_dims_to_operand_dims = scatter_to_operand_axes.constSlice(), .index_vector_dim = indices.rank() - 1, .indices_are_sorted = opts.indices_are_sorted, .unique_indices = opts.indices_are_unique, diff --git a/zml/tensor.zig b/zml/tensor.zig index e2db3bc5..28502be7 100644 --- a/zml/tensor.zig +++ b/zml/tensor.zig @@ -2463,9 +2463,8 @@ pub const Tensor = struct { const platform = zml.testing.env(); const Local = struct { - pub fn scatter(self: Tensor, coord_axes: Shape.AxesArray, indices: Tensor, updates: Tensor) Tensor { + pub fn scatter(self: Tensor, indices: []const Tensor, updates: Tensor) Tensor { return self.scatterSlices( - coord_axes.constSlice(), indices, updates, .{ .update_fn = ScatterOpts.increment }, @@ -2510,45 +2509,44 @@ pub const Tensor = struct { try std.testing.expect(y.value().owner().verify()); } } - // // Test with actual values, no batching. - // { - // const a_host = try zml.HostBuffer.arange(std.testing.allocator, .{ .end = 9 }, .i32); - // const a = (try zml.Buffer.from(platform, a_host.reshape(.{ 3, 3 }))).withTags(.{ .a, .b }); - // defer a.deinit(); - // a_host.deinit(std.testing.allocator); + // Test with actual values, no batching. + { + const a_host = try zml.HostBuffer.arange(std.testing.allocator, .{ .end = 9 }, .i32); + const a = (try zml.Buffer.from(platform, a_host.reshape(.{ 3, 3 }))).withTags(.{ .a, .b }); + defer a.deinit(); + a_host.deinit(std.testing.allocator); - // const scatter_indices = try zml.Buffer.fromArray(platform, [2][1]i32{ .{0}, .{2} }); - // const updates = try zml.Buffer.fromArray(platform, [2][3]i32{ .{ 10, 20, 30 }, .{ 70, 80, 90 } }); + const scatter_indices = try zml.Buffer.fromArray(platform, [2]i32{ 0, 2 }); + const updates = try zml.Buffer.fromArray(platform, [2][3]i32{ .{ 10, 20, 30 }, .{ 70, 80, 90 } }); - // const expected = [3][3]i32{ .{ 10, 21, 32 }, .{ 3, 4, 5 }, .{ 76, 87, 98 } }; - // const result = try zml.testing.compileAndCall(platform, Local.scatter, .{ - // a, - // &.{ scatter_indices.withTags(.{ .n, .coord }), - // updates.withTags(.{ .n, .b }), - // }); - // try std.testing.expect(a.shape().eql(result.shape())); - // try std.testing.expectEqual(expected, result.getValue(@TypeOf(expected))); - // } - // // Test with setting individual values (no batching) - // { - // const a_host = try zml.HostBuffer.arange(std.testing.allocator, .{ .end = 9 }, .i32); - // const a = try zml.Buffer.from(platform, a_host); - // defer a.deinit(); - // a_host.deinit(std.testing.allocator); + const expected = [3][3]i32{ .{ 10, 21, 32 }, .{ 3, 4, 5 }, .{ 76, 87, 98 } }; + const result = try zml.testing.compileAndCall(platform, Local.scatter, .{ + a, + &.{scatter_indices.withTags(.{.n})}, + updates.withTags(.{ .n, .b }), + }); + try std.testing.expect(a.shape().eql(result.shape())); + try std.testing.expectEqual(expected, result.getValue(@TypeOf(expected))); + } + // Test with setting individual values (no batching) + { + const a_host = try zml.HostBuffer.arange(std.testing.allocator, .{ .end = 9 }, .i32); + const a = try zml.Buffer.from(platform, a_host); + defer a.deinit(); + a_host.deinit(std.testing.allocator); - // const scatter_indices = try zml.Buffer.fromArray(platform, [2][1]i32{ .{2}, .{7} }); - // const updates = try zml.Buffer.fromArray(platform, [2]i32{ 20, 70 }); + const scatter_indices = try zml.Buffer.fromArray(platform, [2]i32{ 2, 7 }); + const updates = try zml.Buffer.fromArray(platform, [2]i32{ 20, 70 }); - // const expected = [9]i32{ 0, 1, 22, 3, 4, 5, 6, 77, 8 }; - // const result = try zml.testing.compileAndCall(platform, Local.scatter, .{ - // a, - // a.shape().axes(.{0}), - // scatter_indices.withTags(.{ .n, .coord }), - // updates.withTags(.{.n}), - // }); - // try std.testing.expect(a.shape().eql(result.shape())); - // try std.testing.expectEqual(expected, result.getValue(@TypeOf(expected))); - // } + const expected = [9]i32{ 0, 1, 22, 3, 4, 5, 6, 77, 8 }; + const result = try zml.testing.compileAndCall(platform, Local.scatter, .{ + a, + &.{scatter_indices.withTags(.{.n})}, + updates.withTags(.{.n}), + }); + try std.testing.expect(a.shape().eql(result.shape())); + try std.testing.expectEqual(expected, result.getValue(@TypeOf(expected))); + } // { // // Test with actual values and batching along axis .a // const operand = try zml.Buffer.constant(platform, Shape.init(.{ .a = 2, .b = 3, .c = 4, .d = 2 }, .u16), 0); From 58bc3fe7c1f8d1f30d182a9af86d17a147bf6433 Mon Sep 17 00:00:00 2001 From: Guillaume Wenzek Date: Mon, 6 Jan 2025 08:07:00 +0100 Subject: [PATCH 38/48] scatter: restore last test --- zml/tensor.zig | 88 +++++++++++++++++++++++++++----------------------- 1 file changed, 48 insertions(+), 40 deletions(-) diff --git a/zml/tensor.zig b/zml/tensor.zig index 28502be7..efc57bf1 100644 --- a/zml/tensor.zig +++ b/zml/tensor.zig @@ -2471,6 +2471,14 @@ pub const Tensor = struct { ); } + pub fn scatterCB(self: Tensor, coords: Tensor, updates: Tensor) Tensor { + return self.scatterSlices( + .{ .c = coords.choose1d(.coord, 0), .b = coords.choose1d(.coord, 1) }, + updates, + .{ .update_fn = ScatterOpts.increment }, + ); + } + pub fn idx(idx_shape: anytype) Tensor { return Tensor.constant(idx_shape, .{ .i32 = 0 }); } @@ -2547,49 +2555,49 @@ pub const Tensor = struct { try std.testing.expect(a.shape().eql(result.shape())); try std.testing.expectEqual(expected, result.getValue(@TypeOf(expected))); } - // { - // // Test with actual values and batching along axis .a - // const operand = try zml.Buffer.constant(platform, Shape.init(.{ .a = 2, .b = 3, .c = 4, .d = 2 }, .u16), 0); - // defer operand.deinit(); - // const start_indices = (try zml.Buffer.fromArray( - // platform, - // [2][2][3][2]i32{ - // .{ - // .{ .{ 0, 0 }, .{ 1, 0 }, .{ 2, 1 } }, - // .{ .{ 0, 1 }, .{ 1, 1 }, .{ 0, 9 } }, - // }, - // .{ - // .{ .{ 0, 0 }, .{ 2, 1 }, .{ 2, 2 } }, - // .{ .{ 1, 2 }, .{ 0, 1 }, .{ 1, 0 } }, - // }, - // }, - // )).withTags(.{ .n, .a, .m, .coord }); - // defer start_indices.deinit(); + { + // Test with actual values and batching along axis .a + const operand = try zml.Buffer.constant(platform, Shape.init(.{ .a = 2, .b = 3, .c = 4, .d = 2 }, .u16), 0); + defer operand.deinit(); + const start_indices = (try zml.Buffer.fromArray( + platform, + [2][2][3][2]i32{ + .{ + .{ .{ 0, 0 }, .{ 1, 0 }, .{ 2, 1 } }, + .{ .{ 0, 1 }, .{ 1, 1 }, .{ 0, 9 } }, + }, + .{ + .{ .{ 0, 0 }, .{ 2, 1 }, .{ 2, 2 } }, + .{ .{ 1, 2 }, .{ 0, 1 }, .{ 1, 0 } }, + }, + }, + )).withTags(.{ .n, .a, .m, .coord }); + defer start_indices.deinit(); - // const values = try zml.Buffer.constant( - // platform, - // Shape.init(.{ .n = 2, .a = 2, .m = 3, .c = 2, .d = 2 }, .u16), - // 1, - // ); - // defer values.deinit(); + const values = try zml.Buffer.constant( + platform, + Shape.init(.{ .n = 2, .a = 2, .m = 3, .c = 2, .d = 2 }, .u16), + 1, + ); + defer values.deinit(); - // const result = try zml.testing.compileAndCall(platform, Local.scatter, .{ operand, operand.shape().axes(.{ .c, .b }), start_indices, values }); + const result = try zml.testing.compileAndCall(platform, Local.scatterCB, .{ operand, start_indices, values }); - // const expected = [2][3][4][2]u16{ - // .{ - // .{ .{ 2, 2 }, .{ 3, 3 }, .{ 1, 1 }, .{ 0, 0 } }, - // .{ .{ 0, 0 }, .{ 0, 0 }, .{ 2, 2 }, .{ 2, 2 } }, - // .{ .{ 0, 0 }, .{ 0, 0 }, .{ 1, 1 }, .{ 1, 1 } }, - // }, - // .{ - // .{ .{ 0, 0 }, .{ 1, 1 }, .{ 1, 1 }, .{ 0, 0 } }, - // .{ .{ 2, 2 }, .{ 3, 3 }, .{ 1, 1 }, .{ 0, 0 } }, - // .{ .{ 0, 0 }, .{ 1, 1 }, .{ 1, 1 }, .{ 0, 0 } }, - // }, - // }; - // try std.testing.expect(operand.shape().eql(result.shape())); - // try std.testing.expectEqual(expected, result.getValue(@TypeOf(expected))); - // } + const expected = [2][3][4][2]u16{ + .{ + .{ .{ 2, 2 }, .{ 3, 3 }, .{ 1, 1 }, .{ 0, 0 } }, + .{ .{ 0, 0 }, .{ 0, 0 }, .{ 2, 2 }, .{ 2, 2 } }, + .{ .{ 0, 0 }, .{ 0, 0 }, .{ 1, 1 }, .{ 1, 1 } }, + }, + .{ + .{ .{ 0, 0 }, .{ 1, 1 }, .{ 1, 1 }, .{ 0, 0 } }, + .{ .{ 2, 2 }, .{ 3, 3 }, .{ 1, 1 }, .{ 0, 0 } }, + .{ .{ 0, 0 }, .{ 1, 1 }, .{ 1, 1 }, .{ 0, 0 } }, + }, + }; + try std.testing.expect(operand.shape().eql(result.shape())); + try std.testing.expectEqual(expected, result.getValue(@TypeOf(expected))); + } } /// Returns a Tensor containing the maximum over a given axis. From 5b609a6d398a5bfde2ca590c839e8722cd1608cd Mon Sep 17 00:00:00 2001 From: Guillaume Wenzek Date: Mon, 6 Jan 2025 11:17:17 +0100 Subject: [PATCH 39/48] playing with xla config flags --- zml/module.zig | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/zml/module.zig b/zml/module.zig index 74df746d..a17c1d16 100644 --- a/zml/module.zig +++ b/zml/module.zig @@ -904,7 +904,8 @@ fn compileModuleToPjrtExecutable(arena: std.mem.Allocator, platform: Platform, m // setFlag(&options, "xla_gpu_fused_attention_use_cudnn_rng", true); // setFlag(&options, "xla_gpu_enable_cudnn_layer_norm", true); // setFlag(&options, "xla_gpu_enable_custom_fusions", true); - // setFlag(&options, "xla_gpu_enable_dynamic_slice_fusion", true); + setFlag(&options, "xla_gpu_enable_dynamic_slice_fusion", true); + setFlag(&options, "xla_gpu_enable_while_loop_double_buffering", true); // setFlag(&options, "xla_gpu_use_runtime_fusion", true); // setFlag(&options, "xla_gpu_enable_latency_hiding_scheduler", true); var r_ = try runfiles.Runfiles.create(.{ .allocator = arena }) orelse { From 8a29461d6ed046df957298ce5dc34f45297972c9 Mon Sep 17 00:00:00 2001 From: Guillaume Wenzek Date: Mon, 6 Jan 2025 11:53:36 +0100 Subject: [PATCH 40/48] scatterConfig --- zml/ops.zig | 205 ++++++++++++++++++++++++++++++++++------------------ 1 file changed, 136 insertions(+), 69 deletions(-) diff --git a/zml/ops.zig b/zml/ops.zig index f2d8eb98..7c03e44b 100644 --- a/zml/ops.zig +++ b/zml/ops.zig @@ -784,9 +784,8 @@ pub fn scatter( log.warn(" * coord_axes_ -> {any}", .{coord_axes_.constSlice()}); if (indices_per_axis.len == 0) return inputs; - const indices_shape = indices_per_axis.get(0).shape(); const tagged_api = coord_axes_.len > 0; - if (T == Tensor and indices_per_axis.len == 1 and indices_shape.count() == 1) { + if (T == Tensor and indices_per_axis.len == 1 and indices_per_axis.get(0).count() == 1) { return self.dynamicUpdateSlice1d( updates, if (tagged_api) self.axis(coord_axes_.get(0)) else 0, @@ -797,68 +796,7 @@ pub fn scatter( // TODO: validate indices_shape: all tensors should have the same shape // TODO: validate coord axes: all coord_axes should exist inside self - const AxisKind = enum { batching, update_window, inserted_window, window_id }; - - var self_kind: std.BoundedArray(AxisKind, Tensor.MAX_RANK) = .{}; - var up_kind: std.BoundedArray(AxisKind, Tensor.MAX_RANK) = .{}; - var indices_batch_axes: Shape.DimsArray = .{}; - var scatter_to_operand_axes: Shape.DimsArray = .{}; - - if (tagged_api) { - for (coord_axes_.constSlice()) |t| { - scatter_to_operand_axes.appendAssumeCapacity(self.axis(t)); - } - - for (self._shape.tags()) |t| { - if (update._shape.hasTag(t)) |_| { - if (indices_shape.hasTag(t)) |id_ax| { - if (std.mem.indexOfScalar(Shape.Tag, coord_axes_.constSlice(), t) != null) { - // tag is in indices AND in coords -> it's a batching dim that has been rewritten to a regular insertion dim - self_kind.appendAssumeCapacity(.inserted_window); - } else { - // tag is in self, indices and updates -> it's a batching dim - self_kind.appendAssumeCapacity(.batching); - indices_batch_axes.appendAssumeCapacity(@intCast(id_ax)); - } - } else { - self_kind.appendAssumeCapacity(.update_window); - } - } else { - self_kind.appendAssumeCapacity(.inserted_window); - } - } - - // Note: we assume the scatter_dims appear in the same order inside indices and inside self. - for (update._shape.tags(), 0..) |t, up_ax| { - if (t == Shape.TagUnknown or indices_shape.hasTag(t) != null) { - up_kind.appendAssumeCapacity(.window_id); - } else if (self._shape.hasTag(t)) |self_ax| { - if (self_kind.get(self_ax) == .batching) { - up_kind.appendAssumeCapacity(.batching); - } else { - stdx.debug.assert(update.dim(up_ax) <= self.dim(self_ax), "scatter expects the slices described in 'updates' to fit inside 'self', but along axis .{s} it doesn't. Got self={_}, updates={_}.", .{ t, self, update }); - up_kind.appendAssumeCapacity(.update_window); - } - } else { - std.debug.panic("scatter expects 'updates' to be made of axes from self={_} and from indices={s}, got unknown tag {s} in {_}", .{ self, coord_axes_.constSlice(), t, update }); - } - } - } else { - for (0..indices_per_axis.len) |i| { - self_kind.appendAssumeCapacity(.inserted_window); - scatter_to_operand_axes.appendAssumeCapacity(@intCast(i)); - up_kind.appendAssumeCapacity(.window_id); - } - for (indices_per_axis.len..self.rank()) |_| { - self_kind.appendAssumeCapacity(.update_window); - } - for (indices_per_axis.len..updates.rank()) |_| { - up_kind.appendAssumeCapacity(.update_window); - } - } - log.warn(" * self_kind -> {any}", .{self_kind.constSlice()}); - log.warn(" * up_kind -> {any}", .{up_kind.constSlice()}); - + const config = scatterConfig(self.shape(), update.shape(), indices_per_axis, coord_axes_); // const n_indices_axes = update.rank() - _collectAxes(AxisKind, up_kind, .update_window).len; // stdx.debug.assert(n_indices_axes == coord_axes_.len, "scatter({_}, {any}) expects 'updates' to contain all axes from 'indices', got indices={s}, updates={_}", .{ self, index_tensors, coord_axes_.constSlice(), update }); @@ -888,14 +826,14 @@ pub fn scatter( updates_values.items, update_block, .{ - .update_window_dims = _collectAxes(AxisKind, up_kind, .update_window).constSlice(), - .inserted_window_dims = _collectAxes(AxisKind, self_kind, .inserted_window).constSlice(), + .update_window_dims = _collectAxes(AxisKind, config.up_kind, .update_window).constSlice(), + .inserted_window_dims = _collectAxes(AxisKind, config.op_kind, .inserted_window).constSlice(), // TODO: the batching_dims is a lie // although they are in stablehlo, they aren't handled well by "scatter_simplifier" pass that insert extra transposes when it sees them, // while they act as extra coordinates. we should rewrite them - .input_batching_dims = _collectAxes(AxisKind, self_kind, .batching).constSlice(), - .scatter_indices_batching_dims = indices_batch_axes.constSlice(), - .scatter_dims_to_operand_dims = scatter_to_operand_axes.constSlice(), + .input_batching_dims = _collectAxes(AxisKind, config.op_kind, .batching).constSlice(), + .scatter_indices_batching_dims = config.indices_batch_axes.constSlice(), + .scatter_dims_to_operand_dims = config.scatter_to_operand_axes.constSlice(), .index_vector_dim = indices.rank() - 1, .indices_are_sorted = opts.indices_are_sorted, .unique_indices = opts.indices_are_unique, @@ -920,6 +858,135 @@ pub fn scatter( return res; } +const ScatterConfig = struct { + op_kind: std.BoundedArray(AxisKind, Tensor.MAX_RANK) = .{}, + up_kind: std.BoundedArray(AxisKind, Tensor.MAX_RANK) = .{}, + indices_batch_axes: Shape.DimsArray = .{}, + scatter_to_operand_axes: Shape.DimsArray = .{}, +}; + +const AxisKind = enum { batching, update_window, inserted_window, window_id }; + +fn scatterConfig( + op: Shape, + update: Shape, + indices_per_axis: std.BoundedArray(Tensor, Tensor.MAX_RANK), + coord_axes_: Shape.TagsArray, +) ScatterConfig { + var op_kind: std.BoundedArray(AxisKind, Tensor.MAX_RANK) = .{}; + var up_kind: std.BoundedArray(AxisKind, Tensor.MAX_RANK) = .{}; + var indices_batch_axes: Shape.DimsArray = .{}; + var scatter_to_operand_axes: Shape.DimsArray = .{}; + + const tagged_api = coord_axes_.len > 0; + const indices = indices_per_axis.get(0).shape(); + + if (tagged_api) { + for (coord_axes_.constSlice()) |t| { + scatter_to_operand_axes.appendAssumeCapacity(op.axis(t)); + } + + for (op.tags()) |t| { + if (update.hasTag(t)) |_| { + if (indices.hasTag(t)) |id_ax| { + if (std.mem.indexOfScalar(Shape.Tag, coord_axes_.constSlice(), t) != null) { + // tag is in indices AND in coords -> it's a batching dim that has been rewritten to a regular insertion dim + op_kind.appendAssumeCapacity(.inserted_window); + } else { + // tag is in op, indices and updates -> it's a batching dim + op_kind.appendAssumeCapacity(.batching); + indices_batch_axes.appendAssumeCapacity(@intCast(id_ax)); + } + } else { + op_kind.appendAssumeCapacity(.update_window); + } + } else { + op_kind.appendAssumeCapacity(.inserted_window); + } + } + + // Note: we assume the scatter_dims appear in the same order inside indices and inside op. + for (update.tags(), 0..) |t, up_ax| { + // Handle batch axes right away. + if (op.hasTag(t)) |self_ax| { + if (op_kind.get(self_ax) == .batching) { + up_kind.appendAssumeCapacity(.batching); + continue; + } + } + if (indices.hasTag(t) != null) { + up_kind.appendAssumeCapacity(.window_id); + } else if (op.hasTag(t)) |self_ax| { + stdx.debug.assert(update.dim(up_ax) <= op.dim(self_ax), "scatter expects the slices described in 'updates' to fit inside 'op', but along axis .{s} it doesn't. Got op={_}, updates={_}.", .{ t, op, update }); + up_kind.appendAssumeCapacity(.update_window); + } else { + // TODO: consider accepting untagged update here. + std.debug.panic("scatter expects 'updates' to be made of axes from op={_} and from indices={s}, got unknown tag {s} in {_}", .{ op, coord_axes_.constSlice(), t, update }); + } + } + } else { + for (0..indices_per_axis.len) |i| { + op_kind.appendAssumeCapacity(.inserted_window); + scatter_to_operand_axes.appendAssumeCapacity(@intCast(i)); + up_kind.appendAssumeCapacity(.window_id); + } + for (indices_per_axis.len..op.rank()) |_| { + op_kind.appendAssumeCapacity(.update_window); + } + for (indices_per_axis.len..update.rank()) |_| { + up_kind.appendAssumeCapacity(.update_window); + } + } + log.warn(" * op_kind -> {any}", .{op_kind.constSlice()}); + log.warn(" * up_kind -> {any}", .{up_kind.constSlice()}); + + return .{ + .op_kind = op_kind, + .up_kind = up_kind, + .indices_batch_axes = indices_batch_axes, + .scatter_to_operand_axes = scatter_to_operand_axes, + }; +} + +test scatterConfig { + const zml = @import("zml.zig"); + const platform = zml.testing.env(); + + var comp = try zml.module.CompilationContext.init(std.testing.allocator, "test", platform); + defer comp.deinit(); + comp.activate(); + defer comp.deactivate(); + + const Local = struct { + pub fn idx(idx_shape: anytype) Tensor { + return Tensor.constant(idx_shape, .{ .i32 = 0 }); + } + }; + + const idx = Local.idx; + const op = Shape.init(.{ .a = 10, .b = 20 }, .f32); + + // Use .a as a batching axis with .a=10 x .n=8 updates of 2 elements of .b + { + const indices, const coords_tags = Shape.parseStruct(Tensor, .{ .b = idx(.{ .a = 10, .n = 8 }) }); + const update = Shape.init(.{ .a = 10, .n = 8, .b = 2 }, .f32); + + const cfg = scatterConfig(op, update, indices, coords_tags); + try std.testing.expectEqualSlices(AxisKind, &.{ .batching, .update_window }, cfg.op_kind.constSlice()); + try std.testing.expectEqualSlices(AxisKind, &.{ .batching, .window_id, .update_window }, cfg.up_kind.constSlice()); + } + + // similar, but use the normalized form where .a is no longer an explicit batching axis. + { + const indices, const coords_tags = Shape.parseStruct(Tensor, .{ .a = idx(.{ .a = 10, .n = 8 }), .b = idx(.{ .a = 10, .n = 8 }) }); + const update = Shape.init(.{ .a = 10, .n = 8, .b = 2 }, .f32); + + const cfg = scatterConfig(op, update, indices, coords_tags); + try std.testing.expectEqualSlices(AxisKind, &.{ .inserted_window, .update_window }, cfg.op_kind.constSlice()); + try std.testing.expectEqualSlices(AxisKind, &.{ .window_id, .window_id, .update_window }, cfg.up_kind.constSlice()); + } +} + inline fn toI64(values: anytype) []i64 { var res: [Tensor.MAX_RANK]i64 = undefined; for (values, 0..) |val, i| res[i] = @intCast(val); From 32f80ca2a151ba42dec0e26e0db12e184ff26d5f Mon Sep 17 00:00:00 2001 From: Guillaume Wenzek Date: Tue, 7 Jan 2025 09:52:33 +0100 Subject: [PATCH 41/48] drop _test_compile_opts # Conflicts: # zml/testing.zig --- examples/llama/llama.zig | 2 +- zml/testing.zig | 12 +++++------- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/examples/llama/llama.zig b/examples/llama/llama.zig index d24324e8..f13e0807 100644 --- a/examples/llama/llama.zig +++ b/examples/llama/llama.zig @@ -194,7 +194,7 @@ pub const Llama = struct { pub fn embed(embed_tokens_: zml.nn.TokenEmbedding, tokens_: Tensor, token_index: ?Tensor) Tensor { const tokens = if (token_index) |idx| - tokens_.dynamicSlice1d(-1, 1, idx) + tokens_.dynamicSlice1d(-1, .{ .start = idx, .len = 1 }) else tokens_; return zml.call(embed_tokens_, .forward, .{tokens}).withPartialTags(.{ .s, .d }); diff --git a/zml/testing.zig b/zml/testing.zig index 2c0cc4c6..5818f89c 100644 --- a/zml/testing.zig +++ b/zml/testing.zig @@ -13,19 +13,17 @@ var _platform: ?zml.Platform = null; pub fn env() zml.Platform { if (!builtin.is_test) @compileError("Cannot use zml.testing.env outside of a test block"); if (_platform == null) { - _test_compile_opts = .{ - .sharding_enabled = true, - }; - var ctx = zml.Context.init() catch unreachable; - _platform = ctx.autoPlatform(.{}).withCompilationOptions(_test_compile_opts); + _platform = ctx.autoPlatform(.{}).withCompilationOptions(.{ + .xla_dump_to = "/tmp/zml/tests/", + .sharding_enabled = true, + .xla_dump_hlo_pass_re = ".*", + }); } return _platform.?; } -var _test_compile_opts: zml.CompilationOptions = .{}; - /// In neural network we generally care about the relative precision, /// but on a given dimension, if the output is close to 0, then the precision /// don't matter as much. From bd515c3aceefdb8be7369680f308841a210933e5 Mon Sep 17 00:00:00 2001 From: Guillaume Wenzek Date: Mon, 6 Jan 2025 14:57:24 +0100 Subject: [PATCH 42/48] start scatterRewriter --- zml/ops.zig | 18 +++++++++++++++--- zml/tensor.zig | 1 + 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/zml/ops.zig b/zml/ops.zig index 7c03e44b..d475d3b7 100644 --- a/zml/ops.zig +++ b/zml/ops.zig @@ -796,9 +796,10 @@ pub fn scatter( // TODO: validate indices_shape: all tensors should have the same shape // TODO: validate coord axes: all coord_axes should exist inside self - const config = scatterConfig(self.shape(), update.shape(), indices_per_axis, coord_axes_); + var config = scatterConfig(self.shape(), update.shape(), indices_per_axis, coord_axes_); + const indices = scatterRewrite(&config, indices_per_axis); // const n_indices_axes = update.rank() - _collectAxes(AxisKind, up_kind, .update_window).len; - // stdx.debug.assert(n_indices_axes == coord_axes_.len, "scatter({_}, {any}) expects 'updates' to contain all axes from 'indices', got indices={s}, updates={_}", .{ self, index_tensors, coord_axes_.constSlice(), update }); + // stdx.debug.assert(n_indices_axe == coord_axes_.len, "scatter({_}, {any}) expects 'updates' to contain all axes from 'indices', got indices={s}, updates={_}", .{ self, index_tensors, coord_axes_.constSlice(), update }); const mlir_ctx = ctx.mlirCtx(); var _scalar: T = inputs; @@ -818,7 +819,6 @@ pub fn scatter( defer updates_values.deinit(); meta.collect(CompilationContext.getValue, ctx, &updates_values, &updates) catch unreachable; - const indices = Tensor.stack(indices_per_axis.constSlice(), .last, .coord); const op = dialect.stablehlo.scatter( mlir_ctx, input_values.items, @@ -987,6 +987,18 @@ test scatterConfig { } } +/// Concatenate all indices tensor in one tensor. +/// +/// Is allowed to reorder stuff to simplify the job of the backend, +/// and to expand the batching dims. +fn scatterRewrite( + cfg: *ScatterConfig, + indices_per_axis: std.BoundedArray(Tensor, Tensor.MAX_RANK), +) Tensor { + _ = cfg; // autofix + return Tensor.stack(indices_per_axis.constSlice(), .last, .coord); +} + inline fn toI64(values: anytype) []i64 { var res: [Tensor.MAX_RANK]i64 = undefined; for (values, 0..) |val, i| res[i] = @intCast(val); diff --git a/zml/tensor.zig b/zml/tensor.zig index efc57bf1..5358444e 100644 --- a/zml/tensor.zig +++ b/zml/tensor.zig @@ -1566,6 +1566,7 @@ pub const Tensor = struct { /// Concatenates the input Tensors along the given axis. pub fn concatenate(tensors: []const Tensor, axis_: anytype) Tensor { + if (tensors.len == 1) return tensors[0]; stdx.debug.assert(tensors.len <= 32, "concatenate only supports up to 32 tensors, got {}", .{tensors.len}); var buffer: [32]mlir.Value = undefined; std.debug.assert(tensors.len <= buffer.len); From d08675bb322dda8cbc55916c6ac7606366dcebba Mon Sep 17 00:00:00 2001 From: Guillaume Wenzek Date: Mon, 6 Jan 2025 16:40:56 +0100 Subject: [PATCH 43/48] rewrite batched scatter to nice looking scatter --- zml/ops.zig | 57 +++++++++++++++++++++++++++++++++++++++++++------- zml/tensor.zig | 2 +- 2 files changed, 50 insertions(+), 9 deletions(-) diff --git a/zml/ops.zig b/zml/ops.zig index d475d3b7..3a2feb40 100644 --- a/zml/ops.zig +++ b/zml/ops.zig @@ -16,6 +16,7 @@ const EnumLiteral = @TypeOf(.enum_literal); const HostBuffer = @import("hostbuffer.zig").HostBuffer; const Shape = @import("shape.zig").Shape; const Tensor = @import("tensor.zig").Tensor; +const _collectAxes = @import("tensor.zig")._collectAxes; const dialect = struct { const stablehlo = @import("mlir/dialects").stablehlo; @@ -767,8 +768,6 @@ pub fn scatter( const loc = @src(); const ctx = CompilationContext.current(); - const _collectAxes = @import("tensor.zig")._collectAxes; - const n_inputs = meta.count(Tensor, &inputs); const n_updates = meta.count(Tensor, &updates); stdx.debug.assert(n_inputs == n_updates, "zml.ops.scatter expects the same number of tensors in inputs and updates, got {} and {}", .{ n_inputs, n_updates }); @@ -779,7 +778,7 @@ pub fn scatter( const self = meta.first(Tensor, inputs); const update = meta.first(Tensor, updates); log.warn("{_}.scatterSlices({any}, {})", .{ self, index_tensors, update }); - const indices_per_axis, const coord_axes_ = Shape.parseStruct(Tensor, index_tensors); + var indices_per_axis, var coord_axes_ = Shape.parseStruct(Tensor, index_tensors); log.warn(" * indices_per_axis -> {any}", .{indices_per_axis.constSlice()}); log.warn(" * coord_axes_ -> {any}", .{coord_axes_.constSlice()}); @@ -797,7 +796,7 @@ pub fn scatter( // TODO: validate coord axes: all coord_axes should exist inside self var config = scatterConfig(self.shape(), update.shape(), indices_per_axis, coord_axes_); - const indices = scatterRewrite(&config, indices_per_axis); + const indices = scatterPrepareIndices(&config, self.shape(), update.shape(), &indices_per_axis, &coord_axes_); // const n_indices_axes = update.rank() - _collectAxes(AxisKind, up_kind, .update_window).len; // stdx.debug.assert(n_indices_axe == coord_axes_.len, "scatter({_}, {any}) expects 'updates' to contain all axes from 'indices', got indices={s}, updates={_}", .{ self, index_tensors, coord_axes_.constSlice(), update }); @@ -939,6 +938,7 @@ fn scatterConfig( } log.warn(" * op_kind -> {any}", .{op_kind.constSlice()}); log.warn(" * up_kind -> {any}", .{up_kind.constSlice()}); + log.warn(" * scatter_to_operand_axes -> {any}", .{scatter_to_operand_axes.constSlice()}); return .{ .op_kind = op_kind, @@ -991,12 +991,53 @@ test scatterConfig { /// /// Is allowed to reorder stuff to simplify the job of the backend, /// and to expand the batching dims. -fn scatterRewrite( +fn scatterPrepareIndices( cfg: *ScatterConfig, - indices_per_axis: std.BoundedArray(Tensor, Tensor.MAX_RANK), + op: Shape, + update: Shape, + indices_per_axis: *std.BoundedArray(Tensor, Tensor.MAX_RANK), + indices_axes: *Shape.TagsArray, ) Tensor { - _ = cfg; // autofix - return Tensor.stack(indices_per_axis.constSlice(), .last, .coord); + var old_scatter_to_op_axes = cfg.scatter_to_operand_axes; + const batching = _collectAxes(AxisKind, cfg.op_kind, .batching); + for (batching.constSlice()) |batch_ax| { + const id_shape = indices_per_axis.get(0).shape(); + // batching requires tagging, so we're sure to have a tag here. + const batch_tag = op.tag(batch_ax); + indices_axes.appendAssumeCapacity(batch_tag); + const batch_id = Tensor.iota(id_shape, batch_tag).convert(id_shape.dtype()); + indices_per_axis.appendAssumeCapacity(batch_id); + cfg.op_kind.buffer[@intCast(batch_ax)] = .inserted_window; + cfg.up_kind.buffer[update.axis(batch_tag)] = .window_id; + old_scatter_to_op_axes.appendAssumeCapacity(batch_ax); + } + cfg.indices_batch_axes = .{}; + + log.warn(" * scatter_to_op_axes -> {any}", .{cfg.scatter_to_operand_axes.constSlice()}); + log.warn(" * old_scatter_to_op_axes -> {any}", .{old_scatter_to_op_axes.constSlice()}); + + // Reorder the axes so that in indices_per_axis is ordered like in op if possible. + // TODO: transpose updates if needed + var indices: std.BoundedArray(Tensor, Tensor.MAX_RANK) = .{}; + var scatter_to_op_axes: Shape.DimsArray = .{}; + + while (old_scatter_to_op_axes.len > 0) { + const scatter_ax = std.sort.argMin(i64, old_scatter_to_op_axes.constSlice(), {}, std.sort.asc(i64)).?; + const op_ax = old_scatter_to_op_axes.orderedRemove(scatter_ax); + const scatter_idx = indices_per_axis.orderedRemove(scatter_ax); + + scatter_to_op_axes.appendAssumeCapacity(op_ax); + indices.appendAssumeCapacity(scatter_idx); + } + cfg.scatter_to_operand_axes = scatter_to_op_axes; + + for (scatter_to_op_axes.constSlice(), 0..) |sc_ax, i| { + if (i != sc_ax) { + log.warn("Found a slow scatter pattern, which is going to generate a while loop: scatter({_}, {any}, {_}). Because the index axes aren't the major ones in the input tensor.", .{ op, scatter_to_op_axes.constSlice(), update }); + break; + } + } + return Tensor.stack(indices.constSlice(), .last, .coord); } inline fn toI64(values: anytype) []i64 { diff --git a/zml/tensor.zig b/zml/tensor.zig index 5358444e..7d8d17f3 100644 --- a/zml/tensor.zig +++ b/zml/tensor.zig @@ -1776,7 +1776,7 @@ pub const Tensor = struct { const dt: DataType = if (sh.dim(a) <= std.math.maxInt(i32)) .i32 else .i64; const res_shape = sh.withDtype(dt); const ctx = CompilationContext.current(); - const loc = ctx.location(@src(), "iota({_}, {})", .{ res_shape, axis_ }); + const loc = ctx.location(@src(), "iota({_}, {})", .{ res_shape, a }); const mlir_ctx = ctx.mlirCtx(); var op = dialect.stablehlo.iota(mlir_ctx, a, mlir.ext.RankedTensorType.fromShape(mlir_ctx, res_shape).asType(), loc); From 9ed5f88ff9bb599042db1df85be98d6b9a9a6ed8 Mon Sep 17 00:00:00 2001 From: Guillaume Wenzek Date: Mon, 6 Jan 2025 17:14:56 +0100 Subject: [PATCH 44/48] use i64 for resource id --- pjrt/convert/trace_container.zig | 39 +++++++++++++++++--------------- 1 file changed, 21 insertions(+), 18 deletions(-) diff --git a/pjrt/convert/trace_container.zig b/pjrt/convert/trace_container.zig index a967087b..78f02a67 100644 --- a/pjrt/convert/trace_container.zig +++ b/pjrt/convert/trace_container.zig @@ -32,14 +32,19 @@ pub const TraceContainer = struct { devices: std.AutoArrayHashMapUnmanaged(u32, Device) = .{}, pub const Device = struct { - name: []const u8 = &[_]u8{}, + name: []const u8 = "", device_id: u32 = 0, - resources: std.AutoArrayHashMapUnmanaged(u32, trace_events_proto.Resource) = .{}, + resources: std.AutoArrayHashMapUnmanaged(i64, Resource) = .{}, + }; + + pub const Resource = struct { + name: []const u8, + sort_index: u64 = 0, }; pub const TraceEvent = struct { device_id: u32 = 0, - resource_id: u32 = 0, + resource_id: i64 = 0, name: []const u8 = &[_]u8{}, timestamp_ps: u128 = 0, duration_ps: u64 = 0, @@ -110,19 +115,17 @@ pub const TraceContainer = struct { device.name = plane.name(); device.device_id = device_id; const sort_by_ordinal = (device_id == host_threads_device_id); - var ordinal: u32 = 0; + + var ordinal: u64 = 0; for (plane.plane.lines.items) |*xline| { - const resource_id: u32 = @intCast(xLineDisplayId(xline)); - var resource: trace_events_proto.Resource = .{ - .resource_id = resource_id, - .name = .{ .Const = xLineDisplayName(xline) }, + if (sort_by_ordinal) ordinal += 1; + + const resource: Resource = .{ + .name = xLineDisplayName(xline), + .sort_index = ordinal, }; - if (sort_by_ordinal) { - ordinal += 1; - resource.sort_index = ordinal; - } - try device.resources.put(allocator, resource_id, resource); + try device.resources.put(allocator, xLineDisplayId(xline), resource); } } @@ -135,7 +138,7 @@ pub const TraceContainer = struct { // Convert events. for (xplane.plane.lines.items) |*xline| { - const resource_id: u32 = @intCast(xLineDisplayId(xline)); + const resource_id = xLineDisplayId(xline); if (std.mem.eql(u8, xLineDisplayName(xline), xla_async_op_line_name)) continue; for (xline.events.items) |*xevent| { @@ -257,23 +260,23 @@ pub const TraceContainer = struct { }); device.resources.sort(struct { - keys: []const u32, + keys: []const i64, pub fn lessThan(ctx: @This(), lhs: usize, rhs: usize) bool { return ctx.keys[lhs] < ctx.keys[rhs]; } }{ .keys = device.resources.keys() }); for (device.resources.keys(), device.resources.values()) |resource_id, resource| { - if (resource.name.getSlice().len != 0) { + if (resource.name.len != 0) { try writer.print( \\{{"ph":"M","pid":{d},"tid":{d},"name":"thread_name","args":{{"name":"{s}"}}}}, , .{ device_id, resource_id, - resource.name.getSlice(), + resource.name, }); } - const sort_index = if (resource.sort_index != 0) resource.sort_index else resource_id; + const sort_index: i64 = if (resource.sort_index != 0) @intCast(resource.sort_index) else resource_id; try writer.print( \\{{"ph":"M","pid":{d},"tid":{d},"name":"thread_sort_index","args":{{"sort_index":{d}}}}}, , .{ device_id, resource_id, sort_index }); From 38909101ea3f82129b51924a66089c5576e78f73 Mon Sep 17 00:00:00 2001 From: Guillaume Wenzek Date: Tue, 7 Jan 2025 12:17:33 +0100 Subject: [PATCH 45/48] remove warnings and dynslice rewrite --- zml/ops.zig | 26 +++++++++----------------- 1 file changed, 9 insertions(+), 17 deletions(-) diff --git a/zml/ops.zig b/zml/ops.zig index 3a2feb40..758d4fba 100644 --- a/zml/ops.zig +++ b/zml/ops.zig @@ -777,20 +777,18 @@ pub fn scatter( // we probably should check all of them. const self = meta.first(Tensor, inputs); const update = meta.first(Tensor, updates); - log.warn("{_}.scatterSlices({any}, {})", .{ self, index_tensors, update }); var indices_per_axis, var coord_axes_ = Shape.parseStruct(Tensor, index_tensors); - log.warn(" * indices_per_axis -> {any}", .{indices_per_axis.constSlice()}); - log.warn(" * coord_axes_ -> {any}", .{coord_axes_.constSlice()}); if (indices_per_axis.len == 0) return inputs; - const tagged_api = coord_axes_.len > 0; - if (T == Tensor and indices_per_axis.len == 1 and indices_per_axis.get(0).count() == 1) { - return self.dynamicUpdateSlice1d( - updates, - if (tagged_api) self.axis(coord_axes_.get(0)) else 0, - indices_per_axis.get(0).reshape(.{}), - ); - } + // The rewrite to dynamicUpdateSlice1d doesn't work for {layer=32,b=8,k=1024,h=8!,hd=128,bf16}.scatterSlices(.{ .layer = Tensor({i32}) }, Tensor({b=8,k=1024,h=8!,hd=128,bf16})) + // const tagged_api = coord_axes_.len > 0; + // if (T == Tensor and indices_per_axis.len == 1 and indices_per_axis.get(0).count() == 1 and ) { + // return self.dynamicUpdateSlice1d( + // updates, + // if (tagged_api) self.axis(coord_axes_.get(0)) else 0, + // indices_per_axis.get(0).reshape(.{}), + // ); + // } // TODO: validate indices_shape: all tensors should have the same shape // TODO: validate coord axes: all coord_axes should exist inside self @@ -936,9 +934,6 @@ fn scatterConfig( up_kind.appendAssumeCapacity(.update_window); } } - log.warn(" * op_kind -> {any}", .{op_kind.constSlice()}); - log.warn(" * up_kind -> {any}", .{up_kind.constSlice()}); - log.warn(" * scatter_to_operand_axes -> {any}", .{scatter_to_operand_axes.constSlice()}); return .{ .op_kind = op_kind, @@ -1013,9 +1008,6 @@ fn scatterPrepareIndices( } cfg.indices_batch_axes = .{}; - log.warn(" * scatter_to_op_axes -> {any}", .{cfg.scatter_to_operand_axes.constSlice()}); - log.warn(" * old_scatter_to_op_axes -> {any}", .{old_scatter_to_op_axes.constSlice()}); - // Reorder the axes so that in indices_per_axis is ordered like in op if possible. // TODO: transpose updates if needed var indices: std.BoundedArray(Tensor, Tensor.MAX_RANK) = .{}; From c1bf64415105314a9b0568544bcc4b524e8ffc93 Mon Sep 17 00:00:00 2001 From: Steeve Morin Date: Tue, 7 Jan 2025 17:30:13 +0100 Subject: [PATCH 46/48] WIP --- stdx/BUILD.bazel | 1 + stdx/stdx.zig | 1 + zml/aio.zig | 1 + zml/buffer.zig | 1 + zml/meta.zig | 2 +- 5 files changed, 5 insertions(+), 1 deletion(-) diff --git a/stdx/BUILD.bazel b/stdx/BUILD.bazel index 33c87e06..f15a342b 100644 --- a/stdx/BUILD.bazel +++ b/stdx/BUILD.bazel @@ -5,6 +5,7 @@ zig_library( srcs = [ "debug.zig", "io.zig", + "json.zig", "math.zig", "meta.zig", "signature.zig", diff --git a/stdx/stdx.zig b/stdx/stdx.zig index 9a8cc323..d2f27d7b 100644 --- a/stdx/stdx.zig +++ b/stdx/stdx.zig @@ -1,5 +1,6 @@ pub const debug = @import("debug.zig"); pub const io = @import("io.zig"); +pub const json = @import("json.zig"); pub const math = @import("math.zig"); pub const meta = @import("meta.zig"); pub const time = @import("time.zig"); diff --git a/zml/aio.zig b/zml/aio.zig index 0c49824a..e7a10f75 100644 --- a/zml/aio.zig +++ b/zml/aio.zig @@ -443,6 +443,7 @@ fn _populateStruct( return true; }, .Void => true, + .Union => true, else => if (required) { log.err("{s}: {s} type not supported", .{ prefix, @typeName(T) }); return error.UnsupportedMetadataType; diff --git a/zml/buffer.zig b/zml/buffer.zig index 1fffbaf3..ff324038 100644 --- a/zml/buffer.zig +++ b/zml/buffer.zig @@ -85,6 +85,7 @@ pub const Buffer = struct { const pjrt_buffer = try frame.awaitt(); res._shards.appendAssumeCapacity(pjrt_buffer); } + return res; } diff --git a/zml/meta.zig b/zml/meta.zig index 2e626058..7e8872c6 100644 --- a/zml/meta.zig +++ b/zml/meta.zig @@ -175,7 +175,7 @@ pub fn mapAlloc(comptime cb: anytype, allocator: std.mem.Allocator, ctx: FnParam } else { to.* = null; }, - .Int, .Float, .Enum => to.* = from, + .Int, .Float, .Enum, .Union => to.* = from, else => stdx.debug.compileError("zml.meta.mapAlloc doesn't support: {}", .{FromStruct}), } } From bda3465ea3521a085122264d6a42a1bf2916412b Mon Sep 17 00:00:00 2001 From: Steeve Morin Date: Tue, 7 Jan 2025 17:31:10 +0100 Subject: [PATCH 47/48] WIP --- stdx/json.zig | 72 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 72 insertions(+) create mode 100644 stdx/json.zig diff --git a/stdx/json.zig b/stdx/json.zig new file mode 100644 index 00000000..2f715137 --- /dev/null +++ b/stdx/json.zig @@ -0,0 +1,72 @@ +pub const std = @import("std"); + +pub fn Union(comptime T: type) type { + return struct { + const Self = @This(); + + value: T, + + pub fn jsonParse(allocator: std.mem.Allocator, source: anytype, options: std.json.ParseOptions) !Self { + return jsonParseFromValue( + allocator, + try std.json.innerParse( + std.json.Value, + allocator, + source, + options, + ), + options, + ); + } + + pub fn jsonParseFromValue(allocator: std.mem.Allocator, source: std.json.Value, options: std.json.ParseOptions) !Self { + inline for (std.meta.fields(T)) |field| { + switch (field.type) { + bool => if (source == .bool) return .{ .value = @unionInit(T, field.name, source.bool) }, + []const u8 => switch (source) { + .string => |v| return .{ .value = @unionInit(T, field.name, v) }, + .number_string => |v| return .{ .value = @unionInit(T, field.name, v) }, + else => {}, + }, + else => switch (@typeInfo(field.type)) { + .Int => if (source == .integer) return .{ .value = @unionInit(T, field.name, @intCast(source.integer)) }, + .Float => if (source == .float) return .{ .value = @unionInit(T, field.name, @floatCast(source.float)) }, + .Struct => if (source == .object) return .{ .value = @unionInit(T, field.name, try std.json.innerParseFromValue(field.type, allocator, source.object, options)) }, + inline else => switch (source) { + .number_string, .array => return .{ .value = @unionInit(T, field.name, try std.json.innerParseFromValue(field.type, allocator, source, options)) }, + else => {}, + }, + }, + } + } + return error.UnexpectedToken; + } + }; +} + +pub fn NeverNull(comptime T: type, comptime default_value: T) type { + return struct { + const Self = @This(); + + value: T = default_value, + + pub fn jsonParse(allocator: std.mem.Allocator, source: anytype, options: std.json.ParseOptions) !Self { + return .{ .value = (try std.json.innerParse(?T, allocator, source, options)) orelse default_value }; + } + + pub fn jsonParseFromValue(allocator: std.mem.Allocator, source: std.json.Value, options: std.json.ParseOptions) !Self { + return .{ .value = (try std.json.innerParseFromValue(?T, allocator, source, options)) orelse default_value }; + } + }; +} + +pub fn fillDefaultStructValues(comptime T: type, r: *T) !void { + inline for (@typeInfo(T).Struct.fields) |field| { + if (field.default_value) |default_ptr| { + if (@field(r, field.name) == null) { + const default = @as(*align(1) const field.type, @ptrCast(default_ptr)).*; + @field(r, field.name) = default; + } + } + } +} From cd5772d15c266859ce06b6ed8838bdc843784aaf Mon Sep 17 00:00:00 2001 From: Guillaume Wenzek Date: Tue, 7 Jan 2025 18:03:20 +0100 Subject: [PATCH 48/48] refactor profiler --- pjrt/convert/trace_container.zig | 142 +++++++++++++------------------ pjrt/convert/xplane_visitor.zig | 36 ++++++-- pjrt/profiler.zig | 3 +- 3 files changed, 87 insertions(+), 94 deletions(-) diff --git a/pjrt/convert/trace_container.zig b/pjrt/convert/trace_container.zig index 78f02a67..7156a1bc 100644 --- a/pjrt/convert/trace_container.zig +++ b/pjrt/convert/trace_container.zig @@ -32,14 +32,14 @@ pub const TraceContainer = struct { devices: std.AutoArrayHashMapUnmanaged(u32, Device) = .{}, pub const Device = struct { - name: []const u8 = "", - device_id: u32 = 0, + name: []const u8, + device_id: u32, resources: std.AutoArrayHashMapUnmanaged(i64, Resource) = .{}, }; pub const Resource = struct { name: []const u8, - sort_index: u64 = 0, + sort_index: i64, }; pub const TraceEvent = struct { @@ -51,48 +51,24 @@ pub const TraceContainer = struct { args: std.StringArrayHashMapUnmanaged([]const u8) = .{}, }; - pub fn init(allocator: std.mem.Allocator, pb_buffer: []const u8, max_events: ?usize) !TraceContainer { - var self: TraceContainer = .{ + pub fn init(allocator: std.mem.Allocator) TraceContainer { + return .{ .arena = std.heap.ArenaAllocator.init(allocator), }; - const arena = self.arena.allocator(); - - const xspace = try xplane_proto.XSpace.decode(pb_buffer, arena); - try self.fromXSpace(arena, &xspace, max_events); - return self; } pub fn deinit(self: *TraceContainer) void { self.arena.deinit(); } - fn picoToMicro(p: anytype) f64 { - return @as(f64, @floatFromInt(p)) / 1E6; + pub fn parseXSpaceBytes(self: *TraceContainer, pb_buffer: []const u8, max_events: ?usize) !void { + const arena = self.arena.allocator(); + + const xspace = try xplane_proto.XSpace.decode(pb_buffer, arena); + try self.fromXSpace(arena, xspace, max_events); } - fn xLineDisplayId(xline: *const xplane_proto.XLine) i64 { - return if (xline.display_id != 0) xline.display_id else xline.id; - } - - fn xLineDisplayName(xline: *const xplane_proto.XLine) []const u8 { - return switch (xline.display_name) { - .Empty => xline.name.getSlice(), - else => xline.display_name.getSlice(), - }; - } - - fn xstatValueToString(stat: *const xplane_proto.XStat, plane: *const xplane_visitor.XPlaneVisitor, writer: anytype) !void { - if (stat.value) |val| { - switch (val) { - inline .int64_value, .uint64_value, .double_value => |v| try writer.print("{d}", .{v}), - .str_value => |*v| try writer.writeAll(v.getSlice()), - .bytes_value => try writer.writeAll(""), - .ref_value => |v| try writer.writeAll(plane.getStatMetadataName(@intCast(v))), - } - } else return; - } - - fn findPlaneWithName(space: *const xplane_proto.XSpace, name: []const u8) ?*xplane_proto.XPlane { + fn findPlaneWithName(space: xplane_proto.XSpace, name: []const u8) ?*xplane_proto.XPlane { for (space.planes.items) |*v| { if (std.mem.eql(u8, v.name.getSlice(), name)) return v; } @@ -100,47 +76,37 @@ pub const TraceContainer = struct { } fn findPlanesWithPrefix( - allocator: std.mem.Allocator, - space: *const xplane_proto.XSpace, + out: *std.ArrayList(*const xplane_proto.XPlane), + space: xplane_proto.XSpace, prefix: []const u8, - ) ![]*const xplane_proto.XPlane { - var res = std.ArrayList(*const xplane_proto.XPlane).init(allocator); + ) !void { for (space.planes.items) |*p| { - if (std.mem.startsWith(u8, p.name.getSlice(), prefix)) try res.append(p); - } - return res.toOwnedSlice(); - } - - fn buildDeviceAndResources(allocator: std.mem.Allocator, device_id: u32, plane: *const xplane_visitor.XPlaneVisitor, device: *Device) !void { - device.name = plane.name(); - device.device_id = device_id; - const sort_by_ordinal = (device_id == host_threads_device_id); - - var ordinal: u64 = 0; - for (plane.plane.lines.items) |*xline| { - if (sort_by_ordinal) ordinal += 1; - - const resource: Resource = .{ - .name = xLineDisplayName(xline), - .sort_index = ordinal, - }; - - try device.resources.put(allocator, xLineDisplayId(xline), resource); + if (std.mem.startsWith(u8, p.name.getSlice(), prefix)) { + try out.append(p); + } } } fn xplaneToTraceEvents(self: *TraceContainer, allocator: std.mem.Allocator, device_id: u32, xplane: *const xplane_visitor.XPlaneVisitor) !void { // Convert devices and resources. - const device_entry = try self.devices.getOrPut(allocator, device_id); - if (!device_entry.found_existing) device_entry.value_ptr.* = .{}; + const device_entry = try self.devices.getOrPutValue(allocator, device_id, .{ .name = xplane.name(), .device_id = device_id }); + var device = device_entry.value_ptr.*; + defer device_entry.value_ptr.* = device; - try buildDeviceAndResources(allocator, device_id, xplane, device_entry.value_ptr); + try device.resources.ensureUnusedCapacity(allocator, xplane.plane.lines.items.len); + const sort_by_ordinal = (device_id == host_threads_device_id); // Convert events. - for (xplane.plane.lines.items) |*xline| { - const resource_id = xLineDisplayId(xline); + for (xplane.plane.lines.items, 0..) |*xline, ordinal| { + const resource_id = if (xline.display_id != 0) xline.display_id else xline.id; + const resource_name = if (xline.display_name.isEmpty()) xline.name.getSlice() else xline.display_name.getSlice(); + device.resources.putAssumeCapacity(resource_id, .{ + .name = resource_name, + .sort_index = if (sort_by_ordinal) @intCast(ordinal) else resource_id, + }); + + if (std.mem.eql(u8, resource_name, xla_async_op_line_name)) continue; - if (std.mem.eql(u8, xLineDisplayName(xline), xla_async_op_line_name)) continue; for (xline.events.items) |*xevent| { const event_type = xplane.getEventType(xevent.metadata_id); if (event_type.isInternalEvent()) continue; @@ -149,9 +115,11 @@ pub const TraceContainer = struct { event.resource_id = resource_id; if (xplane.event_metadata_by_id.get(xevent.metadata_id)) |metadata| { + try event.args.ensureUnusedCapacity(allocator, 1 + metadata.stats.items.len); + if (metadata.display_name != .Empty) { event.name = metadata.display_name.getSlice(); - try event.args.put(allocator, "long_name", metadata.name.getSlice()); + event.args.putAssumeCapacity("long_name", metadata.name.getSlice()); } else { event.name = metadata.name.getSlice(); } @@ -159,51 +127,54 @@ pub const TraceContainer = struct { event.timestamp_ps = (@as(u128, @intCast(xline.timestamp_ns)) * 1000) + @as(u128, @intCast(xevent.data.?.offset_ps)); event.duration_ps = @intCast(xevent.duration_ps); - for (metadata.stats.items) |*xstat| { + for (metadata.stats.items) |xstat| { if (xstat.value == null) continue; var stat_buffer = std.ArrayList(u8).init(allocator); - try xstatValueToString(xstat, xplane, stat_buffer.writer().any()); + try xplane.xstatToString(xstat, stat_buffer.writer().any()); const stat_str = try stat_buffer.toOwnedSlice(); const stat_type = xplane.getStatType(xstat.metadata_id); if (stat_type.isInternalStat()) continue; if (stat_type == .step_name) event.name = stat_str; - try event.args.put(allocator, xplane.getStatMetadataName(xstat.metadata_id), stat_str); + event.args.putAssumeCapacity(xplane.getStatMetadataName(xstat.metadata_id), stat_str); } } - for (xevent.stats.items) |*xstat| { + try event.args.ensureUnusedCapacity(allocator, xevent.stats.items.len); + for (xevent.stats.items) |xstat| { if (xstat.value == null) continue; var stat_buffer = std.ArrayList(u8).init(allocator); - try xstatValueToString(xstat, xplane, stat_buffer.writer().any()); + try xplane.xstatToString(xstat, stat_buffer.writer().any()); const stat_str = try stat_buffer.toOwnedSlice(); const stat_type = xplane.getStatType(xstat.metadata_id); if (stat_type.isInternalStat()) continue; if (stat_type == .step_name) event.name = stat_str; - try event.args.put(allocator, xplane.getStatMetadataName(xstat.metadata_id), stat_str); + event.args.putAssumeCapacity(xplane.getStatMetadataName(xstat.metadata_id), stat_str); } } } } - fn fromXSpace(self: *TraceContainer, allocator: std.mem.Allocator, xspace: *const xplane_proto.XSpace, max_events: ?usize) !void { + fn fromXSpace(self: *TraceContainer, allocator: std.mem.Allocator, xspace: xplane_proto.XSpace, max_events: ?usize) !void { if (findPlaneWithName(xspace, host_threads_plane_name)) |hp| { const xplane = try xplane_visitor.XPlaneVisitor.init(allocator, hp); try self.xplaneToTraceEvents(allocator, host_threads_device_id, &xplane); } - var device_planes = try findPlanesWithPrefix(allocator, xspace, gpu_plane_prefix); + var device_planes = std.ArrayList(*const xplane_proto.XPlane).init(allocator); + defer device_planes.deinit(); - // We don't expect GPU and TPU planes and custom devices to be present in the - // same XSpace. - if (device_planes.len == 0) { - device_planes = try findPlanesWithPrefix(allocator, xspace, tpu_plane_prefix); + try findPlanesWithPrefix(&device_planes, xspace, gpu_plane_prefix); + // We don't expect GPU and TPU planes and custom devices to be present in the same XSpace. + if (device_planes.items.len == 0) { + try findPlanesWithPrefix(&device_planes, xspace, tpu_plane_prefix); } - if (device_planes.len == 0) { - device_planes = try findPlanesWithPrefix(allocator, xspace, custom_plane_prefix); + if (device_planes.items.len == 0) { + try findPlanesWithPrefix(&device_planes, xspace, custom_plane_prefix); } - for (device_planes) |dp| { - const xplane = try xplane_visitor.XPlaneVisitor.init(allocator, dp); + for (device_planes.items) |dp| { + var xplane = try xplane_visitor.XPlaneVisitor.init(allocator, dp); + defer xplane.deinit(allocator); const device_id: u32 = first_device_id + @as(u32, @intCast(xplane.plane.id)); try self.xplaneToTraceEvents(allocator, device_id, &xplane); } @@ -276,10 +247,9 @@ pub const TraceContainer = struct { resource.name, }); } - const sort_index: i64 = if (resource.sort_index != 0) @intCast(resource.sort_index) else resource_id; try writer.print( \\{{"ph":"M","pid":{d},"tid":{d},"name":"thread_sort_index","args":{{"sort_index":{d}}}}}, - , .{ device_id, resource_id, sort_index }); + , .{ device_id, resource_id, resource.sort_index }); } } @@ -324,3 +294,7 @@ pub const TraceContainer = struct { try writer.writeAll("{}]}"); } }; + +fn picoToMicro(p: anytype) f64 { + return @as(f64, @floatFromInt(p)) / 1E6; +} diff --git a/pjrt/convert/xplane_visitor.zig b/pjrt/convert/xplane_visitor.zig index 091bec91..a2f8eba8 100644 --- a/pjrt/convert/xplane_visitor.zig +++ b/pjrt/convert/xplane_visitor.zig @@ -13,38 +13,56 @@ pub const XPlaneVisitor = struct { ) !XPlaneVisitor { var res: XPlaneVisitor = .{ .plane = plane }; + try res.event_metadata_by_id.ensureUnusedCapacity(allocator, @intCast(plane.event_metadata.items.len)); // build event metadata map for (plane.event_metadata.items) |*event_metadata| { - try res.event_metadata_by_id.put(allocator, event_metadata.key, &event_metadata.value.?); + res.event_metadata_by_id.putAssumeCapacity(event_metadata.key, &event_metadata.value.?); } // build stat metadata map + try res.stat_metadata_by_id.ensureUnusedCapacity(allocator, @intCast(plane.stat_metadata.items.len)); for (plane.stat_metadata.items) |*stat_metadata| { - try res.stat_metadata_by_id.put(allocator, stat_metadata.key, &stat_metadata.value.?); + res.stat_metadata_by_id.putAssumeCapacity(stat_metadata.key, &stat_metadata.value.?); } return res; } - pub fn getEventType(self: *const XPlaneVisitor, event_metadata_id: i64) xplane_schema.HostEventType { + pub fn deinit(self: *XPlaneVisitor, allocator: std.mem.Allocator) void { + self.stat_metadata_by_id.deinit(allocator); + self.event_metadata_by_id.deinit(allocator); + } + + pub fn name(self: XPlaneVisitor) []const u8 { + return self.plane.name.getSlice(); + } + + pub fn getEventType(self: XPlaneVisitor, event_metadata_id: i64) xplane_schema.HostEventType { if (self.event_metadata_by_id.get(event_metadata_id)) |v| { return xplane_schema.HostEventType.fromString(v.name.getSlice()); } else return .unknown; } - pub fn name(self: *const XPlaneVisitor) []const u8 { - return self.plane.name.getSlice(); - } - - pub fn getStatMetadataName(self: *const XPlaneVisitor, stat_metadata_id: i64) []const u8 { + pub fn getStatMetadataName(self: XPlaneVisitor, stat_metadata_id: i64) []const u8 { if (self.stat_metadata_by_id.get(stat_metadata_id)) |v| { return v.name.getSlice(); } else return &[_]u8{}; } - pub fn getStatType(self: *const XPlaneVisitor, stat_metadata_id: i64) xplane_schema.StatType { + pub fn getStatType(self: XPlaneVisitor, stat_metadata_id: i64) xplane_schema.StatType { if (self.stat_metadata_by_id.get(stat_metadata_id)) |v| { return xplane_schema.StatType.fromString(v.name.getSlice()); } else return .unknown; } + + pub fn xstatToString(self: XPlaneVisitor, stat: xplane_proto.XStat, writer: anytype) !void { + if (stat.value == null) return; + + switch (stat.value.?) { + inline .int64_value, .uint64_value, .double_value => |v| try writer.print("{d}", .{v}), + .str_value => |*v| try writer.writeAll(v.getSlice()), + .bytes_value => try writer.writeAll(""), + .ref_value => |v| try writer.writeAll(self.getStatMetadataName(@intCast(v))), + } + } }; diff --git a/pjrt/profiler.zig b/pjrt/profiler.zig index 1e6e2f00..1b0d1a69 100644 --- a/pjrt/profiler.zig +++ b/pjrt/profiler.zig @@ -135,8 +135,9 @@ pub const Profiler = struct { return; } - var converter = try TraceContainer.init(allocator, profile_data.items(), 1_000_000); + var converter = TraceContainer.init(allocator); defer converter.deinit(); + try converter.parseXSpaceBytes(profile_data.items(), 1_000_000); var output_file = try dir.createFile(file_name, .{}); defer output_file.close();