Skip to content

fix(prefill): atomically reserve and publish snapshots - #187

Merged
FluffyAIcode merged 2 commits into
mainfrom
AgentMemory/atomic-prefill-snapshot-0717
Jul 17, 2026
Merged

fix(prefill): atomically reserve and publish snapshots#187
FluffyAIcode merged 2 commits into
mainfrom
AgentMemory/atomic-prefill-snapshot-0717

Conversation

@FluffyAIcode

Copy link
Copy Markdown
Owner

Summary

  • preflight estimated final-snapshot capacity before enqueuing model work
  • reserve the worker's full current cache budget before each single-concurrency MLX job
  • prevent adaptive cache resize from consuming active reservations
  • atomically publish and lease the final snapshot before optionally retaining intermediate boundaries
  • prioritize final snapshot correctness over intermediate cache density
  • raise allens adaptive cache floor from 0.25 GiB to 1 GiB and reduce reserve from 2 GiB to 0.5 GiB
  • bind Primary gRPC to 0.0.0.0:51051 so allens can reach its advertised Thunderbolt address

Root cause

The failed full-context Critic completed roughly 1,200 seconds of model compute, then published snapshots one by one into a 256 MiB adaptive LRU. Concurrent adaptive shrink and 66 evictions (1.07 GiB evicted) removed the final snapshot before the subsequent lookup/lease, producing computed snapshot was not discoverable.

Correctness guarantees

  • capacity rejection occurs before model compute
  • active reservations survive adaptive budget refresh
  • final snapshot publication and lease creation share one store lock
  • no local Prefill or semantic fallback is introduced

Tests

  • reservation, adaptive shrink, upfront rejection, cancellation, atomic final pinning, and remote orchestration coverage
  • targeted suite — 27 passed
  • full platform-neutral suite — 863 passed, 1 skipped
  • Python, shell, plist, and diff checks pass

Made with Cursor

Reserve worker cache capacity before expensive compute, protect it from adaptive shrink, and atomically lease the final snapshot so completed full-context Prefill cannot be evicted before discovery.

Co-authored-by: Cursor <cursoragent@cursor.com>
@cursor

cursor Bot commented Jul 17, 2026

Copy link
Copy Markdown

Bugbot is not enabled for your account, so this pull request was not reviewed.

Enable Bugbot in the Cursor dashboard to get automatic reviews on future PRs.

Exercise every atomic publish and capacity guard while making public cache writes respect active reservations.

Co-authored-by: Cursor <cursoragent@cursor.com>
@FluffyAIcode
FluffyAIcode merged commit 62ba253 into main Jul 17, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant