Skip to content

fix(weights): release read allocations before completing futures - #256

Closed
Afloat16 wants to merge 1 commit into
Edge0-AI:mainfrom
Afloat16:fix/weight-read-completion-20261116
Closed

Afloat16 wants to merge 1 commit into
Edge0-AI:mainfrom
Afloat16:fix/weight-read-completion-20261116

Conversation

@Afloat16

Copy link
Copy Markdown
Contributor

What & why

An asynchronous weight read retains its allocation in the packaged-task closure. Its future can become ready before that closure is destroyed, so complete() followed by close() can leave the resident-weight budget charged until the worker releases its task. The existing mixed-storage test also intermittently encounters this residual charge.

Move the worker's allocation reference into a local lifetime guard when the task starts. It keeps the buffer alive throughout the read and releases the reference before the task publishes its result, including an error return or exception. Add a regression that completes, checks the loaded bytes and closes 1,000 small weight loads, checking that no completed load retains a resident charge.

Area

  • Engine, CLI or server (edge0-infer/)

How was it tested?

The isolated before/after validation tests these two files against upstream f6bfa5546bcf89919f86946ec669bcc7f4cd526d.

  • Before: the first 1,000-load stress run did not reproduce the race; the second left a resident charge after 115 of 1,000 completed loads and failed the regression. The original, unmodified mixed-storage test also reproduced its existing budget assertion failure in 42 of 100 runs.
  • After: 10 consecutive stress runs, totaling 10,000 completed loads, retained zero charges. Existing shared views, group protection, independent copies and staged admission checks passed.
  • Full Linux L0/L1: 98 passed, 3 device skips and the 3 previously reproduced upstream failures (platform_memory, ordered_json, template_tools). All runnable weights tests passed, including lifecycle and staged read-error coverage.
  • CPU L2 weights_compute and weights_group_compute: both passed.
  • Local Linux: the regression changed from 14/1,000 residual charges to zero; full L0/L1 had 99 passes, 3 device skips and the 2 existing local environment failures (app_generation temporary file and platform_memory). Both CPU L2 weights tests passed locally as well.

Checklist

  • Full local L0/L1 passes: the reproduced environment/baseline failures are listed above.
  • Ran affected native and CPU L2 tests.
  • Added a regression for the changed behavior.
  • Reviewed documentation impact: the patch restores the existing completion and budget-release behavior.

@shuk777

shuk777 commented Nov 19, 2026

Copy link
Copy Markdown
Collaborator

Closing as part of clearing this pre-hygiene queue; see #298 (comment) for the note on the updated review process. Thank you again.

@shuk777 shuk777 closed this Nov 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants