STRA-338 size-fn: strata-control: part_layout and plan_parts within the limits (fn>30 2 -> 0)

This commit is contained in:
Pavlo Ratushnyi
2026-11-06 19:03:31 +01:00
parent 44b428dd9a
commit 113231a5df
2 changed files with 18 additions and 10 deletions
+10 -6
View File
@@ -182,12 +182,7 @@ fn part_layout(
.ok_or("KAR part F32 byte count overflow")?;
let dimensions = part_dimensions(tensor, part_rows)?;
Ok(Layout {
name: format!(
"{}#strata-part-{:03}-of-{:03}",
tensor.name,
number + 1,
plan.count
),
name: part_name(tensor, number, plan.count),
dimensions,
source_byte_offset: cursors.0,
source_bytes: part_elements / geometry.block_elements * geometry.block_bytes,
@@ -196,6 +191,15 @@ fn part_layout(
})
}
fn part_name(tensor: &gguf::TensorInfo, number: u64, count: u64) -> String {
format!(
"{}#strata-part-{:03}-of-{:03}",
tensor.name,
number + 1,
count
)
}
/// The tensor's dimensions with the outermost one replaced by the part's row count.
fn part_dimensions(tensor: &gguf::TensorInfo, part_rows: u64) -> Result<Vec<u64>, String> {
let mut dimensions = tensor.dimensions.clone();
+8 -4
View File
@@ -25,6 +25,13 @@ struct ParentHashes {
}
impl ParentHashes {
fn new() -> Self {
Self {
source: Sha256::new(),
f32: Sha256::new(),
}
}
fn matches(self, original: &derived_mixed::TensorIdentity) -> bool {
self.source.finalize().as_slice() == original.source_sha256
&& self.f32.finalize().as_slice() == original.f32_sha256
@@ -107,10 +114,7 @@ impl<'a> Planner<'a> {
source: &mut File,
) -> Result<Vec<PartIdentity>, String> {
let split = layouts.len() > 1;
let mut parent = ParentHashes {
source: Sha256::new(),
f32: Sha256::new(),
};
let mut parent = ParentHashes::new();
let mut parts = Vec::with_capacity(layouts.len());
for part in layouts {
if !self.names.insert(part.name.clone()) {