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
@@ -1063,11 +1063,7 @@ impl SmoothQuantizedLayer {
/// # Errors
///
/// Returns an error if the activation buffer length is inconsistent with `batch_size`.
pub fn forward_raw(
&self,
activations: &[f32],
batch_size: usize,
) -> Result<Vec<f32>> {
pub fn forward_raw(&self, activations: &[f32], batch_size: usize) -> Result<Vec<f32>> {
let in_f = self.in_features();
let out_f = self.out_features();
@@ -1104,10 +1100,7 @@ impl SmoothQuantizedLayer {
}
// Per-tensor activation scale: max absolute value over the whole batch.
let max_abs = smoothed
.iter()
.map(|v| v.abs())
.fold(0.0f32, f32::max);
let max_abs = smoothed.iter().map(|v| v.abs()).fold(0.0f32, f32::max);
// Guard against zero-tensor inputs; any non-zero scale works here.
let act_scale = if max_abs < f32::EPSILON {
@@ -1302,7 +1295,11 @@ mod tests {
);
let activations = vec![0.0f32; 2 * in_f]; // batch=2
let out = layer.forward_raw(&activations, 2).unwrap();
assert_eq!(out.len(), 2 * out_f, "output length must be batch * out_features");
assert_eq!(
out.len(),
2 * out_f,
"output length must be batch * out_features"
);
}
/// Identity layer (W=I, smoothing=1, zp=0, weight_scale=1) reproduces activations.
@@ -1353,13 +1350,10 @@ mod tests {
];
// Layer with smoothing_scales = [1.0; 4] (baseline)
let layer_no_smooth = make_smooth_layer(
out_f, in_f, identity.clone(), 1.0, 0, vec![1.0f32; in_f],
);
let layer_no_smooth =
make_smooth_layer(out_f, in_f, identity.clone(), 1.0, 0, vec![1.0f32; in_f]);
// Layer with smoothing_scales = [2.0; 4] (halves activations)
let layer_smooth = make_smooth_layer(
out_f, in_f, identity, 1.0, 0, vec![2.0f32; in_f],
);
let layer_smooth = make_smooth_layer(out_f, in_f, identity, 1.0, 0, vec![2.0f32; in_f]);
let activations = vec![10.0f32, 20.0, 30.0, 40.0];
@@ -1397,14 +1391,7 @@ mod tests {
/// Tolerance: 2% (quantisation rounding).
#[test]
fn test_smoothquant_forward_raw_matches_manual() {
let layer = make_smooth_layer(
2,
2,
vec![2i8, 0, 0, 2],
0.5,
0,
vec![1.0f32, 1.0],
);
let layer = make_smooth_layer(2, 2, vec![2i8, 0, 0, 2], 0.5, 0, vec![1.0f32, 1.0]);
let activations = vec![10.0f32, 20.0];
let out = layer.forward_raw(&activations, 1).unwrap();