STRA-338 params p02: rename the quantization input struct Target to QuantTarget (domain name)

This commit is contained in:
Pavlo Ratushnyi
2026-11-08 00:43:59 +01:00
parent 4cecb118ac
commit eefc4a552e
4 changed files with 7 additions and 7 deletions
@@ -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;
@@ -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;
@@ -86,7 +86,7 @@ pub(in super::super) fn search_scale<const N: usize, const G: usize>(
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);
@@ -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;