Skip to content

perf(prefill): export only final MLX snapshot - #191

Merged
FluffyAIcode merged 1 commit into
mainfrom
AgentMemory/final-only-prefill-snapshot-0717
Jul 17, 2026
Merged

perf(prefill): export only final MLX snapshot#191
FluffyAIcode merged 1 commit into
mainfrom
AgentMemory/final-only-prefill-snapshot-0717

Conversation

@FluffyAIcode

Copy link
Copy Markdown
Owner

Summary

  • keep full MLX Prefill computation over every input token
  • export, KakeyaLattice-encode, and zlib-compress only the final snapshot
  • accept final-only worker results while retaining compatibility with engines that publish every boundary
  • preserve atomic capacity reservation and final lease guarantees
  • add tests proving one export for multi-block prompts and final-only remote job discovery

Root cause

The worker previously exported a growing full KV snapshot every 64 tokens. A 1,569-token Critic context therefore performed roughly 25 full exports and compression passes. Since each later snapshot contains a longer prefix, serialization work grew approximately quadratically and made distributed Prefill unusable compared with single-node Prefill.

The final chained hash commits all preceding blocks, so intermediate full snapshots are not required for correctness.

Tests

  • final-only MLX export, cache publication, lease, and remote worker paths — 30 targeted tests pass
  • full platform-neutral suite — 870 passed, 1 skipped
  • Python compile and diff checks pass

Made with Cursor

Eliminate quadratic full-cache serialization by computing every token normally but encoding and compressing only the final chained-prefix snapshot.

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.

@FluffyAIcode
FluffyAIcode merged commit d479e74 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