A high-performance inference engine for AI models
Custom test harness (#533)
Aleksandr Golokoz643faf72bf28
diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.ymlindex 36e72261d..68b03ccbf 100644--- a/.github/workflows/tests.yml+++ b/.github/workflows/tests.yml@@ -121,7 +121,7 @@ jobs:- name: Run testsif: ${{ matrix.backend != 'cpu' && matrix.tracing && matrix.grammar || matrix.backend == 'cpu' && !matrix.tracing && !matrix.grammar && matrix.target == 'wasm32-wasip1-threads' }}run: |- cargo +stable nextest run --profile=ci --no-default-features $FEATURE_FLAGS \+ cargo +nightly nextest run --profile=ci --no-default-features $FEATURE_FLAGS \${{ matrix.target == 'wasm32-wasip1-threads' && '-p backend-uzu backends::common::kernel::tests --lib' || '' }}validate-bindings:diff --git a/crates/backend-uzu/src/inference/chat/bridging.rs b/crates/backend-uzu/src/inference/chat/bridging.rsindex 54457482d..e756babdc 100644--- a/crates/backend-uzu/src/inference/chat/bridging.rs+++ b/crates/backend-uzu/src/inference/chat/bridging.rs@@ -204,6 +204,7 @@ fn build_stats(stats: &Stats) -> ShojiStats {#[cfg(test)]mod tests {+ use proc_macros::uzu_test;use shoji::types::session::chat::ChatMessage;use super::*;@@ -216,12 +217,12 @@ mod tests {ChatMessage::user().with_text("hi".to_string()).with_reasoning_effort(reasoning_effort)}- #[test]+ #[uzu_test]fn enable_thinking_defaults_on_without_effort() {assert!(enable_thinking_for(vec![ChatMessage::user().with_text("hi".to_string())]));}- #[test]+ #[uzu_test]fn enable_thinking_follows_latest_turn() {let reenabled = vec![user(ReasoningEffort::Disabled),diff --git a/crates/backend-uzu/src/lib.rs b/crates/backend-uzu/src/lib.rsindex f4507b352..f7ea4d243 100644--- a/crates/backend-uzu/src/lib.rs+++ b/crates/backend-uzu/src/lib.rs@@ -1,3 +1,6 @@+#![cfg_attr(test, feature(custom_test_frameworks, test))]+#![cfg_attr(test, test_runner(crate::harness::uzu_harness))]+// needed for tests to resolve `backend_uzu::` imports#[cfg(test)]extern crate self as backend_uzu;@@ -34,3 +37,7 @@ pub mod _benchmarks {trie::{TrieCreationConfig, TrieNode},};}++#[cfg(test)]+#[path = "../tests/harness/mod.rs"]+mod harness;diff --git a/crates/backend-uzu/src/session/config/tts_run_config.rs b/crates/backend-uzu/src/session/config/tts_run_config.rsindex d8c7780c6..e76a2081d 100644--- a/crates/backend-uzu/src/session/config/tts_run_config.rs+++ b/crates/backend-uzu/src/session/config/tts_run_config.rs@@ -109,9 +109,11 @@ impl Default for TtsRunConfig {#[cfg(test)]mod tests {+ use proc_macros::uzu_test;+use super::{TtsChunkPolicy, TtsNonStreamingMode, TtsRunConfig};- #[test]+ #[uzu_test]fn default_run_config_matches_production_defaults() {let config = TtsRunConfig::default();assert!(config.streaming_enabled);@@ -128,7 +130,7 @@ mod tests {assert!((config.chunk_hysteresis_fraction - 0.25).abs() < f64::EPSILON);}- #[test]+ #[uzu_test]fn fixed_chunk_constructor_sets_bounds() {let config = TtsRunConfig::fixed_chunk_frames(64);assert_eq!(config.chunk_policy, TtsChunkPolicy::Fixed);@@ -137,7 +139,7 @@ mod tests {assert_eq!(config.max_chunk_frames, 64);}- #[test]+ #[uzu_test]fn run_config_validation_rejects_invalid_bounds() {let invalid = TtsRunConfig {min_chunk_frames: 32,@@ -147,7 +149,7 @@ mod tests {assert!(invalid.validate().is_err());}- #[test]+ #[uzu_test]fn run_config_validation_rejects_zero_initial_chunk() {let invalid = TtsRunConfig {initial_chunk_frames: 0,@@ -156,7 +158,7 @@ mod tests {assert!(invalid.validate().is_err());}- #[test]+ #[uzu_test]fn run_config_validation_rejects_zero_semantic_cap() {let invalid = TtsRunConfig {max_semantic_frames: 0,@@ -165,7 +167,7 @@ mod tests {assert!(invalid.validate().is_err());}- #[test]+ #[uzu_test]fn run_config_validation_rejects_zero_workspace_frames() {let invalid = TtsRunConfig {max_stream_workspace_frames: 0,@@ -174,7 +176,7 @@ mod tests {assert!(invalid.validate().is_err());}- #[test]+ #[uzu_test]fn run_config_validation_rejects_workspace_smaller_than_max_chunk() {let invalid = TtsRunConfig {max_chunk_frames: 256,diff --git a/crates/backend-uzu/src/session/helpers/output_parser.rs b/crates/backend-uzu/src/session/helpers/output_parser.rsindex 8a36682f6..a035b2c63 100644--- a/crates/backend-uzu/src/session/helpers/output_parser.rs+++ b/crates/backend-uzu/src/session/helpers/output_parser.rs@@ -76,11 +76,13 @@ impl OutputParser {#[cfg(test)]mod tests {+ use proc_macros::uzu_test;+use super::*;const QWEN_REGEX: &str = r"(?s)(?:<think>)?(?P<chain_of_thought>.*?)(?:</think>\s*(?P<response>.*))?\Z";- #[test]+ #[uzu_test]fn thinking_enabled_splits_on_close_tag() {let parser = OutputParser::new(Some(QWEN_REGEX.to_string())).unwrap();let parsed = parser.parse("Let me compute.</think>2 + 2 equals 4.".to_string(), true).parsed;@@ -88,7 +90,7 @@ mod tests {assert_eq!(parsed.response.as_deref(), Some("2 + 2 equals 4."));}- #[test]+ #[uzu_test]fn thinking_disabled_keeps_answer_as_response() {let parser = OutputParser::new(Some(QWEN_REGEX.to_string())).unwrap();let parsed = parser.parse("2 + 2 equals 4.".to_string(), false).parsed;@@ -96,7 +98,7 @@ mod tests {assert_eq!(parsed.response.as_deref(), Some("2 + 2 equals 4."));}- #[test]+ #[uzu_test]fn thinking_disabled_strips_emitted_reasoning_tags() {let parser = OutputParser::new(Some(QWEN_REGEX.to_string())).unwrap();let parsed = parser.parse("<think>wait, reconsider</think>2 + 2 equals 4.".to_string(), false).parsed;@@ -104,7 +106,7 @@ mod tests {assert_eq!(parsed.response.as_deref(), Some("2 + 2 equals 4."));}- #[test]+ #[uzu_test]fn thinking_enabled_without_close_tag_is_still_reasoning() {let parser = OutputParser::new(Some(QWEN_REGEX.to_string())).unwrap();let parsed = parser.parse("Let me compute".to_string(), true).parsed;diff --git a/crates/backend-uzu/tests/harness/mod.rs b/crates/backend-uzu/tests/harness/mod.rsnew file mode 100644index 000000000..4cccf7a44--- /dev/null+++ b/crates/backend-uzu/tests/harness/mod.rs@@ -0,0 +1,18 @@+#![cfg(test)]++mod uzu_test;++pub extern crate test;++pub use uzu_test::UzuTest;++pub fn uzu_harness(tests: &[&UzuTest]) {+ let tests = tests+ .iter()+ .filter_map(|test| match test {+ UzuTest::Test(test) => Some(*test),+ UzuTest::Bench(_) => None,+ })+ .collect::<Vec<_>>();+ test::test_main_static(&tests)+}diff --git a/crates/backend-uzu/tests/harness/uzu_test.rs b/crates/backend-uzu/tests/harness/uzu_test.rsnew file mode 100644index 000000000..abfcb1036--- /dev/null+++ b/crates/backend-uzu/tests/harness/uzu_test.rs@@ -0,0 +1,7 @@+extern crate test;++pub enum UzuTest {+ #[allow(dead_code)]+ Bench(&'static dyn Fn()),+ Test(&'static test::TestDescAndFn),+}diff --git a/crates/backend-uzu/tests/integration_entry.rs b/crates/backend-uzu/tests/integration_entry.rsindex 6d3bbe604..0b9b7d9f6 100644--- a/crates/backend-uzu/tests/integration_entry.rs+++ b/crates/backend-uzu/tests/integration_entry.rs@@ -1 +1,7 @@+#![feature(custom_test_frameworks, test)]+#![test_runner(crate::harness::uzu_harness)]++#[path = "harness/mod.rs"]+mod harness;+mod integration;diff --git a/crates/backend-uzu/tests/performance_entry.rs b/crates/backend-uzu/tests/performance_entry.rsindex f0d6f6ba7..e291f028d 100644--- a/crates/backend-uzu/tests/performance_entry.rs+++ b/crates/backend-uzu/tests/performance_entry.rs@@ -1,2 +1,8 @@+#![feature(custom_test_frameworks, test)]+#![test_runner(crate::harness::uzu_harness)]++#[path = "harness/mod.rs"]+mod harness;+mod common;mod performance;diff --git a/crates/backend-uzu/unit/audio/types_test.rs b/crates/backend-uzu/unit/audio/types_test.rsindex 89814d78e..3cc69dbe0 100644--- a/crates/backend-uzu/unit/audio/types_test.rs+++ b/crates/backend-uzu/unit/audio/types_test.rs@@ -1,6 +1,8 @@+use proc_macros::uzu_test;+use super::{AudioError, AudioTokenGrid};-#[test]+#[uzu_test]fn token_grid_get_reads_expected_slots() {let grid = AudioTokenGrid::new(vec![@@ -21,7 +23,7 @@ fn token_grid_get_reads_expected_slots() {assert_eq!(grid.get(1, 1, 1), 7);}-#[test]+#[uzu_test]fn invalid_grid_shape_is_rejected() {let error = AudioTokenGrid::new(vec![0, 1, 2].into_boxed_slice(), 1, 2, 2, vec![2].into_boxed_slice()).expect_err("shape mismatch should fail");diff --git a/crates/backend-uzu/unit/backends/common/allocator/allocator.rs b/crates/backend-uzu/unit/backends/common/allocator/allocator.rsindex bc4351f06..a9d00f340 100644--- a/crates/backend-uzu/unit/backends/common/allocator/allocator.rs+++ b/crates/backend-uzu/unit/backends/common/allocator/allocator.rs@@ -6,6 +6,7 @@ use std::{time::Instant,};+use proc_macros::uzu_test;use serde::{Deserialize, Serialize};use crate::backends::{@@ -48,7 +49,7 @@ enum TraceEventType {},}-#[test]+#[uzu_test]#[ignore]fn bench_allocator_generation_trace() {let file = BufReader::with_capacity(1 << 20, File::open("/tmp/allocator_trace.jsonl").unwrap());diff --git a/crates/backend-uzu/unit/backends/common/hazard_tracker_test.rs b/crates/backend-uzu/unit/backends/common/hazard_tracker_test.rsindex b3d51d89b..8a794cda4 100644--- a/crates/backend-uzu/unit/backends/common/hazard_tracker_test.rs+++ b/crates/backend-uzu/unit/backends/common/hazard_tracker_test.rs@@ -1,6 +1,8 @@+use proc_macros::uzu_test;+use super::*;-#[test]+#[uzu_test]fn test_hazard_tracker_simple_compute_sequence() {let mut ht = HazardTracker::new();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 09439d4dd..daffa67c5 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@@ -4,6 +4,7 @@ use std::fmt::{Debug, Display};use half::bf16;use num_traits::Float;+use proc_macros::uzu_test;use rstest::rstest;use crate::{@@ -63,6 +64,7 @@ fn run_matrix<T: ArrayElement + Float + Debug + Display>(}#[rstest]+#[test_attr(uzu_test)]#[case::base(1.0, false)]#[case::ab_scale(0.5, false)]#[case::accumulate(1.0, true)]@@ -74,12 +76,12 @@ fn matches_cpu_reference_bf16(run_matrix::<bf16>(|shape| Case::new(shape).with_ab_scale(ab_scale).with_accumulate(accumulate), 1.0);}-#[test]+#[uzu_test]fn matches_cpu_reference_f32() {run_matrix::<f32>(Case::new, 0.01);}-#[test]+#[uzu_test]fn b_transpose_false_bf16() {run_matrix::<bf16>(|shape| Case {@@ -95,7 +97,7 @@ fn rht_shapes() -> impl Iterator<Item = crate::common::matmul::Shape> {[Shape::new(8, 128, 64), Shape::new(64, 128, 128), Shape::new(128, 2048, 256), Shape::new(33, 128, 64)].into_iter()}-#[test]+#[uzu_test]fn rht_parity_bf16() {let context = MetalContext::new().expect("Metal context");let mut kernel = <<Metal as Backend>::Kernels as Kernels>::MatmulKernel::new(@@ -113,7 +115,7 @@ fn rht_parity_bf16() {}}-#[test]+#[uzu_test]fn bias_parity_bf16() {use crate::common::matmul::Shape;let context = MetalContext::new().expect("Metal context");@@ -133,7 +135,7 @@ fn bias_parity_bf16() {}}-#[test]+#[uzu_test]fn gemv_fp_partial_output_block_bf16() {use crate::common::matmul::Shape;let context = MetalContext::new().expect("Metal context");@@ -152,7 +154,7 @@ fn gemv_fp_partial_output_block_bf16() {}}-#[test]+#[uzu_test]fn gemv_fp_output_transforms_bf16() {use crate::common::matmul::Shape;let context = MetalContext::new().expect("Metal context");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 d080c73f5..b65d1bf59 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@@ -2,6 +2,7 @@ use std::fmt::{Debug, Display};use half::bf16;use num_traits::Float;+use proc_macros::uzu_test;use rstest::rstest;use crate::{@@ -106,6 +107,7 @@ fn test<T: ArrayElement + Float + Debug + Display>(}#[rstest]+#[test_attr(uzu_test)]#[case::m1(1, 128, 64)]#[case::batched(4, 128, 64)]#[case::max_batch(8, 128, 64)]@@ -122,6 +124,7 @@ fn gemv_bf16(}#[rstest]+#[test_attr(uzu_test)]#[case::m1(1, 128, 64)]#[case::batched(4, 128, 64)]#[case::max_batch(8, 128, 64)]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 fba4d7f8b..2524b0a1c 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@@ -91,6 +91,7 @@ fn run_parity<T: ArrayElement + Float + Debug + Display>(}#[rstest]+#[test_attr(uzu_test)]#[case::gs16_4bit_zp_prefill(64, 256, 64, 16, 4, QuantizationMethod::ScaleZeroPoint)]#[case::gs32_4bit_mlx_prefill(64, 256, 64, 32, 4, QuantizationMethod::ScaleBias)]#[case::gs64_4bit_mlx_prefill(64, 256, 64, 64, 4, QuantizationMethod::ScaleBias)]@@ -112,6 +113,7 @@ fn parity_bf16(}#[rstest]+#[test_attr(uzu_test)]#[case::gs32_8bit_mlx_prefill(64, 256, 64, 32, 8, QuantizationMethod::ScaleBias)]#[case::gs64_8bit_zp_prefill(64, 256, 64, 64, 8, QuantizationMethod::ScaleZeroPoint)]#[case::gs128_8bit_zp_prefill(64, 256, 64, 128, 8, QuantizationMethod::ScaleZeroPoint)]@@ -154,6 +156,7 @@ fn run_parity_gemv<T: ArrayElement + Float + Debug + Display>(}#[rstest]+#[test_attr(uzu_test)]#[case::m1_gs32_4bit_mlx(1, 256, 64, 32, 4, QuantizationMethod::ScaleBias)]#[case::m1_gs64_4bit_mlx(1, 256, 64, 64, 4, QuantizationMethod::ScaleBias)]#[case::m1_gs128_4bit_mlx(1, 256, 64, 128, 4, QuantizationMethod::ScaleBias)]@@ -261,6 +264,7 @@ fn parity_bf16_gemv_qmv_fused_scale_bias() {}#[rstest]+#[test_attr(uzu_test)]#[case::gs64_4bit(1, 96, 64, 64, 4, QuantizationMethod::ScaleBias)]#[case::gs64_4bit_zp(2, 96, 64, 64, 4, QuantizationMethod::ScaleZeroPoint)]#[case::gs128_8bit(1, 192, 64, 128, 8, QuantizationMethod::ScaleBias)]@@ -278,6 +282,7 @@ fn parity_gemv_partial_group_bf16(}#[rstest]+#[test_attr(uzu_test)]#[case::n12_gs32_4bit(1, 256, 12, 32, 4, QuantizationMethod::ScaleBias)]#[case::n20_gs64_4bit_zp(2, 256, 20, 64, 4, QuantizationMethod::ScaleZeroPoint)]#[case::n36_gs32_8bit(1, 256, 36, 32, 8, QuantizationMethod::ScaleBias)]@@ -497,6 +502,7 @@ fn quant_gemm_accumulate_returns_unsupported_dop() {}#[rstest]+#[test_attr(uzu_test)]#[case::gs32_4bit_mlx(128, 256, 64, 32, 4, QuantizationMethod::ScaleBias)]#[case::gs64_4bit_mlx(128, 256, 64, 64, 4, QuantizationMethod::ScaleBias)]#[case::gs128_4bit_mlx(128, 256, 64, 128, 4, QuantizationMethod::ScaleBias)]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 e35cb489d..f16167f9e 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@@ -1,5 +1,7 @@use std::ops::Range;+use proc_macros::uzu_test;+use crate::{backends::{common::{Backend, SparseBuffer},@@ -26,7 +28,7 @@ fn pages_for_heaps((heap_offset * pages_per_heap)..((heap_offset + heap_count) * pages_per_heap)}-#[test]+#[uzu_test]fn test_mapping_succeeds() {let ctx = create_context::<Metal>();let capacity = buffer_capacity(ctx.as_ref(), 4);@@ -36,7 +38,7 @@ fn test_mapping_succeeds() {sparse_buffer.map(ctx.as_ref(), &pages).expect("Failed to map sparse buffer");}-#[test]+#[uzu_test]fn test_unmapping_succeeds() {let ctx = create_context::<Metal>();let capacity = buffer_capacity(ctx.as_ref(), 4);@@ -47,7 +49,7 @@ fn test_unmapping_succeeds() {sparse_buffer.unmap(ctx.as_ref(), &pages).expect("Failed to unmap sparse buffer");}-#[test]+#[uzu_test]fn test_partial_unmapping_succeeds() {let ctx = create_context::<Metal>();let capacity = buffer_capacity(ctx.as_ref(), 4);@@ -59,7 +61,7 @@ fn test_partial_unmapping_succeeds() {sparse_buffer.unmap(ctx.as_ref(), &unmapped).expect("Failed to unmap sparse buffer");}-#[test]+#[uzu_test]fn test_mapping_uses_minimum_heaps() {let ctx = create_context::<Metal>();let heap_count = 4;@@ -74,7 +76,7 @@ fn test_mapping_uses_minimum_heaps() {assert_eq!(heaps.heaps_count(), expected, "mapping should allocate the minimum number of heaps");}-#[test]+#[uzu_test]fn test_remapping_reuses_freed_pages() {let ctx = create_context::<Metal>();let capacity = buffer_capacity(ctx.as_ref(), 6);@@ -96,7 +98,7 @@ fn test_remapping_reuses_freed_pages() {);}-#[test]+#[uzu_test]fn test_full_unmap_then_remap_reuses_heaps() {let ctx = create_context::<Metal>();let capacity = buffer_capacity(ctx.as_ref(), 4);@@ -116,7 +118,7 @@ fn test_full_unmap_then_remap_reuses_heaps() {);}-#[test]+#[uzu_test]fn test_remapping_same_pages_is_noop() {let ctx = create_context::<Metal>();let capacity = buffer_capacity(ctx.as_ref(), 4);@@ -135,7 +137,7 @@ fn test_remapping_same_pages_is_noop() {);}-#[test]+#[uzu_test]fn test_mapping_multiple_gaps_reserves_pages_between_gaps() {let ctx = create_context::<Metal>();let pages_per_heap = ctx.sparse_heap_pool().heap_capacity_pages();@@ -152,7 +154,7 @@ fn test_mapping_multiple_gaps_reserves_pages_between_gaps() {);}-#[test]+#[uzu_test]fn test_drop_releases_pool_heaps() {// Regression: a mapped buffer dropped without an explicit unmap must// still release its heap pages back to the shared pool.@@ -173,7 +175,7 @@ fn test_drop_releases_pool_heaps() {);}-#[test]+#[uzu_test]fn test_drop_does_not_disturb_other_buffer_mappings() {// Dropping one buffer must not unmap heap pages held by another buffer// sharing the same pool.@@ -194,7 +196,7 @@ fn test_drop_does_not_disturb_other_buffer_mappings() {assert_eq!(current_heaps, baseline, "dropping a transient buffer must leave keeper buffer's mappings intact",);}-#[test]+#[uzu_test]fn test_sequential_mappings_are_compact() {let ctx = create_context::<Metal>();let capacity = buffer_capacity(ctx.as_ref(), 4);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 a6d4c794c..4b548c75d 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@@ -1,3 +1,5 @@+use proc_macros::uzu_test;+use crate::{backends::{common::SparseBuffer,@@ -6,13 +8,13 @@ use crate::{common::helpers::{create_context, sparse_buffer_create},};-#[test]+#[uzu_test]fn test_new_pool_is_empty() {let ctx = create_context::<Metal>();assert_eq!(ctx.sparse_heap_pool().heaps_count(), 0);}-#[test]+#[uzu_test]fn test_map_empty_range_allocates_no_heaps() {let ctx = create_context::<Metal>();let cap = ctx.sparse_heap_pool().heap_capacity_bytes();@@ -23,7 +25,7 @@ fn test_map_empty_range_allocates_no_heaps() {assert_eq!(ctx.sparse_heap_pool().heaps_count(), 0);}-#[test]+#[uzu_test]fn test_map_single_heap_allocates_one_heap() {let ctx = create_context::<Metal>();let pages_per_heap = ctx.sparse_heap_pool().heap_capacity_pages();@@ -35,7 +37,7 @@ fn test_map_single_heap_allocates_one_heap() {assert_eq!(ctx.sparse_heap_pool().heaps_count(), 1);}-#[test]+#[uzu_test]fn test_map_multi_heap_allocates_minimum_heaps() {let ctx = create_context::<Metal>();let pages_per_heap = ctx.sparse_heap_pool().heap_capacity_pages();@@ -47,7 +49,7 @@ fn test_map_multi_heap_allocates_minimum_heaps() {assert_eq!(ctx.sparse_heap_pool().heaps_count(), 4);}-#[test]+#[uzu_test]fn test_map_partial_heap_rounds_up_heap_count() {let ctx = create_context::<Metal>();let pages_per_heap = ctx.sparse_heap_pool().heap_capacity_pages();@@ -59,7 +61,7 @@ fn test_map_partial_heap_rounds_up_heap_count() {assert_eq!(ctx.sparse_heap_pool().heaps_count(), 2);}-#[test]+#[uzu_test]fn test_sequential_mappings_pack_into_one_heap() {let ctx = create_context::<Metal>();let pages_per_heap = ctx.sparse_heap_pool().heap_capacity_pages();@@ -73,7 +75,7 @@ fn test_sequential_mappings_pack_into_one_heap() {assert_eq!(ctx.sparse_heap_pool().heaps_count(), 1);}-#[test]+#[uzu_test]fn test_map_overflows_existing_heap_into_new_heap() {let ctx = create_context::<Metal>();let pages_per_heap = ctx.sparse_heap_pool().heap_capacity_pages();@@ -87,7 +89,7 @@ fn test_map_overflows_existing_heap_into_new_heap() {assert_eq!(ctx.sparse_heap_pool().heaps_count(), 2);}-#[test]+#[uzu_test]fn test_two_buffers_share_one_heap() {let ctx = create_context::<Metal>();let pages_per_heap = ctx.sparse_heap_pool().heap_capacity_pages();@@ -102,7 +104,7 @@ fn test_two_buffers_share_one_heap() {assert_eq!(ctx.sparse_heap_pool().heaps_count(), 1);}-#[test]+#[uzu_test]fn test_full_unmap_removes_heaps() {let ctx = create_context::<Metal>();let pages_per_heap = ctx.sparse_heap_pool().heap_capacity_pages();@@ -116,7 +118,7 @@ fn test_full_unmap_removes_heaps() {assert_eq!(ctx.sparse_heap_pool().heaps_count(), 0);}-#[test]+#[uzu_test]fn test_partial_unmap_keeps_heap() {let ctx = create_context::<Metal>();let pages_per_heap = ctx.sparse_heap_pool().heap_capacity_pages();@@ -129,7 +131,7 @@ fn test_partial_unmap_keeps_heap() {assert_eq!(ctx.sparse_heap_pool().heaps_count(), 1);}-#[test]+#[uzu_test]fn test_unmap_with_other_buffer_keeps_mappings() {let ctx = create_context::<Metal>();let pages_per_heap = ctx.sparse_heap_pool().heap_capacity_pages();@@ -144,7 +146,7 @@ fn test_unmap_with_other_buffer_keeps_mappings() {assert_eq!(ctx.sparse_heap_pool().heaps_count(), 1);}-#[test]+#[uzu_test]fn test_unmap_one_buffer_keeps_heap_for_other() {let ctx = create_context::<Metal>();let pages_per_heap = ctx.sparse_heap_pool().heap_capacity_pages();@@ -160,7 +162,7 @@ fn test_unmap_one_buffer_keeps_heap_for_other() {assert_eq!(ctx.sparse_heap_pool().heaps_count(), 1);}-#[test]+#[uzu_test]fn test_remap_after_unmap_does_not_grow_pool() {let ctx = create_context::<Metal>();let pages_per_heap = ctx.sparse_heap_pool().heap_capacity_pages();@@ -176,7 +178,7 @@ fn test_remap_after_unmap_does_not_grow_pool() {assert_eq!(ctx.sparse_heap_pool().heaps_count(), initial);}-#[test]+#[uzu_test]fn test_remap_into_freed_gap_reuses_heap() {let ctx = create_context::<Metal>();let pages_per_heap = ctx.sparse_heap_pool().heap_capacity_pages();@@ -191,7 +193,7 @@ fn test_remap_into_freed_gap_reuses_heap() {assert_eq!(ctx.sparse_heap_pool().heaps_count(), 1);}-#[test]+#[uzu_test]fn test_sequential_partial_unmaps_release_full_heap() {// Regression: after a partial unmap splits a rangemap entry, the surviving// entry must still report the correct buffer↔heap correspondence so that a@@ -209,7 +211,7 @@ fn test_sequential_partial_unmaps_release_full_heap() {assert_eq!(ctx.sparse_heap_pool().heaps_count(), 0);}-#[test]+#[uzu_test]fn test_three_buffers_share_one_heap() {let ctx = create_context::<Metal>();let pages_per_heap = ctx.sparse_heap_pool().heap_capacity_pages();@@ -226,7 +228,7 @@ fn test_three_buffers_share_one_heap() {assert_eq!(ctx.sparse_heap_pool().heaps_count(), 1);}-#[test]+#[uzu_test]fn test_two_buffers_exactly_fill_one_heap() {let ctx = create_context::<Metal>();let pages_per_heap = ctx.sparse_heap_pool().heap_capacity_pages();@@ -241,7 +243,7 @@ fn test_two_buffers_exactly_fill_one_heap() {assert_eq!(ctx.sparse_heap_pool().heaps_count(), 1);}-#[test]+#[uzu_test]fn test_third_buffer_spills_when_heap_filled_by_others() {let ctx = create_context::<Metal>();let pages_per_heap = ctx.sparse_heap_pool().heap_capacity_pages();@@ -258,7 +260,7 @@ fn test_third_buffer_spills_when_heap_filled_by_others() {assert_eq!(ctx.sparse_heap_pool().heaps_count(), 2);}-#[test]+#[uzu_test]fn test_unmap_buffer_frees_pages_for_another_in_same_heap() {let ctx = create_context::<Metal>();let pages_per_heap = ctx.sparse_heap_pool().heap_capacity_pages();@@ -276,7 +278,7 @@ fn test_unmap_buffer_frees_pages_for_another_in_same_heap() {assert_eq!(ctx.sparse_heap_pool().heaps_count(), 1);}-#[test]+#[uzu_test]fn test_unmap_middle_of_three_buffers_keeps_heap() {let ctx = create_context::<Metal>();let pages_per_heap = ctx.sparse_heap_pool().heap_capacity_pages();@@ -294,7 +296,7 @@ fn test_unmap_middle_of_three_buffers_keeps_heap() {assert_eq!(ctx.sparse_heap_pool().heaps_count(), 1);}-#[test]+#[uzu_test]fn test_unmap_all_shared_buffers_releases_heap() {let ctx = create_context::<Metal>();let pages_per_heap = ctx.sparse_heap_pool().heap_capacity_pages();@@ -314,7 +316,7 @@ fn test_unmap_all_shared_buffers_releases_heap() {assert_eq!(ctx.sparse_heap_pool().heaps_count(), 0);}-#[test]+#[uzu_test]fn test_second_buffer_spans_existing_and_new_heap() {let ctx = create_context::<Metal>();let pages_per_heap = ctx.sparse_heap_pool().heap_capacity_pages();@@ -329,7 +331,7 @@ fn test_second_buffer_spans_existing_and_new_heap() {assert_eq!(ctx.sparse_heap_pool().heaps_count(), 2);}-#[test]+#[uzu_test]fn test_unmap_spanning_buffer_keeps_heap_with_other_buffer() {let ctx = create_context::<Metal>();let pages_per_heap = ctx.sparse_heap_pool().heap_capacity_pages();@@ -345,7 +347,7 @@ fn test_unmap_spanning_buffer_keeps_heap_with_other_buffer() {assert_eq!(ctx.sparse_heap_pool().heaps_count(), 1);}-#[test]+#[uzu_test]fn test_remap_two_buffers_after_unmap_does_not_grow_pool() {let ctx = create_context::<Metal>();let pages_per_heap = ctx.sparse_heap_pool().heap_capacity_pages();@@ -365,7 +367,7 @@ fn test_remap_two_buffers_after_unmap_does_not_grow_pool() {assert_eq!(ctx.sparse_heap_pool().heaps_count(), initial);}-#[test]+#[uzu_test]fn test_heap_capacity_pages_matches_byte_capacity() {let ctx = create_context::<Metal>();let pool = ctx.sparse_heap_pool();diff --git a/crates/backend-uzu/unit/encodable_block/attention_gemm_test.rs b/crates/backend-uzu/unit/encodable_block/attention_gemm_test.rsindex dd97c47ee..b9575780d 100644--- a/crates/backend-uzu/unit/encodable_block/attention_gemm_test.rs+++ b/crates/backend-uzu/unit/encodable_block/attention_gemm_test.rs@@ -2,6 +2,7 @@ use std::fmt::{Debug, Display};use half::{bf16, f16};use num_traits::Float;+use proc_macros::uzu_test;use super::{AttentionGemmArguments, AttentionGemmBlock};use crate::{@@ -194,81 +195,81 @@ fn test_unaligned<T: ArrayElement + Float + Debug + Display>() {}// Basic tests-#[test]+#[uzu_test]fn test_basic_f32() {test_basic::<f32>();}-#[test]+#[uzu_test]fn test_basic_f16() {test_basic::<f16>();}-#[test]+#[uzu_test]fn test_basic_bf16() {test_basic::<bf16>();}// Causal tests-#[test]+#[uzu_test]fn test_causal_f32() {test_causal::<f32>();}-#[test]+#[uzu_test]fn test_causal_f16() {test_causal::<f16>();}-#[test]+#[uzu_test]fn test_causal_bf16() {test_causal::<bf16>();}// GQA tests-#[test]+#[uzu_test]fn test_gqa_f32() {test_gqa::<f32>();}-#[test]+#[uzu_test]fn test_gqa_f16() {test_gqa::<f16>();}-#[test]+#[uzu_test]fn test_gqa_bf16() {test_gqa::<bf16>();}// Head dim 128-#[test]+#[uzu_test]fn test_head_dim_128_f32() {test_head_dim::<f32>(128);}-#[test]+#[uzu_test]fn test_head_dim_128_f16() {test_head_dim::<f16>(128);}-#[test]+#[uzu_test]fn test_head_dim_128_bf16() {test_head_dim::<bf16>(128);}// Unaligned tests-#[test]+#[uzu_test]fn test_unaligned_f32() {test_unaligned::<f32>();}-#[test]+#[uzu_test]fn test_unaligned_f16() {test_unaligned::<f16>();}-#[test]+#[uzu_test]fn test_unaligned_bf16() {test_unaligned::<bf16>();}diff --git a/crates/backend-uzu/unit/encodable_block/attention_test.rs b/crates/backend-uzu/unit/encodable_block/attention_test.rsindex fcc747468..e652055cf 100644--- a/crates/backend-uzu/unit/encodable_block/attention_test.rs+++ b/crates/backend-uzu/unit/encodable_block/attention_test.rs@@ -1,6 +1,7 @@#![cfg(metal_backend)]use ndarray::{Array4, s};+use proc_macros::uzu_test;use test_tag::tag;use super::{AttentionGemmArguments, AttentionGemmBlock};@@ -374,7 +375,7 @@ fn compare_results(Ok(())}-#[test]+#[uzu_test]fn test_single_pass_attention_basic() {let context = <Metal as Backend>::Context::new().expect("Failed to create <Metal as Backend>::Context");@@ -394,7 +395,7 @@ fn test_single_pass_attention_basic() {compare_results(&kernel_output, &reference_output, 1e-2, "Single-pass attention").unwrap();}-#[test]+#[uzu_test]fn test_gemm_attention_basic() {let context = <Metal as Backend>::Context::new().expect("Failed to create <Metal as Backend>::Context");@@ -415,7 +416,7 @@ fn test_gemm_attention_basic() {compare_results(&kernel_output, &reference_output, 1e-2, "Gemm attention").unwrap();}-#[test]+#[uzu_test]fn test_gemm_attention_f32_head_dim_128() {let context = <Metal as Backend>::Context::new().expect("Failed to create <Metal as Backend>::Context");@@ -436,7 +437,7 @@ fn test_gemm_attention_f32_head_dim_128() {compare_results(&kernel_output, &reference_output, 1e-2, "Gemm attention f32 head_dim=128").unwrap();}-#[test]+#[uzu_test]fn test_matrix_attention_matches_vector_and_cpu_seq256() {let context = <Metal as Backend>::Context::new().expect("Failed to create <Metal as Backend>::Context");@@ -472,7 +473,7 @@ fn test_matrix_attention_matches_vector_and_cpu_seq256() {);}-#[test]+#[uzu_test]fn test_single_pass_attention_with_sinks() {let context = <Metal as Backend>::Context::new().expect("Failed to create <Metal as Backend>::Context");@@ -495,7 +496,7 @@ fn test_single_pass_attention_with_sinks() {compare_results(&kernel_output, &reference_output, 1e-2, "Single-pass attention with sinks").unwrap();}-#[test]+#[uzu_test]fn test_single_pass_attention_with_sinks_long_sequence() {let context = <Metal as Backend>::Context::new().expect("Failed to create <Metal as Backend>::Context");@@ -519,7 +520,7 @@ fn test_single_pass_attention_with_sinks_long_sequence() {.unwrap();}-#[test]+#[uzu_test]fn test_single_pass_attention_gqa() {let context = <Metal as Backend>::Context::new().expect("Failed to create <Metal as Backend>::Context");@@ -608,7 +609,7 @@ fn run_two_pass_attention(Ok(kernel_output)}-#[test]+#[uzu_test]fn test_two_pass_attention() {let context = <Metal as Backend>::Context::new().expect("Failed to create <Metal as Backend>::Context");@@ -632,7 +633,7 @@ fn test_two_pass_attention() {compare_results(&kernel_output, &reference_output, 1e-2, "Two-pass attention").unwrap();}-#[test]+#[uzu_test]fn test_two_pass_attention_gqa() {let context = <Metal as Backend>::Context::new().expect("Failed to create <Metal as Backend>::Context");@@ -657,7 +658,7 @@ fn test_two_pass_attention_gqa() {}#[tag(heavy)]-#[test]+#[uzu_test]fn perf_two_pass_attention() {use std::time::Instant;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 948b816fd..90568f4cd 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@@ -1,6 +1,7 @@#![cfg(metal_backend)]use ndarray::{Array, Array3, s};+use proc_macros::uzu_test;use super::*;use crate::{@@ -107,7 +108,7 @@ fn test_random_pattern<B: Backend>(context: &B::Context) {assert_eq!(value_result, expected_values);}-#[test]+#[uzu_test]fn test_kv_cache_update_kernel() {let metal_context = match <Metal as Backend>::Context::new() {Ok(ctx) => ctx,@@ -120,7 +121,7 @@ fn test_kv_cache_update_kernel() {test_random_pattern::<Metal>(&metal_context);}-#[test]+#[uzu_test]fn test_direct_swaps() {let sources = [0, 2, 4];let destinations = [1, 3, 5];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 c4a301759..91ff51944 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,3 +1,5 @@+use proc_macros::uzu_test;+use super::{SSDPrefillArguments, SSDPrefillBlock, SSDPrefillMode};use crate::{backends::common::{Backend, Context, Encoder, Kernels, gpu_types::ActivationType, kernel::Conv1dScanKernel},@@ -387,35 +389,35 @@ fn conv1d_scan_deterministic_internal<B: Backend>() {}}-#[test]+#[uzu_test]fn ssd_prefill_sequential_is_deterministic() {for_each_non_cpu_backend!(|B| {assert_deterministic_for_mode::<B>(SSDPrefillMode::Sequential);});}-#[test]+#[uzu_test]fn ssd_prefill_single_pass_is_deterministic() {for_each_non_cpu_backend!(|B| {assert_deterministic_for_mode::<B>(SSDPrefillMode::SinglePass);});}-#[test]+#[uzu_test]fn ssd_prefill_sequential_matches_cpu_reference() {for_each_non_cpu_backend!(|B| {assert_matches_cpu_reference::<B>(SSDPrefillMode::Sequential);});}-#[test]+#[uzu_test]fn ssd_prefill_single_pass_matches_cpu_reference() {for_each_non_cpu_backend!(|B| {assert_matches_cpu_reference::<B>(SSDPrefillMode::SinglePass);});}-#[test]+#[uzu_test]fn conv1d_scan_is_deterministic() {for_each_non_cpu_backend!(|B| {conv1d_scan_deterministic_internal::<B>();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 4fc9c9797..507f83bf7 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,4 +1,5 @@use half::bf16;+use proc_macros::uzu_test;use rand::{RngExt, SeedableRng, rngs::StdRng};use super::{MoeExpertsTwoPassArguments, MoeExpertsTwoPassPrefillBlock, MoeGather};@@ -626,7 +627,7 @@ fn run_moe_parity_test_internal<B: Backend>(}// Test 1: Minimal (K=1, small dims, no clipping, alpha=1.0)-#[test]+#[uzu_test]fn test_moe_minimal() {for_each_non_cpu_backend!(|B| {let ctx = create_context::<B>();@@ -648,7 +649,7 @@ fn test_moe_minimal() {}// Test 2: Multi-expert (K=2, tests finalize weighted sum)-#[test]+#[uzu_test]fn test_moe_multi_expert() {for_each_non_cpu_backend!(|B| {let ctx = create_context::<B>();@@ -670,7 +671,7 @@ fn test_moe_multi_expert() {}// Test 3: Large d_model only (K=1 to isolate from finalize complexity)-#[test]+#[uzu_test]fn test_moe_large_d_model_only() {for_each_non_cpu_backend!(|B| {let ctx = create_context::<B>();@@ -692,7 +693,7 @@ fn test_moe_large_d_model_only() {}// Test 4a: d_ff=32 (exactly 1 full chunk - baseline for multi-chunk)-#[test]+#[uzu_test]fn test_1_full_chunk() {for_each_non_cpu_backend!(|B| {let ctx = create_context::<B>();@@ -714,7 +715,7 @@ fn test_1_full_chunk() {}// Test 4b: d_ff=48 (1.5 chunks - tests partial second chunk)-#[test]+#[uzu_test]fn test_1_5_chunks() {for_each_non_cpu_backend!(|B| {let ctx = create_context::<B>();@@ -736,7 +737,7 @@ fn test_1_5_chunks() {}// Test 4c: d_ff=64 (exactly 2 full chunks)-#[test]+#[uzu_test]fn test_2_full_chunks() {for_each_non_cpu_backend!(|B| {let ctx = create_context::<B>();@@ -758,7 +759,7 @@ fn test_2_full_chunks() {}// Test 5: GELU activation (gating_code=0)-#[test]+#[uzu_test]fn test_gelu_activation() {for_each_non_cpu_backend!(|B| {let ctx = create_context::<B>();@@ -780,7 +781,7 @@ fn test_gelu_activation() {}// Test 6: SiLU activation (gating_code=1)-#[test]+#[uzu_test]fn test_silu_activation() {for_each_non_cpu_backend!(|B| {let ctx = create_context::<B>();@@ -802,7 +803,7 @@ fn test_silu_activation() {}// Test 7: GEGLU activation (gating_code=3)-#[test]+#[uzu_test]fn test_geglu_activation() {for_each_non_cpu_backend!(|B| {let ctx = create_context::<B>();@@ -824,7 +825,7 @@ fn test_geglu_activation() {}// Test 8: Bucket stress - multiple tokens, larger E, stress scatter/gather-#[test]+#[uzu_test]fn test_bucket_stress() {for_each_non_cpu_backend!(|B| {let ctx = create_context::<B>();@@ -846,7 +847,7 @@ fn test_bucket_stress() {}// Test 9a: K=4 small-scale to verify multi-expert accumulation-#[test]+#[uzu_test]fn test_small_scale() {for_each_non_cpu_backend!(|B| {let ctx = create_context::<B>();@@ -868,7 +869,7 @@ fn test_small_scale() {}// Test 9b: d_model=128 (4 k0 chunks, 2 n-tiles)-#[test]+#[uzu_test]fn test_model_128() {for_each_non_cpu_backend!(|B| {let ctx = create_context::<B>();@@ -890,7 +891,7 @@ fn test_model_128() {}// Test 9c: d_model=192 (6 k0 chunks, 3 n-tiles - test threshold)-#[test]+#[uzu_test]fn test_model_192() {for_each_non_cpu_backend!(|B| {let ctx = create_context::<B>();@@ -912,7 +913,7 @@ fn test_model_192() {}// Test 9d: d_model=256 (8 k0 chunks, 4 n-tiles)-#[test]+#[uzu_test]fn test_model_256() {for_each_non_cpu_backend!(|B| {let ctx = create_context::<B>();@@ -934,7 +935,7 @@ fn test_model_256() {}// Test 10a: Isolate large d_ff with small d_model (FF accumulation test)-#[test]+#[uzu_test]fn test_ff_accumulation() {for_each_non_cpu_backend!(|B| {let ctx = create_context::<B>();@@ -956,7 +957,7 @@ fn test_ff_accumulation() {}// Test 10b: d_model=1024 (16 n-tiles)-#[test]+#[uzu_test]fn test_model_1024() {for_each_non_cpu_backend!(|B| {let ctx = create_context::<B>();@@ -979,7 +980,7 @@ fn test_model_1024() {// Test 10c: Verify layout with d_model=96, d_ff=96 (3 chunks each)// This tests non-power-of-2 to catch stride bugs-#[test]+#[uzu_test]fn test_stride() {for_each_non_cpu_backend!(|B| {let ctx = create_context::<B>();@@ -1001,7 +1002,7 @@ fn test_stride() {}// Test 10d: d_model=1536-#[test]+#[uzu_test]fn test_model_1536() {for_each_non_cpu_backend!(|B| {let ctx = create_context::<B>();@@ -1023,7 +1024,7 @@ fn test_model_1536() {}// Test 10e: 2 n-tiles-#[test]+#[uzu_test]fn test_2n_tiles() {for_each_non_cpu_backend!(|B| {let ctx = create_context::<B>();@@ -1045,7 +1046,7 @@ fn test_2n_tiles() {}// Test 10g: 8 n-tiles - find threshold-#[test]+#[uzu_test]fn test_8n_tiles() {for_each_non_cpu_backend!(|B| {let ctx = create_context::<B>();@@ -1067,7 +1068,7 @@ fn test_8n_tiles() {}// Test 11b: Production scale with clipping but K=1-#[test]+#[uzu_test]#[ignore]fn test_prod_scale_clipping() {for_each_non_cpu_backend!(|B| {@@ -1090,7 +1091,7 @@ fn test_prod_scale_clipping() {}// Test 11c: PRODUCTION SCALE T=1 decode (triggers GEMV v2)-#[test]+#[uzu_test]#[ignore]fn test_prod_scale_decode() {for_each_non_cpu_backend!(|B| {@@ -1113,7 +1114,7 @@ fn test_prod_scale_decode() {}// Test 11d: FULL PRODUCTION SCALE with K=2, T=4 (uses tiled MMA)-#[test]+#[uzu_test]#[ignore]fn test_prod_scale_tile_mma() {for_each_non_cpu_backend!(|B| {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 4700a271f..a9d14fc2c 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@@ -1,6 +1,7 @@use std::time::Instant;use half::bf16;+use proc_macros::uzu_test;use rand::{RngExt, SeedableRng, rngs::StdRng};use super::{MoeExpertsTwoPassArguments, MoeExpertsTwoPassDecodeBlock, MoeExpertsTwoPassPrefillBlock};@@ -263,7 +264,7 @@ fn run_two_pass_prefill_case<B: Backend>(eprintln!(" → Throughput: {:.1} µs/token (mean / sum_k)", (mean / sum_k as f64) * 1000.0);}-#[test]+#[uzu_test]#[ignore]fn test_two_pass_decode_speed() {for_each_non_cpu_backend!(|B| {@@ -280,7 +281,7 @@ fn test_two_pass_decode_speed() {});}-#[test]+#[uzu_test]#[ignore]fn test_two_pass_prefill_speed() {for_each_non_cpu_backend!(|B| {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 ceb05586b..ddb947d15 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@@ -7,6 +7,7 @@//! - Numerical correctness against CPU referenceuse half::bf16;+use proc_macros::uzu_test;use rand::{RngExt, SeedableRng, rngs::StdRng};use super::{@@ -279,7 +280,7 @@ fn cpu_moe_reference(y}-#[test]+#[uzu_test]fn test_two_pass_decode_correctness() {for_each_non_cpu_backend!(|B| {let ctx = create_context::<B>();@@ -443,7 +444,7 @@ fn test_two_pass_decode_correctness() {});}-#[test]+#[uzu_test]fn test_two_pass_decode_multi_token() {for_each_non_cpu_backend!(|B| {let ctx = create_context::<B>();@@ -527,7 +528,7 @@ fn test_two_pass_decode_multi_token() {});}-#[test]+#[uzu_test]fn test_two_pass_prefill_correctness() {for_each_non_cpu_backend!(|B| {let ctx = create_context::<B>();@@ -608,7 +609,7 @@ fn test_two_pass_prefill_correctness() {});}-#[test]+#[uzu_test]fn test_tile_infrastructure() {// Test that tile counts/scan/map are computed correctly// This is already tested in moe_tiles_test.rs, but we verify herediff --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 c3cff890e..d415dc7d0 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@@ -1,5 +1,6 @@use half::bf16;use num_traits::Float;+use proc_macros::uzu_test;use rand::{RngExt, SeedableRng, rngs::StdRng};use super::MoeGather;@@ -75,22 +76,22 @@ fn test_gather_internal(})}-#[test]+#[uzu_test]fn test_gather_single_token() {test_gather_internal(1, 2, 64);}-#[test]+#[uzu_test]fn test_gather_small_batch() {test_gather_internal(4, 8, 128);}-#[test]+#[uzu_test]fn test_gather_medium_batch() {test_gather_internal(16, 32, 256)}-#[test]+#[uzu_test]fn test_gather_large_batch() {test_gather_internal(64, 128, 512)}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 2e15ba0c9..ef3ddd272 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,4 +1,5 @@use half::bf16;+use proc_macros::uzu_test;use rand::{RngExt, SeedableRng, rngs::StdRng};use super::{MoeExpertsTwoPassArguments, MoeExpertsTwoPassDecodeBlock, MoeGather};@@ -18,7 +19,7 @@ use crate::{};// Test E2E MoE performance with timing breakdown (decode mode, T=1)-#[test]+#[uzu_test]#[ignore]fn test_moe_e2e_decode_perf() {eprintln!("\n=== End-to-End MoE Performance (DECODE, T=1) ===");@@ -73,7 +74,7 @@ fn test_moe_e2e_decode_perf() {}// Test E2E MoE performance with timing breakdown (prefill mode, T>1)-#[test]+#[uzu_test]#[ignore]fn test_moe_e2e_prefill_perf() {eprintln!("\n=== End-to-End MoE Performance (PREFILL, T>1) ===");@@ -134,7 +135,7 @@ fn test_moe_e2e_prefill_perf() {}// Test complete MoE pipeline timing breakdown (decode mode, T=1)-#[test]+#[uzu_test]#[ignore]fn test_moe_pipeline_breakdown_decode() {for_each_non_cpu_backend!(|B| {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 9ec58b682..dd21c370f 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,3 +1,4 @@+use proc_macros::uzu_test;use rand::{RngExt, SeedableRng, rngs::StdRng};use crate::{@@ -11,7 +12,7 @@ use crate::{encodable_block::mlp::moe::tests::{cpu_tile_counts, cpu_tile_scan},};-#[test]+#[uzu_test]fn test_tile_counts_correctness() {for_each_non_cpu_backend!(|B| {let ctx = create_context::<B>();@@ -54,7 +55,7 @@ fn test_tile_counts_correctness() {});}-#[test]+#[uzu_test]fn test_tile_scan_correctness() {for_each_non_cpu_backend!(|B| {let ctx = create_context::<B>();@@ -97,7 +98,7 @@ fn test_tile_scan_correctness() {});}-#[test]+#[uzu_test]fn test_tile_edge_cases() {for_each_non_cpu_backend!(|B| {let ctx = create_context::<B>();diff --git a/crates/backend-uzu/unit/encodable_block/sampling_test.rs b/crates/backend-uzu/unit/encodable_block/sampling_test.rsindex 4bc4e0af8..06c5abba8 100644--- a/crates/backend-uzu/unit/encodable_block/sampling_test.rs+++ b/crates/backend-uzu/unit/encodable_block/sampling_test.rs@@ -6,6 +6,7 @@ use backend_uzu::{dispatch_dtype,};use num_traits::{Float, NumCast};+use proc_macros::uzu_test;use proptest::prelude::*;use rand::{RngExt, SeedableRng, rngs::SmallRng};use rand_distr::Normal;@@ -167,7 +168,7 @@ fn sampling_case() -> impl Strategy<Value = SamplingCase> {)}-#[test]+#[uzu_test]fn test_sampling_prop() {let contextes = TestContextes::new();diff --git a/crates/backend-uzu/unit/forward_pass/cache_layers_test.rs b/crates/backend-uzu/unit/forward_pass/cache_layers_test.rsindex 8b11e717e..26fa2607e 100644--- a/crates/backend-uzu/unit/forward_pass/cache_layers_test.rs+++ b/crates/backend-uzu/unit/forward_pass/cache_layers_test.rs@@ -2,6 +2,8 @@use std::{mem::size_of, ops::Range};+use proc_macros::uzu_test;+use super::{CacheEntryIndex, CacheLayer, CacheLayers, LayerCacheBinding};use crate::{array::ArrayContextExt,@@ -102,7 +104,7 @@ fn make_cache_layers(}}-#[test]+#[uzu_test]fn test_cache_layers_copy_from_clones_only_live_window_rows() {let Some(context) = <Metal as Backend>::Context::new().ok() else {return;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 5f6da027c..ca0298488 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@@ -1,5 +1,7 @@#![cfg(metal_backend)]+use proc_macros::uzu_test;+use crate::{backends::{common::{Backend, Context, Encoder},@@ -211,7 +213,7 @@ fn run_scenario<B: Backend>();}-#[test]+#[uzu_test]fn kv_cache_state_scenarios() {let Some(context) = <Metal as Backend>::Context::new().ok() else {return;@@ -291,7 +293,7 @@ fn kv_cache_state_scenarios() {}}-#[test]+#[uzu_test]fn kv_cache_slice_apply_contiguous_window() {let Some(context) = <Metal as Backend>::Context::new().ok() else {return;@@ -328,7 +330,7 @@ fn kv_cache_slice_apply_contiguous_window() {assert_eq!(values_after[0..4], initial_values[0..4], "values restored for contiguous slice");}-#[test]+#[uzu_test]fn kv_cache_slice_apply_wrap_window() {let Some(context) = <Metal as Backend>::Context::new().ok() else {return;@@ -365,7 +367,7 @@ fn kv_cache_slice_apply_wrap_window() {assert_eq!(values_after[0..4], initial_values[0..4], "values restored for wrapped slice");}-#[test]+#[uzu_test]fn kv_cache_slice_apply_full_restores_metadata() {let Some(context) = <Metal as Backend>::Context::new().ok() else {return;diff --git a/crates/backend-uzu/unit/trie_test.rs b/crates/backend-uzu/unit/trie_test.rsindex 0c61fccb5..0da4f21b0 100644--- a/crates/backend-uzu/unit/trie_test.rs+++ b/crates/backend-uzu/unit/trie_test.rs@@ -1,5 +1,7 @@use std::collections::HashMap;+use proc_macros::uzu_test;+use crate::{language_model::rng::PRng,speculators::{empty_speculator::EmptySpeculator, speculator::Speculator},@@ -45,14 +47,14 @@ fn verify_sprout(assert_eq!(flat_trie.token_seeds().collect::<Vec<u64>>(), vec![expected_seed]);}-#[test]+#[uzu_test]fn test_trie_manual_sprout() {let trie_root = TrieNode::new(0, None, 0);verify_sprout(&trie_root, 0);}-#[test]+#[uzu_test]fn test_trie_from_speculator_sprout() {let rng = PRng::new(42);@@ -106,7 +108,7 @@ fn verify_stick(}}-#[test]+#[uzu_test]fn test_trie_manual_stick() {let rng = PRng::new(0);let mut trie_root = TrieNode::new(0, None, rng.derive(0));@@ -120,7 +122,7 @@ fn test_trie_manual_stick() {verify_stick(&trie_root, &rng);}-#[test]+#[uzu_test]fn test_trie_from_speculator_stick() {let rng = PRng::new(42);@@ -176,7 +178,7 @@ fn verify_bush(}}-#[test]+#[uzu_test]fn test_trie_manual_bush() {let rng = PRng::new(0);let mut trie_root = TrieNode::new(0, None, rng.derive(0));@@ -191,7 +193,7 @@ fn test_trie_manual_bush() {verify_bush(&trie_root, &rng);}-#[test]+#[uzu_test]fn test_trie_from_speculator_bush() {let rng = PRng::new(0);@@ -250,7 +252,7 @@ fn verify_tree(}}-#[test]+#[uzu_test]fn test_trie_manual_tree() {let rng = PRng::new(0);let mut trie_root = TrieNode::new(0, None, rng.derive(0));diff --git a/crates/backend-uzu/unit/utils/model_size_test.rs b/crates/backend-uzu/unit/utils/model_size_test.rsindex dd730e752..32b3b64a8 100644--- a/crates/backend-uzu/unit/utils/model_size_test.rs+++ b/crates/backend-uzu/unit/utils/model_size_test.rs@@ -1,5 +1,7 @@use std::path::PathBuf;+use proc_macros::uzu_test;+use super::*;use crate::utils::VERSION;pub const MODEL_DIR_NAME: &str = "Llama-3.2-1B-Instruct";@@ -18,7 +20,7 @@ pub fn get_test_model_path() -> PathBuf {path}-#[test]+#[uzu_test]fn test_model_size_from_path() {let model_path = get_test_model_path();diff --git a/crates/proc-macros/src/uzu_test.rs b/crates/proc-macros/src/uzu_test.rsindex 7267a5918..65a8342e8 100644--- a/crates/proc-macros/src/uzu_test.rs+++ b/crates/proc-macros/src/uzu_test.rs@@ -1,16 +1,59 @@use proc_macro::TokenStream;-use quote::quote;-use syn::{ItemFn, parse_macro_input};+use quote::{format_ident, quote};+use syn::{ItemFn, Meta, parse_macro_input};pub fn uzu_test(_args: TokenStream,input: TokenStream,) -> TokenStream {- let func = parse_macro_input!(input as ItemFn);+ let mut func = parse_macro_input!(input as ItemFn);++ let ignore_attr =+ func.attrs.iter().position(|attr| attr.path().is_ident("ignore")).map(|index| func.attrs.remove(index));+ let (ignore, ignore_message) = match ignore_attr.as_ref().map(|attr| &attr.meta) {+ None => (quote! { false }, quote! { ::core::option::Option::None }),+ Some(Meta::Path(_)) => (quote! { true }, quote! { ::core::option::Option::None }),+ Some(Meta::NameValue(name_value)) => {+ let message = &name_value.value;+ (quote! { true }, quote! { ::core::option::Option::Some(#message) })+ },+ Some(meta) => {+ return syn::Error::new_spanned(meta, "unsupported #[ignore] form").to_compile_error().into();+ },+ };++ let name = &func.sig.ident;+ let const_name = format_ident!("__UZU_TEST_CASE_{}", name);quote! {- #[test]#func++ #[test_case]+ #[allow(non_upper_case_globals)]+ const #const_name: crate::harness::UzuTest =+ crate::harness::UzuTest::Test(&crate::harness::test::TestDescAndFn {+ desc: crate::harness::test::TestDesc {+ name: crate::harness::test::StaticTestName(concat!(+ module_path!(),+ "::",+ stringify!(#name),+ )),+ ignore: #ignore,+ ignore_message: #ignore_message,+ source_file: file!(),+ start_line: line!() as usize,+ start_col: column!() as usize,+ end_line: line!() as usize,+ end_col: column!() as usize,+ should_panic: crate::harness::test::ShouldPanic::No,+ compile_fail: false,+ no_run: false,+ test_type: crate::harness::test::TestType::Unknown,+ },+ testfn: crate::harness::test::StaticTestFn(|| {+ crate::harness::test::assert_test_result(#name())+ }),+ });}.into()}