Skip to content

Add batched DFlash v1 decoding with live request membership - #121

Open
ronaldmannak wants to merge 4 commits into
pico/integrationfrom
codex/dflash-batched-integration
Open

ronaldmannak wants to merge 4 commits into
pico/integrationfrom
codex/dflash-batched-integration

Conversation

@ronaldmannak

@ronaldmannak ronaldmannak commented Nov 24, 2026 •

Copy link
Copy Markdown
Owner

Batched DFlash decoding on Pico integration

Add an opt-in BatchedDFlashTokenIterator for text requests using a dense, single-device Qwen3.5 target and a trained DFlash v1 drafter. One verification pass advances multiple requests. Each request keeps its own accepted prefix, sampler, generation limit, and recurrent state. Callers can admit or cancel requests between blocks using stable IDs.

For prompt reuse, a snapshot carries the target cache, projected draft context, and exact token history. A caller that retained only part of a returned block gets a cache miss. Admission currently prefills the arriving request synchronously. The batch uses full-precision, unbounded KV caches. PicoCore serving policy is a separate integration step.

The first commit ports the DFlash loader, verifier, and reference tests from #70 and #71 to pico/integration. It preserves the fork's native MTP and tensor-parallel paths. The batched implementation is a sibling of the existing ordinary iterator.

Verification

  • The ported DFlash loader, sampling, and Python fixture tests passed on Apple silicon.
  • Focused batch tests passed for unequal positions, per-request acceptance, stable seeded streams through admission and cancellation, stop handling, and prefix restoration.
  • The release benchmark compares both paths with the same target, four held-out prompts, row seeds 37–40, temperature 0.8 and top-p 0.9. It includes fixed membership and a staggered workload with cancellation.

Local Release benchmark on an Apple M5 Max, 40 GPU cores and 128 GB. Both the target and drafter were resident in both arms. Rates are median aggregate output tokens per second over three interleaved runs, including admission and final synchronization.

Workload Ordinary batching DFlash, block 4 Change
Four simultaneous requests, 64 outputs each 188.7 273.4 +44.9%
Requests join and one cancels between blocks 127.4 204.1 +60.2%

For the fixed batch the p95 inter-token gap rose from 19.6 to 29.0 ms. The staggered workload cancels at a token-progress threshold. That request produced 16 tokens under ordinary batching and 21 under DFlash. The other three requests each completed all 64 tokens. Both arms reproduced their token streams on all measured repeats.

The full local MLXLMTests run at 5107ce2 recorded 3,128 passes, 10 skips, one existing expected failure (MiniCPM5 tool parsing), and zero unexpected failures. The pinned pre-commit formatter passed. Both the iterator and public token stream now reject unsupported token log probabilities before prefill. Regression tests passed for zero and three requested alternatives. GitHub skipped its hosted jobs under the fork’s upstream-only workflow guards.

AI usage

OpenAI Codex adapted the existing DFlash port, implemented and reviewed the batched path, and ran the local validation.

Carry the Qwen verifier, v1/v2 drafter, loader, and Python-reference tests from #70 and #71. Preserve the integration branch’s native MTP, batched position handling, and tensor-parallel path.

Original DFlash2 port: spokvulcan (6059057). The v1 loader and review fixes are from 7791ace.
Verify blocks at independent request positions, retain per-request sampling and recurrent state across admission or cancellation, and capture target/drafter prefixes only at retained delivery boundaries.
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 24, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-24T14:48:22.477396Z 5107ce2 New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 650158d72b

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

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.

1 participant