Skip to content

Commit

Permalink
Fix split.count GGUF duplication handling (#695)
Browse files Browse the repository at this point in the history
* Fix n splits duplication handling

* Better logging and errors
  • Loading branch information
EricLBuehler authored Aug 20, 2024
1 parent 70c647c commit 2daef26
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions mistralrs-core/src/gguf/content.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,15 +61,23 @@ impl<'a, R: std::io::Seek + std::io::Read> Content<'a, R> {
.get("split.count")
.map(|val| val.to_u64().unwrap())
})
.collect::<Vec<_>>();
.fold(Vec::new(), |mut accum, x| {
if !accum.contains(&x) {
accum.push(x);
}
accum
});
if n_splits.len() > 1 {
candle_core::bail!("Multiple contents have multiple `split.count` fields");
candle_core::bail!("GGUF files have differing `split.count` values: {n_splits:?}. Perhaps the GGUF files do not match?");
}
#[allow(clippy::cast_possible_truncation)]
if !n_splits.is_empty() && n_readers != n_splits[0] as usize {
candle_core::bail!("Number of readers does not match the number of splits.");
candle_core::bail!(
"Number of GGUF files does not match the number of splits, expected {} files.",
n_splits[0]
);
} else if n_splits.len() == 1 {
info!("Model n splits: {}", n_splits[0]);
info!("GGUF file has been split into {} shards", n_splits[0]);
}

let mut arch = None;
Expand Down

0 comments on commit 2daef26

Please sign in to comment.