From eefc4a552ef8c9b8100f27054d1050ee5ecdce9f Mon Sep 17 00:00:00 2001 From: Pavlo Ratushnyi Date: Sun, 8 Nov 2026 00:43:59 +0100 Subject: [PATCH] STRA-338 params p02: rename the quantization input struct Target to QuantTarget (domain name) --- crates/native-cpu-expert/src/rust_weight_iq.rs | 2 +- crates/native-cpu-expert/src/rust_weight_iq/alloc_fn.rs | 6 +++--- .../src/rust_weight_iq/alloc_fn/scale_search.rs | 2 +- crates/native-cpu-expert/src/rust_weight_iq/iq2_xxs_fn.rs | 4 ++-- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/crates/native-cpu-expert/src/rust_weight_iq.rs b/crates/native-cpu-expert/src/rust_weight_iq.rs index 577341dc..68e97ca2 100644 --- a/crates/native-cpu-expert/src/rust_weight_iq.rs +++ b/crates/native-cpu-expert/src/rust_weight_iq.rs @@ -48,7 +48,7 @@ use alloc_fn::signs; #[allow(unused_imports)] use alloc_fn::totals; #[allow(unused_imports)] -use alloc_fn::{CandidateStep, Target, quant_candidates}; +use alloc_fn::{CandidateStep, QuantTarget, quant_candidates}; mod iq2_xxs_fn; #[allow(unused_imports)] use iq2_xxs_fn::iq2_xs; diff --git a/crates/native-cpu-expert/src/rust_weight_iq/alloc_fn.rs b/crates/native-cpu-expert/src/rust_weight_iq/alloc_fn.rs index 6a93ebfe..daf17ae1 100644 --- a/crates/native-cpu-expert/src/rust_weight_iq/alloc_fn.rs +++ b/crates/native-cpu-expert/src/rust_weight_iq/alloc_fn.rs @@ -231,7 +231,7 @@ pub(super) fn totals(x: &[f32], w: &[f32], l: &[i8]) -> (f32, f32) { } /// The values to quantize and their weights. #[derive(Clone, Copy)] -pub(super) struct Target<'a> { +pub(super) struct QuantTarget<'a> { pub(super) x: &'a [f32], pub(super) w: &'a [f32], } @@ -242,8 +242,8 @@ pub(super) struct CandidateStep { pub(super) scale: f32, pub(super) max: i32, } -pub(super) fn quant_candidates(g: &Grid, target: Target, step: CandidateStep, l: &mut [i8], on: &mut [bool]) { - let Target { x, w } = target; +pub(super) fn quant_candidates(g: &Grid, target: QuantTarget, step: CandidateStep, l: &mut [i8], on: &mut [bool]) { + let QuantTarget { x, w } = target; let CandidateStep { inv, scale, max } = step; for k in 0..x.len() / g.dim { let at = k * g.dim; diff --git a/crates/native-cpu-expert/src/rust_weight_iq/alloc_fn/scale_search.rs b/crates/native-cpu-expert/src/rust_weight_iq/alloc_fn/scale_search.rs index 35ed59ef..2bcab69e 100644 --- a/crates/native-cpu-expert/src/rust_weight_iq/alloc_fn/scale_search.rs +++ b/crates/native-cpu-expert/src/rust_weight_iq/alloc_fn/scale_search.rs @@ -86,7 +86,7 @@ pub(in super::super) fn search_scale( let inv = (t.centre + is as f32 * t.step) / max; let mut aux = [0i8; N]; let mut ao = [true; G]; - let target = Target { x: &b.xv, w: &b.wa }; + let target = QuantTarget { x: &b.xv, w: &b.wa }; let step = CandidateStep { inv, scale: 1.0 / inv, max: t.levels }; quant_candidates(g, target, step, &mut aux, &mut ao); let (sx, s2) = totals(&b.xv, &b.w, &aux); diff --git a/crates/native-cpu-expert/src/rust_weight_iq/iq2_xxs_fn.rs b/crates/native-cpu-expert/src/rust_weight_iq/iq2_xxs_fn.rs index ac1a48a3..1c1821a0 100644 --- a/crates/native-cpu-expert/src/rust_weight_iq/iq2_xxs_fn.rs +++ b/crates/native-cpu-expert/src/rust_weight_iq/iq2_xxs_fn.rs @@ -70,7 +70,7 @@ fn iq2_xxs_search(g: &Grid, b: &Block<32>, start: (f32, [i8; 32]), effective: f3 let inv = (5.0 + is as f32 * 0.1) / effective; let mut aux = [0i8; 32]; let step = CandidateStep { inv, scale: 1.0 / inv, max: 3 }; - quant_candidates(g, Target { x: &b.xv, w: &b.wa }, step, &mut aux, &mut [false; 4]); + quant_candidates(g, QuantTarget { x: &b.xv, w: &b.wa }, step, &mut aux, &mut [false; 4]); let (sx, s2) = totals(&b.xv, &b.w, &aux); if s2 > 0.0 && sx * sx > best * s2 { scale = sx / s2; @@ -80,7 +80,7 @@ fn iq2_xxs_search(g: &Grid, b: &Block<32>, start: (f32, [i8; 32]), effective: f3 } if scale > 0.0 { let step = CandidateStep { inv: 1.0 / scale, scale, max: 3 }; - quant_candidates(g, Target { x: &b.xv, w: &b.wa }, step, &mut l, &mut [false; 4]); + quant_candidates(g, QuantTarget { x: &b.xv, w: &b.wa }, step, &mut l, &mut [false; 4]); let (sx, s2) = totals(&b.xv, &b.w, &l); if s2 > 0.0 { scale = sx / s2;