Skip to content

armgit / uzu

Public Imported from GitHub
0

A high-performance inference engine for AI models

wasi tests (#343)

Aleksandr Golokozcc035d6c4dfc
diff --git a/.cargo/config.toml b/.cargo/config.toml
index 8af59dd8c..2e8b6aa8f 100644
--- a/.cargo/config.toml
+++ b/.cargo/config.toml
@@ -1,2 +1,11 @@
[env]
RUST_TEST_THREADS = "1"
+
+[target.wasm32-wasip1-threads]
+# threads=y — wasmtime need this flag to use threads
+# shared-memory=y — wasmtime need this flag to use shared memory
+# --dir /::/ — allow wasmtime to read current directory
+runner = ["wasmtime", "-W", "threads=y,shared-memory=y", "-S", "threads=y", "--dir", "/::/", "--"]
+
+# --max-memory — default max memory = 1Gb
+rustflags = ["-C", "link-arg=--max-memory=4294967296"]
\ No newline at end of file
diff --git a/.github/actions/setup/action.yml b/.github/actions/setup/action.yml
index 068e19952..24e889723 100644
--- a/.github/actions/setup/action.yml
+++ b/.github/actions/setup/action.yml
@@ -18,19 +18,25 @@ inputs:
description: "Install nextest"
required: false
default: 'false'
+ target:
+ description: "Additional Rust target to install"
+ required: false
+ default: ''
runs:
using: composite
steps:
- uses: dtolnay/rust-toolchain@stable
with:
- targets:
- wasm32-wasip1-threads
+ targets: ${{ inputs.target }}
- uses: dtolnay/rust-toolchain@nightly
with:
components: ${{ inputs.linters == 'true' && 'rustfmt' || '' }}
+ - if: inputs.target == 'wasm32-wasip1-threads'
+ uses: bytecodealliance/actions/wasmtime/setup@v1
+
- if: inputs.linters == 'true'
run: |
arch -arm64 brew install clang-format cargo-deny
diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml
index 80cbe0987..e0e839213 100644
--- a/.github/workflows/tests.yml
+++ b/.github/workflows/tests.yml
@@ -86,6 +86,7 @@ jobs:
metal: ${{ matrix.backend == 'metal' }}
test_model: true
nextest: true
+ target: ${{ matrix.target }}
- name: Build crates
run: cargo +stable build --no-default-features $FEATURE_FLAGS ${{ matrix.target == 'wasm32-wasip1-threads' && '-p uzu' || '' }}
@@ -95,8 +96,10 @@ jobs:
run: cargo +nightly bench --no-run --no-default-features $FEATURE_FLAGS
- name: Run tests
- if: ${{ matrix.backend != 'cpu' && matrix.tracing && matrix.grammar }}
- run: cargo +stable nextest run --profile=ci --no-default-features $FEATURE_FLAGS
+ if: ${{ matrix.backend != 'cpu' && matrix.tracing && matrix.grammar || matrix.backend == 'cpu' && !matrix.tracing && !matrix.grammar && matrix.target == 'wasm32-wasip1-threads' }}
+ run: |
+ cargo +stable nextest run --profile=ci --no-default-features $FEATURE_FLAGS \
+ ${{ matrix.target == 'wasm32-wasip1-threads' && '-p uzu --lib --test kernel' || '' }}
completed:
name: completed
diff --git a/Cargo.lock b/Cargo.lock
index b0708e1d5..230d61722 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -380,9 +380,9 @@ checksum = "5e764a1d40d510daf35e07be9eb06e75770908c27d411ee6c92109c9840eaaf7"
[[package]]
name = "bitflags"
-version = "2.11.0"
+version = "2.11.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "843867be96c8daad0d758b57df9392b6d8d271134fce549de6ce169ff98a92af"
+checksum = "c4512299f36f043ab09a583e57bceb5a5aab7a73db1805848e8fef3c9e8c78b3"
[[package]]
name = "blake3"
@@ -483,7 +483,7 @@ checksum = "befbfd072a8e81c02f8c507aefce431fe5e7d051f83d48a23ffc9b9fe5a11799"
dependencies = [
"clap",
"heck",
- "indexmap 2.13.1",
+ "indexmap 2.14.0",
"log",
"proc-macro2",
"quote",
@@ -496,9 +496,9 @@ dependencies = [
[[package]]
name = "cc"
-version = "1.2.59"
+version = "1.2.60"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "b7a4d3ec6524d28a329fc53654bbadc9bdd7b0431f5d65f1a56ffb28a1ee5283"
+checksum = "43c5703da9466b66a946814e1adf53ea2c90f10063b86290cc9eb67ce3478a20"
dependencies = [
"find-msvc-tools",
"shlex",
@@ -533,7 +533,7 @@ checksum = "6f8d983286843e49675a4b7a2d174efe136dc93a18d69130dd18198a6c167601"
dependencies = [
"cfg-if",
"cpufeatures 0.3.0",
- "rand_core 0.10.0",
+ "rand_core 0.10.1",
]
[[package]]
@@ -675,7 +675,6 @@ version = "7.2.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "958c5d6ecf1f214b4c2bbbbf6ab9523a864bd136dcf71a7e8904799acfe1ad47"
dependencies = [
- "crossterm",
"unicode-segmentation",
"unicode-width 0.2.2",
]
@@ -762,7 +761,7 @@ dependencies = [
"cookie",
"document-features",
"idna",
- "indexmap 2.13.1",
+ "indexmap 2.14.0",
"log",
"serde",
"serde_derive",
@@ -971,7 +970,7 @@ checksum = "b0f4697d190a142477b16aef7da8a99bfdc41e7e8b1687583c0d23a79c7afc1e"
dependencies = [
"cc",
"codespan-reporting",
- "indexmap 2.13.1",
+ "indexmap 2.14.0",
"proc-macro2",
"quote",
"scratch",
@@ -985,7 +984,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "035b6c61a944483e8a4b2ad4fb8b13830d63491bd004943716ad16d85dcc64bc"
dependencies = [
"codespan-reporting",
- "indexmap 2.13.1",
+ "indexmap 2.14.0",
"proc-macro2",
"quote",
"syn 2.0.117",
@@ -999,7 +998,7 @@ checksum = "d0956799fa8678d4c50eed028f2de1c0552ae183c76e976cf7ca8c4e36a7c328"
dependencies = [
"clap",
"codespan-reporting",
- "indexmap 2.13.1",
+ "indexmap 2.14.0",
"proc-macro2",
"quote",
"syn 2.0.117",
@@ -1017,7 +1016,7 @@ version = "1.0.194"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e6acc6b5822b9526adfb4fc377b67128fdd60aac757cc4a741a6278603f763cf"
dependencies = [
- "indexmap 2.13.1",
+ "indexmap 2.14.0",
"proc-macro2",
"quote",
"syn 2.0.117",
@@ -1559,7 +1558,7 @@ dependencies = [
"cfg-if",
"libc",
"r-efi 6.0.0",
- "rand_core 0.10.0",
+ "rand_core 0.10.1",
"wasip2",
"wasip3",
]
@@ -1582,7 +1581,7 @@ dependencies = [
"futures-sink",
"futures-util",
"http 0.2.12",
- "indexmap 2.13.1",
+ "indexmap 2.14.0",
"slab",
"tokio",
"tokio-util",
@@ -1601,7 +1600,7 @@ dependencies = [
"futures-core",
"futures-sink",
"http 1.4.0",
- "indexmap 2.13.1",
+ "indexmap 2.14.0",
"slab",
"tokio",
"tokio-util",
@@ -1638,9 +1637,9 @@ dependencies = [
[[package]]
name = "hashbrown"
-version = "0.16.1"
+version = "0.17.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "841d1cc9bed7f9236f321df977030373f4a4163ae1a7dbfe1a51a2c1a51d9100"
+checksum = "4f467dd6dccf739c208452f8014c75c18bb8301b050ad1cfb27153803edb0f51"
[[package]]
name = "heck"
@@ -1677,7 +1676,7 @@ dependencies = [
"log",
"native-tls",
"num_cpus",
- "rand 0.9.2",
+ "rand 0.9.4",
"reqwest",
"serde",
"serde_json",
@@ -1807,15 +1806,14 @@ dependencies = [
[[package]]
name = "hyper-rustls"
-version = "0.27.7"
+version = "0.27.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "e3c93eb611681b207e1fe55d5a71ecf91572ec8a6705cdb6857f7d8d5242cf58"
+checksum = "33ca68d021ef39cf6463ab54c1d0f5daf03377b70561305bb89a8f83aab66e0f"
dependencies = [
"http 1.4.0",
"hyper 1.9.0",
"hyper-util",
"rustls",
- "rustls-pki-types",
"tokio",
"tokio-rustls",
"tower-service",
@@ -1990,12 +1988,12 @@ dependencies = [
[[package]]
name = "indexmap"
-version = "2.13.1"
+version = "2.14.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "45a8a2b9cb3e0b0c1803dbb0758ffac5de2f425b23c28f518faabd9d805342ff"
+checksum = "d466e9454f08e4a911e14806c24e16fba1b4c121d1ea474396f396069cf949d9"
dependencies = [
"equivalent",
- "hashbrown 0.16.1",
+ "hashbrown 0.17.0",
"serde",
"serde_core",
]
@@ -2125,9 +2123,9 @@ checksum = "8f42a60cbdf9a97f5d2305f08a87dc4e09308d1276d28c869c684d7777685682"
[[package]]
name = "js-sys"
-version = "0.3.94"
+version = "0.3.95"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "2e04e2ef80ce82e13552136fabeef8a5ed1f985a96805761cbb9a2c34e7664d9"
+checksum = "2964e92d1d9dc3364cae4d718d93f227e3abb088e747d92e0395bfdedf1c12ca"
dependencies = [
"cfg-if",
"futures-util",
@@ -2149,9 +2147,9 @@ checksum = "09edd9e8b54e49e587e4f6295a7d29c3ea94d469cb40ab8ca70b288248a81db2"
[[package]]
name = "libc"
-version = "0.2.184"
+version = "0.2.185"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "48f5d2a454e16a5ea0f4ced81bd44e4cfc7bd3a507b61887c99fd3538b28e4af"
+checksum = "52ff2c0fe9bc6cb6b14a0592c2ff4fa9ceb83eea9db979b0487cd054946a2b8f"
[[package]]
name = "libloading"
@@ -2171,9 +2169,9 @@ checksum = "b6d2cec3eae94f9f509c767b45932f1ada8350c4bdb85af2fcab4a3c14807981"
[[package]]
name = "libredox"
-version = "0.1.15"
+version = "0.1.16"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "7ddbf48fd451246b1f8c2610bd3b4ac0cc6e149d89832867093ab69a17194f08"
+checksum = "e02f3bb43d335493c96bf3fd3a321600bf6bd07ed34bc64118e9293bdffea46c"
dependencies = [
"libc",
]
@@ -2698,9 +2696,9 @@ checksum = "d6790f58c7ff633d8771f42965289203411a5e5c68388703c06e14f24770b41e"
[[package]]
name = "openssl"
-version = "0.10.76"
+version = "0.10.77"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "951c002c75e16ea2c65b8c7e4d3d51d5530d8dfa7d060b4776828c88cfb18ecf"
+checksum = "bfe4646e360ec77dff7dde40ed3d6c5fee52d156ef4a62f53973d38294dad87f"
dependencies = [
"bitflags",
"cfg-if",
@@ -2730,9 +2728,9 @@ checksum = "7c87def4c32ab89d880effc9e097653c8da5d6ef28e6b539d313baaacfbafcbe"
[[package]]
name = "openssl-sys"
-version = "0.9.112"
+version = "0.9.113"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "57d55af3b3e226502be1526dfdba67ab0e9c96fc293004e79576b2b9edb0dbdb"
+checksum = "ad2f2c0eba47118757e4c6d2bff2838f3e0523380021356e7875e858372ce644"
dependencies = [
"cc",
"libc",
@@ -2874,9 +2872,9 @@ checksum = "a89322df9ebe1c1578d689c92318e070967d1042b512afbe49518723f4e6d5cd"
[[package]]
name = "pkg-config"
-version = "0.3.32"
+version = "0.3.33"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "7edddbd0b52d732b21ad9a5fab5c704c14cd949e5e9a1ec5929a24fded1b904c"
+checksum = "19f132c84eca552bf34cab8ec81f1c1dcc229b811638f9d283dceabe58c5569e"
[[package]]
name = "plotters"
@@ -3011,7 +3009,7 @@ dependencies = [
"bit-vec",
"bitflags",
"num-traits",
- "rand 0.9.2",
+ "rand 0.9.4",
"rand_chacha 0.9.0",
"rand_xorshift",
"regex-syntax 0.8.10",
@@ -3060,9 +3058,9 @@ dependencies = [
[[package]]
name = "rand"
-version = "0.9.2"
+version = "0.9.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "6db2770f06117d490610c7488547d543617b21bfa07796d7a12f6f1bd53850d1"
+checksum = "44c5af06bb1b7d3216d91932aed5265164bf384dc89cd6ba05cf59a35f5f76ea"
dependencies = [
"rand_chacha 0.9.0",
"rand_core 0.9.5",
@@ -3070,13 +3068,13 @@ dependencies = [
[[package]]
name = "rand"
-version = "0.10.0"
+version = "0.10.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "bc266eb313df6c5c09c1c7b1fbe2510961e5bcd3add930c1e31f7ed9da0feff8"
+checksum = "d2e8e8bcc7961af1fdac401278c6a831614941f6164ee3bf4ce61b7edb162207"
dependencies = [
"chacha20",
"getrandom 0.4.2",
- "rand_core 0.10.0",
+ "rand_core 0.10.1",
]
[[package]]
@@ -3119,9 +3117,9 @@ dependencies = [
[[package]]
name = "rand_core"
-version = "0.10.0"
+version = "0.10.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "0c8d0fd677905edcbeedbf2edb6494d676f0e98d54d5cf9bda0b061cb8fb8aba"
+checksum = "63b8176103e19a2643978565ca18b50549f6101881c443590420e4dc998a3c69"
[[package]]
name = "rand_distr"
@@ -3130,7 +3128,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4d431c2703ccf129de4d45253c03f49ebb22b97d6ad79ee3ecfc7e3f4862c1d8"
dependencies = [
"num-traits",
- "rand 0.10.0",
+ "rand 0.10.1",
]
[[package]]
@@ -3156,9 +3154,9 @@ checksum = "60a357793950651c4ed0f3f52338f53b2f809f32d83a07f72909fa13e4c6c1e3"
[[package]]
name = "rayon"
-version = "1.11.0"
+version = "1.12.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "368f01d005bf8fd9b1206fb6fa653e6c4a81ceb1466406b81792d87c5677a58f"
+checksum = "fb39b166781f92d482534ef4b4b1b2568f42613b53e5b6c160e24cfbfa30926d"
dependencies = [
"either",
"rayon-core",
@@ -3393,7 +3391,7 @@ dependencies = [
"either",
"figment",
"futures",
- "indexmap 2.13.1",
+ "indexmap 2.14.0",
"log",
"memchr",
"multer",
@@ -3425,7 +3423,7 @@ checksum = "575d32d7ec1a9770108c879fc7c47815a80073f96ca07ff9525a94fcede1dd46"
dependencies = [
"devise",
"glob",
- "indexmap 2.13.1",
+ "indexmap 2.14.0",
"proc-macro2",
"quote",
"rocket_http",
@@ -3445,7 +3443,7 @@ dependencies = [
"futures",
"http 0.2.12",
"hyper 0.14.32",
- "indexmap 2.13.1",
+ "indexmap 2.14.0",
"log",
"memchr",
"pear",
@@ -3491,9 +3489,9 @@ dependencies = [
[[package]]
name = "rustls"
-version = "0.23.37"
+version = "0.23.38"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "758025cb5fccfd3bc2fd74708fd4682be41d99e5dff73c377c0646c6012c73a4"
+checksum = "69f9466fb2c14ea04357e91413efb882e2a6d4a406e625449bc0a5d360d53a21"
dependencies = [
"log",
"once_cell",
@@ -3515,9 +3513,9 @@ dependencies = [
[[package]]
name = "rustls-webpki"
-version = "0.103.10"
+version = "0.103.12"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "df33b2b81ac578cabaf06b89b0631153a3f416b0a886e8a7a1707fb51abbd1ef"
+checksum = "8279bb85272c9f10811ae6a6c547ff594d6a7f3c6c6b02ee9726d1d0dcfcdd06"
dependencies = [
"ring",
"rustls-pki-types",
@@ -4022,9 +4020,9 @@ dependencies = [
[[package]]
name = "thin-vec"
-version = "0.2.14"
+version = "0.2.16"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "144f754d318415ac792f9d69fc87abbbfc043ce2ef041c60f16ad828f638717d"
+checksum = "259cdf8ed4e4aca6f1e9d011e10bd53f524a2d0637d7b28450f6c64ac298c4c6"
[[package]]
name = "thiserror"
@@ -4156,7 +4154,7 @@ dependencies = [
"monostate",
"onig",
"paste",
- "rand 0.9.2",
+ "rand 0.9.4",
"rayon",
"rayon-cond",
"regex",
@@ -4172,9 +4170,9 @@ dependencies = [
[[package]]
name = "tokio"
-version = "1.51.0"
+version = "1.52.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "2bd1c4c0fc4a7ab90fc15ef6daaa3ec3b893f004f915f2392557ed23237820cd"
+checksum = "a91135f59b1cbf38c91e73cf3386fca9bb77915c45ce2771460c9d92f0f3d776"
dependencies = [
"bytes",
"libc",
@@ -4260,7 +4258,7 @@ version = "0.9.12+spec-1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cf92845e79fc2e2def6a5d828f0801e29a2f8acc037becc5ab08595c7d5e9863"
dependencies = [
- "indexmap 2.13.1",
+ "indexmap 2.14.0",
"serde_core",
"serde_spanned 1.1.1",
"toml_datetime 0.7.5+spec-1.1.0",
@@ -4293,7 +4291,7 @@ version = "0.22.27"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "41fe8c660ae4257887cf66394862d21dbca4a6ddd26f04a3560410406a2f819a"
dependencies = [
- "indexmap 2.13.1",
+ "indexmap 2.14.0",
"serde",
"serde_spanned 0.6.9",
"toml_datetime 0.6.11",
@@ -4640,7 +4638,7 @@ dependencies = [
"proc-macro2",
"proptest",
"quote",
- "rand 0.10.0",
+ "rand 0.10.1",
"rand_distr",
"rangemap",
"regex",
@@ -4735,9 +4733,9 @@ dependencies = [
[[package]]
name = "wasm-bindgen"
-version = "0.2.117"
+version = "0.2.118"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "0551fc1bb415591e3372d0bc4780db7e587d84e2a7e79da121051c5c4b89d0b0"
+checksum = "0bf938a0bacb0469e83c1e148908bd7d5a6010354cf4fb73279b7447422e3a89"
dependencies = [
"cfg-if",
"once_cell",
@@ -4748,9 +4746,9 @@ dependencies = [
[[package]]
name = "wasm-bindgen-futures"
-version = "0.4.67"
+version = "0.4.68"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "03623de6905b7206edd0a75f69f747f134b7f0a2323392d664448bf2d3c5d87e"
+checksum = "f371d383f2fb139252e0bfac3b81b265689bf45b6874af544ffa4c975ac1ebf8"
dependencies = [
"js-sys",
"wasm-bindgen",
@@ -4758,9 +4756,9 @@ dependencies = [
[[package]]
name = "wasm-bindgen-macro"
-version = "0.2.117"
+version = "0.2.118"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "7fbdf9a35adf44786aecd5ff89b4563a90325f9da0923236f6104e603c7e86be"
+checksum = "eeff24f84126c0ec2db7a449f0c2ec963c6a49efe0698c4242929da037ca28ed"
dependencies = [
"quote",
"wasm-bindgen-macro-support",
@@ -4768,9 +4766,9 @@ dependencies = [
[[package]]
name = "wasm-bindgen-macro-support"
-version = "0.2.117"
+version = "0.2.118"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "dca9693ef2bab6d4e6707234500350d8dad079eb508dca05530c85dc3a529ff2"
+checksum = "9d08065faf983b2b80a79fd87d8254c409281cf7de75fc4b773019824196c904"
dependencies = [
"bumpalo",
"proc-macro2",
@@ -4781,9 +4779,9 @@ dependencies = [
[[package]]
name = "wasm-bindgen-shared"
-version = "0.2.117"
+version = "0.2.118"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "39129a682a6d2d841b6c429d0c51e5cb0ed1a03829d8b3d1e69a011e62cb3d3b"
+checksum = "5fd04d9e306f1907bd13c6361b5c6bfc7b3b3c095ed3f8a9246390f8dbdee129"
dependencies = [
"unicode-ident",
]
@@ -4805,7 +4803,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bb0e353e6a2fbdc176932bbaab493762eb1255a7900fe0fea1a2f96c296cc909"
dependencies = [
"anyhow",
- "indexmap 2.13.1",
+ "indexmap 2.14.0",
"wasm-encoder",
"wasmparser",
]
@@ -4831,15 +4829,15 @@ checksum = "47b807c72e1bac69382b3a6fb3dbe8ea4c0ed87ff5629b8685ae6b9a611028fe"
dependencies = [
"bitflags",
"hashbrown 0.15.5",
- "indexmap 2.13.1",
+ "indexmap 2.14.0",
"semver",
]
[[package]]
name = "web-sys"
-version = "0.3.94"
+version = "0.3.95"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "cd70027e39b12f0849461e08ffc50b9cd7688d942c1c8e3c7b22273236b4dd0a"
+checksum = "4f2dfbb17949fa2088e5d39408c48368947b86f7834484e87b73de55bc14d97d"
dependencies = [
"js-sys",
"wasm-bindgen",
@@ -5216,7 +5214,7 @@ checksum = "b7c566e0f4b284dd6561c786d9cb0142da491f46a9fbed79ea69cdad5db17f21"
dependencies = [
"anyhow",
"heck",
- "indexmap 2.13.1",
+ "indexmap 2.14.0",
"prettyplease",
"syn 2.0.117",
"wasm-metadata",
@@ -5247,7 +5245,7 @@ checksum = "9d66ea20e9553b30172b5e831994e35fbde2d165325bec84fc43dbf6f4eb9cb2"
dependencies = [
"anyhow",
"bitflags",
- "indexmap 2.13.1",
+ "indexmap 2.14.0",
"log",
"serde",
"serde_derive",
@@ -5266,7 +5264,7 @@ checksum = "ecc8ac4bc1dc3381b7f59c34f00b67e18f910c2c0f50015669dde7def656a736"
dependencies = [
"anyhow",
"id-arena",
- "indexmap 2.13.1",
+ "indexmap 2.14.0",
"log",
"semver",
"serde",
diff --git a/Cargo.toml b/Cargo.toml
index fe5a546e0..8270ef506 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -67,14 +67,14 @@ inquire = "0.9"
console = "0.16"
rocket = { version = "0.5", features = ["json"] }
uuid = { version = "1.20", features = ["v4"] }
-comfy-table = "7.2"
+comfy-table = { version = "7.2", default-features = false }
autocxx = "0.30"
cxx = "1.0"
cmake = "0.1"
autocxx-build = "0.30"
test-tag = "0.1"
-proptest = "1.10"
-criterion = "0.8.2"
+proptest = { version = "1.10", default-features = false, features = ["std"] }
+criterion = { version = "0.8.2", default-features = false }
criterion-macro = "0.4.0"
rustix = "1.1.4"
diff --git a/crates/uzu/Cargo.toml b/crates/uzu/Cargo.toml
index 1c913fd7c..54a79f861 100644
--- a/crates/uzu/Cargo.toml
+++ b/crates/uzu/Cargo.toml
@@ -55,6 +55,10 @@ schemars.workspace = true
comfy-table.workspace = true
indicatif.workspace = true
+[target.'cfg(not(target_arch = "wasm32"))'.dev-dependencies]
+criterion = { workspace = true, default-features = true }
+proptest = { workspace = true, default-features = true }
+
[build-dependencies]
anyhow.workspace = true
async-trait.workspace = true
diff --git a/crates/uzu/src/session/helpers/memory_checker.rs b/crates/uzu/src/session/helpers/memory_checker.rs
index af31d412f..75189a2a1 100644
--- a/crates/uzu/src/session/helpers/memory_checker.rs
+++ b/crates/uzu/src/session/helpers/memory_checker.rs
@@ -1,5 +1,7 @@
use std::path::Path;
+use crate::utils::memory::{get_free_ram, get_free_swap};
+
fn get_directory_size(path: &Path) -> std::io::Result<u64> {
let mut size = 0u64;
for entry_result in std::fs::read_dir(path)? {
@@ -15,20 +17,7 @@ fn get_directory_size(path: &Path) -> std::io::Result<u64> {
}
pub fn is_directory_fits_ram(path: &Path) -> bool {
- use sysinfo::System;
-
- let mut sys = System::new();
- sys.refresh_memory();
-
- let total_ram = sys.total_memory();
- let used_ram = sys.used_memory();
- let free_ram = total_ram - used_ram;
-
- let total_swap = sys.total_swap();
- let used_swap = sys.used_swap();
- let free_swap = total_swap - used_swap;
-
let model_size_bytes = get_directory_size(path).unwrap_or(0);
- let available_total = free_ram + free_swap;
+ let available_total = get_free_ram() + get_free_swap();
model_size_bytes <= available_total
}
diff --git a/crates/uzu/src/utils/memory.rs b/crates/uzu/src/utils/memory.rs
new file mode 100644
index 000000000..105cb31f2
--- /dev/null
+++ b/crates/uzu/src/utils/memory.rs
@@ -0,0 +1,30 @@
+#[cfg(not(target_arch = "wasm32"))]
+pub fn get_free_ram() -> u64 {
+ use sysinfo::System;
+ let mut sys = System::new();
+ sys.refresh_memory();
+ sys.total_memory() - sys.used_memory()
+}
+
+#[cfg(target_arch = "wasm32")]
+pub fn get_free_ram() -> u64 {
+ use core::arch::wasm32::memory_size;
+ const TOTAL_AVAILABLE: u64 = 4 * 1024 * 1024 * 1024;
+ const PAGE_SIZE: u64 = 65536;
+
+ let used = (memory_size::<0>() as u64) * PAGE_SIZE;
+ TOTAL_AVAILABLE - used
+}
+
+#[cfg(not(target_arch = "wasm32"))]
+pub fn get_free_swap() -> u64 {
+ use sysinfo::System;
+ let mut sys = System::new();
+ sys.refresh_memory();
+ sys.total_swap() - sys.used_swap()
+}
+
+#[cfg(target_arch = "wasm32")]
+pub fn get_free_swap() -> u64 {
+ 0u64
+}
diff --git a/crates/uzu/src/utils/mod.rs b/crates/uzu/src/utils/mod.rs
index a36794f08..35259d2f2 100644
--- a/crates/uzu/src/utils/mod.rs
+++ b/crates/uzu/src/utils/mod.rs
@@ -1,5 +1,6 @@
pub mod env_utils;
pub mod fs;
+pub mod memory;
#[cfg(metal_backend)]
pub mod model_size;
pub mod pointers;
diff --git a/crates/uzu/tests/unit/backends/cpu/argmax_test.rs b/crates/uzu/tests/unit/backends/cpu/argmax_test.rs
index 36e45590e..a3985cd32 100644
--- a/crates/uzu/tests/unit/backends/cpu/argmax_test.rs
+++ b/crates/uzu/tests/unit/backends/cpu/argmax_test.rs
@@ -1,8 +1,9 @@
+#![cfg(target_arch = "aarch64")]
+
use std::time::Instant;
use super::*;
-#[cfg(target_arch = "aarch64")]
#[test]
fn test_neon_argmax_correctness() {
// Single deterministic 64k array test with random values
@@ -31,7 +32,6 @@ fn test_neon_argmax_correctness() {
assert_eq!(expected, 42_000, "Expected max should be at index 42_000");
}
-#[cfg(target_arch = "aarch64")]
#[test]
fn test_neon_performance_128k() {
const SEQ_LEN: usize = 128 * 1024;