Skip to content

Commit 74e04cc

Browse files
authored
Merge pull request #506 from AdaWorldAPI/claude/sleepy-cori-aRK2x
fix(bgz-tensor): resolve 5 CI-invisible test failures (3 stale tests + 1 slice-bounds bug)
2 parents e8fd2ca + 7472ce4 commit 74e04cc

4 files changed

Lines changed: 9 additions & 6 deletions

File tree

crates/bgz-tensor/src/gamma_calibration.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -432,7 +432,7 @@ mod tests {
432432

433433
#[test]
434434
fn calibration_profile_size() {
435-
assert_eq!(CalibrationProfile::byte_size(), 40); // 28 + 12
435+
assert_eq!(CalibrationProfile::byte_size(), 48); // RoleGamma 36 + CosineGamma 12
436436
}
437437

438438
#[test]

crates/bgz-tensor/src/hhtl_cache.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -630,8 +630,8 @@ mod tests {
630630
cache.serialize(path).expect("serialize");
631631

632632
let size = std::fs::metadata(path).map(|m| m.len()).unwrap_or(0);
633-
// 4 magic + 2 k + 256×34 entries + 256×256×2 distances + 256×256×1 routes + 256×4 radii
634-
let expected = 4 + 2 + 256 * 34 + 256 * 256 * 2 + 256 * 256 + 256 * 4;
633+
// 4 magic + 2 k + 256×34 entries + 256×256×2 distances + 256×256×1 routes + 256×4 radii + 16 gamma_meta
634+
let expected = 4 + 2 + 256 * 34 + 256 * 256 * 2 + 256 * 256 + 256 * 4 + 16;
635635
assert_eq!(
636636
size, expected as u64,
637637
"expected {expected} bytes, got {size}"

crates/bgz-tensor/src/hhtl_d.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -553,7 +553,7 @@ mod tests {
553553

554554
#[test]
555555
fn hhtl_d_entry_roundtrip() {
556-
let entry = HhtlDEntry::new(HeelBasin::Gate, 7, 42, true, 0x3C00); // BF16 1.0
556+
let entry = HhtlDEntry::new(HeelBasin::Gate, 7, 42, true, 0x3F80); // BF16 1.0 (0x3F80, not the F16 0x3C00)
557557
let bytes = entry.to_le_bytes();
558558
let decoded = HhtlDEntry::from_le_bytes(&bytes);
559559

crates/bgz-tensor/src/matryoshka.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -466,7 +466,7 @@ pub fn encode_row(row: &[f32], basis: &SvdBasis, profile: &BandProfile) -> Matry
466466

467467
for band in &profile.bands {
468468
let max_val = band.precision.max_val();
469-
let band_coeffs = &coeffs[band.start..band.end.min(coeffs.len())];
469+
let band_coeffs = &coeffs[band.start.min(coeffs.len())..band.end.min(coeffs.len())];
470470

471471
// Find scale for this band
472472
let band_max = band_coeffs
@@ -552,7 +552,10 @@ pub fn decode_row(encoded: &MatryoshkaRow, basis: &SvdBasis, profile: &BandProfi
552552
offset += 2;
553553
let inv_scale = band_max / max_val as f32;
554554

555-
let n = band.n_components();
555+
// Cap to the coeff buffer: the basis rank can be lower than the
556+
// profile's nominal max (e.g. fewer sample rows than requested
557+
// components), so a band may extend past the available coeffs.
558+
let n = band.n_components().min(coeffs.len().saturating_sub(band.start));
556559

557560
match band.precision {
558561
BandPrecision::I16 => {

0 commit comments

Comments
 (0)