Implement batched server parity and observability
This commit is contained in:
@@ -46,6 +46,8 @@ pub(super) struct Tensor {
|
||||
pub(super) struct Gguf {
|
||||
path: PathBuf,
|
||||
map: Mmap,
|
||||
data_offset: u64,
|
||||
max_tensor_bytes: u64,
|
||||
pub(super) metadata: HashMap<String, Value>,
|
||||
pub(super) tensors: HashMap<String, Tensor>,
|
||||
}
|
||||
@@ -141,6 +143,7 @@ impl Gguf {
|
||||
}
|
||||
|
||||
let data_start = align(cursor.position() as u64, alignment)?;
|
||||
let mut max_tensor_bytes = 0;
|
||||
for (name, tensor) in &mut tensors {
|
||||
tensor.offset = data_start
|
||||
.checked_add(tensor.offset)
|
||||
@@ -152,11 +155,14 @@ impl Gguf {
|
||||
if end > map.len() as u64 {
|
||||
return Err(format!("tensor {name} points outside the GGUF file"));
|
||||
}
|
||||
max_tensor_bytes = max_tensor_bytes.max(tensor.bytes);
|
||||
}
|
||||
|
||||
Ok(Self {
|
||||
path: path.to_owned(),
|
||||
map,
|
||||
data_offset: data_start,
|
||||
max_tensor_bytes,
|
||||
metadata,
|
||||
tensors,
|
||||
})
|
||||
@@ -174,6 +180,14 @@ impl Gguf {
|
||||
self.map.as_ptr()
|
||||
}
|
||||
|
||||
pub(super) fn data_offset(&self) -> u64 {
|
||||
self.data_offset
|
||||
}
|
||||
|
||||
pub(super) fn max_tensor_bytes(&self) -> u64 {
|
||||
self.max_tensor_bytes
|
||||
}
|
||||
|
||||
pub(super) fn tensor(&self, name: &str) -> Result<&Tensor, String> {
|
||||
self.tensors
|
||||
.get(name)
|
||||
|
||||
Reference in New Issue
Block a user