From 113231a5dfaaf70b4f9ed6cefe55dd7bf4e454cd Mon Sep 17 00:00:00 2001 From: Pavlo Ratushnyi Date: Fri, 6 Nov 2026 19:03:31 +0100 Subject: [PATCH] STRA-338 size-fn: strata-control: part_layout and plan_parts within the limits (fn>30 2 -> 0) --- control-plane/src/stream_parts/layout.rs | 16 ++++++++++------ control-plane/src/stream_parts/plan.rs | 12 ++++++++---- 2 files changed, 18 insertions(+), 10 deletions(-) diff --git a/control-plane/src/stream_parts/layout.rs b/control-plane/src/stream_parts/layout.rs index d2bc5ff4..4944a02c 100644 --- a/control-plane/src/stream_parts/layout.rs +++ b/control-plane/src/stream_parts/layout.rs @@ -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, String> { let mut dimensions = tensor.dimensions.clone(); diff --git a/control-plane/src/stream_parts/plan.rs b/control-plane/src/stream_parts/plan.rs index e691053d..07ce49dd 100644 --- a/control-plane/src/stream_parts/plan.rs +++ b/control-plane/src/stream_parts/plan.rs @@ -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, 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()) {