context: heal pre-refactor image logs with token_count=0
Recompute image token counts from persisted dimensions when loading old logs that stored count=0 (server-authoritative count was applied after AppendImage before client-side pad expansion). graph: cache neighbor sets for clustering coefficient Pre-compute neighbor HashSets so the O(deg^2) triangle-counting inner loop doesn't re-allocate on every (i,j) pair. avg_clustering_ coefficient() now builds the cache once instead of O(N*deg) times.
This commit is contained in:
parent
371b40078d
commit
5210f7dd66
2 changed files with 60 additions and 20 deletions
|
|
@ -125,7 +125,19 @@ impl<'de> Deserialize<'de> for NodeLeaf {
|
|||
body: NodeBody,
|
||||
timestamp: DateTime<Utc>,
|
||||
}
|
||||
let raw = Raw::deserialize(deserializer)?;
|
||||
let mut raw = Raw::deserialize(deserializer)?;
|
||||
// Heal pre-refactor logs: Image leaves used to be deserialized
|
||||
// with token_count=0 (server-authoritative count was applied
|
||||
// after AppendImage). With pads now expanded client-side at
|
||||
// construction, recompute from the persisted dimensions if
|
||||
// the stored count is 0.
|
||||
if let NodeBody::Image { orig_height, orig_width, token_count, .. }
|
||||
= &mut raw.body
|
||||
{
|
||||
if *token_count == 0 {
|
||||
*token_count = qwen3_image_token_count(*orig_height, *orig_width);
|
||||
}
|
||||
}
|
||||
let token_ids = raw.body.compute_token_ids();
|
||||
Ok(NodeLeaf { body: raw.body, token_ids, timestamp: raw.timestamp })
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue