Skip to content

Commit 4013e52

Browse files
Merge pull request #924 from 0xASTRA:fix/weights-readallbf16-missing-blob-size-assert
PiperOrigin-RevId: 925467040
2 parents f3e57ec + 3455221 commit 4013e52

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

gemma/weights.cc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -593,6 +593,10 @@ static void ReadAllToBF16(const std::vector<TensorToRead>& tensors,
593593
GCPP_ZONE(ctx, thread, Zones::kStartupWeightsReadAllToBF16);
594594
const TensorToRead& tensor = tensors[task];
595595
MatPtr& mat = *tensor.mat;
596+
// Validate blob size matches allocated buffer before any read.
597+
// MapAll (line ~557) and MakeBatches (line ~645) both assert this;
598+
// this path was the only one missing the check.
599+
HWY_ASSERT_M(tensor.range.bytes == mat.PackedBytes(), mat.Name());
596600

597601
if (tensor.keep_type) {
598602
HWY_ASSERT(reader.file().Read(

0 commit comments

Comments
 (0)