A high-performance inference engine for AI models
Update XGrammar (#535)
eugene23619e5c5146
diff --git a/Cargo.lock b/Cargo.lockindex b4f2e40cf..d44096a8a 100644--- a/Cargo.lock+++ b/Cargo.lock@@ -169,19 +169,6 @@ dependencies = ["security-framework",]-[[package]]-name = "aquamarine"-version = "0.1.12"-source = "registry+https://github.com/rust-lang/crates.io-index"-checksum = "a941c39708478e8eea39243b5983f1c42d2717b3620ee91f4a52115fd02ac43f"-dependencies = [- "itertools 0.9.0",- "proc-macro-error",- "proc-macro2",- "quote",- "syn 1.0.109",-]-[[package]]name = "arbitrary"version = "1.4.2"@@ -379,127 +366,12 @@ version = "1.1.2"source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "1505bd5d3d116872e7271a6d4e16d81d0c8570876c8de68093a09ac269d8aac0"-[[package]]-name = "atty"-version = "0.2.14"-source = "registry+https://github.com/rust-lang/crates.io-index"-checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8"-dependencies = [- "hermit-abi 0.1.19",- "libc",- "winapi",-]-[[package]]name = "autocfg"version = "1.5.1"source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "f2032f911046de80f0a198e0901378627c33f59ea0ac00e363d481118bd70a53"-[[package]]-name = "autocxx"-version = "0.30.0"-source = "registry+https://github.com/rust-lang/crates.io-index"-checksum = "5ae6bbbec65d053b6fd803a4d63d21d0bd4a92f84f917847f216fec8bb8ae6ae"-dependencies = [- "aquamarine",- "autocxx-macro",- "cxx",- "moveit",-]--[[package]]-name = "autocxx-bindgen"-version = "0.73.0"-source = "registry+https://github.com/rust-lang/crates.io-index"-checksum = "ecaaf84d9cf1a772409c0abdac7d2477a31fd890dbdf606d8f684dc60129aa94"-dependencies = [- "bitflags 2.11.1",- "cexpr",- "clang-sys",- "itertools 0.13.0",- "log",- "proc-macro2",- "quote",- "regex",- "rustc-hash 2.1.2",- "shlex 1.3.0",- "syn 2.0.117",-]--[[package]]-name = "autocxx-build"-version = "0.30.0"-source = "registry+https://github.com/rust-lang/crates.io-index"-checksum = "b16fa879472d80dc40ca826a59347772b3f15e69a7a74df41c4935942f62cf30"-dependencies = [- "autocxx-engine",- "env_logger",- "indexmap 1.9.3",- "syn 2.0.117",-]--[[package]]-name = "autocxx-engine"-version = "0.30.0"-source = "registry+https://github.com/rust-lang/crates.io-index"-checksum = "9866b109f7091a3470a49906d35c7f34597828be8885508e9395d1194f8283ca"-dependencies = [- "aquamarine",- "autocxx-bindgen",- "autocxx-parser",- "cc",- "cxx-gen",- "indexmap 1.9.3",- "indoc 1.0.9",- "itertools 0.10.5",- "log",- "miette",- "once_cell",- "prettyplease",- "proc-macro2",- "quote",- "regex",- "regex_static",- "rustversion",- "serde_json",- "syn 2.0.117",- "tempfile",- "thiserror 1.0.69",- "version_check",-]--[[package]]-name = "autocxx-macro"-version = "0.30.0"-source = "registry+https://github.com/rust-lang/crates.io-index"-checksum = "c26712d744702e6fe61fdc618cc107a581a009ec8bfaffc67707d82501dbd907"-dependencies = [- "autocxx-parser",- "proc-macro-error",- "proc-macro2",- "quote",- "syn 2.0.117",-]--[[package]]-name = "autocxx-parser"-version = "0.30.0"-source = "registry+https://github.com/rust-lang/crates.io-index"-checksum = "6bcfc473ec409e612fb0e0c5c4a1b5b7611eca2bac71bc27b3cda98f15a25124"-dependencies = [- "indexmap 1.9.3",- "itertools 0.10.5",- "log",- "once_cell",- "proc-macro2",- "quote",- "serde",- "serde_json",- "syn 2.0.117",- "thiserror 1.0.69",-]-[[package]]name = "av-scenechange"version = "0.14.1"@@ -1619,13 +1491,11 @@ checksum = "01334b89b69ff726750c5ce5073fc8bd860e99aa9a8fc5ca11b04730e3aee97a"[[package]]name = "cxx"version = "1.0.194"-source = "registry+https://github.com/rust-lang/crates.io-index"-checksum = "747d8437319e3a2f43d93b341c137927ca70c0f5dabeea7a005a73665e247c7e"+source = "git+https://github.com/trymirai/cxx.git?branch=master#654cece461ed00cc8aaf86e80aed4eb24cd6ae0f"dependencies = [- "cc","cxx-build",+ "cxx-cc","cxxbridge-cmd",- "cxxbridge-flags","cxxbridge-macro","foldhash 0.2.0","link-cplusplus",@@ -1634,11 +1504,11 @@ dependencies = [[[package]]name = "cxx-build"version = "1.0.194"-source = "registry+https://github.com/rust-lang/crates.io-index"-checksum = "b0f4697d190a142477b16aef7da8a99bfdc41e7e8b1687583c0d23a79c7afc1e"+source = "git+https://github.com/trymirai/cxx.git?branch=master#654cece461ed00cc8aaf86e80aed4eb24cd6ae0f"dependencies = ["cc","codespan-reporting",+ "cxx-cc","indexmap 2.14.0","proc-macro2","quote",@@ -1647,23 +1517,18 @@ dependencies = [][[package]]-name = "cxx-gen"-version = "0.7.194"-source = "registry+https://github.com/rust-lang/crates.io-index"-checksum = "035b6c61a944483e8a4b2ad4fb8b13830d63491bd004943716ad16d85dcc64bc"+name = "cxx-cc"+version = "1.0.194"+source = "git+https://github.com/trymirai/cxx.git?branch=master#654cece461ed00cc8aaf86e80aed4eb24cd6ae0f"dependencies = [- "codespan-reporting",- "indexmap 2.14.0",- "proc-macro2",- "quote",- "syn 2.0.117",+ "cc",+ "cxxbridge-flags",][[package]]name = "cxxbridge-cmd"version = "1.0.194"-source = "registry+https://github.com/rust-lang/crates.io-index"-checksum = "d0956799fa8678d4c50eed028f2de1c0552ae183c76e976cf7ca8c4e36a7c328"+source = "git+https://github.com/trymirai/cxx.git?branch=master#654cece461ed00cc8aaf86e80aed4eb24cd6ae0f"dependencies = ["clap","codespan-reporting",@@ -1676,14 +1541,12 @@ dependencies = [[[package]]name = "cxxbridge-flags"version = "1.0.194"-source = "registry+https://github.com/rust-lang/crates.io-index"-checksum = "23384a836ab4f0ad98ace7e3955ad2de39de42378ab487dc28d3990392cb283a"+source = "git+https://github.com/trymirai/cxx.git?branch=master#654cece461ed00cc8aaf86e80aed4eb24cd6ae0f"[[package]]name = "cxxbridge-macro"version = "1.0.194"-source = "registry+https://github.com/rust-lang/crates.io-index"-checksum = "e6acc6b5822b9526adfb4fc377b67128fdd60aac757cc4a741a6278603f763cf"+source = "git+https://github.com/trymirai/cxx.git?branch=master#654cece461ed00cc8aaf86e80aed4eb24cd6ae0f"dependencies = ["indexmap 2.14.0","proc-macro2",@@ -2050,19 +1913,6 @@ dependencies = ["cfg-if",]-[[package]]-name = "env_logger"-version = "0.9.3"-source = "registry+https://github.com/rust-lang/crates.io-index"-checksum = "a12e6657c4c97ebab115a42dcee77225f7f482cdd841cf7088c657a42e9e00e7"-dependencies = [- "atty",- "humantime",- "log",- "regex",- "termcolor",-]-[[package]]name = "equator"version = "0.4.2"@@ -2178,7 +2028,7 @@ checksum = "531e46835a22af56d1e3b66f04844bed63158bc094a628bec1d321d9b4c44bf2"dependencies = ["bit-set 0.5.3","regex-automata",- "regex-syntax 0.8.10",+ "regex-syntax",][[package]]@@ -2189,7 +2039,7 @@ checksum = "6e24cb5a94bcae1e5408b0effca5cd7172ea3c5755049c5f3af4cd283a165298"dependencies = ["bit-set 0.8.0","regex-automata",- "regex-syntax 0.8.10",+ "regex-syntax",][[package]]@@ -2200,7 +2050,7 @@ checksum = "72cf461f865c862bb7dc573f643dd6a2b6842f7c30b07882b56bd148cc2761b8"dependencies = ["bit-set 0.8.0","regex-automata",- "regex-syntax 0.8.10",+ "regex-syntax",][[package]]@@ -2211,7 +2061,7 @@ checksum = "e1e1dacd0d2082dfcf1351c4bdd566bbe89a2b263235a2b50058f1e130a47277"dependencies = ["bit-set 0.8.0","regex-automata",- "regex-syntax 0.8.10",+ "regex-syntax",][[package]]@@ -2553,7 +2403,7 @@ dependencies = ["bstr","log","regex-automata",- "regex-syntax 0.8.10",+ "regex-syntax",][[package]]@@ -2695,15 +2545,6 @@ version = "0.5.0"source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea"-[[package]]-name = "hermit-abi"-version = "0.1.19"-source = "registry+https://github.com/rust-lang/crates.io-index"-checksum = "62b467343b94ba476dcb2500d242dadbb39557df889310ac77c5d99100aaac33"-dependencies = [- "libc",-]-[[package]]name = "hermit-abi"version = "0.5.2"@@ -2798,12 +2639,6 @@ version = "1.0.3"source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "df3b46402a9d5adb4c86a0cf463f42e19994e3ee891101b1841f30a545cb49a9"-[[package]]-name = "humantime"-version = "2.3.0"-source = "registry+https://github.com/rust-lang/crates.io-index"-checksum = "135b12329e5e3ce057a9f972339ea52bc954fe1e9358ef27f95e89716fbc5424"-[[package]]name = "hyper"version = "0.14.32"@@ -3123,12 +2958,6 @@ dependencies = ["web-time",]-[[package]]-name = "indoc"-version = "1.0.9"-source = "registry+https://github.com/rust-lang/crates.io-index"-checksum = "bfa799dd5ed20a7e349f3b4639aa80d74549c81716d9ec4f994c9b5815598306"-[[package]]name = "indoc"version = "2.0.7"@@ -3151,7 +2980,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "5eb2d60ef19920a3a9193c3e371f726ec1dafc045dac788d0fb3704272458971"dependencies = ["darling 0.23.0",- "indoc 2.0.7",+ "indoc","proc-macro2","quote","syn 2.0.117",@@ -3237,7 +3066,7 @@ version = "0.4.17"source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "3640c1c38b8e4e43584d8df18be5fc6b0aa314ce6ebf51b53313d4306cca8e46"dependencies = [- "hermit-abi 0.5.2",+ "hermit-abi","libc","windows-sys 0.61.2",]@@ -3257,24 +3086,6 @@ version = "1.70.2"source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "a6cb138bb79a146c1bd460005623e142ef0181e3d0219cb493e02f7d08a35695"-[[package]]-name = "itertools"-version = "0.9.0"-source = "registry+https://github.com/rust-lang/crates.io-index"-checksum = "284f18f85651fe11e8a991b2adb42cb078325c996ed026d994719efcfca1d54b"-dependencies = [- "either",-]--[[package]]-name = "itertools"-version = "0.10.5"-source = "registry+https://github.com/rust-lang/crates.io-index"-checksum = "b0fd2260e829bddf4cb6ea802289de2f86d6a7a690192fbe91b3f46e0f2c8473"-dependencies = [- "either",-]-[[package]]name = "itertools"version = "0.11.0"@@ -3440,7 +3251,7 @@ dependencies = ["percent-encoding","referencing","regex",- "regex-syntax 0.8.10",+ "regex-syntax","reqwest 0.13.4","rustls","serde",@@ -3638,7 +3449,7 @@ dependencies = ["lazy_static","proc-macro2","quote",- "regex-syntax 0.8.10",+ "regex-syntax","rustc_version","syn 2.0.117",]@@ -3820,29 +3631,6 @@ version = "0.3.0"source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "c2a86d3146ed3995b5913c414f6664344b9617457320782e64f0bb44afd49d74"-[[package]]-name = "miette"-version = "5.10.0"-source = "registry+https://github.com/rust-lang/crates.io-index"-checksum = "59bb584eaeeab6bd0226ccf3509a69d7936d148cf3d036ad350abe35e8c6856e"-dependencies = [- "miette-derive",- "once_cell",- "thiserror 1.0.69",- "unicode-width 0.1.14",-]--[[package]]-name = "miette-derive"-version = "5.10.0"-source = "registry+https://github.com/rust-lang/crates.io-index"-checksum = "49e7bc1560b95a3c4a25d03de42fe76ca718ab92d1a22a55b9b4cf67b3ae635c"-dependencies = [- "proc-macro2",- "quote",- "syn 2.0.117",-]-[[package]]name = "mime"version = "0.3.17"@@ -3950,15 +3738,6 @@ dependencies = ["syn 2.0.117",]-[[package]]-name = "moveit"-version = "0.6.0"-source = "registry+https://github.com/rust-lang/crates.io-index"-checksum = "87d7335204cb6ef7bd647fa6db0be3e4d7aa25b5823a7aa030027ddf512cefba"-dependencies = [- "cxx",-]-[[package]]name = "moxcms"version = "0.8.1"@@ -4321,7 +4100,7 @@ version = "1.17.0"source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "91df4bbde75afed763b708b7eee1e8e7651e02d97f6d5dd763e89367e957b23b"dependencies = [- "hermit-abi 0.5.2",+ "hermit-abi","libc",]@@ -4904,30 +4683,6 @@ dependencies = ["toml_edit 0.25.12+spec-1.1.0",]-[[package]]-name = "proc-macro-error"-version = "1.0.4"-source = "registry+https://github.com/rust-lang/crates.io-index"-checksum = "da25490ff9892aab3fcf7c36f08cfb902dd3e71ca0f9f9517bea02a73a5ce38c"-dependencies = [- "proc-macro-error-attr",- "proc-macro2",- "quote",- "syn 1.0.109",- "version_check",-]--[[package]]-name = "proc-macro-error-attr"-version = "1.0.4"-source = "registry+https://github.com/rust-lang/crates.io-index"-checksum = "a1be40180e52ecc98ad80b184934baf3d0d29f979574e439af5a55274b35f869"-dependencies = [- "proc-macro2",- "quote",- "version_check",-]-[[package]]name = "proc-macro2"version = "1.0.106"@@ -4991,7 +4746,7 @@ dependencies = ["rand 0.9.4","rand_chacha 0.9.0","rand_xorshift",- "regex-syntax 0.8.10",+ "regex-syntax","rusty-fork","tempfile","unarray",@@ -5340,7 +5095,7 @@ dependencies = ["bitflags 2.11.1","compact_str","hashbrown 0.16.1",- "indoc 2.0.7",+ "indoc","itertools 0.14.0","kasuari","lru",@@ -5404,7 +5159,7 @@ checksum = "d7dbfa023cd4e604c2553483820c5fe8aa9d71a42eea5aa77c6e7f35756612db"dependencies = ["bitflags 2.11.1","hashbrown 0.16.1",- "indoc 2.0.7",+ "indoc","instability","itertools 0.14.0","line-clipping",@@ -5569,7 +5324,7 @@ dependencies = ["aho-corasick","memchr","regex-automata",- "regex-syntax 0.8.10",+ "regex-syntax",][[package]]@@ -5580,55 +5335,15 @@ checksum = "6e1dd4122fc1595e8162618945476892eefca7b88c52820e74af6262213cae8f"dependencies = ["aho-corasick","memchr",- "regex-syntax 0.8.10",+ "regex-syntax",]-[[package]]-name = "regex-syntax"-version = "0.6.29"-source = "registry+https://github.com/rust-lang/crates.io-index"-checksum = "f162c6dd7b008981e4d40210aca20b4bd0f9b60ca9271061b07f78537722f2e1"-[[package]]name = "regex-syntax"version = "0.8.10"source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "dc897dd8d9e8bd1ed8cdad82b5966c3e0ecae09fb1907d58efaa013543185d0a"-[[package]]-name = "regex_static"-version = "0.1.1"-source = "registry+https://github.com/rust-lang/crates.io-index"-checksum = "6126d61c5e4b41929098f73b42fc1d257116cc95d19739248c51591f77cc0021"-dependencies = [- "once_cell",- "regex",- "regex_static_macro",-]--[[package]]-name = "regex_static_impl"-version = "0.1.0"-source = "registry+https://github.com/rust-lang/crates.io-index"-checksum = "9c3755019886a70e772e6360b0b58501d75cf7dc17a53e08aa97e59ecb2c2bc5"-dependencies = [- "proc-macro2",- "quote",- "regex-syntax 0.6.29",- "syn 1.0.109",-]--[[package]]-name = "regex_static_macro"-version = "0.1.0"-source = "registry+https://github.com/rust-lang/crates.io-index"-checksum = "79b15495fd034158635bc8b762a132dfc83864d6992aeda1ffabf01b03b611a1"-dependencies = [- "proc-macro2",- "regex_static_impl",- "syn 1.0.109",-]-[[package]]name = "relative-path"version = "1.9.3"@@ -7163,7 +6878,7 @@ dependencies = ["rayon","rayon-cond","regex",- "regex-syntax 0.8.10",+ "regex-syntax","serde","serde_json","spm_precompiled",@@ -7897,7 +7612,7 @@ dependencies = ["futures-util","indexmap 2.14.0","indicatif",- "indoc 2.0.7",+ "indoc","inventory","iocraft","keyring-core",@@ -8865,13 +8580,11 @@ checksum = "1ffae5123b2d3fc086436f8834ae3ab053a283cfac8fe0a0b8eaae044768a4c4"[[package]]name = "xgrammar-rs"version = "0.1.33"-source = "registry+https://github.com/rust-lang/crates.io-index"-checksum = "2f62aaf862c4c02642e381bc17172be4096889bb3834aa47a1bead94df70f0c6"+source = "git+https://github.com/trymirai/xgrammar-rs.git?rev=58def68d6e0e523e183b23e7a7a23f6ba1b572fa#58def68d6e0e523e183b23e7a7a23f6ba1b572fa"dependencies = [- "autocxx",- "autocxx-build","cmake","cxx",+ "cxx-build","serde_json","tokenizers","walkdir",diff --git a/Cargo.toml b/Cargo.tomlindex 60570e553..347c17e9a 100644--- a/Cargo.toml+++ b/Cargo.toml@@ -58,7 +58,7 @@ download-manager = { path = "crates/download-manager", default-features = falsemock-registry = { path = "crates/mock-registry", default-features = false }benchmarks = { path = "crates/benchmarks", default-features = false }uzu = { path = "crates/uzu", default-features = false }-xgrammar = { package = "xgrammar-rs", version = "0.1.33", features = ["tokenizers"] }+xgrammar = { package = "xgrammar-rs", git = "https://github.com/trymirai/xgrammar-rs.git", rev = "58def68d6e0e523e183b23e7a7a23f6ba1b572fa", features = ["tokenizers"] }half = { version = "2.7", features = ["bytemuck", "num-traits"] }ndarray = "0.17"serde = { version = "1.0", features = ["derive"] }diff --git a/crates/backend-uzu/Cargo.toml b/crates/backend-uzu/Cargo.tomlindex 383cb164e..1380fa286 100644--- a/crates/backend-uzu/Cargo.toml+++ b/crates/backend-uzu/Cargo.toml@@ -40,6 +40,9 @@ rustix.workspace = truefutures.workspace = truetokio-util.workspace = true+# grammar requires xgrammar+xgrammar = { workspace = true, optional = true }+# metal on macos requires objc2, bytesize, metal[target.'cfg(any(target_os = "macos", target_os = "ios", target_os = "tvos", target_os = "visionos"))'.dependencies]objc2 = { workspace = true, optional = true }@@ -47,10 +50,6 @@ objc2-foundation = { workspace = true, optional = true }bytesize = { workspace = true, optional = true }metal = { workspace = true, optional = true }-# grammar on non-wasm requires xgrammar-[target.'cfg(not(target_arch = "wasm32"))'.dependencies]-xgrammar = { workspace = true, optional = true }-[dev-dependencies]test-tag.workspace = truetest-runner = { workspace = true, features = ["nightly-harness"] }diff --git a/crates/backend-uzu/build/main.rs b/crates/backend-uzu/build/main.rsindex 3e8599c58..64d4ff5b5 100644--- a/crates/backend-uzu/build/main.rs+++ b/crates/backend-uzu/build/main.rs@@ -23,7 +23,6 @@ async fn main() -> anyhow::Result<()> {println!("cargo::rerun-if-changed=/var/empty/hack_nonexistent_file_to_always_rerun");}- let target_arch = env::var("CARGO_CFG_TARGET_ARCH")?;let target_os = env::var("CARGO_CFG_TARGET_OS")?;let metal_backend = cfg!(feature = "metal") && matches!(target_os.as_ref(), "macos" | "ios" | "tvos" | "visionos");@@ -32,7 +31,7 @@ async fn main() -> anyhow::Result<()> {println!("cargo::rustc-cfg=metal_backend");}- let grammar_xgrammar = cfg!(feature = "grammar") && target_arch != "wasm32";+ let grammar_xgrammar = cfg!(feature = "grammar");println!("cargo::rustc-check-cfg=cfg(grammar_xgrammar)");if grammar_xgrammar {println!("cargo::rustc-cfg=grammar_xgrammar");diff --git a/crates/backend-uzu/src/language_model/grammar/xgram.rs b/crates/backend-uzu/src/language_model/grammar/xgram.rsindex a4fe6ad49..6eabdf851 100644--- a/crates/backend-uzu/src/language_model/grammar/xgram.rs+++ b/crates/backend-uzu/src/language_model/grammar/xgram.rs@@ -4,7 +4,7 @@ use std::iter::repeat_n;use xgrammar::{DLDataType, DLDataTypeCode, DLDevice, DLDeviceType, DLTensor, Grammar, GrammarCompiler, GrammarMatcher,- TokenizerInfo,+ TokenizerInfo, c_void,};use crate::{@@ -128,21 +128,23 @@ impl CompiledGrammar for CompiledXGrammar {let mut cpu_mask = repeat_n(0, self.vocab_size.div_ceil(32)).collect::<Box<[u32]>>();let batch_mask_slice = &mut cpu_mask;let mut shape_i64 = [self.vocab_size.div_ceil(32) as i64];- let mut bitmask_tensor = DLTensor {- data: batch_mask_slice.as_mut_ptr() as *mut core::ffi::c_void,- device: DLDevice {- device_type: DLDeviceType::kDLCPU,- device_id: 0,- },- ndim: 1,- dtype: DLDataType {- code: 0,- bits: 32,- lanes: 1,- },- shape: shape_i64.as_mut_ptr(),- strides: core::ptr::null_mut(),- byte_offset: 0,+ let mut bitmask_tensor = unsafe {+ DLTensor::new(+ batch_mask_slice.as_mut_ptr() as *mut c_void,+ DLDevice {+ device_type: DLDeviceType::kDLCPU,+ device_id: 0,+ },+ 1,+ DLDataType {+ code: 0,+ bits: 32,+ lanes: 1,+ },+ shape_i64.as_mut_ptr(),+ core::ptr::null_mut(),+ 0,+ )};let success = self.matcher.fill_next_token_bitmask(&mut bitmask_tensor, 0, false);diff --git a/crates/backend-uzu/unit/language_model/grammar.rs b/crates/backend-uzu/unit/language_model/grammar.rsindex 05c9e8a16..18f5e294a 100644--- a/crates/backend-uzu/unit/language_model/grammar.rs+++ b/crates/backend-uzu/unit/language_model/grammar.rs@@ -6,7 +6,7 @@ use schemars::JsonSchema;use serde::{Deserialize, Serialize};use test_runner::path::get_test_model_path;use tokenizers::Tokenizer;-use xgrammar::{DLDevice, DLDeviceType, DLTensor, Grammar, GrammarCompiler, GrammarMatcher, TokenizerInfo};+use xgrammar::{DLDevice, DLDeviceType, DLTensor, Grammar, GrammarCompiler, GrammarMatcher, TokenizerInfo, c_void};use crate::{array::Array,@@ -71,17 +71,19 @@ fn person_schema_metal_bitmask() {let metal_bitmask = unsafe { Array::<Metal>::from_allocation(allocation, 0, &shape, DataType::I32) };let mut shape_i64 = [buffer_size as i64];- let mut bitmask_tensor = DLTensor {- data: metal_bitmask.cpu_ptr().as_ptr(),- device: DLDevice {- device_type: DLDeviceType::kDLCPU,- device_id,- },- ndim: 1,- dtype: DataType::I32.into(),- shape: shape_i64.as_mut_ptr(),- strides: core::ptr::null_mut(),- byte_offset: 0,+ let mut bitmask_tensor = unsafe {+ DLTensor::new(+ metal_bitmask.cpu_ptr().as_ptr() as *mut c_void,+ DLDevice {+ device_type: DLDeviceType::kDLCPU,+ device_id,+ },+ 1,+ DataType::I32.into(),+ shape_i64.as_mut_ptr(),+ core::ptr::null_mut(),+ 0,+ )};let _ok = matcher.fill_next_token_bitmask(&mut bitmask_tensor, 0, false);diff --git a/deny.toml b/deny.tomlindex b1edb3eda..c8e9c75f3 100644--- a/deny.toml+++ b/deny.toml@@ -1,8 +1,6 @@[advisories]ignore = [- "RUSTSEC-2024-0370", # proc-macro-error is unmaintained"RUSTSEC-2024-0436", # paste - no longer maintained- "RUSTSEC-2024-0375", # `atty` is unmaintained"RUSTSEC-2024-0384", # instant is unmaintained"RUSTSEC-2025-0012", # backoff is unmaintained]@@ -26,3 +24,6 @@ allow = [[bans]multiple-versions = "allow"++[sources.allow-org]+github = ["trymirai"]