A high-performance inference engine for AI models
Clean lib.rs (#540)
Aleksandr Golokozb310f534095f
diff --git a/Cargo.lock b/Cargo.lockindex 29ce81413..b4f2e40cf 100644--- a/Cargo.lock+++ b/Cargo.lock@@ -605,7 +605,6 @@ dependencies = ["itertools 0.14.0","libc","libm",- "macmon","memmap2","minijinja","minijinja-contrib",@@ -634,6 +633,7 @@ dependencies = ["syn 2.0.117","sysinfo","tempfile",+ "test-runner","test-tag","thiserror 2.0.18","tokenizers",@@ -6946,6 +6946,16 @@ dependencies = ["winapi",]+[[package]]+name = "test-runner"+version = "0.5.12"+dependencies = [+ "criterion",+ "macmon",+ "objc2",+ "objc2-foundation",+]+[[package]]name = "test-tag"version = "0.1.6"diff --git a/Cargo.toml b/Cargo.tomlindex a79c29df0..60570e553 100644--- a/Cargo.toml+++ b/Cargo.toml@@ -17,6 +17,7 @@ members = ["crates/cli","crates/cli-storage","crates/cli-tools",+ "crates/test-runner",]resolver = "3"@@ -43,6 +44,7 @@ keywords = [[workspace.dependencies]proc-macros = { path = "crates/proc-macros" }+test-runner = { path = "crates/test-runner" }bindings-types = { path = "crates/bindings-types", default-features = false }bindings = { path = "crates/bindings", default-features = false }shoji = { path = "crates/shoji", default-features = false }diff --git a/crates/backend-uzu/Cargo.toml b/crates/backend-uzu/Cargo.tomlindex 294bae638..383cb164e 100644--- a/crates/backend-uzu/Cargo.toml+++ b/crates/backend-uzu/Cargo.toml@@ -53,6 +53,7 @@ xgrammar = { workspace = true, optional = true }[dev-dependencies]test-tag.workspace = true+test-runner = { workspace = true, features = ["nightly-harness"] }proptest.workspace = truecriterion.workspace = truecriterion-macro.workspace = true@@ -67,10 +68,6 @@ rstest.workspace = truecriterion = { workspace = true, default-features = true }proptest = { workspace = true, default-features = true }-[target.'cfg(target_os = "macos")'.dev-dependencies]-# for getting gpu temperature-macmon.workspace = true-[build-dependencies]anyhow.workspace = trueasync-trait.workspace = truediff --git a/crates/backend-uzu/benches/main.rs b/crates/backend-uzu/benches/main.rsindex 74445affd..b8e31f514 100644--- a/crates/backend-uzu/benches/main.rs+++ b/crates/backend-uzu/benches/main.rs@@ -1,10 +1,4 @@-#![feature(custom_test_frameworks, test)]-#![test_runner(crate::tests::uzu_harness)]--#[macro_use]-#[path = "../tests/common/mod.rs"]-mod common;-#[path = "../src/tests/mod.rs"]-mod tests;+#![feature(custom_test_frameworks)]+#![test_runner(test_runner::uzu_harness)]mod session;diff --git a/crates/backend-uzu/benches/session/chat_session_bench.rs b/crates/backend-uzu/benches/session/chat_session_bench.rsindex cd5e8401e..fab934d7a 100644--- a/crates/backend-uzu/benches/session/chat_session_bench.rs+++ b/crates/backend-uzu/benches/session/chat_session_bench.rs@@ -10,8 +10,7 @@ use backend_uzu::{};use criterion::{BenchmarkId, Criterion};use proc_macros::uzu_bench;--use crate::common::{metrics::wait_gpu_cooldown, path::get_test_model_path};+use test_runner::{for_each_non_cpu_backend, metrics::wait_gpu_cooldown, path::get_test_model_path};fn create_session<B: Backend>() -> ChatSession {let model_path = get_test_model_path();diff --git a/crates/backend-uzu/benches/session/mod.rs b/crates/backend-uzu/benches/session/mod.rsindex 6e1c28097..1e8b0be54 100644--- a/crates/backend-uzu/benches/session/mod.rs+++ b/crates/backend-uzu/benches/session/mod.rs@@ -1 +1,2 @@mod chat_session_bench;+mod model_loading_bench;diff --git a/crates/backend-uzu/benches/session/model_loading_bench.rs b/crates/backend-uzu/benches/session/model_loading_bench.rsnew file mode 100644index 000000000..33c8f72eb--- /dev/null+++ b/crates/backend-uzu/benches/session/model_loading_bench.rs@@ -0,0 +1,19 @@+use std::time::Duration;++use backend_uzu::session::{ChatSession, config::DecodingConfig};+use criterion::{BenchmarkId, Criterion};+use proc_macros::uzu_bench;+use test_runner::path::get_test_model_path;++#[uzu_bench]+fn bench_model_loading(c: &mut Criterion) {+ let mut group = c.benchmark_group("Model loading");+ group.sample_size(10);+ group.warm_up_time(Duration::from_secs(1));+ group.bench_function(BenchmarkId::from_parameter("test model path"), |b| {+ b.iter(|| {+ let model_path = get_test_model_path();+ let _ = ChatSession::new(model_path, DecodingConfig::default());+ });+ });+}diff --git a/crates/backend-uzu/src/lib.rs b/crates/backend-uzu/src/lib.rsindex 60e91d6db..df917b5ea 100644--- a/crates/backend-uzu/src/lib.rs+++ b/crates/backend-uzu/src/lib.rs@@ -1,33 +1,27 @@#![cfg_attr(test, feature(custom_test_frameworks, test))]-#![cfg_attr(test, test_runner(crate::tests::uzu_harness))]+#![cfg_attr(test, test_runner(test_runner::uzu_harness))]-// needed for tests to resolve `backend_uzu::` imports-#[cfg(test)]-extern crate self as backend_uzu;--#[cfg(test)]-#[macro_use]-#[path = "../tests/common/mod.rs"]-mod common;--pub mod array;+mod array;mod audio;mod classifier;mod config;-pub mod data_type;mod encodable_block;mod forward_pass;mod language_model;mod parameters;-pub mod speculators;+mod speculators;mod trie;mod utils;pub mod backends;+pub mod data_type;pub mod inference;pub mod session;pub use utils::{TOOLCHAIN_VERSION, VERSION};+// needed for tests to resolve `backend_uzu::` imports+#[cfg(test)]+extern crate self as backend_uzu;#[cfg(test)]pub mod tests;diff --git a/crates/backend-uzu/src/speculators/mod.rs b/crates/backend-uzu/src/speculators/mod.rsindex 06f1fa8e6..cf759e9fc 100644--- a/crates/backend-uzu/src/speculators/mod.rs+++ b/crates/backend-uzu/src/speculators/mod.rs@@ -1,7 +1,11 @@+#[cfg(test)]pub mod chain_acceptance;pub mod empty_speculator;pub mod fixed_token_speculator;+#[allow(dead_code)]pub mod ngram_speculator;pub mod prompt_lookup_speculator;+#[cfg(test)]+pub mod repeat_speculator;pub mod speculator;pub mod token_finder;diff --git a/crates/backend-uzu/tests/common/repeat_speculator.rs b/crates/backend-uzu/src/speculators/repeat_speculator.rssimilarity index 87%rename from crates/backend-uzu/tests/common/repeat_speculator.rsrename to crates/backend-uzu/src/speculators/repeat_speculator.rsindex 89095912e..ebdff4680 100644--- a/crates/backend-uzu/tests/common/repeat_speculator.rs+++ b/crates/backend-uzu/src/speculators/repeat_speculator.rs@@ -1,6 +1,8 @@+#![allow(dead_code)]+use std::collections::HashMap;-use backend_uzu::speculators::speculator::Speculator;+use crate::speculators::speculator::Speculator;pub struct RepeatSpeculator;diff --git a/crates/backend-uzu/tests/common/assert.rs b/crates/backend-uzu/src/tests/assert.rssimilarity index 95%rename from crates/backend-uzu/tests/common/assert.rsrename to crates/backend-uzu/src/tests/assert.rsindex a8f8728ed..569375579 100644--- a/crates/backend-uzu/tests/common/assert.rs+++ b/crates/backend-uzu/src/tests/assert.rs@@ -1,8 +1,9 @@use std::fmt::Display;-use backend_uzu::array::ArrayElement;use num_traits::Float;+use crate::array::ArrayElement;+pub fn assert_eq_float<T: ArrayElement + Float + Display>(expected: &[T],actual: &[T],diff --git a/crates/backend-uzu/tests/common/audio/fsq_reference.rs b/crates/backend-uzu/src/tests/audio/fsq_reference.rssimilarity index 100%rename from crates/backend-uzu/tests/common/audio/fsq_reference.rsrename to crates/backend-uzu/src/tests/audio/fsq_reference.rsdiff --git a/crates/backend-uzu/tests/common/audio/mod.rs b/crates/backend-uzu/src/tests/audio/mod.rssimilarity index 100%rename from crates/backend-uzu/tests/common/audio/mod.rsrename to crates/backend-uzu/src/tests/audio/mod.rsdiff --git a/crates/backend-uzu/tests/common/audio/ops_reference.rs b/crates/backend-uzu/src/tests/audio/ops_reference.rssimilarity index 100%rename from crates/backend-uzu/tests/common/audio/ops_reference.rsrename to crates/backend-uzu/src/tests/audio/ops_reference.rsdiff --git a/crates/backend-uzu/tests/common/helpers.rs b/crates/backend-uzu/src/tests/helpers.rssimilarity index 99%rename from crates/backend-uzu/tests/common/helpers.rsrename to crates/backend-uzu/src/tests/helpers.rsindex 0a91f81f9..fa489d58b 100644--- a/crates/backend-uzu/tests/common/helpers.rs+++ b/crates/backend-uzu/src/tests/helpers.rs@@ -1,6 +1,6 @@use std::{mem::size_of, rc::Rc};-use backend_uzu::{+use crate::{array::ArrayElement,backends::common::{Allocation, AllocationType, AsBufferRangeMut, Backend, Context, DenseBuffer, Encoder, SparseBuffer,diff --git a/crates/backend-uzu/tests/common/matmul/bench.rs b/crates/backend-uzu/src/tests/matmul/bench.rssimilarity index 96%rename from crates/backend-uzu/tests/common/matmul/bench.rsrename to crates/backend-uzu/src/tests/matmul/bench.rsindex 7e57688bb..837d6d241 100644--- a/crates/backend-uzu/tests/common/matmul/bench.rs+++ b/crates/backend-uzu/src/tests/matmul/bench.rs@@ -5,10 +5,10 @@ use std::{time::{SystemTime, UNIX_EPOCH},};-use backend_uzu::backends::common::{Backend, Context, Encoder};use criterion::Bencher;+use test_runner::env_vars;-use crate::tests::env_vars;+use crate::backends::common::{Backend, Context, Encoder};static CAPTURE_TAKEN: AtomicBool = AtomicBool::new(false);diff --git a/crates/backend-uzu/tests/common/matmul/harness.rs b/crates/backend-uzu/src/tests/matmul/harness.rssimilarity index 95%rename from crates/backend-uzu/tests/common/matmul/harness.rsrename to crates/backend-uzu/src/tests/matmul/harness.rsindex 512debeee..eb1f3ed78 100644--- a/crates/backend-uzu/tests/common/matmul/harness.rs+++ b/crates/backend-uzu/src/tests/matmul/harness.rs@@ -1,10 +1,13 @@+use num_traits::Float;++use super::Shape;#[cfg(metal_backend)]-use backend_uzu::backends::metal::{GemmDispatchPath, Metal, MetalContext};-use backend_uzu::{+use crate::backends::metal::{GemmDispatchPath, Metal, MetalContext};+use crate::{array::{ArrayContextExt, ArrayElement},backends::{common::{- Allocation, AllocationType, AsBufferRangeRef, Backend, Buffer, Context, Encoder,+ AllocationType, Backend, Context, Encoder,kernel::{Kernels,matmul::{MatmulArguments, MatmulB, MatmulDOps, MatmulKernel},@@ -12,12 +15,7 @@ use backend_uzu::{},cpu::Cpu,},-};-use num_traits::Float;--use super::{- super::helpers::{alloc_allocation_with_data, allocation_to_vec},- Shape,+ tests::helpers::{alloc_allocation_with_data, allocation_to_vec},};#[cfg(metal_backend)]diff --git a/crates/backend-uzu/tests/common/matmul/mod.rs b/crates/backend-uzu/src/tests/matmul/mod.rssimilarity index 100%rename from crates/backend-uzu/tests/common/matmul/mod.rsrename to crates/backend-uzu/src/tests/matmul/mod.rsdiff --git a/crates/backend-uzu/tests/common/matmul/quant.rs b/crates/backend-uzu/src/tests/matmul/quant.rssimilarity index 97%rename from crates/backend-uzu/tests/common/matmul/quant.rsrename to crates/backend-uzu/src/tests/matmul/quant.rsindex 580959b61..2ad058aa5 100644--- a/crates/backend-uzu/tests/common/matmul/quant.rs+++ b/crates/backend-uzu/src/tests/matmul/quant.rs@@ -1,6 +1,9 @@+use num_traits::Float;+use rand::{RngExt, SeedableRng, rngs::SmallRng};+#[cfg(metal_backend)]-use backend_uzu::backends::metal::{GemmDispatchPath, Metal, MetalContext};-use backend_uzu::{+use crate::backends::metal::{GemmDispatchPath, Metal, MetalContext};+use crate::{array::ArrayElement,backends::{common::{@@ -13,11 +16,8 @@ use backend_uzu::{},cpu::Cpu,},+ tests::helpers::{alloc_allocation, alloc_allocation_with_data, allocation_to_vec},};-use num_traits::Float;-use rand::{RngExt, SeedableRng, rngs::SmallRng};--use super::super::helpers::{alloc_allocation, alloc_allocation_with_data, allocation_to_vec};pub struct QuantInput<T: ArrayElement + Float> {pub w_packed: Vec<u32>,diff --git a/crates/backend-uzu/tests/common/matmul/shape.rs b/crates/backend-uzu/src/tests/matmul/shape.rssimilarity index 100%rename from crates/backend-uzu/tests/common/matmul/shape.rsrename to crates/backend-uzu/src/tests/matmul/shape.rsdiff --git a/crates/backend-uzu/src/tests/mod.rs b/crates/backend-uzu/src/tests/mod.rsindex 207b130e5..7c714015b 100644--- a/crates/backend-uzu/src/tests/mod.rs+++ b/crates/backend-uzu/src/tests/mod.rs@@ -1,41 +1,11 @@#![cfg(test)]-#![allow(dead_code)]--pub mod env_vars;-pub mod util;+#![allow(dead_code, unused_imports, unused_macros)]pub extern crate test;-use crate::tests::util::enable_benchmark_gpu_capture_if_requested;--pub enum UzuTest {- Bench(&'static dyn Fn()),- Test(&'static test::TestDescAndFn),-}--pub fn uzu_harness(tests: &[&UzuTest]) {- let args = std::env::args().collect::<Vec<String>>();- let benchmarks = args.contains(&"--bench".to_string());- if benchmarks {- #[cfg(target_os = "ios")]- crate::common::path::ios_set_current_dir();- enable_benchmark_gpu_capture_if_requested();- let bench_tests: Vec<&dyn Fn()> = tests- .iter()- .filter_map(|test| match test {- UzuTest::Bench(test) => Some(*test),- UzuTest::Test(_) => None,- })- .collect::<Vec<_>>();- criterion::runner(bench_tests.as_slice());- } else {- let default_tests: Vec<&test::TestDescAndFn> = tests- .iter()- .filter_map(|test| match test {- UzuTest::Bench(_) => None,- UzuTest::Test(test) => Some(*test),- })- .collect::<Vec<_>>();- test::test_main_static(&default_tests)- }-}+pub mod assert;+pub mod audio;+pub mod helpers;+pub mod matmul;+pub mod proptest;+pub mod util;diff --git a/crates/backend-uzu/tests/common/proptest.rs b/crates/backend-uzu/src/tests/proptest.rssimilarity index 94%rename from crates/backend-uzu/tests/common/proptest.rsrename to crates/backend-uzu/src/tests/proptest.rsindex 79c871590..a34939191 100644--- a/crates/backend-uzu/tests/common/proptest.rs+++ b/crates/backend-uzu/src/tests/proptest.rs@@ -1,15 +1,16 @@use std::rc::Rc;+use proptest::prelude::*;+#[cfg(metal_backend)]-use backend_uzu::backends::metal::Metal;-use backend_uzu::{+use crate::backends::metal::Metal;+use crate::{backends::{common::{Backend, Context},cpu::Cpu,},data_type::DataType,};-use proptest::prelude::*;pub fn kernel_data_type() -> impl Strategy<Value = DataType> {prop_oneof![Just(DataType::BF16), Just(DataType::F32)]@@ -39,7 +40,7 @@ pub struct TestResults<T> {macro_rules! for_each_context {($CONTEXTES:ident, |$CONTEXT_NAME:ident: $CONTEXT_TYPE:ident| $body:expr) => {- crate::common::proptest::TestResults {+ crate::tests::proptest::TestResults {cpu: ({type $CONTEXT_TYPE =<backend_uzu::backends::cpu::Cpu as backend_uzu::backends::common::Backend>::Context;diff --git a/crates/backend-uzu/src/tests/util.rs b/crates/backend-uzu/src/tests/util.rsindex 6bdc4a815..904e22ea6 100644--- a/crates/backend-uzu/src/tests/util.rs+++ b/crates/backend-uzu/src/tests/util.rs@@ -1,9 +1,14 @@-use crate::tests::env_vars;+use test_runner::env_vars;-pub fn enable_benchmark_gpu_capture_if_requested() {- if env_vars::enabled(env_vars::UZU_CAPTURE_BENCH) {- unsafe {- std::env::set_var(env_vars::METAL_CAPTURE_ENABLED, "1");- }+#[cfg(metal_backend)]+pub fn shared_metal_context() -> std::rc::Rc<crate::backends::metal::MetalContext> {+ use crate::backends::{common::Context, metal::MetalContext};+ thread_local! {+ static CTX: std::cell::OnceCell<std::rc::Rc<MetalContext>> = const { std::cell::OnceCell::new() };}+ CTX.with(|cell| cell.get_or_init(|| MetalContext::new().expect("Metal context")).clone())+}++pub fn type_short_name<T>() -> &'static str {+ std::any::type_name::<T>().rsplit("::").next().unwrap()}diff --git a/crates/backend-uzu/tests/common/mod.rs b/crates/backend-uzu/tests/common/mod.rsdeleted file mode 100644index 360114fda..000000000--- a/crates/backend-uzu/tests/common/mod.rs+++ /dev/null@@ -1,59 +0,0 @@-#![allow(dead_code, unused_imports, unused_macros)]--pub mod assert;-pub mod audio;-pub mod helpers;-pub mod matmul;-pub mod metrics;-pub mod path;-pub mod perf;-pub mod proptest;-pub mod repeat_speculator;--pub(crate) use proptest::for_each_context;--pub fn type_short_name<T>() -> &'static str {- std::any::type_name::<T>().rsplit("::").next().unwrap()-}--#[cfg(metal_backend)]-pub fn shared_metal_context() -> std::rc::Rc<backend_uzu::backends::metal::MetalContext> {- use backend_uzu::backends::{common::Context, metal::MetalContext};- thread_local! {- static CTX: std::cell::OnceCell<std::rc::Rc<MetalContext>> = const { std::cell::OnceCell::new() };- }- CTX.with(|cell| cell.get_or_init(|| MetalContext::new().expect("Metal context")).clone())-}--/// Invokes `$body` once per available backend, with `$B` bound to each backend type.-macro_rules! for_each_backend {- (|$B:ident| $body:expr) => {{- {- type $B = backend_uzu::backends::cpu::Cpu;- $body- }- #[cfg(metal_backend)]- {- type $B = backend_uzu::backends::metal::Metal;- $body- }- }};-}-pub(crate) use for_each_backend;--macro_rules! for_each_non_cpu_backend {- (|$B:ident| $body:expr) => {{- #[cfg(metal_backend)]- {- type $B = backend_uzu::backends::metal::Metal;- $body- }- {- if false {- type $B = backend_uzu::backends::cpu::Cpu;- $body- }- }- }};-}-pub(crate) use for_each_non_cpu_backend;diff --git a/crates/backend-uzu/tests/integration/mod.rs b/crates/backend-uzu/tests/integration/mod.rsdeleted file mode 100644index 7f33ec2b7..000000000--- a/crates/backend-uzu/tests/integration/mod.rs+++ /dev/null@@ -1 +0,0 @@-mod session;diff --git a/crates/backend-uzu/tests/integration_main.rs b/crates/backend-uzu/tests/integration_main.rsindex e044db389..9f8be2e4e 100644--- a/crates/backend-uzu/tests/integration_main.rs+++ b/crates/backend-uzu/tests/integration_main.rs@@ -1,7 +1,4 @@#![feature(custom_test_frameworks, test)]-#![test_runner(crate::tests::uzu_harness)]+#![test_runner(test_runner::uzu_harness)]-#[path = "../src/tests/mod.rs"]-mod tests;--mod integration;+mod session;diff --git a/crates/backend-uzu/tests/performance/mod.rs b/crates/backend-uzu/tests/performance/mod.rsdeleted file mode 100644index 52f2d4249..000000000--- a/crates/backend-uzu/tests/performance/mod.rs+++ /dev/null@@ -1,2 +0,0 @@-mod audio_kernel_perf_test;-mod model_loading_perf_test;diff --git a/crates/backend-uzu/tests/performance/model_loading_perf_test.rs b/crates/backend-uzu/tests/performance/model_loading_perf_test.rsdeleted file mode 100644index 0c01644ac..000000000--- a/crates/backend-uzu/tests/performance/model_loading_perf_test.rs+++ /dev/null@@ -1,14 +0,0 @@-use backend_uzu::session::{ChatSession, config::DecodingConfig};-use proc_macros::uzu_test;--use crate::common::{path::get_test_model_path, perf::run_perf};--#[uzu_test]-#[ignore]-fn test_perf_model_loading() {- let perf_results = run_perf("Model loading", 10, || {- let model_path = get_test_model_path();- let _ = ChatSession::new(model_path, DecodingConfig::default());- });- perf_results.print();-}diff --git a/crates/backend-uzu/tests/performance_main.rs b/crates/backend-uzu/tests/performance_main.rsdeleted file mode 100644index a460a0016..000000000--- a/crates/backend-uzu/tests/performance_main.rs+++ /dev/null@@ -1,8 +0,0 @@-#![feature(custom_test_frameworks, test)]-#![test_runner(crate::tests::uzu_harness)]--#[path = "../src/tests/mod.rs"]-mod tests;--mod common;-mod performance;diff --git a/crates/backend-uzu/tests/integration/session/chat_session/load_perf_test.rs b/crates/backend-uzu/tests/session/chat_session/load_perf_test.rssimilarity index 100%rename from crates/backend-uzu/tests/integration/session/chat_session/load_perf_test.rsrename to crates/backend-uzu/tests/session/chat_session/load_perf_test.rsdiff --git a/crates/backend-uzu/tests/integration/session/chat_session/mod.rs b/crates/backend-uzu/tests/session/chat_session/mod.rssimilarity index 100%rename from crates/backend-uzu/tests/integration/session/chat_session/mod.rsrename to crates/backend-uzu/tests/session/chat_session/mod.rsdiff --git a/crates/backend-uzu/tests/integration/session/chat_session/sampling_test.rs b/crates/backend-uzu/tests/session/chat_session/sampling_test.rssimilarity index 100%rename from crates/backend-uzu/tests/integration/session/chat_session/sampling_test.rsrename to crates/backend-uzu/tests/session/chat_session/sampling_test.rsdiff --git a/crates/backend-uzu/tests/integration/session/chat_session/thinking_toggle_test.rs b/crates/backend-uzu/tests/session/chat_session/thinking_toggle_test.rssimilarity index 100%rename from crates/backend-uzu/tests/integration/session/chat_session/thinking_toggle_test.rsrename to crates/backend-uzu/tests/session/chat_session/thinking_toggle_test.rsdiff --git a/crates/backend-uzu/tests/integration/session/mod.rs b/crates/backend-uzu/tests/session/mod.rssimilarity index 100%rename from crates/backend-uzu/tests/integration/session/mod.rsrename to crates/backend-uzu/tests/session/mod.rsdiff --git a/crates/backend-uzu/unit/audio/nanocodec/runtime.rs b/crates/backend-uzu/unit/audio/nanocodec/runtime.rsindex 41dcdbf51..a388d1f2c 100644--- a/crates/backend-uzu/unit/audio/nanocodec/runtime.rs+++ b/crates/backend-uzu/unit/audio/nanocodec/runtime.rs@@ -7,7 +7,7 @@ use crate::{AudioCodecRuntime, AudioError, AudioPcmBatch, AudioTokenGrid, NanoCodecFsqRuntime, NanoCodecFsqRuntimeConfig,},backends::metal::Metal,- common::audio::fsq_reference::{fsq_decode_reference, fsq_encode_reference},+ tests::audio::fsq_reference::{fsq_decode_reference, fsq_encode_reference},};fn create_runtime() -> NanoCodecFsqRuntime<Metal> {diff --git a/crates/backend-uzu/unit/backends/common/kernel/activation_test.rs b/crates/backend-uzu/unit/backends/common/kernel/activation_test.rsindex d0061c69e..af709dd60 100644--- a/crates/backend-uzu/unit/backends/common/kernel/activation_test.rs+++ b/crates/backend-uzu/unit/backends/common/kernel/activation_test.rs@@ -3,18 +3,19 @@ use std::fmt::{Debug, Display};use half::{bf16, f16};use num_traits::Float;use proc_macros::uzu_test;+use test_runner::for_each_non_cpu_backend;use crate::{array::ArrayElement,backends::{- common::{Backend, Context, Encoder, Kernels, gpu_types::ActivationType, kernel::ActivationKernel},+ common::{Allocation, Backend, Context, Encoder, Kernels, gpu_types::ActivationType, kernel::ActivationKernel},cpu::Cpu,},- common::{+ data_type::DataType,+ tests::{assert::assert_eq_float,helpers::{alloc_allocation, alloc_allocation_with_data, allocation_to_vec},},- data_type::DataType,};struct Input<T: ArrayElement + Float> {@@ -42,13 +43,7 @@ fn get_output<T: ArrayElement + Float, B: Backend>(input: &Input<T>) -> Vec<T> {if input.in_place {let mut output_allocation = alloc_allocation_with_data::<B, T>(&context, &input.data);let mut encoder = Encoder::new(context.as_ref()).expect("Failed to get encoder");- kernel.encode(- None::<&backend_uzu::backends::common::Allocation<B>>,- &mut output_allocation,- n as u32,- input.act_type,- &mut encoder,- );+ kernel.encode(None::<&Allocation<B>>, &mut output_allocation, n as u32, input.act_type, &mut encoder);encoder.end_encoding().submit().wait_until_completed().unwrap();allocation_to_vec::<B, T>(&output_allocation)} else {diff --git a/crates/backend-uzu/unit/backends/common/kernel/attention/attention_fallback_test.rs b/crates/backend-uzu/unit/backends/common/kernel/attention/attention_fallback_test.rsindex 7a1f60e14..459e2f306 100644--- a/crates/backend-uzu/unit/backends/common/kernel/attention/attention_fallback_test.rs+++ b/crates/backend-uzu/unit/backends/common/kernel/attention/attention_fallback_test.rs@@ -1,5 +1,6 @@use half::bf16;use proc_macros::uzu_test;+use test_runner::for_each_non_cpu_backend;use crate::{backends::{@@ -13,11 +14,11 @@ use crate::{},cpu::Cpu,},- common::{+ data_type::DataType,+ tests::{assert::assert_eq_float,helpers::{alloc_allocation, alloc_allocation_with_data, allocation_to_vec},},- data_type::DataType,};const NUM_HEADS: u32 = 4;diff --git a/crates/backend-uzu/unit/backends/common/kernel/attention/attention_single_pass_test.rs b/crates/backend-uzu/unit/backends/common/kernel/attention/attention_single_pass_test.rsindex 0e2493db6..dc56dc2df 100644--- a/crates/backend-uzu/unit/backends/common/kernel/attention/attention_single_pass_test.rs+++ b/crates/backend-uzu/unit/backends/common/kernel/attention/attention_single_pass_test.rs@@ -3,6 +3,7 @@ use std::fmt::{Debug, Display};use half::{bf16, f16};use num_traits::Float;use proc_macros::uzu_test;+use test_runner::for_each_non_cpu_backend;use crate::{array::ArrayElement,@@ -10,11 +11,11 @@ use crate::{common::{Allocation, Backend, Context, Encoder, Kernels, kernel::AttentionSinglePassKernel},cpu::Cpu,},- common::{+ data_type::DataType,+ tests::{assert::assert_eq_float,helpers::{alloc_allocation, alloc_allocation_with_data, allocation_to_vec},},- data_type::DataType,};struct Input<T: ArrayElement + Float> {diff --git a/crates/backend-uzu/unit/backends/common/kernel/attention/attention_two_pass_test.rs b/crates/backend-uzu/unit/backends/common/kernel/attention/attention_two_pass_test.rsindex 6e835472f..edc9bac0f 100644--- a/crates/backend-uzu/unit/backends/common/kernel/attention/attention_two_pass_test.rs+++ b/crates/backend-uzu/unit/backends/common/kernel/attention/attention_two_pass_test.rs@@ -3,18 +3,19 @@ use std::fmt::{Debug, Display};use half::{bf16, f16};use num_traits::Float;use proc_macros::uzu_test;+use test_runner::for_each_non_cpu_backend;use crate::{array::{ArrayContextExt, ArrayElement},backends::{common::{- Backend, Context, Encoder, Kernels,+ Allocation, Backend, Context, Encoder, Kernels,kernel::{AttentionTwoPass1Kernel, AttentionTwoPass2Kernel},},cpu::Cpu,},- common::assert::assert_eq_float,data_type::DataType,+ tests::assert::assert_eq_float,};const TOTAL_BLOCKS_COUNT: u32 = 32;@@ -130,17 +131,17 @@ fn get_first_pass_output<T: ArrayElement + Float, B: Backend>(input: &FirstPassIinput.scale,input.num_heads,input.suffix_length,- None::<&backend_uzu::backends::common::Allocation<B>>,+ None::<&Allocation<B>>,None,- None::<&backend_uzu::backends::common::Allocation<B>>,+ None::<&Allocation<B>>,&mut encoder,);encoder.end_encoding().submit().wait_until_completed().unwrap();FirstPassOutput {- partials: crate::common::helpers::allocation_to_vec(&partials),- sums: crate::common::helpers::allocation_to_vec(&sums),- maxs: crate::common::helpers::allocation_to_vec(&maxs),+ partials: crate::tests::helpers::allocation_to_vec(&partials),+ sums: crate::tests::helpers::allocation_to_vec(&sums),+ maxs: crate::tests::helpers::allocation_to_vec(&maxs),}}@@ -217,7 +218,7 @@ fn get_second_pass_output<T: ArrayElement + Float, B: Backend>(input: &SecondPas);encoder.end_encoding().submit().wait_until_completed().unwrap();- crate::common::helpers::allocation_to_vec(&output)+ crate::tests::helpers::allocation_to_vec(&output)}// --- First pass tests ---diff --git a/crates/backend-uzu/unit/backends/common/kernel/attention/attention_update_kv_cache_test.rs b/crates/backend-uzu/unit/backends/common/kernel/attention/attention_update_kv_cache_test.rsindex b124a663e..40b9d42d1 100644--- a/crates/backend-uzu/unit/backends/common/kernel/attention/attention_update_kv_cache_test.rs+++ b/crates/backend-uzu/unit/backends/common/kernel/attention/attention_update_kv_cache_test.rs@@ -3,6 +3,7 @@ use std::fmt::{Debug, Display};use half::{bf16, f16};use num_traits::Float;use proc_macros::uzu_test;+use test_runner::for_each_non_cpu_backend;use crate::{array::{ArrayContextExt, ArrayElement},@@ -10,8 +11,8 @@ use crate::{common::{Backend, Context, Encoder, Kernels, kernel::AttentionUpdateKVCacheKernel},cpu::Cpu,},- common::assert::assert_eq_float,data_type::DataType,+ tests::assert::assert_eq_float,};struct Input<T: ArrayElement + Float> {@@ -63,7 +64,7 @@ fn get_output<T: ArrayElement + Float, B: Backend>(input: &Input<T>) -> (Vec<T>,);encoder.end_encoding().submit().wait_until_completed().unwrap();- (crate::common::helpers::allocation_to_vec(&key_cache), crate::common::helpers::allocation_to_vec(&value_cache))+ (crate::tests::helpers::allocation_to_vec(&key_cache), crate::tests::helpers::allocation_to_vec(&value_cache))}fn get_test_data_basic<T: ArrayElement + Float>(keys_in_place: bool) -> Input<T> {diff --git a/crates/backend-uzu/unit/backends/common/kernel/attention/sigmoid_gate_test.rs b/crates/backend-uzu/unit/backends/common/kernel/attention/sigmoid_gate_test.rsindex 43c7864c2..c5d98fbed 100644--- a/crates/backend-uzu/unit/backends/common/kernel/attention/sigmoid_gate_test.rs+++ b/crates/backend-uzu/unit/backends/common/kernel/attention/sigmoid_gate_test.rs@@ -3,6 +3,7 @@ use std::fmt::Debug;use half::{bf16, f16};use num_traits::Float;use proc_macros::uzu_test;+use test_runner::for_each_non_cpu_backend;use crate::{array::{ArrayContextExt, ArrayElement},@@ -36,7 +37,7 @@ fn get_output<T: ArrayElement + Float, B: Backend>(kernel.encode(gate_array.allocation(), &mut output, total_elements, &mut encoder);encoder.end_encoding().submit().wait_until_completed().unwrap();- crate::common::helpers::allocation_to_vec(&output)+ crate::tests::helpers::allocation_to_vec(&output)}fn run_test<T: ArrayElement + Float + Debug>(config: &Config) {diff --git a/crates/backend-uzu/tests/performance/audio_kernel_perf_test.rs b/crates/backend-uzu/unit/backends/common/kernel/audio/audio_kernel_perf.rssimilarity index 99%rename from crates/backend-uzu/tests/performance/audio_kernel_perf_test.rsrename to crates/backend-uzu/unit/backends/common/kernel/audio/audio_kernel_perf.rsindex 80d73a184..c0379ea49 100644--- a/crates/backend-uzu/tests/performance/audio_kernel_perf_test.rs+++ b/crates/backend-uzu/unit/backends/common/kernel/audio/audio_kernel_perf.rs@@ -2,7 +2,9 @@use std::time::Instant;-use backend_uzu::{+use proc_macros::uzu_test;++use crate::{array::{Array, ArrayContextExt},backends::{common::{@@ -19,7 +21,6 @@ use backend_uzu::{},data_type::DataType,};-use proc_macros::uzu_test;type Ctx = <Metal as Backend>::Context;diff --git a/crates/backend-uzu/unit/backends/common/kernel/audio/audio_test.rs b/crates/backend-uzu/unit/backends/common/kernel/audio/audio_test.rsindex c23a48cb7..23bc5dd06 100644--- a/crates/backend-uzu/unit/backends/common/kernel/audio/audio_test.rs+++ b/crates/backend-uzu/unit/backends/common/kernel/audio/audio_test.rs@@ -16,7 +16,8 @@ use crate::{},metal::Metal,},- common::{+ data_type::DataType,+ tests::{audio::{fsq_reference::{fsq_decode_reference, fsq_encode_reference},ops_reference::{@@ -27,7 +28,6 @@ use crate::{},helpers::allocation_to_vec,},- data_type::DataType,};macro_rules! borrow_array_buffer {diff --git a/crates/backend-uzu/unit/backends/common/kernel/audio/mod.rs b/crates/backend-uzu/unit/backends/common/kernel/audio/mod.rsindex 0ba6abbfd..3c08930b3 100644--- a/crates/backend-uzu/unit/backends/common/kernel/audio/mod.rs+++ b/crates/backend-uzu/unit/backends/common/kernel/audio/mod.rs@@ -1 +1,2 @@+mod audio_kernel_perf;mod audio_test;diff --git a/crates/backend-uzu/unit/backends/common/kernel/delta_net_test.rs b/crates/backend-uzu/unit/backends/common/kernel/delta_net_test.rsindex da0bf5193..b6d69e05d 100644--- a/crates/backend-uzu/unit/backends/common/kernel/delta_net_test.rs+++ b/crates/backend-uzu/unit/backends/common/kernel/delta_net_test.rs@@ -51,8 +51,8 @@ fn run_conv_update<B: Backend>();encoder.end_encoding().submit().wait_until_completed().unwrap();- let out = crate::common::helpers::allocation_prefix_to_vec::<B, f32>(&in_out, conv_dim as usize);- let new_state = crate::common::helpers::allocation_to_vec::<B, f32>(&state_allocation);+ let out = crate::tests::helpers::allocation_prefix_to_vec::<B, f32>(&in_out, conv_dim as usize);+ let new_state = crate::tests::helpers::allocation_to_vec::<B, f32>(&state_allocation);(out, new_state)}@@ -99,8 +99,8 @@ fn run_delta_net_update<B: Backend>();encoder.end_encoding().submit().wait_until_completed().unwrap();- let out = crate::common::helpers::allocation_to_vec::<B, f32>(&out);- let new_state = crate::common::helpers::allocation_to_vec::<B, f32>(&state_allocation);+ let out = crate::tests::helpers::allocation_to_vec::<B, f32>(&out);+ let new_state = crate::tests::helpers::allocation_to_vec::<B, f32>(&state_allocation);(out, new_state)}@@ -222,14 +222,14 @@ fn test_delta_net_conv_scan() {);encoder.end_encoding().submit().wait_until_completed().unwrap();- let in_proj_result: Vec<bf16> = crate::common::helpers::allocation_to_vec(&in_proj_array);+ let in_proj_result: Vec<bf16> = crate::tests::helpers::allocation_to_vec(&in_proj_array);let in_proj_result: Vec<f32> = in_proj_result.into_iter().map(f32::from).collect();let mut scan_outputs = vec![0.0f32; suffix_len * conv_dim];for t in 0..suffix_len {scan_outputs[t * conv_dim..(t + 1) * conv_dim].copy_from_slice(&in_proj_result[t * total_proj_dim..t * total_proj_dim + conv_dim]);}- let scan_state: Vec<f32> = crate::common::helpers::allocation_to_vec(&state_out_array);+ let scan_state: Vec<f32> = crate::tests::helpers::allocation_to_vec(&state_out_array);assert_close(&ref_outputs, &scan_outputs, 1e-4, 1e-3, "ConvScan output");assert_close(&ref_state, &scan_state, 1e-5, 1e-4, "ConvScan state");@@ -388,9 +388,9 @@ fn run_prefill_with_norm_gate_typed<T: ArrayElement>();encoder.end_encoding().submit().wait_until_completed().unwrap();- let out: Vec<T> = crate::common::helpers::allocation_to_vec(&out_array);+ let out: Vec<T> = crate::tests::helpers::allocation_to_vec(&out_array);let out = out.into_iter().map(|value| value.to_f32().expect("output to f32")).collect();- let state = crate::common::helpers::allocation_to_vec(&state_array);+ let state = crate::tests::helpers::allocation_to_vec(&state_array);(out, state)}@@ -527,10 +527,10 @@ fn test_delta_net_prefill_prep() {);cpu_enc.end_encoding().submit().wait_until_completed().unwrap();- let ref_q: Vec<f32> = crate::common::helpers::allocation_to_vec(&cpu_q);- let ref_k: Vec<f32> = crate::common::helpers::allocation_to_vec(&cpu_k);- let ref_beta: Vec<f32> = crate::common::helpers::allocation_to_vec(&cpu_beta);- let ref_decay: Vec<f32> = crate::common::helpers::allocation_to_vec(&cpu_decay);+ let ref_q: Vec<f32> = crate::tests::helpers::allocation_to_vec(&cpu_q);+ let ref_k: Vec<f32> = crate::tests::helpers::allocation_to_vec(&cpu_k);+ let ref_beta: Vec<f32> = crate::tests::helpers::allocation_to_vec(&cpu_beta);+ let ref_decay: Vec<f32> = crate::tests::helpers::allocation_to_vec(&cpu_decay);// Metallet context = <Metal as Backend>::Context::new().expect("context");@@ -568,10 +568,10 @@ fn test_delta_net_prefill_prep() {);encoder.end_encoding().submit().wait_until_completed().unwrap();- let gpu_q: Vec<f32> = crate::common::helpers::allocation_to_vec(&q_norm_array);- let gpu_k: Vec<f32> = crate::common::helpers::allocation_to_vec(&k_norm_array);- let gpu_beta: Vec<f32> = crate::common::helpers::allocation_to_vec(&beta_array);- let gpu_decay: Vec<f32> = crate::common::helpers::allocation_to_vec(&decay_array);+ let gpu_q: Vec<f32> = crate::tests::helpers::allocation_to_vec(&q_norm_array);+ let gpu_k: Vec<f32> = crate::tests::helpers::allocation_to_vec(&k_norm_array);+ let gpu_beta: Vec<f32> = crate::tests::helpers::allocation_to_vec(&beta_array);+ let gpu_decay: Vec<f32> = crate::tests::helpers::allocation_to_vec(&decay_array);assert_close(&gpu_q, &ref_q, 1e-4, 1e-3, "prep q_norm");assert_close(&gpu_k, &ref_k, 1e-4, 1e-3, "prep k_norm");@@ -582,7 +582,7 @@ fn test_delta_net_prefill_prep() {#[uzu_test]#[ignore]fn bench_delta_net_prefill() {- use crate::common::perf::run_perf_with_warmup;+ use test_runner::perf::run_perf_with_warmup;let num_v_heads = 48usize;let num_k_heads = 16usize;diff --git a/crates/backend-uzu/unit/backends/common/kernel/embedding/embedding_rows_sum_test.rs b/crates/backend-uzu/unit/backends/common/kernel/embedding/embedding_rows_sum_test.rsindex a47ba4b08..b02cf3d23 100644--- a/crates/backend-uzu/unit/backends/common/kernel/embedding/embedding_rows_sum_test.rs+++ b/crates/backend-uzu/unit/backends/common/kernel/embedding/embedding_rows_sum_test.rs@@ -3,6 +3,7 @@ use std::fmt::{Debug, Display};use half::{bf16, f16};use num_traits::Float;use proc_macros::uzu_test;+use test_runner::for_each_non_cpu_backend;use crate::{array::{ArrayContextExt, ArrayElement},@@ -10,8 +11,8 @@ use crate::{common::{Backend, Context, Encoder, Kernels, kernel::EmbeddingRowsSumKernel},cpu::Cpu,},- common::assert::assert_eq_float,data_type::DataType,+ tests::assert::assert_eq_float,};struct Input<T: ArrayElement + Float> {@@ -122,7 +123,7 @@ fn get_output<T: ArrayElement + Float, B: Backend>(input: &Input<T>) -> Vec<T> {);encoder.end_encoding().submit().wait_until_completed().unwrap();- crate::common::helpers::allocation_to_vec(&output)+ crate::tests::helpers::allocation_to_vec(&output)}fn test_basic<T: ArrayElement + Float + Debug + Display>() {diff --git a/crates/backend-uzu/unit/backends/common/kernel/embedding/full_precision_embedding_test.rs b/crates/backend-uzu/unit/backends/common/kernel/embedding/full_precision_embedding_test.rsindex 2c39e10e5..a1ab98fd7 100644--- a/crates/backend-uzu/unit/backends/common/kernel/embedding/full_precision_embedding_test.rs+++ b/crates/backend-uzu/unit/backends/common/kernel/embedding/full_precision_embedding_test.rs@@ -3,6 +3,7 @@ use std::fmt::Debug;use half::{bf16, f16};use num_traits::Float;use proc_macros::uzu_test;+use test_runner::for_each_backend;use crate::{array::{ArrayContextExt, ArrayElement},@@ -72,7 +73,7 @@ fn get_output<T: ArrayElement + Float, B: Backend>(input: &Input<T>) -> Vec<T> {);encoder.end_encoding().submit().wait_until_completed().unwrap();- crate::common::helpers::allocation_to_vec(&output)+ crate::tests::helpers::allocation_to_vec(&output)}fn test<T: ArrayElement + Float + Debug>() {diff --git a/crates/backend-uzu/unit/backends/common/kernel/embedding/quant_embedding_test.rs b/crates/backend-uzu/unit/backends/common/kernel/embedding/quant_embedding_test.rsindex 192914d55..6d095b019 100644--- a/crates/backend-uzu/unit/backends/common/kernel/embedding/quant_embedding_test.rs+++ b/crates/backend-uzu/unit/backends/common/kernel/embedding/quant_embedding_test.rs@@ -3,19 +3,20 @@ use std::fmt::{Debug, Display};use half::{bf16, f16};use num_traits::Float;use proc_macros::uzu_test;+use test_runner::for_each_non_cpu_backend;use crate::{array::{ArrayContextExt, ArrayElement},backends::{common::{- Backend, Context, Encoder, Kernels,+ Allocation, Backend, Context, Encoder, Kernels,gpu_types::{QuantizationMethod, QuantizationMode},kernel::QuantizedEmbeddingLookupKernel,},cpu::Cpu,},- common::assert::assert_eq_float,data_type::DataType,+ tests::assert::assert_eq_float,};struct Input<T: ArrayElement + Float> {@@ -235,7 +236,7 @@ fn get_output<T: ArrayElement + Float, B: Backend>(input: &Input<T>) -> Vec<T> {zero_points_array.as_ref().map(|array| array.allocation()),biases_array.as_ref().map(|array| array.allocation()),&mut output,- None::<&backend_uzu::backends::common::Allocation<B>>,+ None::<&Allocation<B>>,input.batch_size,input.vocab_size,input.model_dim,@@ -244,7 +245,7 @@ fn get_output<T: ArrayElement + Float, B: Backend>(input: &Input<T>) -> Vec<T> {);encoder.end_encoding().submit().wait_until_completed().unwrap();- crate::common::helpers::allocation_to_vec(&output)+ crate::tests::helpers::allocation_to_vec(&output)}fn test_zero_point_group16<T: ArrayElement + Float + Debug + Display>() {diff --git a/crates/backend-uzu/unit/backends/common/kernel/gated_act_mul_test.rs b/crates/backend-uzu/unit/backends/common/kernel/gated_act_mul_test.rsindex a398de84e..8bf84d27b 100644--- a/crates/backend-uzu/unit/backends/common/kernel/gated_act_mul_test.rs+++ b/crates/backend-uzu/unit/backends/common/kernel/gated_act_mul_test.rs@@ -3,6 +3,7 @@ use std::fmt::{Debug, Display};use half::bf16;use num_traits::Float;use proc_macros::uzu_test;+use test_runner::{for_each_backend, for_each_non_cpu_backend};use crate::{array::ArrayElement,@@ -12,11 +13,11 @@ use crate::{},cpu::Cpu,},- common::{+ data_type::DataType,+ tests::{assert::assert_eq_float,helpers::{alloc_allocation, alloc_allocation_with_data, allocation_to_vec},},- data_type::DataType,};struct InterleavedInput<T: ArrayElement + Float> {diff --git a/crates/backend-uzu/unit/backends/common/kernel/hadamard_transform_test.rs b/crates/backend-uzu/unit/backends/common/kernel/hadamard_transform_test.rsindex 65a2be7e2..844ac926d 100644--- a/crates/backend-uzu/unit/backends/common/kernel/hadamard_transform_test.rs+++ b/crates/backend-uzu/unit/backends/common/kernel/hadamard_transform_test.rs@@ -3,6 +3,7 @@ use std::fmt::Debug;use half::bf16;use num_traits::Float;use proc_macros::uzu_test;+use test_runner::for_each_non_cpu_backend;use crate::{array::{ArrayContextExt, ArrayElement},@@ -121,7 +122,7 @@ fn run_kernel<T: ArrayElement + Float, B: Backend>(input: &TestInput<T>) -> Vec<);encoder.end_encoding().submit().wait_until_completed().unwrap();- crate::common::helpers::allocation_to_vec(&data)+ crate::tests::helpers::allocation_to_vec(&data)}fn test_hadamard_transform<T: ArrayElement + Float + Debug>(tolerance: f64) {diff --git a/crates/backend-uzu/unit/backends/common/kernel/kv_cache_update_test.rs b/crates/backend-uzu/unit/backends/common/kernel/kv_cache_update_test.rsindex 53b691a24..595074ba3 100644--- a/crates/backend-uzu/unit/backends/common/kernel/kv_cache_update_test.rs+++ b/crates/backend-uzu/unit/backends/common/kernel/kv_cache_update_test.rs@@ -3,6 +3,7 @@ use std::fmt::{Debug, Display};use half::{bf16, f16};use num_traits::Float;use proc_macros::uzu_test;+use test_runner::for_each_non_cpu_backend;use crate::{array::{ArrayContextExt, ArrayElement},@@ -10,7 +11,7 @@ use crate::{common::{Backend, Context, Encoder, Kernels, gpu_types::Swap, kernel::KVCacheUpdateKernel},cpu::Cpu,},- common::assert::assert_eq_float,+ tests::assert::assert_eq_float,};struct Input<T: ArrayElement + Float> {@@ -58,7 +59,7 @@ fn get_output<T: ArrayElement + Float, B: Backend>(input: &Input<T>) -> (Vec<T>,);encoder.end_encoding().submit().wait_until_completed().unwrap();- (crate::common::helpers::allocation_to_vec(&keys), crate::common::helpers::allocation_to_vec(&values))+ (crate::tests::helpers::allocation_to_vec(&keys), crate::tests::helpers::allocation_to_vec(&values))}/// Single swap between two different positions.diff --git a/crates/backend-uzu/unit/backends/common/kernel/layer_norm_test.rs b/crates/backend-uzu/unit/backends/common/kernel/layer_norm_test.rsindex 3172d9121..cbbe58505 100644--- a/crates/backend-uzu/unit/backends/common/kernel/layer_norm_test.rs+++ b/crates/backend-uzu/unit/backends/common/kernel/layer_norm_test.rs@@ -3,6 +3,7 @@ use std::fmt::{Debug, Display};use half::{bf16, f16};use num_traits::Float;use proc_macros::uzu_test;+use test_runner::for_each_non_cpu_backend;use crate::{array::{ArrayContextExt, ArrayElement},@@ -10,8 +11,8 @@ use crate::{common::{Backend, Context, Encoder, Kernels, kernel::LayerNormKernel},cpu::Cpu,},- common::assert::assert_eq_float,data_type::DataType,+ tests::assert::assert_eq_float,};static BOOL_ALL: &[bool] = &[true, false];@@ -150,7 +151,7 @@ fn get_output<);encoder.end_encoding().submit().wait_until_completed().unwrap();- crate::common::helpers::allocation_to_vec(&output)+ crate::tests::helpers::allocation_to_vec(&output)}fn test_internal<diff --git a/crates/backend-uzu/unit/backends/common/kernel/logit_soft_cap_test.rs b/crates/backend-uzu/unit/backends/common/kernel/logit_soft_cap_test.rsindex 9edbb5422..66cf4d3b4 100644--- a/crates/backend-uzu/unit/backends/common/kernel/logit_soft_cap_test.rs+++ b/crates/backend-uzu/unit/backends/common/kernel/logit_soft_cap_test.rs@@ -3,6 +3,7 @@ use std::fmt::Display;use half::bf16;use num_traits::Float;use proc_macros::uzu_test;+use test_runner::for_each_non_cpu_backend;use crate::{array::ArrayElement,@@ -10,11 +11,11 @@ use crate::{common::{Backend, Context, Encoder, Kernels, kernel::LogitSoftCapKernel},cpu::Cpu,},- common::{+ data_type::DataType,+ tests::{assert::assert_eq_float,helpers::{alloc_allocation_with_data, allocation_to_vec},},- data_type::DataType,};fn get_output<T: ArrayElement + Float, B: Backend>(diff --git a/crates/backend-uzu/unit/backends/common/kernel/matmul/dispatch_paths_test.rs b/crates/backend-uzu/unit/backends/common/kernel/matmul/dispatch_paths_test.rsindex daffa67c5..72810fe69 100644--- a/crates/backend-uzu/unit/backends/common/kernel/matmul/dispatch_paths_test.rs+++ b/crates/backend-uzu/unit/backends/common/kernel/matmul/dispatch_paths_test.rs@@ -16,7 +16,7 @@ use crate::{},metal::{GemmDispatchPath, Metal, MetalContext},},- common::{+ tests::{assert::assert_eq_float,matmul::{Case, all_correctness_shapes, cpu_reference, deterministic_input, run_metal},},@@ -44,7 +44,7 @@ fn check_case<T: ArrayElement + Float + Debug + Display>(}fn run_matrix<T: ArrayElement + Float + Debug + Display>(- case_for_shape: impl Fn(crate::common::matmul::Shape) -> Case,+ case_for_shape: impl Fn(crate::tests::matmul::Shape) -> Case,tolerance: f32,) {let context = MetalContext::new().expect("Metal context");@@ -92,8 +92,8 @@ fn b_transpose_false_bf16() {);}-fn rht_shapes() -> impl Iterator<Item = crate::common::matmul::Shape> {- use crate::common::matmul::Shape;+fn rht_shapes() -> impl Iterator<Item = crate::tests::matmul::Shape> {+ use crate::tests::matmul::Shape;[Shape::new(8, 128, 64), Shape::new(64, 128, 128), Shape::new(128, 2048, 256), Shape::new(33, 128, 64)].into_iter()}@@ -117,7 +117,7 @@ fn rht_parity_bf16() {#[uzu_test]fn bias_parity_bf16() {- use crate::common::matmul::Shape;+ use crate::tests::matmul::Shape;let context = MetalContext::new().expect("Metal context");let mut kernel = <<Metal as Backend>::Kernels as Kernels>::MatmulKernel::new(&context,@@ -137,7 +137,7 @@ fn bias_parity_bf16() {#[uzu_test]fn gemv_fp_partial_output_block_bf16() {- use crate::common::matmul::Shape;+ use crate::tests::matmul::Shape;let context = MetalContext::new().expect("Metal context");let mut kernel = <<Metal as Backend>::Kernels as Kernels>::MatmulKernel::new(&context,@@ -156,7 +156,7 @@ fn gemv_fp_partial_output_block_bf16() {#[uzu_test]fn gemv_fp_output_transforms_bf16() {- use crate::common::matmul::Shape;+ use crate::tests::matmul::Shape;let context = MetalContext::new().expect("Metal context");let mut kernel = <<Metal as Backend>::Kernels as Kernels>::MatmulKernel::new(&context,diff --git a/crates/backend-uzu/unit/backends/common/kernel/matmul/gemm_bench.rs b/crates/backend-uzu/unit/backends/common/kernel/matmul/gemm_bench.rsindex 064b669a7..1d794105f 100644--- a/crates/backend-uzu/unit/backends/common/kernel/matmul/gemm_bench.rs+++ b/crates/backend-uzu/unit/backends/common/kernel/matmul/gemm_bench.rs@@ -16,15 +16,15 @@ use crate::{},metal::{GemmDispatchPath, Metal},},- common::{+ tests::{matmul::{bench_fp_gemm_shapes, iter_encode_loop},- type_short_name,+ util::type_short_name,},};#[uzu_bench]fn bench_gemm(c: &mut Criterion) {- let context = crate::common::shared_metal_context();+ let context = crate::tests::util::shared_metal_context();let mut kernel = <<Metal as Backend>::Kernels as Kernels>::MatmulKernel::new(&context,bf16::data_type(),diff --git a/crates/backend-uzu/unit/backends/common/kernel/matmul/gemv_test.rs b/crates/backend-uzu/unit/backends/common/kernel/matmul/gemv_test.rsindex b65d1bf59..85de32dcc 100644--- a/crates/backend-uzu/unit/backends/common/kernel/matmul/gemv_test.rs+++ b/crates/backend-uzu/unit/backends/common/kernel/matmul/gemv_test.rs@@ -4,6 +4,7 @@ use half::bf16;use num_traits::Float;use proc_macros::uzu_test;use rstest::rstest;+use test_runner::for_each_non_cpu_backend;use crate::{array::{ArrayContextExt, ArrayElement},@@ -17,7 +18,7 @@ use crate::{},cpu::Cpu,},- common::{+ tests::{assert::assert_eq_float,helpers::{alloc_allocation_with_data, allocation_to_vec},},diff --git a/crates/backend-uzu/unit/backends/common/kernel/matmul/quant_dispatch_test.rs b/crates/backend-uzu/unit/backends/common/kernel/matmul/quant_dispatch_test.rsindex 2524b0a1c..31f8f58e2 100644--- a/crates/backend-uzu/unit/backends/common/kernel/matmul/quant_dispatch_test.rs+++ b/crates/backend-uzu/unit/backends/common/kernel/matmul/quant_dispatch_test.rs@@ -24,7 +24,7 @@ use crate::{cpu::Cpu,metal::{GemmDispatchPath, Metal, MetalContext},},- common::{+ tests::{helpers::allocation_to_vec,matmul::{QuantBuffers, QuantInput, quant_arguments, run_quant_cpu, run_quant_metal},},@@ -187,7 +187,7 @@ fn parity_bf16_gs32_4bit_mlx_with_bias() {let bias_t: Vec<bf16> = bias_f32.iter().map(|&v| bf16::from_f32(v)).collect();let mut buffers = QuantBuffers::<Metal, bf16>::allocate(&context, &input);- let bias_pp_buf = crate::common::helpers::alloc_allocation_with_data::<Metal, bf16>(&context, &bias_t);+ let bias_pp_buf = crate::tests::helpers::alloc_allocation_with_data::<Metal, bf16>(&context, &bias_t);let mut matmul = <<Metal as Backend>::Kernels as Kernels>::MatmulKernel::new(&context,bf16::data_type(),@@ -239,7 +239,7 @@ fn parity_bf16_gemv_qmv_fused_scale_bias() {.collect();let mut buffers = QuantBuffers::<Metal, bf16>::allocate(&context, &input);- let bias_buf = crate::common::helpers::alloc_allocation_with_data::<Metal, bf16>(&context, &bias_t);+ let bias_buf = crate::tests::helpers::alloc_allocation_with_data::<Metal, bf16>(&context, &bias_t);let mut matmul = <<Metal as Backend>::Kernels as Kernels>::MatmulKernel::new(&context,bf16::data_type(),@@ -318,8 +318,8 @@ fn parity_bf16_gemv_quant_rht_with_bias() {// Hadamard pass transforms the result) — the same order GEMV uses.let cpu_context = <Cpu as Backend>::Context::new().expect("Cpu context");let mut cpu_buffers = QuantBuffers::<Cpu, bf16>::allocate(&cpu_context, &input);- let cpu_rht = crate::common::helpers::alloc_allocation_with_data::<Cpu, i32>(&cpu_context, &rht);- let cpu_bias = crate::common::helpers::alloc_allocation_with_data::<Cpu, bf16>(&cpu_context, &bias_t);+ let cpu_rht = crate::tests::helpers::alloc_allocation_with_data::<Cpu, i32>(&cpu_context, &rht);+ let cpu_bias = crate::tests::helpers::alloc_allocation_with_data::<Cpu, bf16>(&cpu_context, &bias_t);let mut cpu_matmul = <<Cpu as Backend>::Kernels as Kernels>::MatmulKernel::new(&cpu_context,bf16::data_type(),@@ -340,8 +340,8 @@ fn parity_bf16_gemv_quant_rht_with_bias() {let reference = allocation_to_vec::<Cpu, bf16>(&cpu_buffers.y);let mut buffers = QuantBuffers::<Metal, bf16>::allocate(&context, &input);- let metal_rht = crate::common::helpers::alloc_allocation_with_data::<Metal, i32>(&context, &rht);- let metal_bias = crate::common::helpers::alloc_allocation_with_data::<Metal, bf16>(&context, &bias_t);+ let metal_rht = crate::tests::helpers::alloc_allocation_with_data::<Metal, i32>(&context, &rht);+ let metal_bias = crate::tests::helpers::alloc_allocation_with_data::<Metal, bf16>(&context, &bias_t);let mut matmul = <<Metal as Backend>::Kernels as Kernels>::MatmulKernel::new(&context,bf16::data_type(),@@ -382,7 +382,7 @@ fn parity_bf16_gemv_quant_rht() {// CPU reference applies the RHT through the CPU matmul kernel.let cpu_context = <Cpu as Backend>::Context::new().expect("Cpu context");let mut cpu_buffers = QuantBuffers::<Cpu, bf16>::allocate(&cpu_context, &input);- let cpu_rht = crate::common::helpers::alloc_allocation_with_data::<Cpu, i32>(&cpu_context, &rht);+ let cpu_rht = crate::tests::helpers::alloc_allocation_with_data::<Cpu, i32>(&cpu_context, &rht);let mut cpu_matmul = <<Cpu as Backend>::Kernels as Kernels>::MatmulKernel::new(&cpu_context,bf16::data_type(),@@ -404,7 +404,7 @@ fn parity_bf16_gemv_quant_rht() {// Metal GEMV: m = 1 quant routes to GEMV, RHT selects the 8-simdgroup (32-row) layout.let mut buffers = QuantBuffers::<Metal, bf16>::allocate(&context, &input);- let metal_rht = crate::common::helpers::alloc_allocation_with_data::<Metal, i32>(&context, &rht);+ let metal_rht = crate::tests::helpers::alloc_allocation_with_data::<Metal, i32>(&context, &rht);let mut matmul = <<Metal as Backend>::Kernels as Kernels>::MatmulKernel::new(&context,bf16::data_type(),diff --git a/crates/backend-uzu/unit/backends/common/kernel/matmul/quant_gemm_bench.rs b/crates/backend-uzu/unit/backends/common/kernel/matmul/quant_gemm_bench.rsindex 3a90461c7..9a09ebdb6 100644--- a/crates/backend-uzu/unit/backends/common/kernel/matmul/quant_gemm_bench.rs+++ b/crates/backend-uzu/unit/backends/common/kernel/matmul/quant_gemm_bench.rs@@ -15,9 +15,9 @@ use crate::{},metal::{GemmDispatchPath, Metal, MetalContext},},- common::{+ tests::{matmul::{QuantBuffers, QuantInput, bench_quant_gemm_shapes, iter_encode_loop, quant_arguments},- type_short_name,+ util::type_short_name,},};@@ -71,7 +71,7 @@ fn bench_unified_quant_typed<T: ArrayElement + Float>(#[uzu_bench]fn bench_unified_quantized_gemm(c: &mut Criterion) {- let context = crate::common::shared_metal_context();+ let context = crate::tests::util::shared_metal_context();bench_unified_quant_typed::<bf16>(c, &context, "ScaleBias_BF16_gs64", 64, 4, QuantizationMethod::ScaleBias);bench_unified_quant_typed::<bf16>(c, &context, "ZP_BF16_gs64", 64, 4, QuantizationMethod::ScaleZeroPoint);bench_unified_quant_typed::<bf16>(c, &context, "ScaleBias_BF16_gs128", 128, 4, QuantizationMethod::ScaleBias);diff --git a/crates/backend-uzu/unit/backends/common/kernel/matmul/quant_gemv_bench.rs b/crates/backend-uzu/unit/backends/common/kernel/matmul/quant_gemv_bench.rsindex 1af381ade..7afd256ad 100644--- a/crates/backend-uzu/unit/backends/common/kernel/matmul/quant_gemv_bench.rs+++ b/crates/backend-uzu/unit/backends/common/kernel/matmul/quant_gemv_bench.rs@@ -2,6 +2,7 @@ use criterion::{BenchmarkId, Criterion, Throughput};use half::bf16;use num_traits::Float;use proc_macros::uzu_bench;+use test_runner::for_each_backend;use crate::{array::ArrayElement,@@ -10,9 +11,9 @@ use crate::{gpu_types::QuantizationMethod,kernel::{Kernels, matmul::MatmulKernel},},- common::{+ tests::{matmul::{QuantBuffers, QuantInput, bench_quant_gemv_shapes, iter_encode_loop_named, quant_arguments},- type_short_name,+ util::type_short_name,},};diff --git a/crates/backend-uzu/unit/backends/common/kernel/matmul/qwen3_bench.rs b/crates/backend-uzu/unit/backends/common/kernel/matmul/qwen3_bench.rsindex e9dc1b9f2..d9d6f9b32 100644--- a/crates/backend-uzu/unit/backends/common/kernel/matmul/qwen3_bench.rs+++ b/crates/backend-uzu/unit/backends/common/kernel/matmul/qwen3_bench.rs@@ -15,9 +15,9 @@ use crate::{},metal::{Metal, MetalContext},},- common::{+ tests::{matmul::{QuantBuffers, QuantInput, iter_encode_loop, quant_arguments, qwen3_layer_shapes},- type_short_name,+ util::type_short_name,},};@@ -53,7 +53,7 @@ fn bench_qwen3_layers_typed<T: ArrayElement + Float>(#[uzu_bench]fn bench_qwen3_layers(c: &mut Criterion) {- let context = crate::common::shared_metal_context();+ let context = crate::tests::util::shared_metal_context();bench_qwen3_layers_typed::<bf16>(c, &context, "ScaleBias_BF16_gs128_4b", 128, 4, QuantizationMethod::ScaleBias);bench_qwen3_layers_typed::<bf16>(c, &context, "ZP_BF16_gs128_4b", 128, 4, QuantizationMethod::ScaleZeroPoint);}diff --git a/crates/backend-uzu/unit/backends/common/kernel/moe/moe_counts_offsets_fused_test.rs b/crates/backend-uzu/unit/backends/common/kernel/moe/moe_counts_offsets_fused_test.rsindex ae2268b1e..48441d722 100644--- a/crates/backend-uzu/unit/backends/common/kernel/moe/moe_counts_offsets_fused_test.rs+++ b/crates/backend-uzu/unit/backends/common/kernel/moe/moe_counts_offsets_fused_test.rs@@ -1,5 +1,6 @@use proc_macros::uzu_test;use rand::{RngExt, SeedableRng, rngs::StdRng};+use test_runner::{for_each_backend, for_each_non_cpu_backend};use crate::{array::{ArrayContextExt, ArrayElement},@@ -60,9 +61,9 @@ fn get_output<B: Backend>();encoder.end_encoding().submit().wait_until_completed().unwrap();- let offsets = crate::common::helpers::allocation_to_vec::<B, u32>(&offsets);- let sum_k = crate::common::helpers::allocation_to_vec::<B, u32>(&sum_k)[0];- let partials = crate::common::helpers::allocation_prefix_to_vec::<B, u32>(&partials, e);+ let offsets = crate::tests::helpers::allocation_to_vec::<B, u32>(&offsets);+ let sum_k = crate::tests::helpers::allocation_to_vec::<B, u32>(&sum_k)[0];+ let partials = crate::tests::helpers::allocation_prefix_to_vec::<B, u32>(&partials, e);(offsets, sum_k, partials)}diff --git a/crates/backend-uzu/unit/backends/common/kernel/moe/moe_finalize_test.rs b/crates/backend-uzu/unit/backends/common/kernel/moe/moe_finalize_test.rsindex 6ec7d2073..4bf2ff740 100644--- a/crates/backend-uzu/unit/backends/common/kernel/moe/moe_finalize_test.rs+++ b/crates/backend-uzu/unit/backends/common/kernel/moe/moe_finalize_test.rs@@ -2,6 +2,7 @@ use half::bf16;use num_traits::Float;use proc_macros::uzu_test;use rand::{RngExt, SeedableRng, rngs::StdRng};+use test_runner::for_each_non_cpu_backend;use crate::{array::{ArrayContextExt, ArrayElement},@@ -9,8 +10,8 @@ use crate::{common::{Backend, Encoder, Kernels, kernel::MoeFinalizeKernel},cpu::Cpu,},- common::{assert::assert_eq_float, helpers::create_context},data_type::DataType,+ tests::{assert::assert_eq_float, helpers::create_context},};struct Input<T: ArrayElement + Float> {@@ -43,7 +44,7 @@ fn get_output<B: Backend, T: ArrayElement + Float>(input: &Input<T>) -> Vec<T> {);encoder.end_encoding().submit().wait_until_completed().unwrap();- crate::common::helpers::allocation_to_vec(&y_out)+ crate::tests::helpers::allocation_to_vec(&y_out)}fn test_finalize_internal(diff --git a/crates/backend-uzu/unit/backends/common/kernel/moe/moe_router_topk_test.rs b/crates/backend-uzu/unit/backends/common/kernel/moe/moe_router_topk_test.rsindex 033f8aa6a..4ccc4f653 100644--- a/crates/backend-uzu/unit/backends/common/kernel/moe/moe_router_topk_test.rs+++ b/crates/backend-uzu/unit/backends/common/kernel/moe/moe_router_topk_test.rs@@ -4,6 +4,7 @@ use half::bf16;use num_traits::Float;use proc_macros::uzu_test;use rand::{RngExt, SeedableRng, rngs::StdRng};+use test_runner::for_each_non_cpu_backend;use crate::{array::{ArrayContextExt, ArrayElement},@@ -11,8 +12,8 @@ use crate::{common::{Backend, Encoder, Kernels, kernel::MoeRouterTopKKernel},cpu::Cpu,},- common::helpers::create_context,data_type::DataType,+ tests::helpers::create_context,};fn get_output<B: Backend, T: ArrayElement + Float>(@@ -50,7 +51,7 @@ fn get_output<B: Backend, T: ArrayElement + Float>();encoder.end_encoding().submit().wait_until_completed().unwrap();- (crate::common::helpers::allocation_to_vec(&ids), crate::common::helpers::allocation_to_vec(&probs))+ (crate::tests::helpers::allocation_to_vec(&ids), crate::tests::helpers::allocation_to_vec(&probs))}fn run_router_topk_once<B: Backend, T: ArrayElement + Debug + Float>(diff --git a/crates/backend-uzu/unit/backends/common/kernel/moe/moe_scatter_test.rs b/crates/backend-uzu/unit/backends/common/kernel/moe/moe_scatter_test.rsindex e504f4871..43fb848c8 100644--- a/crates/backend-uzu/unit/backends/common/kernel/moe/moe_scatter_test.rs+++ b/crates/backend-uzu/unit/backends/common/kernel/moe/moe_scatter_test.rs@@ -2,6 +2,7 @@ use half::bf16;use num_traits::Float;use proc_macros::uzu_test;use rand::{RngExt, SeedableRng, rngs::StdRng};+use test_runner::for_each_non_cpu_backend;use crate::{array::{ArrayContextExt, ArrayElement},@@ -15,8 +16,8 @@ use crate::{},cpu::Cpu,},- common::helpers::create_context,data_type::DataType,+ tests::helpers::create_context,};fn cpu_expert_buckets<T: ArrayElement + Float>(@@ -140,7 +141,7 @@ fn get_output<B: Backend, T: ArrayElement + Float>(&mut encoder,);encoder.end_encoding().submit().wait_until_completed().unwrap();- let sumk = crate::common::helpers::allocation_to_vec::<B, u32>(&sumk)[0] as usize;+ let sumk = crate::tests::helpers::allocation_to_vec::<B, u32>(&sumk)[0] as usize;// scatterlet scatter_kernel = <<B as Backend>::Kernels as Kernels>::MoeScatterBucketsKernel::new(&ctx, T::data_type())@@ -166,9 +167,9 @@ fn get_output<B: Backend, T: ArrayElement + Float>(encoder.end_encoding().submit().wait_until_completed().unwrap();(- crate::common::helpers::allocation_to_vec(&out_ids),- crate::common::helpers::allocation_to_vec(&out_probs),- crate::common::helpers::allocation_to_vec(&offsets),+ crate::tests::helpers::allocation_to_vec(&out_ids),+ crate::tests::helpers::allocation_to_vec(&out_probs),+ crate::tests::helpers::allocation_to_vec(&offsets),)}@@ -201,8 +202,8 @@ fn test_scatter_internal<B: Backend, T: ArrayElement + Float>(e,k,);- let cpu_topk_ids: Vec<i32> = crate::common::helpers::allocation_to_vec(&topk_ids_cpu);- let cpu_topk_probs: Vec<T> = crate::common::helpers::allocation_to_vec(&topk_probs_cpu);+ let cpu_topk_ids: Vec<i32> = crate::tests::helpers::allocation_to_vec(&topk_ids_cpu);+ let cpu_topk_probs: Vec<T> = crate::tests::helpers::allocation_to_vec(&topk_probs_cpu);let (cpu_ids, _cpu_probs, offsets_cpu) = cpu_expert_buckets(&cpu_topk_ids, &cpu_topk_probs, t, e, k);assert_eq!(out_offsets_array, offsets_cpu);diff --git a/crates/backend-uzu/unit/backends/common/kernel/pooling/pooling_cls_test.rs b/crates/backend-uzu/unit/backends/common/kernel/pooling/pooling_cls_test.rsindex 94efe494e..f74c36698 100644--- a/crates/backend-uzu/unit/backends/common/kernel/pooling/pooling_cls_test.rs+++ b/crates/backend-uzu/unit/backends/common/kernel/pooling/pooling_cls_test.rs@@ -3,6 +3,7 @@ use std::fmt::{Debug, Display};use half::{bf16, f16};use num_traits::Float;use proc_macros::uzu_test;+use test_runner::for_each_non_cpu_backend;use crate::{array::{ArrayContextExt, ArrayElement},@@ -10,8 +11,8 @@ use crate::{common::{Backend, Context, Encoder, Kernels, kernel::PoolingClsKernel},cpu::Cpu,},- common::assert::assert_eq_float,data_type::DataType,+ tests::assert::assert_eq_float,};struct Input<T: ArrayElement + Float> {@@ -63,7 +64,7 @@ fn get_output<T: ArrayElement + Float, B: Backend>(input: &Input<T>) -> Vec<T> {);encoder.end_encoding().submit().wait_until_completed().unwrap();- crate::common::helpers::allocation_to_vec(&output)+ crate::tests::helpers::allocation_to_vec(&output)}fn test_internal<T: ArrayElement + Float + Debug + Display>(diff --git a/crates/backend-uzu/unit/backends/common/kernel/pooling/pooling_mean_test.rs b/crates/backend-uzu/unit/backends/common/kernel/pooling/pooling_mean_test.rsindex 1f50d9bd1..f9685e6da 100644--- a/crates/backend-uzu/unit/backends/common/kernel/pooling/pooling_mean_test.rs+++ b/crates/backend-uzu/unit/backends/common/kernel/pooling/pooling_mean_test.rs@@ -3,6 +3,7 @@ use std::fmt::{Debug, Display};use half::{bf16, f16};use num_traits::Float;use proc_macros::uzu_test;+use test_runner::for_each_non_cpu_backend;use crate::{array::{ArrayContextExt, ArrayElement},@@ -10,8 +11,8 @@ use crate::{common::{Backend, Context, Encoder, Kernels, kernel::PoolingMeanKernel},cpu::Cpu,},- common::assert::assert_eq_float,data_type::DataType,+ tests::assert::assert_eq_float,};struct Input<T: ArrayElement + Float> {@@ -63,7 +64,7 @@ fn get_output<T: ArrayElement + Float, B: Backend>(input: &Input<T>) -> Vec<T> {);encoder.end_encoding().submit().wait_until_completed().unwrap();- crate::common::helpers::allocation_to_vec(&output)+ crate::tests::helpers::allocation_to_vec(&output)}fn test_internal<T: ArrayElement + Float + Debug + Display>(diff --git a/crates/backend-uzu/unit/backends/common/kernel/qk_unpack_test.rs b/crates/backend-uzu/unit/backends/common/kernel/qk_unpack_test.rsindex ff80602cd..87e478ee9 100644--- a/crates/backend-uzu/unit/backends/common/kernel/qk_unpack_test.rs+++ b/crates/backend-uzu/unit/backends/common/kernel/qk_unpack_test.rs@@ -3,6 +3,7 @@ use std::fmt::{Debug, Display};use half::bf16;use num_traits::Float;use proc_macros::uzu_test;+use test_runner::for_each_non_cpu_backend;use crate::{array::{ArrayContextExt, ArrayElement},@@ -10,7 +11,7 @@ use crate::{common::{Backend, Context, Encoder, Kernels, kernel::QkUnpackKernel},cpu::Cpu,},- common::assert::assert_eq_float,+ tests::assert::assert_eq_float,};fn run<T: ArrayElement + Float + Debug + Display, B: Backend>(@@ -46,7 +47,7 @@ fn run<T: ArrayElement + Float + Debug + Display, B: Backend>();encoder.end_encoding().submit().wait_until_completed().unwrap();- (crate::common::helpers::allocation_to_vec(&queries), crate::common::helpers::allocation_to_vec(&keys))+ (crate::tests::helpers::allocation_to_vec(&queries), crate::tests::helpers::allocation_to_vec(&keys))}fn check<T: ArrayElement + Float + Debug + Display>(diff --git a/crates/backend-uzu/unit/backends/common/kernel/qkv_norm_test.rs b/crates/backend-uzu/unit/backends/common/kernel/qkv_norm_test.rsindex 6576df437..8276e6f5d 100644--- a/crates/backend-uzu/unit/backends/common/kernel/qkv_norm_test.rs+++ b/crates/backend-uzu/unit/backends/common/kernel/qkv_norm_test.rs@@ -3,6 +3,7 @@ use std::fmt::{Debug, Display};use half::{bf16, f16};use num_traits::Float;use proc_macros::uzu_test;+use test_runner::for_each_non_cpu_backend;use crate::{array::{ArrayContextExt, ArrayElement},@@ -10,8 +11,8 @@ use crate::{common::{Allocation, Backend, Context, Encoder, Kernels, kernel::QKVNormKernel},cpu::Cpu,},- common::assert::assert_eq_float,data_type::DataType,+ tests::assert::assert_eq_float,};struct Input<InputT: ArrayElement + Float, ScaleT: ArrayElement + Float, OutputT: ArrayElement + Float> {@@ -156,7 +157,7 @@ fn get_output<);encoder.end_encoding().submit().wait_until_completed().expect("Failed to wait command buffer");- crate::common::helpers::allocation_to_vec(&qkv)+ crate::tests::helpers::allocation_to_vec(&qkv)}fn test_internal<diff --git a/crates/backend-uzu/unit/backends/common/kernel/rms_norm_bench.rs b/crates/backend-uzu/unit/backends/common/kernel/rms_norm_bench.rsindex 91a06fd7b..fcf05bbb1 100644--- a/crates/backend-uzu/unit/backends/common/kernel/rms_norm_bench.rs+++ b/crates/backend-uzu/unit/backends/common/kernel/rms_norm_bench.rs@@ -2,11 +2,12 @@ use criterion::{BenchmarkId, Criterion, Throughput};use itertools::iproduct;use proc_macros::uzu_bench;use rand::{RngExt, SeedableRng, rngs::SmallRng};+use test_runner::for_each_backend;use crate::{array::{ArrayContextExt, ArrayElement},backends::common::{Allocation, Backend, Context, Encoder, Kernels, kernel::RMSNormKernel},- common::type_short_name,+ tests::util::type_short_name,};fn get_rms_norm_data(diff --git a/crates/backend-uzu/unit/backends/common/kernel/rms_norm_test.rs b/crates/backend-uzu/unit/backends/common/kernel/rms_norm_test.rsindex 550bd408f..f66756305 100644--- a/crates/backend-uzu/unit/backends/common/kernel/rms_norm_test.rs+++ b/crates/backend-uzu/unit/backends/common/kernel/rms_norm_test.rs@@ -7,6 +7,7 @@ use half::{bf16, f16};use num_traits::Float;use proc_macros::uzu_test;use rand::{RngExt, SeedableRng, rngs::SmallRng};+use test_runner::for_each_non_cpu_backend;use crate::{array::{ArrayContextExt, ArrayElement},@@ -14,8 +15,8 @@ use crate::{common::{Allocation, Backend, Context, Encoder, Kernels, kernel::RMSNormKernel},cpu::Cpu,},- common::assert::assert_eq_float,data_type::DataType,+ tests::assert::assert_eq_float,};static BOOL_ALL: &[bool] = &[true, false];@@ -165,7 +166,7 @@ fn get_output<let host_elapsed_ms = instant.elapsed().as_secs_f64() * 1e3;let gpu_elapsed_ms = completed.gpu_execution_time();- (crate::common::helpers::allocation_to_vec(&output), host_elapsed_ms, gpu_elapsed_ms)+ (crate::tests::helpers::allocation_to_vec(&output), host_elapsed_ms, gpu_elapsed_ms)}fn test_internal<@@ -417,8 +418,8 @@ fn run_scaled_rms<B: Backend>();encoder.end_encoding().submit().wait_until_completed().expect("Failed to wait command buffer");- let output_values = crate::common::helpers::allocation_to_vec(&output);- let shortcut_values = shortcut_buffer.as_ref().map(crate::common::helpers::allocation_to_vec).unwrap_or_default();+ let output_values = crate::tests::helpers::allocation_to_vec(&output);+ let shortcut_values = shortcut_buffer.as_ref().map(crate::tests::helpers::allocation_to_vec).unwrap_or_default();(output_values, shortcut_values)}diff --git a/crates/backend-uzu/unit/backends/common/kernel/rope_test.rs b/crates/backend-uzu/unit/backends/common/kernel/rope_test.rsindex 186718a03..ed2d517f6 100644--- a/crates/backend-uzu/unit/backends/common/kernel/rope_test.rs+++ b/crates/backend-uzu/unit/backends/common/kernel/rope_test.rs@@ -3,15 +3,16 @@ use std::fmt::{Debug, Display};use half::{bf16, f16};use num_traits::Float;use proc_macros::uzu_test;+use test_runner::for_each_non_cpu_backend;use crate::{array::{ArrayContextExt, ArrayElement},backends::{- common::{Backend, Context, Encoder, Kernels, kernel::RopeKernel},+ common::{Allocation, Backend, Context, Encoder, Kernels, kernel::RopeKernel},cpu::Cpu,},- common::assert::assert_eq_float,data_type::DataType,+ tests::assert::assert_eq_float,};struct Input<T: ArrayElement + Float> {@@ -119,7 +120,7 @@ fn get_output<T: ArrayElement + Float, B: Backend>(sines_array.allocation(),&mut rotated_queries,if query_only {- None::<&mut backend_uzu::backends::common::Allocation<B>>+ None::<&mut Allocation<B>>} else {Some(&mut rotated_keys)},@@ -136,11 +137,11 @@ fn get_output<T: ArrayElement + Float, B: Backend>();encoder.end_encoding().submit().wait_until_completed().unwrap();- let queries = crate::common::helpers::allocation_to_vec(&rotated_queries);+ let queries = crate::tests::helpers::allocation_to_vec(&rotated_queries);let keys = if query_only {None} else {- Some(crate::common::helpers::allocation_to_vec(&rotated_keys))+ Some(crate::tests::helpers::allocation_to_vec(&rotated_keys))};(queries, keys)}diff --git a/crates/backend-uzu/unit/backends/common/kernel/short_conv/short_conv_decode_test.rs b/crates/backend-uzu/unit/backends/common/kernel/short_conv/short_conv_decode_test.rsindex 97198c13d..5b3fed681 100644--- a/crates/backend-uzu/unit/backends/common/kernel/short_conv/short_conv_decode_test.rs+++ b/crates/backend-uzu/unit/backends/common/kernel/short_conv/short_conv_decode_test.rs@@ -3,6 +3,7 @@ use std::fmt::{Debug, Display};use half::{bf16, f16};use num_traits::Float;use proc_macros::uzu_test;+use test_runner::for_each_non_cpu_backend;use crate::{array::{ArrayContextExt, ArrayElement},@@ -10,8 +11,8 @@ use crate::{common::{Backend, Context, Encoder, Kernels, kernel::ShortConvDecodeKernel},cpu::Cpu,},- common::assert::assert_eq_float,data_type::DataType,+ tests::assert::assert_eq_float,};struct Input<T: ArrayElement + Float> {@@ -79,7 +80,7 @@ fn get_output<T: ArrayElement + Float, B: Backend>();encoder.end_encoding().submit().wait_until_completed().unwrap();- (crate::common::helpers::allocation_to_vec(&out), crate::common::helpers::allocation_to_vec(&next_state))+ (crate::tests::helpers::allocation_to_vec(&out), crate::tests::helpers::allocation_to_vec(&next_state))}fn get_test_data_basic<T: ArrayElement + Float>(diff --git a/crates/backend-uzu/unit/backends/common/kernel/short_conv/short_conv_pack_test.rs b/crates/backend-uzu/unit/backends/common/kernel/short_conv/short_conv_pack_test.rsindex e6dee8383..28c7f6234 100644--- a/crates/backend-uzu/unit/backends/common/kernel/short_conv/short_conv_pack_test.rs+++ b/crates/backend-uzu/unit/backends/common/kernel/short_conv/short_conv_pack_test.rs@@ -3,6 +3,7 @@ use std::fmt::{Debug, Display};use half::{bf16, f16};use num_traits::Float;use proc_macros::uzu_test;+use test_runner::for_each_non_cpu_backend;use crate::{array::{ArrayContextExt, ArrayElement},@@ -10,8 +11,8 @@ use crate::{common::{Backend, Context, Encoder, Kernels, kernel::ShortConvPackKernel},cpu::Cpu,},- common::assert::assert_eq_float,data_type::DataType,+ tests::assert::assert_eq_float,};struct Input<T: ArrayElement + Float> {@@ -49,7 +50,7 @@ fn get_output<T: ArrayElement + Float, B: Backend>(input: &Input<T>) -> Vec<T> {);encoder.end_encoding().submit().wait_until_completed().unwrap();- crate::common::helpers::allocation_to_vec(&padded)+ crate::tests::helpers::allocation_to_vec(&padded)}/// Build test input for ShortConvPack.diff --git a/crates/backend-uzu/unit/backends/common/kernel/short_conv/short_conv_prefill_test.rs b/crates/backend-uzu/unit/backends/common/kernel/short_conv/short_conv_prefill_test.rsindex 26822a6c0..f2a3f73e5 100644--- a/crates/backend-uzu/unit/backends/common/kernel/short_conv/short_conv_prefill_test.rs+++ b/crates/backend-uzu/unit/backends/common/kernel/short_conv/short_conv_prefill_test.rs@@ -3,6 +3,7 @@ use std::fmt::{Debug, Display};use half::{bf16, f16};use num_traits::Float;use proc_macros::uzu_test;+use test_runner::for_each_non_cpu_backend;use crate::{array::{ArrayContextExt, ArrayElement},@@ -10,8 +11,8 @@ use crate::{common::{Backend, Context, Encoder, Kernels, kernel::ShortConvPrefillKernel},cpu::Cpu,},- common::assert::assert_eq_float,data_type::DataType,+ tests::assert::assert_eq_float,};struct Input<T: ArrayElement + Float> {@@ -66,7 +67,7 @@ fn get_output<T: ArrayElement + Float, B: Backend>(input: &Input<T>) -> (Vec<T>,);encoder.end_encoding().submit().wait_until_completed().unwrap();- (crate::common::helpers::allocation_to_vec(&out), crate::common::helpers::allocation_to_vec(&state_out))+ (crate::tests::helpers::allocation_to_vec(&out), crate::tests::helpers::allocation_to_vec(&state_out))}fn get_test_data_basic<T: ArrayElement + Float>(diff --git a/crates/backend-uzu/unit/backends/common/kernel/short_conv/short_conv_trie_test.rs b/crates/backend-uzu/unit/backends/common/kernel/short_conv/short_conv_trie_test.rsindex 478bd1292..2c254e4b3 100644--- a/crates/backend-uzu/unit/backends/common/kernel/short_conv/short_conv_trie_test.rs+++ b/crates/backend-uzu/unit/backends/common/kernel/short_conv/short_conv_trie_test.rs@@ -3,6 +3,7 @@ use std::fmt::{Debug, Display};use half::{bf16, f16};use num_traits::Float;use proc_macros::uzu_test;+use test_runner::for_each_non_cpu_backend;use crate::{array::{ArrayContextExt, ArrayElement},@@ -10,8 +11,8 @@ use crate::{common::{Backend, Context, Encoder, Kernels, kernel::ShortConvTrieKernel},cpu::Cpu,},- common::assert::assert_eq_float,data_type::DataType,+ tests::assert::assert_eq_float,};struct Input<T: ArrayElement + Float> {@@ -80,7 +81,7 @@ fn get_output<T: ArrayElement + Float, B: Backend>(input: &Input<T>) -> (Vec<T>,);encoder.end_encoding().submit().wait_until_completed().unwrap();- (crate::common::helpers::allocation_to_vec(&out), crate::common::helpers::allocation_to_vec(&suffix_state))+ (crate::tests::helpers::allocation_to_vec(&out), crate::tests::helpers::allocation_to_vec(&suffix_state))}/// Linear chain: node 0 has parent -1 (root), node i has parent i-1.diff --git a/crates/backend-uzu/unit/backends/common/kernel/ssm/ssm_conv1d_decode_test.rs b/crates/backend-uzu/unit/backends/common/kernel/ssm/ssm_conv1d_decode_test.rsindex 3c82b1c5a..c5d9e3270 100644--- a/crates/backend-uzu/unit/backends/common/kernel/ssm/ssm_conv1d_decode_test.rs+++ b/crates/backend-uzu/unit/backends/common/kernel/ssm/ssm_conv1d_decode_test.rs@@ -3,15 +3,18 @@ use std::fmt::{Debug, Display};use half::{bf16, f16};use num_traits::Float;use proc_macros::uzu_test;+use test_runner::for_each_non_cpu_backend;use crate::{array::{ArrayContextExt, ArrayElement},backends::{- common::{Backend, Context, Encoder, Kernels, gpu_types::ActivationType, kernel::Conv1dDecodeKernel},+ common::{+ Allocation, Backend, Context, Encoder, Kernels, gpu_types::ActivationType, kernel::Conv1dDecodeKernel,+ },cpu::Cpu,},- common::assert::assert_eq_float,data_type::DataType,+ tests::assert::assert_eq_float,};struct Input<T: ArrayElement + Float> {@@ -116,7 +119,7 @@ fn get_output<B: Backend, T: ArrayElement + Float>(input: &Input<T>) -> Output<Tx_array.allocation(),w_array.allocation(),b_array.as_ref().map(|bias| bias.allocation()),- None::<&backend_uzu::backends::common::Allocation<B>>,+ None::<&Allocation<B>>,&mut x_out,&mut b_out,&mut c_out,@@ -134,10 +137,10 @@ fn get_output<B: Backend, T: ArrayElement + Float>(input: &Input<T>) -> Output<Tencoder.end_encoding().submit().wait_until_completed().expect("Failed to wait command buffer");Output {- x_out: crate::common::helpers::allocation_to_vec(&x_out),- b_out: crate::common::helpers::allocation_to_vec(&b_out),- c_out: crate::common::helpers::allocation_to_vec(&c_out),- next_state: crate::common::helpers::allocation_to_vec(&next_state),+ x_out: crate::tests::helpers::allocation_to_vec(&x_out),+ b_out: crate::tests::helpers::allocation_to_vec(&b_out),+ c_out: crate::tests::helpers::allocation_to_vec(&c_out),+ next_state: crate::tests::helpers::allocation_to_vec(&next_state),}} else {let state_array = context.create_array_from(&[state_size], &input.state);@@ -166,10 +169,10 @@ fn get_output<B: Backend, T: ArrayElement + Float>(input: &Input<T>) -> Output<Tencoder.end_encoding().submit().wait_until_completed().expect("Failed to wait command buffer");Output {- x_out: crate::common::helpers::allocation_to_vec(&x_out),- b_out: crate::common::helpers::allocation_to_vec(&b_out),- c_out: crate::common::helpers::allocation_to_vec(&c_out),- next_state: crate::common::helpers::allocation_to_vec(&next_state),+ x_out: crate::tests::helpers::allocation_to_vec(&x_out),+ b_out: crate::tests::helpers::allocation_to_vec(&b_out),+ c_out: crate::tests::helpers::allocation_to_vec(&c_out),+ next_state: crate::tests::helpers::allocation_to_vec(&next_state),}}}diff --git a/crates/backend-uzu/unit/backends/common/kernel/ssm/ssm_conv1d_pack_test.rs b/crates/backend-uzu/unit/backends/common/kernel/ssm/ssm_conv1d_pack_test.rsindex 6aec4651f..a79b0d8fb 100644--- a/crates/backend-uzu/unit/backends/common/kernel/ssm/ssm_conv1d_pack_test.rs+++ b/crates/backend-uzu/unit/backends/common/kernel/ssm/ssm_conv1d_pack_test.rs@@ -3,6 +3,7 @@ use std::fmt::{Debug, Display};use half::bf16;use num_traits::Float;use proc_macros::uzu_test;+use test_runner::for_each_non_cpu_backend;use crate::{array::{ArrayContextExt, ArrayElement},@@ -10,8 +11,8 @@ use crate::{common::{Backend, Context, Encoder, Kernels, kernel::Conv1dPackKernel},cpu::Cpu,},- common::assert::assert_eq_float,data_type::DataType,+ tests::assert::assert_eq_float,};struct Input<T: ArrayElement + Float> {@@ -72,7 +73,7 @@ fn get_output<B: Backend, T: ArrayElement + Float>(input: &Input<T>) -> Vec<T> {);encoder.end_encoding().submit().wait_until_completed().expect("Failed to wait command buffer");- crate::common::helpers::allocation_to_vec(&padded)+ crate::tests::helpers::allocation_to_vec(&padded)}fn get_test_data<T: ArrayElement + Float>(diff --git a/crates/backend-uzu/unit/backends/common/kernel/ssm/ssm_conv1d_scan_test.rs b/crates/backend-uzu/unit/backends/common/kernel/ssm/ssm_conv1d_scan_test.rsindex 7ed07d878..7b7e74476 100644--- a/crates/backend-uzu/unit/backends/common/kernel/ssm/ssm_conv1d_scan_test.rs+++ b/crates/backend-uzu/unit/backends/common/kernel/ssm/ssm_conv1d_scan_test.rs@@ -3,6 +3,7 @@ use std::fmt::{Debug, Display};use half::{bf16, f16};use num_traits::Float;use proc_macros::uzu_test;+use test_runner::for_each_non_cpu_backend;use crate::{array::{ArrayContextExt, ArrayElement},@@ -10,8 +11,8 @@ use crate::{common::{Backend, Context, Encoder, Kernels, gpu_types::ActivationType, kernel::Conv1dScanKernel},cpu::Cpu,},- common::assert::assert_eq_float,data_type::DataType,+ tests::assert::assert_eq_float,};struct Input<T: ArrayElement + Float> {@@ -120,10 +121,10 @@ fn get_output<B: Backend, T: ArrayElement + Float>(input: &Input<T>) -> Output<Tencoder.end_encoding().submit().wait_until_completed().expect("Failed to wait command buffer");Output {- x_out: crate::common::helpers::allocation_to_vec(&x_out),- b_out: crate::common::helpers::allocation_to_vec(&b_out),- c_out: crate::common::helpers::allocation_to_vec(&c_out),- state_out: crate::common::helpers::allocation_to_vec(&state_out),+ x_out: crate::tests::helpers::allocation_to_vec(&x_out),+ b_out: crate::tests::helpers::allocation_to_vec(&b_out),+ c_out: crate::tests::helpers::allocation_to_vec(&c_out),+ state_out: crate::tests::helpers::allocation_to_vec(&state_out),}}diff --git a/crates/backend-uzu/unit/backends/common/kernel/ssm/ssm_prefill_test.rs b/crates/backend-uzu/unit/backends/common/kernel/ssm/ssm_prefill_test.rsindex 7fc146a0d..465ac3984 100644--- a/crates/backend-uzu/unit/backends/common/kernel/ssm/ssm_prefill_test.rs+++ b/crates/backend-uzu/unit/backends/common/kernel/ssm/ssm_prefill_test.rs@@ -3,6 +3,7 @@ use std::fmt::{Debug, Display};use half::{bf16, f16};use num_traits::Float;use proc_macros::uzu_test;+use test_runner::for_each_non_cpu_backend;use crate::{array::{ArrayContextExt, ArrayElement},@@ -13,8 +14,8 @@ use crate::{},cpu::Cpu,},- common::assert::assert_eq_float,data_type::DataType,+ tests::assert::assert_eq_float,};struct Input<T: ArrayElement + Float> {@@ -170,8 +171,8 @@ fn get_output<B: Backend, T: ArrayElement + Float>(encoder.end_encoding().submit().wait_until_completed().expect("Failed to wait command buffer");Output {- y: crate::common::helpers::allocation_to_vec(&y),- state: crate::common::helpers::allocation_to_vec(&state),+ y: crate::tests::helpers::allocation_to_vec(&y),+ state: crate::tests::helpers::allocation_to_vec(&state),}}diff --git a/crates/backend-uzu/unit/backends/common/kernel/ssm/ssm_split_inproj_test.rs b/crates/backend-uzu/unit/backends/common/kernel/ssm/ssm_split_inproj_test.rsindex 583d27934..272949b4c 100644--- a/crates/backend-uzu/unit/backends/common/kernel/ssm/ssm_split_inproj_test.rs+++ b/crates/backend-uzu/unit/backends/common/kernel/ssm/ssm_split_inproj_test.rs@@ -3,6 +3,7 @@ use std::fmt::{Debug, Display};use half::{bf16, f16};use num_traits::Float;use proc_macros::uzu_test;+use test_runner::for_each_non_cpu_backend;use crate::{array::{ArrayContextExt, ArrayElement},@@ -10,8 +11,8 @@ use crate::{common::{Backend, Context, Encoder, Kernels, kernel::SplitInProjKernel},cpu::Cpu,},- common::assert::assert_eq_float,data_type::DataType,+ tests::assert::assert_eq_float,};struct Input<T: ArrayElement + Float> {@@ -86,9 +87,9 @@ fn get_output<B: Backend, T: ArrayElement + Float>(input: &Input<T>) -> Output<Tencoder.end_encoding().submit().wait_until_completed().expect("Failed to wait command buffer");Output {- conv_out: crate::common::helpers::allocation_to_vec(&conv_out),- z_out: crate::common::helpers::allocation_to_vec(&z_out),- dt_out: crate::common::helpers::allocation_to_vec(&dt_out),+ conv_out: crate::tests::helpers::allocation_to_vec(&conv_out),+ z_out: crate::tests::helpers::allocation_to_vec(&z_out),+ dt_out: crate::tests::helpers::allocation_to_vec(&dt_out),}}diff --git a/crates/backend-uzu/unit/backends/common/kernel/ssm/ssm_update_test.rs b/crates/backend-uzu/unit/backends/common/kernel/ssm/ssm_update_test.rsindex 6e88d8291..5f4173047 100644--- a/crates/backend-uzu/unit/backends/common/kernel/ssm/ssm_update_test.rs+++ b/crates/backend-uzu/unit/backends/common/kernel/ssm/ssm_update_test.rs@@ -3,15 +3,16 @@ use std::fmt::{Debug, Display};use half::{bf16, f16};use num_traits::Float;use proc_macros::uzu_test;+use test_runner::for_each_non_cpu_backend;use crate::{array::{ArrayContextExt, ArrayElement},backends::{- common::{Backend, Context, Encoder, Kernels, kernel::SSDUpdateKernel},+ common::{Allocation, Backend, Context, Encoder, Kernels, kernel::SSDUpdateKernel},cpu::Cpu,},- common::assert::assert_eq_float,data_type::DataType,+ tests::assert::assert_eq_float,};struct Input<T: ArrayElement + Float> {@@ -115,7 +116,7 @@ fn get_output<B: Backend, T: ArrayElement + Float>(input: &Input<T>) -> Output<Tc_array.allocation(),d_array.allocation(),z_array.allocation(),- None::<&backend_uzu::backends::common::Allocation<B>>,+ None::<&Allocation<B>>,&mut y,&mut next_state,(h / g) as u32,@@ -132,8 +133,8 @@ fn get_output<B: Backend, T: ArrayElement + Float>(input: &Input<T>) -> Output<Tencoder.end_encoding().submit().wait_until_completed().expect("Failed to wait command buffer");Output {- y: crate::common::helpers::allocation_to_vec(&y),- next_state: crate::common::helpers::allocation_to_vec(&next_state),+ y: crate::tests::helpers::allocation_to_vec(&y),+ next_state: crate::tests::helpers::allocation_to_vec(&next_state),}} else {let state_array = context.create_array_from(&[ns_size], &input.state);@@ -164,8 +165,8 @@ fn get_output<B: Backend, T: ArrayElement + Float>(input: &Input<T>) -> Output<Tencoder.end_encoding().submit().wait_until_completed().expect("Failed to wait command buffer");Output {- y: crate::common::helpers::allocation_to_vec(&y),- next_state: crate::common::helpers::allocation_to_vec(&next_state),+ y: crate::tests::helpers::allocation_to_vec(&y),+ next_state: crate::tests::helpers::allocation_to_vec(&next_state),}}}diff --git a/crates/backend-uzu/unit/backends/common/kernel/tensor_add_bias_test.rs b/crates/backend-uzu/unit/backends/common/kernel/tensor_add_bias_test.rsindex 1196acb21..5ceee6461 100644--- a/crates/backend-uzu/unit/backends/common/kernel/tensor_add_bias_test.rs+++ b/crates/backend-uzu/unit/backends/common/kernel/tensor_add_bias_test.rs@@ -3,11 +3,12 @@ use std::fmt::Debug;use half::{bf16, f16};use num_traits::Float;use proc_macros::uzu_test;+use test_runner::for_each_backend;use crate::{array::ArrayElement,backends::common::{Backend, Context, Encoder, Kernels, kernel::TensorAddBiasKernel},- common::helpers::{alloc_allocation, alloc_allocation_with_data, allocation_to_vec},+ tests::helpers::{alloc_allocation, alloc_allocation_with_data, allocation_to_vec},};struct Input<T: ArrayElement + Float> {diff --git a/crates/backend-uzu/unit/backends/common/kernel/tensor_add_scale_test.rs b/crates/backend-uzu/unit/backends/common/kernel/tensor_add_scale_test.rsindex 634636063..91567d7c4 100644--- a/crates/backend-uzu/unit/backends/common/kernel/tensor_add_scale_test.rs+++ b/crates/backend-uzu/unit/backends/common/kernel/tensor_add_scale_test.rs@@ -3,6 +3,7 @@ use std::fmt::{Debug, Display};use half::{bf16, f16};use num_traits::Float;use proc_macros::uzu_test;+use test_runner::for_each_non_cpu_backend;use crate::{array::ArrayElement,@@ -10,11 +11,11 @@ use crate::{common::{Backend, Context, Encoder, Kernels, kernel::TensorAddScaleKernel},cpu::Cpu,},- common::{+ data_type::DataType,+ tests::{assert::assert_eq_float,helpers::{alloc_allocation, alloc_allocation_with_data, allocation_to_vec},},- data_type::DataType,};struct Input<T: ArrayElement + Float> {diff --git a/crates/backend-uzu/unit/backends/common/kernel/tensor_add_swap_test.rs b/crates/backend-uzu/unit/backends/common/kernel/tensor_add_swap_test.rsindex d642d05e5..e3f44ba7b 100644--- a/crates/backend-uzu/unit/backends/common/kernel/tensor_add_swap_test.rs+++ b/crates/backend-uzu/unit/backends/common/kernel/tensor_add_swap_test.rs@@ -3,11 +3,12 @@ use std::fmt::Debug;use half::{bf16, f16};use num_traits::Float;use proc_macros::uzu_test;+use test_runner::for_each_backend;use crate::{array::ArrayElement,backends::common::{Backend, Context, Encoder, Kernels, kernel::TensorAddSwapKernel},- common::helpers::{alloc_allocation_with_data, allocation_to_vec},+ tests::helpers::{alloc_allocation_with_data, allocation_to_vec},};struct Input<T: ArrayElement + Float> {diff --git a/crates/backend-uzu/unit/backends/common/kernel/tensor_copy_test.rs b/crates/backend-uzu/unit/backends/common/kernel/tensor_copy_test.rsindex 5d545401d..bded046f3 100644--- a/crates/backend-uzu/unit/backends/common/kernel/tensor_copy_test.rs+++ b/crates/backend-uzu/unit/backends/common/kernel/tensor_copy_test.rs@@ -3,11 +3,12 @@ use std::fmt::Debug;use half::{bf16, f16};use num_traits::Float;use proc_macros::uzu_test;+use test_runner::for_each_backend;use crate::{array::ArrayElement,backends::common::{Backend, Context, Encoder, Kernels, kernel::TensorCopyKernel},- common::helpers::{alloc_allocation, alloc_allocation_with_data, allocation_to_vec},+ tests::helpers::{alloc_allocation, alloc_allocation_with_data, allocation_to_vec},};struct Input<T: ArrayElement + Float> {diff --git a/crates/backend-uzu/unit/backends/common/kernel/token_copy_test.rs b/crates/backend-uzu/unit/backends/common/kernel/token_copy_test.rsindex 5b9c22236..4af4d17a9 100644--- a/crates/backend-uzu/unit/backends/common/kernel/token_copy_test.rs+++ b/crates/backend-uzu/unit/backends/common/kernel/token_copy_test.rs@@ -1,11 +1,12 @@use proc_macros::uzu_test;+use test_runner::for_each_backend;use crate::{backends::common::{Allocation, Backend, Context, Encoder, Kernels,kernel::{TokenCopySampledKernel, TokenCopyToResultsKernel},},- common::helpers::{alloc_allocation, alloc_allocation_with_data, allocation_to_vec},+ tests::helpers::{alloc_allocation, alloc_allocation_with_data, allocation_to_vec},};fn test_token_copy_sampled_impl<B: Backend>(src_value: u32) {diff --git a/crates/backend-uzu/unit/backends/metal/sparse/sparse_buffer_test.rs b/crates/backend-uzu/unit/backends/metal/sparse/sparse_buffer_test.rsindex f16167f9e..65e3d7b0a 100644--- a/crates/backend-uzu/unit/backends/metal/sparse/sparse_buffer_test.rs+++ b/crates/backend-uzu/unit/backends/metal/sparse/sparse_buffer_test.rs@@ -7,7 +7,7 @@ use crate::{common::{Backend, SparseBuffer},metal::Metal,},- common::helpers::{create_context, sparse_buffer_create},+ tests::helpers::{create_context, sparse_buffer_create},};/// Capacity sized to fit `heap_count` worth of heaps.diff --git a/crates/backend-uzu/unit/backends/metal/sparse/sparse_heap_pool_test.rs b/crates/backend-uzu/unit/backends/metal/sparse/sparse_heap_pool_test.rsindex 4b548c75d..eb0d3de98 100644--- a/crates/backend-uzu/unit/backends/metal/sparse/sparse_heap_pool_test.rs+++ b/crates/backend-uzu/unit/backends/metal/sparse/sparse_heap_pool_test.rs@@ -5,7 +5,7 @@ use crate::{common::SparseBuffer,metal::{Metal, metal_extensions::SparsePageSizeExt},},- common::helpers::{create_context, sparse_buffer_create},+ tests::helpers::{create_context, sparse_buffer_create},};#[uzu_test]diff --git a/crates/backend-uzu/unit/encodable_block/attention_gemm_test.rs b/crates/backend-uzu/unit/encodable_block/attention_gemm_test.rsindex b9575780d..fbb493c25 100644--- a/crates/backend-uzu/unit/encodable_block/attention_gemm_test.rs+++ b/crates/backend-uzu/unit/encodable_block/attention_gemm_test.rs@@ -3,6 +3,7 @@ use std::fmt::{Debug, Display};use half::{bf16, f16};use num_traits::Float;use proc_macros::uzu_test;+use test_runner::for_each_non_cpu_backend;use super::{AttentionGemmArguments, AttentionGemmBlock};use crate::{@@ -11,11 +12,11 @@ use crate::{common::{Allocation, Backend, Context, Encoder},cpu::Cpu,},- common::{+ data_type::DataType,+ tests::{assert::assert_eq_float,helpers::{alloc_allocation, alloc_allocation_with_data, allocation_to_vec},},- data_type::DataType,};struct Input<T: ArrayElement + Float> {diff --git a/crates/backend-uzu/unit/encodable_block/attention_test.rs b/crates/backend-uzu/unit/encodable_block/attention_test.rsindex e652055cf..a51a245cb 100644--- a/crates/backend-uzu/unit/encodable_block/attention_test.rs+++ b/crates/backend-uzu/unit/encodable_block/attention_test.rs@@ -13,8 +13,8 @@ use crate::{},metal::Metal,},- common::helpers::{alloc_allocation, alloc_allocation_with_data, allocation_to_vec, submit_encoder},data_type::DataType,+ tests::helpers::{alloc_allocation, alloc_allocation_with_data, allocation_to_vec, submit_encoder},};fn reference_attention(diff --git a/crates/backend-uzu/unit/encodable_block/kv_cache_update_test.rs b/crates/backend-uzu/unit/encodable_block/kv_cache_update_test.rsindex 90568f4cd..ecad546e2 100644--- a/crates/backend-uzu/unit/encodable_block/kv_cache_update_test.rs+++ b/crates/backend-uzu/unit/encodable_block/kv_cache_update_test.rs@@ -9,7 +9,7 @@ use crate::{common::{Context, Encoder},metal::Metal,},- common::helpers::{sparse_buffer_create_with, sparse_buffer_read_vec},+ tests::helpers::{sparse_buffer_create_with, sparse_buffer_read_vec},};fn apply_swaps_3d<T: Clone>(diff --git a/crates/backend-uzu/unit/encodable_block/mamba_mixer/ssd_prefill_test.rs b/crates/backend-uzu/unit/encodable_block/mamba_mixer/ssd_prefill_test.rsindex 91ff51944..8e3d14528 100644--- a/crates/backend-uzu/unit/encodable_block/mamba_mixer/ssd_prefill_test.rs+++ b/crates/backend-uzu/unit/encodable_block/mamba_mixer/ssd_prefill_test.rs@@ -1,10 +1,11 @@use proc_macros::uzu_test;+use test_runner::for_each_non_cpu_backend;use super::{SSDPrefillArguments, SSDPrefillBlock, SSDPrefillMode};use crate::{backends::common::{Backend, Context, Encoder, Kernels, gpu_types::ActivationType, kernel::Conv1dScanKernel},- common::helpers::{alloc_allocation_with_data, allocation_to_vec},data_type::DataType,+ tests::helpers::{alloc_allocation_with_data, allocation_to_vec},};fn ssd_prefill_cpu_reference(diff --git a/crates/backend-uzu/unit/encodable_block/moe/moe_block_e2e_test.rs b/crates/backend-uzu/unit/encodable_block/moe/moe_block_e2e_test.rsindex 507f83bf7..85b51f673 100644--- a/crates/backend-uzu/unit/encodable_block/moe/moe_block_e2e_test.rs+++ b/crates/backend-uzu/unit/encodable_block/moe/moe_block_e2e_test.rs@@ -1,6 +1,7 @@use half::bf16;use proc_macros::uzu_test;use rand::{RngExt, SeedableRng, rngs::StdRng};+use test_runner::for_each_non_cpu_backend;use super::{MoeExpertsTwoPassArguments, MoeExpertsTwoPassPrefillBlock, MoeGather};use crate::{@@ -12,10 +13,10 @@ use crate::{MoeScatterBucketsMapKernel,},},- common::helpers::{+ data_type::DataType,+ tests::helpers::{alloc_allocation, alloc_allocation_with_data, allocation_prefix_to_vec, allocation_to_vec, create_context,},- data_type::DataType,};fn moe_cpu_reference(diff --git a/crates/backend-uzu/unit/encodable_block/moe/moe_experts_perf_test.rs b/crates/backend-uzu/unit/encodable_block/moe/moe_experts_perf_test.rsindex a9d14fc2c..eb9cee9d0 100644--- a/crates/backend-uzu/unit/encodable_block/moe/moe_experts_perf_test.rs+++ b/crates/backend-uzu/unit/encodable_block/moe/moe_experts_perf_test.rs@@ -3,12 +3,13 @@ use std::time::Instant;use half::bf16;use proc_macros::uzu_test;use rand::{RngExt, SeedableRng, rngs::StdRng};+use test_runner::for_each_non_cpu_backend;use super::{MoeExpertsTwoPassArguments, MoeExpertsTwoPassDecodeBlock, MoeExpertsTwoPassPrefillBlock};use crate::{backends::common::{Backend, Encoder},- common::helpers::{alloc_allocation_with_data, create_context},data_type::DataType,+ tests::helpers::{alloc_allocation_with_data, create_context},};fn build_offsets(diff --git a/crates/backend-uzu/unit/encodable_block/moe/moe_experts_test.rs b/crates/backend-uzu/unit/encodable_block/moe/moe_experts_test.rsindex ddb947d15..87afbfb09 100644--- a/crates/backend-uzu/unit/encodable_block/moe/moe_experts_test.rs+++ b/crates/backend-uzu/unit/encodable_block/moe/moe_experts_test.rs@@ -9,6 +9,7 @@use half::bf16;use proc_macros::uzu_test;use rand::{RngExt, SeedableRng, rngs::StdRng};+use test_runner::for_each_non_cpu_backend;use super::{MoeExpertsTwoPassArguments, MoeExpertsTwoPassDecodeBlock, MoeExpertsTwoPassPrefillBlock, cpu_tile_counts,@@ -19,11 +20,11 @@ use crate::{Encoder,gpu_types::{ActivationType, activation_silu_alpha},},- common::{+ data_type::DataType,+ tests::{assert::assert_eq_float,helpers::{alloc_allocation_with_data, allocation_prefix_to_vec, create_context},},- data_type::DataType,};/// Test data for MoE expertsdiff --git a/crates/backend-uzu/unit/encodable_block/moe/moe_gather_test.rs b/crates/backend-uzu/unit/encodable_block/moe/moe_gather_test.rsindex d415dc7d0..3abf5ea9c 100644--- a/crates/backend-uzu/unit/encodable_block/moe/moe_gather_test.rs+++ b/crates/backend-uzu/unit/encodable_block/moe/moe_gather_test.rs@@ -2,6 +2,7 @@ use half::bf16;use num_traits::Float;use proc_macros::uzu_test;use rand::{RngExt, SeedableRng, rngs::StdRng};+use test_runner::for_each_non_cpu_backend;use super::MoeGather;use crate::{@@ -10,7 +11,7 @@ use crate::{common::{Backend, Encoder},cpu::Cpu,},- common::{+ tests::{assert::assert_eq_float,helpers::{alloc_allocation_with_data, allocation_to_vec, create_context},},diff --git a/crates/backend-uzu/unit/encodable_block/moe/moe_perf_test.rs b/crates/backend-uzu/unit/encodable_block/moe/moe_perf_test.rsindex ef3ddd272..3862f88e1 100644--- a/crates/backend-uzu/unit/encodable_block/moe/moe_perf_test.rs+++ b/crates/backend-uzu/unit/encodable_block/moe/moe_perf_test.rs@@ -1,6 +1,7 @@use half::bf16;use proc_macros::uzu_test;use rand::{RngExt, SeedableRng, rngs::StdRng};+use test_runner::{for_each_non_cpu_backend, perf::run_perf_with_warmup};use super::{MoeExpertsTwoPassArguments, MoeExpertsTwoPassDecodeBlock, MoeGather};use crate::{@@ -11,11 +12,8 @@ use crate::{MoeScatterBucketsMapKernel,},},- common::{- helpers::{alloc_allocation, alloc_allocation_with_data, create_context},- perf::run_perf_with_warmup,- },data_type::DataType,+ tests::helpers::{alloc_allocation, alloc_allocation_with_data, create_context},};// Test E2E MoE performance with timing breakdown (decode mode, T=1)diff --git a/crates/backend-uzu/unit/encodable_block/moe/moe_tiles_test.rs b/crates/backend-uzu/unit/encodable_block/moe/moe_tiles_test.rsindex dd21c370f..5ea60b9b0 100644--- a/crates/backend-uzu/unit/encodable_block/moe/moe_tiles_test.rs+++ b/crates/backend-uzu/unit/encodable_block/moe/moe_tiles_test.rs@@ -1,15 +1,16 @@use proc_macros::uzu_test;use rand::{RngExt, SeedableRng, rngs::StdRng};+use test_runner::for_each_non_cpu_backend;use crate::{backends::common::{Backend, Encoder, Kernels,kernel::{MoeTileCountsKernel, MoeTileScanKernel},},- common::helpers::{+ encodable_block::mlp::moe::tests::{cpu_tile_counts, cpu_tile_scan},+ tests::helpers::{alloc_allocation, alloc_allocation_with_data, allocation_prefix_to_vec, allocation_to_vec, create_context,},- encodable_block::mlp::moe::tests::{cpu_tile_counts, cpu_tile_scan},};#[uzu_test]diff --git a/crates/backend-uzu/unit/encodable_block/sampling_test.rs b/crates/backend-uzu/unit/encodable_block/sampling_test.rsindex 06c5abba8..6f878b24f 100644--- a/crates/backend-uzu/unit/encodable_block/sampling_test.rs+++ b/crates/backend-uzu/unit/encodable_block/sampling_test.rs@@ -1,10 +1,5 @@use std::{iter::repeat_with, mem::MaybeUninit};-use backend_uzu::{- array::ArrayElement,- backends::common::{AllocationType, Backend, Context, Encoder},- dispatch_dtype,-};use num_traits::{Float, NumCast};use proc_macros::uzu_test;use proptest::prelude::*;@@ -12,13 +7,13 @@ use rand::{RngExt, SeedableRng, rngs::SmallRng};use rand_distr::Normal;use crate::{- common::{- for_each_context,- proptest::{ComparableTestResults, TestContextes, kernel_data_type},- },+ array::ArrayElement,+ backends::common::{AllocationType, Backend, Context, Encoder},data_type::DataType,+ dispatch_dtype,encodable_block::Sampling,session::parameter::{SamplingMethod, SamplingProcessingOrder},+ tests::proptest::{ComparableTestResults, TestContextes, for_each_context, kernel_data_type},};struct SamplingTestResults(Vec<u32>);diff --git a/crates/backend-uzu/unit/forward_pass/kv_cache_state_test.rs b/crates/backend-uzu/unit/forward_pass/kv_cache_state_test.rsindex ca0298488..e13b2b6c8 100644--- a/crates/backend-uzu/unit/forward_pass/kv_cache_state_test.rs+++ b/crates/backend-uzu/unit/forward_pass/kv_cache_state_test.rs@@ -7,10 +7,10 @@ use crate::{common::{Backend, Context, Encoder},metal::Metal,},- common::helpers::{sparse_buffer_create_with, sparse_buffer_read_vec, sparse_buffer_write},data_type::DataType,encodable_block::KVCacheUpdate,forward_pass::kv_cache_layer::{KVCacheLayer, KVCacheLayerState, KVCacheLayerTrait},+ tests::helpers::{sparse_buffer_create_with, sparse_buffer_read_vec, sparse_buffer_write},};#[derive(Debug)]diff --git a/crates/backend-uzu/unit/forward_pass/traces/trace_validator.rs b/crates/backend-uzu/unit/forward_pass/traces/trace_validator.rsindex 349c404c5..f10676b44 100644--- a/crates/backend-uzu/unit/forward_pass/traces/trace_validator.rs+++ b/crates/backend-uzu/unit/forward_pass/traces/trace_validator.rs@@ -21,7 +21,6 @@ use crate::{array::{Array, ArrayElement},backends::common::{Allocation, AllocationType, Backend, Context, Encoder},classifier::{ActivationTrace, Classifier},- common,config::model::AnyModelConfig,data_type::DataType,encodable_block::DecoderDecodeInput,@@ -33,6 +32,7 @@ use crate::{parameter::{AsyncBatchSize, ConfigResolvableValue, ContextLength, ContextMode, PrefillStepSize, SamplingSeed},types::Error,},+ tests::helpers::sparse_buffer_read_allocation,};fn argmax<T: ArrayElement>(input: &[T]) -> usize {@@ -375,7 +375,7 @@ impl<B: Backend> TraceValidator<B> {Self::read_required_array(&traces_view, &trace_shapes, &keys_path, ctx.model_shape.data_type);let size = shape.iter().product::<usize>() * ctx.model_shape.data_type.size_in_bytes();let keys = if let Some(layer) = kv.as_any().downcast_ref::<KVCacheLayer<B, B::SparseBuffer>>() {- common::helpers::sparse_buffer_read_allocation(ctx.context.as_ref(), &layer.keys, size)+ sparse_buffer_read_allocation(ctx.context.as_ref(), &layer.keys, size)} else if let Some(layer) = kv.as_any().downcast_ref::<KVCacheLayer<B, B::DenseBuffer>>() {let mut allocation = ctx.context@@ -404,7 +404,7 @@ impl<B: Backend> TraceValidator<B> {let expected =Self::read_required_array(&traces_view, &trace_shapes, &values_path, ctx.model_shape.data_type);let values = if let Some(layer) = kv.as_any().downcast_ref::<KVCacheLayer<B, B::SparseBuffer>>() {- common::helpers::sparse_buffer_read_allocation(ctx.context.as_ref(), &layer.values, size)+ sparse_buffer_read_allocation(ctx.context.as_ref(), &layer.values, size)} else if let Some(layer) = kv.as_any().downcast_ref::<KVCacheLayer<B, B::DenseBuffer>>() {let mut allocation = ctx.contextdiff --git a/crates/backend-uzu/unit/forward_pass/traces/trace_validator_test.rs b/crates/backend-uzu/unit/forward_pass/traces/trace_validator_test.rsindex 973ba74cb..648b13b6e 100644--- a/crates/backend-uzu/unit/forward_pass/traces/trace_validator_test.rs+++ b/crates/backend-uzu/unit/forward_pass/traces/trace_validator_test.rs@@ -1,11 +1,9 @@use std::path::PathBuf;use proc_macros::uzu_test;+use test_runner::{for_each_non_cpu_backend, path::get_test_model_path};-use crate::{- backends::common::Backend, common::path::get_test_model_path,- forward_pass::traces::tests::trace_validator::TraceValidator,-};+use crate::{backends::common::Backend, forward_pass::traces::tests::trace_validator::TraceValidator};const TRACES_FILE_NAME: &str = "traces.safetensors";diff --git a/crates/backend-uzu/unit/language_model/grammar.rs b/crates/backend-uzu/unit/language_model/grammar.rsindex ccd9ced04..05c9e8a16 100644--- a/crates/backend-uzu/unit/language_model/grammar.rs+++ b/crates/backend-uzu/unit/language_model/grammar.rs@@ -4,6 +4,7 @@ use metal::MTLDevice;use proc_macros::uzu_test;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};@@ -13,7 +14,6 @@ use crate::{common::{AllocationType, Backend, Context},metal::Metal,},- common::path::get_test_model_path,data_type::DataType,};diff --git a/crates/backend-uzu/unit/language_model/language_model_generator_bench.rs b/crates/backend-uzu/unit/language_model/language_model_generator_bench.rsindex ae6273a0e..092ce2cbd 100644--- a/crates/backend-uzu/unit/language_model/language_model_generator_bench.rs+++ b/crates/backend-uzu/unit/language_model/language_model_generator_bench.rs@@ -1,16 +1,14 @@use std::time::Duration;-use backend_uzu::{- backends::common::Backend,- session::{config::DecodingConfig, parameter::SamplingMethod},-};use criterion::{BenchmarkId, Criterion, Throughput};use proc_macros::uzu_bench;+use test_runner::{for_each_non_cpu_backend, metrics::wait_gpu_cooldown, path::get_test_model_path};use crate::{- common::{metrics::wait_gpu_cooldown, path::get_test_model_path},+ backends::common::Backend,config::model::language_model::LanguageModelConfig,language_model::{LanguageModelGenerator, language_model_generator::RunModelResult},+ session::{config::DecodingConfig, parameter::SamplingMethod},trie::{TrieCreationConfig, TrieNode},};diff --git a/crates/backend-uzu/unit/parameters/loader.rs b/crates/backend-uzu/unit/parameters/loader.rsindex 5c4267774..d4e48384c 100644--- a/crates/backend-uzu/unit/parameters/loader.rs+++ b/crates/backend-uzu/unit/parameters/loader.rs@@ -2,11 +2,11 @@ use std::fs::File;use half::bf16;use proc_macros::uzu_test;+use test_runner::{for_each_backend, path::get_test_weights_path};use test_tag::tag;use crate::{backends::common::{Backend, Context},- common::path::get_test_weights_path,data_type::DataType,parameters::{ParameterLoader, safetensors_metadata::read_metadata},};diff --git a/crates/backend-uzu/unit/parameters/safetensors_metadata.rs b/crates/backend-uzu/unit/parameters/safetensors_metadata.rsindex 7e07e6592..aeeec73b6 100644--- a/crates/backend-uzu/unit/parameters/safetensors_metadata.rs+++ b/crates/backend-uzu/unit/parameters/safetensors_metadata.rs@@ -1,8 +1,9 @@use std::fs::File;use proc_macros::uzu_test;+use test_runner::path::get_test_weights_path;-use crate::{common::path::get_test_weights_path, parameters::safetensors_metadata::read_metadata};+use crate::parameters::safetensors_metadata::read_metadata;#[uzu_test]fn test_metadata_loading() {diff --git a/crates/backend-uzu/unit/session/chat_session.rs b/crates/backend-uzu/unit/session/chat_session.rsindex 0e20385db..6b1d7b6e8 100644--- a/crates/backend-uzu/unit/session/chat_session.rs+++ b/crates/backend-uzu/unit/session/chat_session.rs@@ -2,11 +2,11 @@ use std::sync::Arc;use proc_macros::uzu_test;use shoji::types::basic::Feature;+use test_runner::path::get_test_model_path;use test_tag::tag;use tokenizers::Tokenizer;use crate::{- common::path::get_test_model_path,session::{Session,config::{DecodingConfig, RunConfig, SpeculatorConfig},diff --git a/crates/backend-uzu/unit/session/config/grammar_config.rs b/crates/backend-uzu/unit/session/config/grammar_config.rsindex ab907263a..b4650ec4e 100644--- a/crates/backend-uzu/unit/session/config/grammar_config.rs+++ b/crates/backend-uzu/unit/session/config/grammar_config.rs@@ -5,16 +5,17 @@ use std::sync::Arc;use proc_macros::uzu_test;use schemars::JsonSchema;use serde::{Deserialize, Serialize};+use test_runner::path::get_test_model_path;use test_tag::tag;use crate::{- common::{path::get_test_model_path, repeat_speculator::RepeatSpeculator},session::{Session,config::{DecodingConfig, GrammarConfig, RunConfig, SpeculatorConfig, StructuredOutput},parameter::{SamplingPolicy, SamplingSeed},types::Input,},+ speculators::repeat_speculator::RepeatSpeculator,};#[derive(Debug, Serialize, Deserialize, JsonSchema)]@@ -58,7 +59,7 @@ fn test_grammar(speculator_config: SpeculatorConfig) {RunConfig::default().tokens_limit(1024).sampling_policy(SamplingPolicy::Default).grammar_config(grammar_config);let output = session- .run(input, run_config, None::<fn(backend_uzu::session::types::Output) -> bool>)+ .run(input, run_config, None::<fn(crate::session::types::Output) -> bool>).expect("Failed to run session");let stats = output.stats;diff --git a/crates/backend-uzu/unit/session/parameter/context_mode.rs b/crates/backend-uzu/unit/session/parameter/context_mode.rsindex 416bec912..349b0fb71 100644--- a/crates/backend-uzu/unit/session/parameter/context_mode.rs+++ b/crates/backend-uzu/unit/session/parameter/context_mode.rs@@ -1,16 +1,14 @@use proc_macros::uzu_test;+use test_runner::path::get_test_model_path;use test_tag::tag;-use crate::{- common::path::get_test_model_path,- session::{- Session,- config::{DecodingConfig, RunConfig, SpeculatorConfig},- parameter::{- AsyncBatchSize, ContextLength, ContextMode, PrefillStepSize, SamplingMethod, SamplingPolicy, SamplingSeed,- },- types::{Input, Message, Output},+use crate::session::{+ Session,+ config::{DecodingConfig, RunConfig, SpeculatorConfig},+ parameter::{+ AsyncBatchSize, ContextLength, ContextMode, PrefillStepSize, SamplingMethod, SamplingPolicy, SamplingSeed,},+ types::{Input, Message, Output},};fn build_decoding_config() -> DecodingConfig {diff --git a/crates/backend-uzu/unit/speculators/prompt_lookup_speculator.rs b/crates/backend-uzu/unit/speculators/prompt_lookup_speculator.rsindex e551236f0..28227a2d9 100644--- a/crates/backend-uzu/unit/speculators/prompt_lookup_speculator.rs+++ b/crates/backend-uzu/unit/speculators/prompt_lookup_speculator.rs@@ -1,12 +1,10 @@use std::collections::HashMap;use proc_macros::uzu_test;+use test_runner::path::get_test_model_path;use tokenizers::Tokenizer;-use crate::{- common::path::get_test_model_path,- speculators::{prompt_lookup_speculator::PromptLookupSpeculator, speculator::Speculator},-};+use crate::speculators::{prompt_lookup_speculator::PromptLookupSpeculator, speculator::Speculator};fn load_tokenizer() -> Tokenizer {let tokenizer_path = get_test_model_path().join("tokenizer.json");diff --git a/crates/proc-macros/src/uzu_test.rs b/crates/proc-macros/src/uzu_test.rsindex 5d047fe9c..8fe4913b9 100644--- a/crates/proc-macros/src/uzu_test.rs+++ b/crates/proc-macros/src/uzu_test.rs@@ -30,10 +30,10 @@ pub fn uzu_test(#[test_case]#[allow(non_upper_case_globals)]- const #const_name: crate::tests::UzuTest =- crate::tests::UzuTest::Test(&crate::tests::test::TestDescAndFn {- desc: crate::tests::test::TestDesc {- name: crate::tests::test::StaticTestName(concat!(+ const #const_name: test_runner::UzuTest =+ test_runner::UzuTest::Test(&test_runner::test::TestDescAndFn {+ desc: test_runner::test::TestDesc {+ name: test_runner::test::StaticTestName(concat!(module_path!(),"::",stringify!(#name),@@ -45,13 +45,13 @@ pub fn uzu_test(start_col: column!() as usize,end_line: line!() as usize,end_col: column!() as usize,- should_panic: crate::tests::test::ShouldPanic::No,+ should_panic: test_runner::test::ShouldPanic::No,compile_fail: false,no_run: false,- test_type: crate::tests::test::TestType::Unknown,+ test_type: test_runner::test::TestType::Unknown,},- testfn: crate::tests::test::StaticTestFn(|| {- crate::tests::test::assert_test_result(#name())+ testfn: test_runner::test::StaticTestFn(|| {+ test_runner::test::assert_test_result(#name())}),});}@@ -72,7 +72,7 @@ pub fn uzu_bench(#[test_case]#[allow(non_upper_case_globals)]- const #const_name: crate::tests::UzuTest = crate::tests::UzuTest::Bench(&|| {+ const #const_name: test_runner::UzuTest = test_runner::UzuTest::Bench(&|| {let mut criterion = ::criterion::Criterion::default().configure_from_args();#name(&mut criterion);});diff --git a/crates/test-runner/Cargo.toml b/crates/test-runner/Cargo.tomlnew file mode 100644index 000000000..c7346f78c--- /dev/null+++ b/crates/test-runner/Cargo.toml@@ -0,0 +1,27 @@+[package]+name = "test-runner"+edition.workspace = true+rust-version.workspace = true+version.workspace = true+authors.workspace = true+homepage.workspace = true+repository.workspace = true+license.workspace = true++[lints]+workspace = true++[features]+default = []+nightly-harness = []++[dependencies]+criterion.workspace = true++[target.'cfg(target_os = "macos")'.dependencies]+# for getting gpu temperature+macmon.workspace = true++[target.'cfg(any(target_os = "macos", target_os = "ios"))'.dependencies]+objc2 = { workspace = true, optional = true }+objc2-foundation = { workspace = true, optional = true }diff --git a/crates/backend-uzu/src/tests/env_vars.rs b/crates/test-runner/src/env_vars.rssimilarity index 100%rename from crates/backend-uzu/src/tests/env_vars.rsrename to crates/test-runner/src/env_vars.rsdiff --git a/crates/test-runner/src/harness.rs b/crates/test-runner/src/harness.rsnew file mode 100644index 000000000..7495fa62d--- /dev/null+++ b/crates/test-runner/src/harness.rs@@ -0,0 +1,33 @@+use crate::util::enable_benchmark_gpu_capture_if_requested;++pub enum UzuTest {+ Bench(&'static dyn Fn()),+ Test(&'static test::TestDescAndFn),+}++pub fn uzu_harness(tests: &[&UzuTest]) {+ let args = std::env::args().collect::<Vec<String>>();+ let benchmarks = args.contains(&"--bench".to_string());+ if benchmarks {+ #[cfg(target_os = "ios")]+ crate::path::ios_set_current_dir();+ enable_benchmark_gpu_capture_if_requested();+ let bench_tests: Vec<&dyn Fn()> = tests+ .iter()+ .filter_map(|test| match test {+ UzuTest::Bench(test) => Some(*test),+ UzuTest::Test(_) => None,+ })+ .collect::<Vec<_>>();+ criterion::runner(bench_tests.as_slice());+ } else {+ let default_tests: Vec<&test::TestDescAndFn> = tests+ .iter()+ .filter_map(|test| match test {+ UzuTest::Bench(_) => None,+ UzuTest::Test(test) => Some(*test),+ })+ .collect::<Vec<_>>();+ test::test_main_static(&default_tests)+ }+}diff --git a/crates/test-runner/src/lib.rs b/crates/test-runner/src/lib.rsnew file mode 100644index 000000000..6aa2370db--- /dev/null+++ b/crates/test-runner/src/lib.rs@@ -0,0 +1,49 @@+#![cfg_attr(feature = "nightly-harness", feature(test))]++pub mod env_vars;+pub mod metrics;+pub mod path;+pub mod perf;+pub mod util;++#[cfg(feature = "nightly-harness")]+pub extern crate test;++#[cfg(feature = "nightly-harness")]+mod harness;++#[cfg(feature = "nightly-harness")]+pub use harness::{UzuTest, uzu_harness};++/// Invokes `$body` once per available backend, with `$B` bound to each backend type.+#[macro_export]+macro_rules! for_each_backend {+ (|$B:ident| $body:expr) => {{+ {+ type $B = backend_uzu::backends::cpu::Cpu;+ $body+ }+ #[cfg(metal_backend)]+ {+ type $B = backend_uzu::backends::metal::Metal;+ $body+ }+ }};+}++#[macro_export]+macro_rules! for_each_non_cpu_backend {+ (|$B:ident| $body:expr) => {{+ #[cfg(metal_backend)]+ {+ type $B = backend_uzu::backends::metal::Metal;+ $body+ }+ {+ if false {+ type $B = backend_uzu::backends::cpu::Cpu;+ $body+ }+ }+ }};+}diff --git a/crates/backend-uzu/tests/common/metrics.rs b/crates/test-runner/src/metrics.rssimilarity index 100%rename from crates/backend-uzu/tests/common/metrics.rsrename to crates/test-runner/src/metrics.rsdiff --git a/crates/backend-uzu/tests/common/path.rs b/crates/test-runner/src/path.rssimilarity index 100%rename from crates/backend-uzu/tests/common/path.rsrename to crates/test-runner/src/path.rsdiff --git a/crates/backend-uzu/tests/common/perf.rs b/crates/test-runner/src/perf.rssimilarity index 100%rename from crates/backend-uzu/tests/common/perf.rsrename to crates/test-runner/src/perf.rsdiff --git a/crates/test-runner/src/util.rs b/crates/test-runner/src/util.rsnew file mode 100644index 000000000..b25b914c5--- /dev/null+++ b/crates/test-runner/src/util.rs@@ -0,0 +1,9 @@+use crate::env_vars;++pub fn enable_benchmark_gpu_capture_if_requested() {+ if env_vars::enabled(env_vars::UZU_CAPTURE_BENCH) {+ unsafe {+ std::env::set_var(env_vars::METAL_CAPTURE_ENABLED, "1");+ }+ }+}