Skip to content

armgit / uzu

Public Imported from GitHub
0

A high-performance inference engine for AI models

Tiny cleanup after #501 (#525)

uuuvnadf4149d863b
diff --git a/crates/backend-uzu/benches/language_model/language_model_generator_bench.rs b/crates/backend-uzu/benches/language_model/language_model_generator_bench.rs
index 078983b8d..f679c40c2 100644
--- a/crates/backend-uzu/benches/language_model/language_model_generator_bench.rs
+++ b/crates/backend-uzu/benches/language_model/language_model_generator_bench.rs
@@ -3,7 +3,7 @@ use std::time::Duration;
use backend_uzu::{
_benchmarks::{LanguageModelConfig, LanguageModelGenerator, RunModelResult, TrieCreationConfig, TrieNode},
backends::common::Backend,
- prelude::{DecodingConfig, SamplingMethod},
+ session::{config::DecodingConfig, parameter::SamplingMethod},
};
use criterion::{BenchmarkId, Criterion, Throughput};
use proc_macros::uzu_bench;
diff --git a/crates/backend-uzu/benches/session/chat_session_bench.rs b/crates/backend-uzu/benches/session/chat_session_bench.rs
index 6eaaf1ae8..cd5e8401e 100644
--- a/crates/backend-uzu/benches/session/chat_session_bench.rs
+++ b/crates/backend-uzu/benches/session/chat_session_bench.rs
@@ -2,8 +2,11 @@ use std::time::Duration;
use backend_uzu::{
backends::common::Backend,
- prelude::{DecodingConfig, Input, Output, RunConfig},
- session::ChatSession,
+ session::{
+ ChatSession,
+ config::{DecodingConfig, RunConfig},
+ types::{Input, Output},
+ },
};
use criterion::{BenchmarkId, Criterion};
use proc_macros::uzu_bench;
diff --git a/crates/backend-uzu/src/audio/codec.rs b/crates/backend-uzu/src/audio/codec.rs
index 231fc1735..b37497e7b 100644
--- a/crates/backend-uzu/src/audio/codec.rs
+++ b/crates/backend-uzu/src/audio/codec.rs
@@ -1,6 +1,7 @@
use super::{AudioPcmBatch, AudioResult, AudioTokenGrid};
pub trait AudioCodecRuntime {
+ #[cfg(test)]
fn encode(
&self,
pcm: &AudioPcmBatch,
diff --git a/crates/backend-uzu/src/audio/mod.rs b/crates/backend-uzu/src/audio/mod.rs
index a4e3e3779..8faa3c41e 100644
--- a/crates/backend-uzu/src/audio/mod.rs
+++ b/crates/backend-uzu/src/audio/mod.rs
@@ -1,9 +1,11 @@
+#[cfg(metal_backend)]
mod codec;
#[cfg(metal_backend)]
mod context;
pub mod nanocodec;
mod types;
+#[cfg(metal_backend)]
pub use codec::AudioCodecRuntime;
#[cfg(metal_backend)]
pub use context::AudioGenerationContext;
@@ -11,4 +13,6 @@ pub use context::AudioGenerationContext;
pub use nanocodec::NanoCodecFsqRuntime;
#[cfg(all(metal_backend, test))]
pub use nanocodec::NanoCodecFsqRuntimeConfig;
-pub use types::{AudioError, AudioPcmBatch, AudioResult, AudioTokenGrid};
+pub use types::AudioError;
+#[cfg(metal_backend)]
+pub use types::{AudioPcmBatch, AudioResult, AudioTokenGrid};
diff --git a/crates/backend-uzu/src/audio/nanocodec/runtime.rs b/crates/backend-uzu/src/audio/nanocodec/runtime.rs
index 46e68a0c5..2095c1bbf 100644
--- a/crates/backend-uzu/src/audio/nanocodec/runtime.rs
+++ b/crates/backend-uzu/src/audio/nanocodec/runtime.rs
@@ -8,6 +8,8 @@ use std::{
use serde::Deserialize;
+#[cfg(test)]
+use crate::backends::common::kernel::AudioFsqEncodeKernel;
use crate::{
array::{ArrayContextExt, size_for_shape},
audio::{AudioCodecRuntime, AudioError, AudioPcmBatch, AudioResult, AudioTokenGrid},
@@ -16,8 +18,7 @@ use crate::{
kernel::{
ActivationKernel, AudioAddKernel, AudioCausalConv1dGroupedKernel, AudioCausalConv1dGroupedResidualKernel,
AudioCausalConv1dKernel, AudioCausalConvTranspose1dCausalPadKernel, AudioConv1dKernel,
- AudioFsqDecodeKernel, AudioFsqEncodeKernel, AudioHalfSnakeKernel, AudioNormNcsKernel,
- AudioQuantizerDecodeKernel,
+ AudioFsqDecodeKernel, AudioHalfSnakeKernel, AudioNormNcsKernel, AudioQuantizerDecodeKernel,
},
},
config::{
@@ -44,8 +45,10 @@ mod support;
use loaders::load_audio_runtime_from_tts_config;
pub(crate) use profile::PendingStreamPcmChunk;
+#[cfg(test)]
+use stream::pack_pcm_to_padded;
pub use stream::{AudioDecodeStepStats, AudioDecodeStreamState};
-use stream::{extract_delta_from_padded_with_offset_snapshot, pack_pcm_to_padded, unpack_padded_to_pcm};
+use stream::{extract_delta_from_padded_with_offset_snapshot, unpack_padded_to_pcm};
use structured::{StructuredAudioCodecGraph, StructuredAudioRuntimeResources};
use support::{DecodedPaddedAudio, checked_product, convert_lengths_to_i32, usize_to_i32};
@@ -198,6 +201,7 @@ impl NanoCodecFsqRuntimeConfig {
self.structured_decoder.as_ref().map(|decoder| decoder.semantic_codebook_size)
}
+ #[cfg(test)]
pub fn eps(&self) -> f32 {
self.eps
}
@@ -369,6 +373,7 @@ impl<B: Backend> NanoCodecFsqRuntime<B> {
})
}
+ #[cfg(test)]
fn fsq_encode(
&self,
pcm: &AudioPcmBatch,
@@ -748,6 +753,7 @@ impl<B: Backend> NanoCodecFsqRuntime<B> {
}
impl<B: Backend> AudioCodecRuntime for NanoCodecFsqRuntime<B> {
+ #[cfg(test)]
fn encode(
&self,
pcm: &AudioPcmBatch,
diff --git a/crates/backend-uzu/src/audio/nanocodec/runtime/stream.rs b/crates/backend-uzu/src/audio/nanocodec/runtime/stream.rs
index 330eb0804..ea1547231 100644
--- a/crates/backend-uzu/src/audio/nanocodec/runtime/stream.rs
+++ b/crates/backend-uzu/src/audio/nanocodec/runtime/stream.rs
@@ -383,6 +383,7 @@ pub(super) fn extract_delta_from_padded_with_offset_snapshot(
})
}
+#[cfg(test)]
pub(super) fn pack_pcm_to_padded(
pcm: &AudioPcmBatch,
expected_channels: usize,
diff --git a/crates/backend-uzu/src/audio/types.rs b/crates/backend-uzu/src/audio/types.rs
index 880409a16..c0e4ddeef 100644
--- a/crates/backend-uzu/src/audio/types.rs
+++ b/crates/backend-uzu/src/audio/types.rs
@@ -1,3 +1,4 @@
+#[cfg(metal_backend)]
use std::num::{NonZeroU32, NonZeroUsize};
use crate::{backends::common::Backend, parameters::ParameterLoaderError};
@@ -47,6 +48,7 @@ pub enum AudioError {
Runtime(String),
}
+#[cfg(metal_backend)]
pub type AudioResult<T> = Result<T, AudioError>;
impl<B: Backend> From<ParameterLoaderError<B>> for AudioError {
@@ -55,6 +57,7 @@ impl<B: Backend> From<ParameterLoaderError<B>> for AudioError {
}
}
+#[cfg(metal_backend)]
#[derive(Debug, Clone, PartialEq)]
pub struct AudioPcmBatch {
samples: Box<[f32]>,
@@ -63,6 +66,7 @@ pub struct AudioPcmBatch {
lengths: Box<[usize]>,
}
+#[cfg(metal_backend)]
impl AudioPcmBatch {
pub fn new(
samples: Box<[f32]>,
@@ -117,6 +121,7 @@ impl AudioPcmBatch {
}
}
+#[cfg(metal_backend)]
#[derive(Debug, Clone, PartialEq)]
pub struct AudioTokenGrid {
tokens: Box<[u32]>,
@@ -126,6 +131,7 @@ pub struct AudioTokenGrid {
lengths: Box<[usize]>,
}
+#[cfg(metal_backend)]
impl AudioTokenGrid {
pub fn new(
tokens: Box<[u32]>,
@@ -220,6 +226,6 @@ impl AudioTokenGrid {
}
}
-#[cfg(test)]
+#[cfg(all(metal_backend, test))]
#[path = "../../unit/audio/types_test.rs"]
mod tests;
diff --git a/crates/backend-uzu/src/backends/metal/command_buffer.rs b/crates/backend-uzu/src/backends/metal/command_buffer.rs
index ab2cd58bf..b4e96c831 100644
--- a/crates/backend-uzu/src/backends/metal/command_buffer.rs
+++ b/crates/backend-uzu/src/backends/metal/command_buffer.rs
@@ -7,15 +7,12 @@ use metal::{
use objc2::{Message, rc::Retained, runtime::ProtocolObject};
use super::{Metal, buffer::BufferDowncastExt};
-use crate::{
- backends::{
- common::{
- AccessFlags, Buffer, BufferRangeMut, BufferRangeRef, CommandBuffer, CommandBufferCompleted,
- CommandBufferEncoding, CommandBufferExecutable, CommandBufferInitial, CommandBufferPending,
- },
- metal::error::MetalError,
+use crate::backends::{
+ common::{
+ AccessFlags, Buffer, BufferRangeMut, BufferRangeRef, CommandBuffer, CommandBufferCompleted,
+ CommandBufferEncoding, CommandBufferExecutable, CommandBufferInitial, CommandBufferPending,
},
- prelude::MetalContext,
+ metal::{MetalContext, error::MetalError},
};
pub struct MetalCommandBuffer;
diff --git a/crates/backend-uzu/src/backends/metal/sparse/sparse_buffer.rs b/crates/backend-uzu/src/backends/metal/sparse/sparse_buffer.rs
index 2b220314d..868d71a99 100644
--- a/crates/backend-uzu/src/backends/metal/sparse/sparse_buffer.rs
+++ b/crates/backend-uzu/src/backends/metal/sparse/sparse_buffer.rs
@@ -9,12 +9,11 @@ use metal::{MTLBuffer, MTLDeviceExt, MTLResourceOptions, MTLSparsePageSize};
use objc2::{rc::Retained, runtime::ProtocolObject};
use rangemap::RangeSet;
-use crate::{
- backends::{
- common::{Backend, Buffer, SparseBuffer, SparseBufferExt},
- metal::{Metal, error::MetalError, metal_extensions::SparsePageSizeExt, sparse::MetalSparseMappingOpsBatch},
+use crate::backends::{
+ common::{Backend, Buffer, SparseBuffer, SparseBufferExt},
+ metal::{
+ Metal, MetalContext, error::MetalError, metal_extensions::SparsePageSizeExt, sparse::MetalSparseMappingOpsBatch,
},
- prelude::MetalContext,
};
pub struct MetalSparseBuffer {
diff --git a/crates/backend-uzu/src/backends/metal/sparse/sparse_heap.rs b/crates/backend-uzu/src/backends/metal/sparse/sparse_heap.rs
index 73519dbe6..85436a7ea 100644
--- a/crates/backend-uzu/src/backends/metal/sparse/sparse_heap.rs
+++ b/crates/backend-uzu/src/backends/metal/sparse/sparse_heap.rs
@@ -7,13 +7,11 @@ use metal::{
use objc2::{rc::Retained, runtime::ProtocolObject};
use rangemap::{RangeMap, RangeSet};
-use crate::{
- backends::metal::{
- error::MetalError,
- metal_extensions::SparsePageSizeExt,
- sparse::{MetalSparseMappingOpsBatch, sparse_utils::MetalSparseHeapBufferMapping},
- },
- prelude::MetalContext,
+use crate::backends::metal::{
+ MetalContext,
+ error::MetalError,
+ metal_extensions::SparsePageSizeExt,
+ sparse::{MetalSparseMappingOpsBatch, sparse_utils::MetalSparseHeapBufferMapping},
};
pub(crate) struct MetalSparseHeap {
diff --git a/crates/backend-uzu/src/backends/metal/sparse/sparse_heap_pool.rs b/crates/backend-uzu/src/backends/metal/sparse/sparse_heap_pool.rs
index 6a7ca8803..bdbf8386d 100644
--- a/crates/backend-uzu/src/backends/metal/sparse/sparse_heap_pool.rs
+++ b/crates/backend-uzu/src/backends/metal/sparse/sparse_heap_pool.rs
@@ -8,13 +8,11 @@ use std::{
use metal::{MTL4UpdateSparseBufferMappingOperation, MTLBuffer, MTLSparsePageSize, MTLSparseTextureMappingMode};
use objc2::{rc::Retained, runtime::ProtocolObject};
-use crate::{
- backends::metal::{
- error::MetalError,
- metal_extensions::SparsePageSizeExt,
- sparse::{MetalSparseMappingOpsBatch, sparse_heap::MetalSparseHeap},
- },
- prelude::MetalContext,
+use crate::backends::metal::{
+ MetalContext,
+ error::MetalError,
+ metal_extensions::SparsePageSizeExt,
+ sparse::{MetalSparseMappingOpsBatch, sparse_heap::MetalSparseHeap},
};
pub struct MetalSparseHeapPool {
diff --git a/crates/backend-uzu/src/config/model/language_model.rs b/crates/backend-uzu/src/config/model/language_model.rs
index 8c398f1e9..5562f2d39 100644
--- a/crates/backend-uzu/src/config/model/language_model.rs
+++ b/crates/backend-uzu/src/config/model/language_model.rs
@@ -4,7 +4,7 @@ use proc_macros::uzu_config;
use crate::{
config::{decoder::DecoderConfig, model::generation::GenerationConfig},
- prelude::Error,
+ session::types::Error,
};
#[uzu_config(super::ModelConfig)]
diff --git a/crates/backend-uzu/src/encodable_block/linear/qlora_wrapper.rs b/crates/backend-uzu/src/encodable_block/linear/qlora_wrapper.rs
index 46f2fc7e8..eae82b9ff 100644
--- a/crates/backend-uzu/src/encodable_block/linear/qlora_wrapper.rs
+++ b/crates/backend-uzu/src/encodable_block/linear/qlora_wrapper.rs
@@ -18,7 +18,7 @@ use crate::{
Linear,
linear::{LinearMatmul, LinearMatmulError},
},
- prelude::{ParameterLoaderError, ParameterTree},
+ parameters::{ParameterLoaderError, ParameterTree},
};
#[derive(Debug, Error)]
diff --git a/crates/backend-uzu/src/language_model/grammar/xgram.rs b/crates/backend-uzu/src/language_model/grammar/xgram.rs
index e9731354b..a4fe6ad49 100644
--- a/crates/backend-uzu/src/language_model/grammar/xgram.rs
+++ b/crates/backend-uzu/src/language_model/grammar/xgram.rs
@@ -8,7 +8,9 @@ use xgrammar::{
};
use crate::{
- data_type::DataType, language_model::grammar::CompiledGrammar, prelude::Error, session::config::GrammarConfig,
+ data_type::DataType,
+ language_model::grammar::CompiledGrammar,
+ session::{config::GrammarConfig, types::Error},
};
enum CompiledGrammarEngagementState {
diff --git a/crates/backend-uzu/src/language_model/language_model_generator_context.rs b/crates/backend-uzu/src/language_model/language_model_generator_context.rs
index c491ecb29..3f5b4bdb8 100644
--- a/crates/backend-uzu/src/language_model/language_model_generator_context.rs
+++ b/crates/backend-uzu/src/language_model/language_model_generator_context.rs
@@ -16,10 +16,9 @@ use crate::{
forward_pass::{cache_layers::CacheLayers, model_shape::ModelShape},
language_model::rng::PRng,
parameters::ParameterLoader,
- prelude::ContextLength,
session::{
config::DecodingConfig,
- parameter::{ConfigResolvableValue, ResolvableValue},
+ parameter::{ConfigResolvableValue, ContextLength, ResolvableValue},
types::Error,
},
};
diff --git a/crates/backend-uzu/src/lib.rs b/crates/backend-uzu/src/lib.rs
index a5f8d16f2..f4507b352 100644
--- a/crates/backend-uzu/src/lib.rs
+++ b/crates/backend-uzu/src/lib.rs
@@ -16,13 +16,12 @@ mod encodable_block;
mod forward_pass;
mod language_model;
mod parameters;
-mod speculators;
+pub mod speculators;
mod trie;
mod utils;
pub mod backends;
pub mod inference;
-pub mod prelude;
pub mod session;
pub use utils::{TOOLCHAIN_VERSION, VERSION};
diff --git a/crates/backend-uzu/src/parameters/mod.rs b/crates/backend-uzu/src/parameters/mod.rs
index c4492bdfd..394462308 100644
--- a/crates/backend-uzu/src/parameters/mod.rs
+++ b/crates/backend-uzu/src/parameters/mod.rs
@@ -1,7 +1,6 @@
mod loader;
mod safetensors_metadata;
-pub use loader::{ParameterLeaf, ParameterLoader, ParameterLoaderError, ParameterTree};
-pub use safetensors_metadata::HeaderLoadingError;
+pub use loader::{ParameterLoader, ParameterLoaderError, ParameterTree};
#[cfg(all(test, feature = "tracing"))]
pub use safetensors_metadata::read_metadata;
diff --git a/crates/backend-uzu/src/prelude.rs b/crates/backend-uzu/src/prelude.rs
deleted file mode 100644
index cf3fef1af..000000000
--- a/crates/backend-uzu/src/prelude.rs
+++ /dev/null
@@ -1,34 +0,0 @@
-//! Prelude module containing commonly used types from the uzu crate.
-//!
-//! This module can be imported with `use backend_uzu::prelude::*;` to bring the most
-//! frequently used types into scope.
-
-// Constants & Utilities
-// Session Core
-// Session Config
-// Session Parameters
-// Session Types
-// Speculators
-#[cfg(metal_backend)]
-pub use crate::backends::metal::MetalContext;
-#[cfg(metal_backend)]
-pub use crate::session::TtsSession;
-pub use crate::{
- audio::{AudioCodecRuntime, AudioError, AudioPcmBatch, AudioResult, AudioTokenGrid},
- classifier::{ClassificationOutput, ClassificationStats},
- parameters::{HeaderLoadingError, ParameterLeaf, ParameterLoaderError, ParameterTree},
- session::{
- ChatSession, ClassificationSession,
- config::{DecodingConfig, RunConfig, SpeculatorConfig},
- parameter::{ContextLength, ContextMode, PrefillStepSize, SamplingMethod, SamplingPolicy, SamplingSeed},
- types::{
- Error, FinishReason, Input, Message, Output, ParsedText, Role, RunStats, Stats, StepStats, Text, TotalStats,
- },
- },
- speculators::{
- empty_speculator::EmptySpeculator, fixed_token_speculator::FixedTokensSpeculator,
- ngram_speculator::NGramSpeculator, prompt_lookup_speculator::PromptLookupSpeculator, speculator::Speculator,
- token_finder::TokenFinder,
- },
- utils::{TOOLCHAIN_VERSION, VERSION},
-};
diff --git a/crates/backend-uzu/tests/common/audio/fsq_reference.rs b/crates/backend-uzu/tests/common/audio/fsq_reference.rs
index 8692e3658..a870556f5 100644
--- a/crates/backend-uzu/tests/common/audio/fsq_reference.rs
+++ b/crates/backend-uzu/tests/common/audio/fsq_reference.rs
@@ -1,10 +1,5 @@
-use backend_uzu::prelude::{AudioError, AudioResult};
-
-fn checked_product(values: &[usize]) -> AudioResult<usize> {
- values
- .iter()
- .try_fold(1usize, |acc, &value| acc.checked_mul(value))
- .ok_or(AudioError::Runtime("dimension product overflow".to_string()))
+fn checked_product(values: &[usize]) -> usize {
+ values.iter().try_fold(1usize, |acc, &value| acc.checked_mul(value)).expect("dimension product overflow")
}
fn round_ties_to_even(value: f32) -> f32 {
@@ -27,41 +22,19 @@ fn validate_fsq_common(
codebook_dim: usize,
num_levels: &[i32],
lengths: &[i32],
-) -> AudioResult<()> {
- if num_groups == 0 || codebook_dim == 0 {
- return Err(AudioError::InvalidTokenCardinality);
- }
-
- if num_levels.len() != codebook_dim {
- return Err(AudioError::InvalidTokenShape {
- expected_tokens: codebook_dim,
- actual_tokens: num_levels.len(),
- });
- }
+) {
+ assert!(num_groups != 0 && codebook_dim != 0, "invalid group/codebook configuration");
+ assert_eq!(num_levels.len(), codebook_dim, "num_levels size mismatch");
for &levels in num_levels {
- if levels <= 1 {
- return Err(AudioError::InvalidTokenCardinality);
- }
+ assert!(levels > 1, "invalid levels {levels}");
}
- if lengths.len() != batch_size {
- return Err(AudioError::InvalidTokenLengths {
- expected_lengths: batch_size,
- actual_lengths: lengths.len(),
- });
- }
+ assert_eq!(lengths.len(), batch_size, "lengths count mismatch");
for &length in lengths {
- if length < 0 || length as usize > seq_len {
- return Err(AudioError::InvalidTokenLengthValue {
- length: length.max(0) as usize,
- frames: seq_len,
- });
- }
+ assert!(length >= 0 && length as usize <= seq_len, "invalid length {length} for {seq_len} frames");
}
-
- Ok(())
}
pub fn fsq_decode_reference(
@@ -72,18 +45,11 @@ pub fn fsq_decode_reference(
seq_len: usize,
codebook_dim: usize,
num_levels: &[i32],
-) -> AudioResult<Vec<f32>> {
- validate_fsq_common(batch_size, num_groups, seq_len, codebook_dim, num_levels, lengths)?;
-
- let expected_tokens = checked_product(&[batch_size, num_groups, seq_len])?;
- if tokens.len() != expected_tokens {
- return Err(AudioError::InvalidTokenShape {
- expected_tokens,
- actual_tokens: tokens.len(),
- });
- }
+) -> Vec<f32> {
+ validate_fsq_common(batch_size, num_groups, seq_len, codebook_dim, num_levels, lengths);
+ assert_eq!(tokens.len(), checked_product(&[batch_size, num_groups, seq_len]), "tokens size mismatch");
- let output_len = checked_product(&[batch_size, num_groups * codebook_dim, seq_len])?;
+ let output_len = checked_product(&[batch_size, num_groups * codebook_dim, seq_len]);
let mut output = vec![0.0_f32; output_len];
for batch in 0..batch_size {
@@ -114,14 +80,13 @@ pub fn fsq_decode_reference(
let output_index = (batch * (num_groups * codebook_dim) + channel) * seq_len + time;
output[output_index] = value;
- base =
- base.checked_mul(levels).ok_or(AudioError::Runtime("fsq decode base overflow".to_string()))?;
+ base = base.checked_mul(levels).expect("fsq decode base overflow");
}
}
}
}
- Ok(output)
+ output
}
pub fn fsq_encode_reference(
@@ -134,25 +99,12 @@ pub fn fsq_encode_reference(
num_levels: &[i32],
dim_base_index: &[i32],
eps: f32,
-) -> AudioResult<Vec<i32>> {
- validate_fsq_common(batch_size, num_groups, seq_len, codebook_dim, num_levels, lengths)?;
-
- if dim_base_index.len() != codebook_dim {
- return Err(AudioError::InvalidTokenShape {
- expected_tokens: codebook_dim,
- actual_tokens: dim_base_index.len(),
- });
- }
-
- let expected_input = checked_product(&[batch_size, num_groups * codebook_dim, seq_len])?;
- if input.len() != expected_input {
- return Err(AudioError::InvalidTokenShape {
- expected_tokens: expected_input,
- actual_tokens: input.len(),
- });
- }
+) -> Vec<i32> {
+ validate_fsq_common(batch_size, num_groups, seq_len, codebook_dim, num_levels, lengths);
+ assert_eq!(dim_base_index.len(), codebook_dim, "dim_base_index size mismatch");
+ assert_eq!(input.len(), checked_product(&[batch_size, num_groups * codebook_dim, seq_len]), "input size mismatch");
- let output_len = checked_product(&[batch_size, num_groups, seq_len])?;
+ let output_len = checked_product(&[batch_size, num_groups, seq_len]);
let mut tokens = vec![0_i32; output_len];
for batch in 0..batch_size {
@@ -191,5 +143,5 @@ pub fn fsq_encode_reference(
}
}
- Ok(tokens)
+ tokens
}
diff --git a/crates/backend-uzu/tests/common/audio/ops_reference.rs b/crates/backend-uzu/tests/common/audio/ops_reference.rs
index 724ec7eff..f1a42c8e4 100644
--- a/crates/backend-uzu/tests/common/audio/ops_reference.rs
+++ b/crates/backend-uzu/tests/common/audio/ops_reference.rs
@@ -1,40 +1,23 @@
-use backend_uzu::prelude::{AudioError, AudioResult};
-
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum PadMode {
Zeros,
Replicate,
}
-fn checked_product(values: &[usize]) -> AudioResult<usize> {
- values
- .iter()
- .try_fold(1usize, |acc, &value| acc.checked_mul(value))
- .ok_or(AudioError::Runtime("dimension product overflow".to_string()))
+fn checked_product(values: &[usize]) -> usize {
+ values.iter().try_fold(1usize, |acc, &value| acc.checked_mul(value)).expect("dimension product overflow")
}
fn validate_lengths(
lengths: &[i32],
batch_size: usize,
frames: usize,
-) -> AudioResult<()> {
- if lengths.len() != batch_size {
- return Err(AudioError::InvalidTokenLengths {
- expected_lengths: batch_size,
- actual_lengths: lengths.len(),
- });
- }
+) {
+ assert_eq!(lengths.len(), batch_size, "lengths count mismatch");
for &length in lengths {
- if length < 0 || length as usize > frames {
- return Err(AudioError::InvalidTokenLengthValue {
- length: length.max(0) as usize,
- frames,
- });
- }
+ assert!(length >= 0 && length as usize <= frames, "invalid length {length} for {frames} frames");
}
-
- Ok(())
}
pub struct Conv1dSpec<'a> {
@@ -54,7 +37,7 @@ pub struct Conv1dSpec<'a> {
pub pad_mode: PadMode,
}
-pub fn conv1d_reference(spec: Conv1dSpec<'_>) -> AudioResult<Vec<f32>> {
+pub fn conv1d_reference(spec: Conv1dSpec<'_>) -> Vec<f32> {
let Conv1dSpec {
input,
weight,
@@ -72,32 +55,12 @@ pub fn conv1d_reference(spec: Conv1dSpec<'_>) -> AudioResult<Vec<f32>> {
pad_mode,
} = spec;
- validate_lengths(lengths, batch_size, seq_len_out)?;
+ validate_lengths(lengths, batch_size, seq_len_out);
+ assert_eq!(input.len(), checked_product(&[batch_size, cin, seq_len_in]), "input size mismatch");
+ assert_eq!(weight.len(), checked_product(&[cout, cin, kernel_size]), "weight size mismatch");
+ assert_eq!(bias.len(), cout, "bias size mismatch");
- let expected_input = checked_product(&[batch_size, cin, seq_len_in])?;
- if input.len() != expected_input {
- return Err(AudioError::InvalidTokenShape {
- expected_tokens: expected_input,
- actual_tokens: input.len(),
- });
- }
-
- let expected_weight = checked_product(&[cout, cin, kernel_size])?;
- if weight.len() != expected_weight {
- return Err(AudioError::InvalidTokenShape {
- expected_tokens: expected_weight,
- actual_tokens: weight.len(),
- });
- }
-
- if bias.len() != cout {
- return Err(AudioError::InvalidTokenShape {
- expected_tokens: cout,
- actual_tokens: bias.len(),
- });
- }
-
- let output_len = checked_product(&[batch_size, cout, seq_len_out])?;
+ let output_len = checked_product(&[batch_size, cout, seq_len_out]);
let mut output = vec![0.0_f32; output_len];
for batch in 0..batch_size {
@@ -139,7 +102,7 @@ pub fn conv1d_reference(spec: Conv1dSpec<'_>) -> AudioResult<Vec<f32>> {
}
}
- Ok(output)
+ output
}
pub struct CausalConv1dSpec<'a> {
@@ -155,7 +118,7 @@ pub struct CausalConv1dSpec<'a> {
pub dilation: usize,
}
-pub fn causal_conv1d_reference(spec: CausalConv1dSpec<'_>) -> AudioResult<Vec<f32>> {
+pub fn causal_conv1d_reference(spec: CausalConv1dSpec<'_>) -> Vec<f32> {
let CausalConv1dSpec {
input,
weight,
@@ -169,32 +132,12 @@ pub fn causal_conv1d_reference(spec: CausalConv1dSpec<'_>) -> AudioResult<Vec<f3
dilation,
} = spec;
- validate_lengths(lengths, batch_size, seq_len)?;
-
- let expected_input = checked_product(&[batch_size, cin, seq_len])?;
- if input.len() != expected_input {
- return Err(AudioError::InvalidTokenShape {
- expected_tokens: expected_input,
- actual_tokens: input.len(),
- });
- }
-
- let expected_weight = checked_product(&[cout, cin, kernel_size])?;
- if weight.len() != expected_weight {
- return Err(AudioError::InvalidTokenShape {
- expected_tokens: expected_weight,
- actual_tokens: weight.len(),
- });
- }
-
- if bias.len() != cout {
- return Err(AudioError::InvalidTokenShape {
- expected_tokens: cout,
- actual_tokens: bias.len(),
- });
- }
+ validate_lengths(lengths, batch_size, seq_len);
+ assert_eq!(input.len(), checked_product(&[batch_size, cin, seq_len]), "input size mismatch");
+ assert_eq!(weight.len(), checked_product(&[cout, cin, kernel_size]), "weight size mismatch");
+ assert_eq!(bias.len(), cout, "bias size mismatch");
- let output_len = checked_product(&[batch_size, cout, seq_len])?;
+ let output_len = checked_product(&[batch_size, cout, seq_len]);
let mut output = vec![0.0_f32; output_len];
let pad = (kernel_size - 1) * dilation;
@@ -229,7 +172,7 @@ pub fn causal_conv1d_reference(spec: CausalConv1dSpec<'_>) -> AudioResult<Vec<f3
}
}
- Ok(output)
+ output
}
pub struct CausalConvTranspose1dSpec<'a> {
@@ -246,7 +189,7 @@ pub struct CausalConvTranspose1dSpec<'a> {
pub groups: usize,
}
-pub fn causal_conv_transpose1d_reference(spec: CausalConvTranspose1dSpec<'_>) -> AudioResult<Vec<f32>> {
+pub fn causal_conv_transpose1d_reference(spec: CausalConvTranspose1dSpec<'_>) -> Vec<f32> {
let CausalConvTranspose1dSpec {
input,
weight,
@@ -261,37 +204,19 @@ pub fn causal_conv_transpose1d_reference(spec: CausalConvTranspose1dSpec<'_>) ->
groups,
} = spec;
- validate_lengths(lengths, batch_size, seq_len_out)?;
- if groups == 0 || cin == 0 || cout == 0 || cin % groups != 0 || cout % groups != 0 {
- return Err(AudioError::InvalidTokenCardinality);
- }
-
- let expected_input = checked_product(&[batch_size, cin, seq_len_in])?;
- if input.len() != expected_input {
- return Err(AudioError::InvalidTokenShape {
- expected_tokens: expected_input,
- actual_tokens: input.len(),
- });
- }
+ validate_lengths(lengths, batch_size, seq_len_out);
+ assert!(
+ groups != 0 && cin != 0 && cout != 0 && cin % groups == 0 && cout % groups == 0,
+ "invalid channel/group configuration"
+ );
+ assert_eq!(input.len(), checked_product(&[batch_size, cin, seq_len_in]), "input size mismatch");
let kernel_size = 2 * stride;
let cin_per_group = cin / groups;
- let expected_weight = checked_product(&[cout, cin_per_group, kernel_size])?;
- if weight.len() != expected_weight {
- return Err(AudioError::InvalidTokenShape {
- expected_tokens: expected_weight,
- actual_tokens: weight.len(),
- });
- }
-
- if bias.len() != cout {
- return Err(AudioError::InvalidTokenShape {
- expected_tokens: cout,
- actual_tokens: bias.len(),
- });
- }
+ assert_eq!(weight.len(), checked_product(&[cout, cin_per_group, kernel_size]), "weight size mismatch");
+ assert_eq!(bias.len(), cout, "bias size mismatch");
- let output_len = checked_product(&[batch_size, cout, seq_len_out])?;
+ let output_len = checked_product(&[batch_size, cout, seq_len_out]);
let mut output = vec![0.0_f32; output_len];
let cout_per_group = cout / groups;
@@ -333,10 +258,10 @@ pub fn causal_conv_transpose1d_reference(spec: CausalConvTranspose1dSpec<'_>) ->
}
}
- Ok(output)
+ output
}
-pub fn causal_conv_transpose1d_causal_pad_reference(spec: CausalConvTranspose1dSpec<'_>) -> AudioResult<Vec<f32>> {
+pub fn causal_conv_transpose1d_causal_pad_reference(spec: CausalConvTranspose1dSpec<'_>) -> Vec<f32> {
let CausalConvTranspose1dSpec {
input,
weight,
@@ -351,42 +276,23 @@ pub fn causal_conv_transpose1d_causal_pad_reference(spec: CausalConvTranspose1dS
groups,
} = spec;
- validate_lengths(lengths, batch_size, seq_len_out)?;
- if groups == 0 || stride == 0 || cin == 0 || cout == 0 || cin % groups != 0 || cout % groups != 0 {
- return Err(AudioError::InvalidTokenCardinality);
- }
-
- let expected_input = checked_product(&[batch_size, cin, seq_len_in])?;
- if input.len() != expected_input {
- return Err(AudioError::InvalidTokenShape {
- expected_tokens: expected_input,
- actual_tokens: input.len(),
- });
- }
+ validate_lengths(lengths, batch_size, seq_len_out);
+ assert!(
+ groups != 0 && stride != 0 && cin != 0 && cout != 0 && cin % groups == 0 && cout % groups == 0,
+ "invalid channel/group configuration"
+ );
+ assert_eq!(input.len(), checked_product(&[batch_size, cin, seq_len_in]), "input size mismatch");
let cout_per_group = cout / groups;
let cin_per_group = cin / groups;
- let weight_plane = checked_product(&[cout, cin_per_group])?;
- if weight_plane == 0 || weight.len() % weight_plane != 0 {
- return Err(AudioError::InvalidTokenShape {
- expected_tokens: weight_plane,
- actual_tokens: weight.len(),
- });
- }
+ let weight_plane = checked_product(&[cout, cin_per_group]);
+ assert!(weight_plane != 0 && weight.len() % weight_plane == 0, "weight size mismatch");
let kernel_size = weight.len() / weight_plane;
- if kernel_size == 0 {
- return Err(AudioError::InvalidTokenCardinality);
- }
-
- if bias.len() != cout {
- return Err(AudioError::InvalidTokenShape {
- expected_tokens: cout,
- actual_tokens: bias.len(),
- });
- }
+ assert_ne!(kernel_size, 0, "empty kernel");
+ assert_eq!(bias.len(), cout, "bias size mismatch");
- let output_len = checked_product(&[batch_size, cout, seq_len_out])?;
+ let output_len = checked_product(&[batch_size, cout, seq_len_out]);
let mut output = vec![0.0_f32; output_len];
let seq_len_expanded = if seq_len_in == 0 {
0
@@ -394,7 +300,7 @@ pub fn causal_conv_transpose1d_causal_pad_reference(spec: CausalConvTranspose1dS
(seq_len_in - 1)
.checked_mul(stride)
.and_then(|value| value.checked_add(1))
- .ok_or(AudioError::Runtime("expanded sequence length overflow".to_string()))?
+ .expect("expanded sequence length overflow")
};
let left_pad = kernel_size - 1;
@@ -444,7 +350,7 @@ pub fn causal_conv_transpose1d_causal_pad_reference(spec: CausalConvTranspose1dS
}
}
- Ok(output)
+ output
}
pub struct HalfSnakeSpec<'a> {
@@ -458,7 +364,7 @@ pub struct HalfSnakeSpec<'a> {
pub eps: f32,
}
-pub fn half_snake_reference(spec: HalfSnakeSpec<'_>) -> AudioResult<Vec<f32>> {
+pub fn half_snake_reference(spec: HalfSnakeSpec<'_>) -> Vec<f32> {
let HalfSnakeSpec {
input,
alpha,
@@ -470,24 +376,9 @@ pub fn half_snake_reference(spec: HalfSnakeSpec<'_>) -> AudioResult<Vec<f32>> {
eps,
} = spec;
- if snake_channels > channels {
- return Err(AudioError::InvalidTokenCardinality);
- }
-
- let expected_input = checked_product(&[batch_size, channels, seq_len])?;
- if input.len() != expected_input {
- return Err(AudioError::InvalidTokenShape {
- expected_tokens: expected_input,
- actual_tokens: input.len(),
- });
- }
-
- if alpha.len() != snake_channels {
- return Err(AudioError::InvalidTokenShape {
- expected_tokens: snake_channels,
- actual_tokens: alpha.len(),
- });
- }
+ assert!(snake_channels <= channels, "snake channels exceed channel count");
+ assert_eq!(input.len(), checked_product(&[batch_size, channels, seq_len]), "input size mismatch");
+ assert_eq!(alpha.len(), snake_channels, "alpha size mismatch");
let mut output = vec![0.0_f32; input.len()];
for batch in 0..batch_size {
@@ -508,5 +399,5 @@ pub fn half_snake_reference(spec: HalfSnakeSpec<'_>) -> AudioResult<Vec<f32>> {
}
}
- Ok(output)
+ output
}
diff --git a/crates/backend-uzu/tests/common/repeat_speculator.rs b/crates/backend-uzu/tests/common/repeat_speculator.rs
index 50de1804d..89095912e 100644
--- a/crates/backend-uzu/tests/common/repeat_speculator.rs
+++ b/crates/backend-uzu/tests/common/repeat_speculator.rs
@@ -1,6 +1,6 @@
use std::collections::HashMap;
-use backend_uzu::prelude::Speculator;
+use backend_uzu::speculators::speculator::Speculator;
pub struct RepeatSpeculator;
diff --git a/crates/backend-uzu/tests/performance/model_loading_perf_test.rs b/crates/backend-uzu/tests/performance/model_loading_perf_test.rs
index bee05782a..0c01644ac 100644
--- a/crates/backend-uzu/tests/performance/model_loading_perf_test.rs
+++ b/crates/backend-uzu/tests/performance/model_loading_perf_test.rs
@@ -1,4 +1,4 @@
-use backend_uzu::prelude::{ChatSession, DecodingConfig};
+use backend_uzu::session::{ChatSession, config::DecodingConfig};
use proc_macros::uzu_test;
use crate::common::{path::get_test_model_path, perf::run_perf};
diff --git a/crates/backend-uzu/unit/audio/nanocodec/runtime.rs b/crates/backend-uzu/unit/audio/nanocodec/runtime.rs
index e9629738a..41dcdbf51 100644
--- a/crates/backend-uzu/unit/audio/nanocodec/runtime.rs
+++ b/crates/backend-uzu/unit/audio/nanocodec/runtime.rs
@@ -3,10 +3,11 @@
use proc_macros::uzu_test;
use crate::{
- audio::{NanoCodecFsqRuntime, NanoCodecFsqRuntimeConfig},
+ audio::{
+ AudioCodecRuntime, AudioError, AudioPcmBatch, AudioTokenGrid, NanoCodecFsqRuntime, NanoCodecFsqRuntimeConfig,
+ },
backends::metal::Metal,
common::audio::fsq_reference::{fsq_decode_reference, fsq_encode_reference},
- prelude::{AudioCodecRuntime, AudioError, AudioPcmBatch, AudioTokenGrid},
};
fn create_runtime() -> NanoCodecFsqRuntime<Metal> {
@@ -88,8 +89,7 @@ fn nanocodec_runtime_encode_matches_fsq_reference() {
runtime.config().num_levels_per_group(),
runtime.config().dim_base_index(),
runtime.config().eps(),
- )
- .expect("fsq reference encode");
+ );
let expected_u32: Vec<u32> = expected_i32.into_iter().map(|value| value as u32).collect();
let expected = AudioTokenGrid::new(
expected_u32.into_boxed_slice(),
@@ -124,8 +124,7 @@ fn nanocodec_runtime_decode_matches_fsq_reference() {
encoded.frames(),
runtime.config().codebook_dim_per_group(),
runtime.config().num_levels_per_group(),
- )
- .expect("fsq reference decode");
+ );
let expected_samples =
unpack_reference_output(&reference_padded, runtime.config().channels(), encoded.frames(), encoded.lengths());
@@ -178,7 +177,7 @@ fn nanocodec_runtime_encode_rejects_channel_mismatch() {
#[uzu_test]
fn fsq_decode_reference_masks_values_beyond_lengths() {
- let output = fsq_decode_reference(&[0, 7, 11, 3, 5, 9], &[2], 1, 2, 3, 2, &[8, 5]).expect("decode");
+ let output = fsq_decode_reference(&[0, 7, 11, 3, 5, 9], &[2], 1, 2, 3, 2, &[8, 5]);
assert_eq!(output.len(), 12);
let masked_t2 = [output[2], output[5], output[8], output[11]];
@@ -197,8 +196,7 @@ fn fsq_encode_reference_masks_values_beyond_lengths() {
&[8, 6],
&[1, 8],
1e-3,
- )
- .expect("encode");
+ );
assert_eq!(tokens.len(), 8);
assert_eq!(tokens[3], 0);
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.rs
index f83d517c0..c23a48cb7 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
@@ -111,8 +111,7 @@ fn audio_conv1d_replicate_matches_reference_f32() {
dilation,
padding,
pad_mode: PadMode::Replicate,
- })
- .expect("reference conv1d");
+ });
run_command_buffer(&context, |command_buffer| {
borrow_array_buffer!(input_buffer = input);
@@ -200,8 +199,7 @@ fn audio_causal_conv1d_matches_reference_f32() {
seq_len,
kernel_size,
dilation,
- })
- .expect("reference causal conv1d");
+ });
run_command_buffer(&context, |command_buffer| {
borrow_array_buffer!(input_buffer = input);
@@ -290,8 +288,7 @@ fn audio_causal_conv_transpose1d_matches_reference_f32() {
seq_len_out,
stride,
groups,
- })
- .expect("reference causal conv transpose1d");
+ });
run_command_buffer(&context, |command_buffer| {
borrow_array_buffer!(input_buffer = input);
@@ -367,8 +364,7 @@ fn audio_causal_conv_transpose1d_causal_pad_matches_reference_f32() {
seq_len_out,
stride,
groups,
- })
- .expect("reference causal conv transpose lalamo");
+ });
let mut input_values_nsc = vec![0.0_f32; input_len];
for b in 0..batch_size {
@@ -594,8 +590,7 @@ fn audio_half_snake_matches_reference_f32() {
snake_channels,
negative_slope,
eps,
- })
- .expect("reference half snake");
+ });
for index in 0..n {
let delta = (expected[index] - got[index]).abs();
assert!(
@@ -760,8 +755,7 @@ fn audio_fsq_decode_matches_reference() {
});
let expected =
- fsq_decode_reference(&[0, 7, 11, 3, 5, 9], &[2], batch_size, num_groups, seq_len, codebook_dim, &num_levels)
- .expect("reference decode");
+ fsq_decode_reference(&[0, 7, 11, 3, 5, 9], &[2], batch_size, num_groups, seq_len, codebook_dim, &num_levels);
let actual = allocation_to_vec::<Metal, f32>(&output);
for (index, (&a, &e)) in actual.iter().zip(expected.iter()).enumerate() {
@@ -829,8 +823,7 @@ fn audio_fsq_encode_matches_reference() {
&num_levels,
&dim_base_index,
eps,
- )
- .expect("reference encode");
+ );
let actual = allocation_to_vec::<Metal, i32>(&tokens);
assert_eq!(actual, expected);
diff --git a/crates/backend-uzu/unit/encodable_block/sampling_test.rs b/crates/backend-uzu/unit/encodable_block/sampling_test.rs
index f3030f00a..4bc4e0af8 100644
--- a/crates/backend-uzu/unit/encodable_block/sampling_test.rs
+++ b/crates/backend-uzu/unit/encodable_block/sampling_test.rs
@@ -17,8 +17,7 @@ use crate::{
},
data_type::DataType,
encodable_block::Sampling,
- prelude::SamplingMethod,
- session::parameter::SamplingProcessingOrder,
+ session::parameter::{SamplingMethod, SamplingProcessingOrder},
};
struct SamplingTestResults(Vec<u32>);
diff --git a/crates/backend-uzu/unit/session/chat_session.rs b/crates/backend-uzu/unit/session/chat_session.rs
index 22ceb9874..0e20385db 100644
--- a/crates/backend-uzu/unit/session/chat_session.rs
+++ b/crates/backend-uzu/unit/session/chat_session.rs
@@ -7,13 +7,13 @@ use tokenizers::Tokenizer;
use crate::{
common::path::get_test_model_path,
- prelude::{FixedTokensSpeculator, PromptLookupSpeculator, SpeculatorConfig},
session::{
Session,
- config::{DecodingConfig, RunConfig},
+ config::{DecodingConfig, RunConfig, SpeculatorConfig},
parameter::{AsyncBatchSize, SamplingSeed},
types::{Input, Message, Output},
},
+ speculators::{fixed_token_speculator::FixedTokensSpeculator, prompt_lookup_speculator::PromptLookupSpeculator},
};
fn build_decoding_config() -> DecodingConfig {
diff --git a/crates/backend-uzu/unit/session/config/grammar_config.rs b/crates/backend-uzu/unit/session/config/grammar_config.rs
index d1075f2a6..b010bb2ef 100644
--- a/crates/backend-uzu/unit/session/config/grammar_config.rs
+++ b/crates/backend-uzu/unit/session/config/grammar_config.rs
@@ -12,7 +12,7 @@ use crate::{
session::{
Session,
config::{DecodingConfig, GrammarConfig, RunConfig, SpeculatorConfig},
- parameter::SamplingPolicy,
+ parameter::{SamplingPolicy, SamplingSeed},
types::Input,
},
};
@@ -46,7 +46,7 @@ fn test_grammar(speculator_config: SpeculatorConfig) {
}
let decoding_config = DecodingConfig::default()
- .with_sampling_seed(backend_uzu::prelude::SamplingSeed::Custom(42))
+ .with_sampling_seed(SamplingSeed::Custom(42))
.with_speculator_config(speculator_config);
let mut session = Session::new(model_dir, decoding_config).expect("Failed to create session");
diff --git a/crates/backend-uzu/unit/speculators/fixed_token_speculator.rs b/crates/backend-uzu/unit/speculators/fixed_token_speculator.rs
index 64974ff1f..f2b3d2025 100644
--- a/crates/backend-uzu/unit/speculators/fixed_token_speculator.rs
+++ b/crates/backend-uzu/unit/speculators/fixed_token_speculator.rs
@@ -2,7 +2,7 @@ use std::collections::HashMap;
use proc_macros::uzu_test;
-use crate::prelude::{FixedTokensSpeculator, Speculator};
+use crate::speculators::{fixed_token_speculator::FixedTokensSpeculator, speculator::Speculator};
#[uzu_test]
fn test_fixed_token_speculator_single() {
diff --git a/crates/backend-uzu/unit/speculators/prompt_lookup_speculator.rs b/crates/backend-uzu/unit/speculators/prompt_lookup_speculator.rs
index e1ff1f322..e551236f0 100644
--- a/crates/backend-uzu/unit/speculators/prompt_lookup_speculator.rs
+++ b/crates/backend-uzu/unit/speculators/prompt_lookup_speculator.rs
@@ -5,7 +5,7 @@ use tokenizers::Tokenizer;
use crate::{
common::path::get_test_model_path,
- prelude::{PromptLookupSpeculator, Speculator},
+ speculators::{prompt_lookup_speculator::PromptLookupSpeculator, speculator::Speculator},
};
fn load_tokenizer() -> Tokenizer {
diff --git a/crates/backend-uzu/unit/speculators/token_finder_speculator.rs b/crates/backend-uzu/unit/speculators/token_finder_speculator.rs
index 64247febb..4db3d4d41 100644
--- a/crates/backend-uzu/unit/speculators/token_finder_speculator.rs
+++ b/crates/backend-uzu/unit/speculators/token_finder_speculator.rs
@@ -1,6 +1,6 @@
use proc_macros::uzu_test;
-use crate::prelude::TokenFinder;
+use crate::speculators::token_finder::TokenFinder;
#[uzu_test]
fn test_find_candidate_pred_token_empty_sequence() {
diff --git a/crates/backend-uzu/unit/trie_test.rs b/crates/backend-uzu/unit/trie_test.rs
index 4e07d32df..0c61fccb5 100644
--- a/crates/backend-uzu/unit/trie_test.rs
+++ b/crates/backend-uzu/unit/trie_test.rs
@@ -2,8 +2,7 @@ use std::collections::HashMap;
use crate::{
language_model::rng::PRng,
- prelude::Speculator,
- speculators::empty_speculator::EmptySpeculator,
+ speculators::{empty_speculator::EmptySpeculator, speculator::Speculator},
trie::{TrieCreationConfig, TrieNode},
};
diff --git a/crates/proc-macros/src/lib.rs b/crates/proc-macros/src/lib.rs
index cc6f96cf0..fae235a29 100644
--- a/crates/proc-macros/src/lib.rs
+++ b/crates/proc-macros/src/lib.rs
@@ -4,6 +4,7 @@ mod uzu_test;
use proc_macro::TokenStream;
+// CPU kernel DSL
#[proc_macro_attribute]
pub fn kernel(
args: TokenStream,
@@ -12,6 +13,7 @@ pub fn kernel(
dsl::kernel(args, input)
}
+// Config DSL
#[proc_macro_attribute]
pub fn uzu_config_abstract(
args: TokenStream,
@@ -28,12 +30,13 @@ pub fn uzu_config(
uzu_config::uzu_config(args, input)
}
+// Test DSL
#[proc_macro_attribute]
pub fn uzu_test(
args: TokenStream,
input: TokenStream,
) -> TokenStream {
- uzu_test::__internal_uzu_test(args, input)
+ uzu_test::uzu_test(args, input)
}
#[proc_macro_attribute]
@@ -41,13 +44,5 @@ pub fn uzu_bench(
args: TokenStream,
input: TokenStream,
) -> TokenStream {
- uzu_test::__internal_uzu_bench(args, input)
-}
-
-#[proc_macro_attribute]
-pub fn uzu_ignore(
- args: TokenStream,
- input: TokenStream,
-) -> TokenStream {
- uzu_test::__internal_uzu_ignored(args, input)
+ uzu_test::uzu_bench(args, input)
}
diff --git a/crates/proc-macros/src/uzu_test.rs b/crates/proc-macros/src/uzu_test.rs
index d07d58741..7267a5918 100644
--- a/crates/proc-macros/src/uzu_test.rs
+++ b/crates/proc-macros/src/uzu_test.rs
@@ -2,7 +2,7 @@ use proc_macro::TokenStream;
use quote::quote;
use syn::{ItemFn, parse_macro_input};
-pub fn __internal_uzu_test(
+pub fn uzu_test(
_args: TokenStream,
input: TokenStream,
) -> TokenStream {
@@ -15,7 +15,7 @@ pub fn __internal_uzu_test(
.into()
}
-pub fn __internal_uzu_bench(
+pub fn uzu_bench(
_args: TokenStream,
input: TokenStream,
) -> TokenStream {
@@ -27,16 +27,3 @@ pub fn __internal_uzu_bench(
}
.into()
}
-
-pub fn __internal_uzu_ignored(
- _args: TokenStream,
- input: TokenStream,
-) -> TokenStream {
- let func = parse_macro_input!(input as ItemFn);
-
- quote! {
- #[allow(unused)]
- #func
- }
- .into()
-}