Skip to content

Commit 91b0ebd

Browse files
authored
Merge pull request #368 from AdaWorldAPI/claude/gguf-data-offset-fix
fix(gguf): restore 32-byte scaling on data_offset (chatgpt-codex catch on PR #367)
2 parents f6c63d9 + 48d6628 commit 91b0ebd

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

crates/bgz-tensor/examples/gguf_thinking_styles.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -357,7 +357,15 @@ fn parse_gguf_header<R: Read + Seek>(r: &mut R) -> Result<GgufHeader, String> {
357357
let pos = r.stream_position().map_err(|e| e.to_string())?;
358358
Ok(GgufHeader {
359359
tensors,
360-
data_offset: (pos + 31).div_ceil(32),
360+
// data_offset is the BYTE OFFSET of the tensor payload, rounded
361+
// up to a 32-byte boundary. `pos.div_ceil(32) * 32` matches the
362+
// GGUF spec (align-32) and the parallel parsers in
363+
// gguf_euler_fold.rs / gguf_families.rs / gamma_phi_gguf.rs.
364+
// (chatgpt-codex catch on PR #367: the earlier `(pos + 31).div_ceil(32)`
365+
// dropped the `* 32` byte-scaling — that returned the 32-byte
366+
// block COUNT, off by a factor of 32, causing tensor reads to
367+
// seek into the header.)
368+
data_offset: pos.div_ceil(32) * 32,
361369
})
362370
}
363371

0 commit comments

Comments
 (0)