style: cargo fmt --workspace (whitespace/wrapping only, no semantic change)

Whole-workspace rustfmt pass picked up while iterating on Mamba GPU
backward work. Verified formatting-only via diff sampling; no logic
changed.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
This commit is contained in:
osobh
2026-08-10 07:09:36 -07:00
co-authored by Claude Sonnet 5
parent ad6405663f
commit 4aaa36a57a
305 changed files with 25537 additions and 18337 deletions
@@ -284,7 +284,12 @@ impl LookaheadDecoder {
///
/// # Returns
/// The newly generated tokens (does not include `initial_tokens`).
pub fn decode<F>(&mut self, initial_tokens: &[u32], max_new_tokens: usize, score_fn: F) -> Vec<u32>
pub fn decode<F>(
&mut self,
initial_tokens: &[u32],
max_new_tokens: usize,
score_fn: F,
) -> Vec<u32>
where
F: Fn(&[u32]) -> u32,
{
@@ -313,7 +318,11 @@ impl LookaheadDecoder {
// The prefix spans the end of tokens and the start of draft.
let from_tokens = prefix_len - draft.len();
let token_start = tokens.len().saturating_sub(from_tokens);
tokens[token_start..].iter().chain(draft.iter()).cloned().collect()
tokens[token_start..]
.iter()
.chain(draft.iter())
.cloned()
.collect()
}
} else {
// Not enough history yet — build what we can.
@@ -380,9 +389,7 @@ impl LookaheadDecoder {
// ----------------------------------------------------------
// 4. Extend sequence
// ----------------------------------------------------------
let to_add = accepted_this_step
.len()
.min(remaining);
let to_add = accepted_this_step.len().min(remaining);
let accepted_slice = &accepted_this_step[..to_add];
tokens.extend_from_slice(accepted_slice);
@@ -399,8 +406,8 @@ impl LookaheadDecoder {
}
// Update derived statistic.
self.stats.avg_tokens_per_step = self.stats.total_tokens_generated as f32
/ self.stats.total_steps.max(1) as f32;
self.stats.avg_tokens_per_step =
self.stats.total_tokens_generated as f32 / self.stats.total_steps.max(1) as f32;
generated
}
@@ -466,7 +473,10 @@ mod tests {
fn test_ngram_cache_empty_prefix_returns_empty() {
let cache = NGramCache::new(3, 100);
let candidates = cache.top_candidates(&[99, 100], 5);
assert!(candidates.is_empty(), "unknown prefix must return empty vec");
assert!(
candidates.is_empty(),
"unknown prefix must return empty vec"
);
}
#[test]
@@ -518,7 +528,10 @@ mod tests {
decoder.warm_cache(&[10, 20, 30, 40, 50]);
// After warming, the prefix [10,20] should yield at least one candidate.
let candidates = decoder.cache().top_candidates(&[10, 20], 3);
assert!(!candidates.is_empty(), "warm_cache should populate the cache");
assert!(
!candidates.is_empty(),
"warm_cache should populate the cache"
);
}
// ------------------------------------------------------------------
@@ -707,6 +720,9 @@ mod tests {
fn test_decode_zero_new_tokens_returns_empty() {
let mut decoder = LookaheadDecoder::new(LookaheadConfig::default());
let generated = decoder.decode(&[1, 2, 3], 0, incrementer);
assert!(generated.is_empty(), "max_new_tokens=0 should return empty vec");
assert!(
generated.is_empty(),
"max_new_tokens=0 should return empty vec"
);
}
}