perf: Batched DFlash2 drafting for concurrent Raon-1 mini requests

オープン
#3,469 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
5/5
見積もり時間
1週間以上
初心者へのやさしさ
35/100
issue の種類
機能追加
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
rust

調査の方向性

Read the batched Qwen 3.5 path in src/server/batch/dflash_target.rs, the Raon speculative forward in src/models/raon1_mini_speculative.rs, and the sampling checks in src/server/batch/speculative_burst.rs. First establish whether batched verify can meet the 2-row width-3 cost gate while staying bit-identical to single-row decode; also investigate per-row token history in src/lib/mlxcel-core/src/speculative/mtp/target.rs. Done means both preconditions hold, exactness and sampling tests pass, and either benchmarks show the required throughput win or a benchmark document records the result.

索引モデルが issue の本文から書いたものです。

説明

area:inference area:models modeltype:text priority:low status:ready type:enhancement

Problem / Background

Concurrent Raon-1 mini requests decode classically: the DFlash2 burst is B = 1 only, so with a drafter loaded two or more queued requests never share a speculative window. #3458 item 3 asked for batched DFlash2 and PR #3461 dropped it on measurement (docs/benchmark_results/raon-perf-m3ultra-2026-11-26.md, section 7, M3 Ultra):

Rows Batched decode step (ms) Exact verify, width 3 (ms) Width 5 (ms)
1 21.8 35.7 46.7
2 23.7 50.7 72.4
4 28.2 79.7 over the 16-row limit

A batched decode step costs 9% more for two rows than one; an exact verify block costs 42 to 59% more. The ceiling on batched drafting (rows * tokens emitted per verify / verify time, solo acceptance, draft cost free) is 13 to 22% below classic batched decode at four rows (110 to 123 against 141 tok/s) and 3 to 15% above it at two rows and width 3, a margin the draft cost (about 2 ms per row per round) and the uniform accept of the batched round loop consume. This issue records the two preconditions under which the work is worth doing, and is closed either by a measured win or by a recorded measurement.

Current Behavior

  • impl DFlashTargetModel for crate::models::Raon1MiniModel in src/server/batch/dflash_target.rs:444 returns false from supports_batched(), so the scheduler collects no window and a window that reaches the batched gate declines to classic decode.
  • Raon1MiniModel::forward_speculative (src/models/raon1_mini_speculative.rs:146) asserts B = 1 (:160). In a verify block (2 to row_invariant::MAX_ROWS = 16 rows) every row is formed alone so it equals its decode step bit for bit: RDA projections through row_invariant products with the conv and delta-rule recurrence stepped per position (RaonDeltaAttention::forward_recording), MLA as one decode-shaped attention per position (:189), mHC, router and SiTU MLPs through row_invariant products (row_scope, :81). Off MLXCEL_RAON_ROW_INVARIANT, each dense weight is read once per row, which is why verify cost grows almost linearly with rows.
  • sampling_config_eq (src/server/batch/speculative_burst.rs:3127) requires !needs_token_history() on both configs because the batched path samples each row's first bonus with an empty history (prefill_and_seed_batched, run_dflash_batched_on_target at dflash_target.rs:980). Since #3459 the server applies the checkpoint's presence_penalty 1.5 by default (src/server/startup.rs:2185), which makes SamplingConfig::needs_token_history() (src/lib/mlxcel-core/src/generate.rs:1765) true, so default-setting Raon requests would never join a batched window even if supports_batched() were true.

Preconditions to revisit

  1. A cheaper exact multi-row verify. A verify block of B rows whose cost grows like a batched decode step, not like B separate steps, while each row stays bit-identical to its decode step. Candidates: the row-invariant matvec kernel (src/lib/mlxcelverse/kernels/row_invariant_matvec.cpp) made fast enough to be the default for RDA, mHC and the SiTU MLPs, or a batched RDA and MLA verify that matches the per-position decode form. Gate: a probe (as in section 7) shows a 2-row width-3 verify at or under 1.2x the 1-row verify.
  2. Per-row token history in batched windows. Thread each row's token history through the batched round loop (MtpTarget::prefill_and_seed_batched, src/lib/mlxcel-core/src/speculative/mtp/target.rs:501, and the batched DFlash runner) so penalty-bearing rows sample like their B = 1 burst, then drop the two !needs_token_history() clauses from sampling_config_eq. This is shared with the Qwen 3.5 batched path and must keep its existing tests green.

Do not flip supports_batched() for Raon until both hold. Precondition 2 is independently useful and may land alone.

Scope

In scope: the two preconditions, a B > 1 Raon verify forward and rollback, the drafter side, supports_batched() -> true, the measurement.

Out of scope: the B = 1 burst, the DFlash2 default width (3, raon_dflash2::DEFAULT_VERIFY_WIDTH), prefill batching for drafting (rows stay prefilled alone for exactness).

Implementation Notes

  • Reuse: the Qwen 3.5 batched burst (supports_batched() == true path in dflash_target.rs) for windowing, per-row rollback and accept; compare_block_against_chain / mtp_exactness_gate for the exactness probe at B > 1.
  • Constraints: greedy drafted text must equal plain decode for every row; a row whose exactness probe fails declines to classic decode, never to a non-exact verify.
  • Edge cases: rows of unequal prompt length (current window collection requires equal lengths), rows at different reasoning efforts (alpha is per cache; a window must not mix alphas unless steering is per row), a row finishing mid-window.

Acceptance Criteria

  • Either: at 2 and 4 concurrent requests (mlxcel-server --parallel 4 --model-draft models/raon-1-mini-dflash2, 128 tokens each, the section 7 client) aggregate tok/s beats classic batched decode of the same binary on the short prose, code and long prompts, with the server's default presence_penalty of 1.5 in force; or a benchmark doc under docs/benchmark_results/ records the measurement that justifies closing this issue.
  • Greedy text of every row in a batched burst equals plain decode of that prompt (server check over the three prompts at 2 and 4 rows).
  • Test: with precondition 2, a batched window of two rows carrying presence_penalty = 1.5 produces the same tokens as two B = 1 bursts (fails today because sampling_config_eq refuses the window).
  • Test: the Raon B > 1 verify forward equals stacked B = 1 decode steps bit for bit on the tiny steered model (raon1_mini::steering_tests::steered_model).
  • Integrated: the scheduler routes concurrent Raon requests with a DFlash2 drafter through the batched burst by default, not behind a test-only path.

Verification

make test-fast FILTER=speculative_burst
make test-fast FILTER=raon1_mini
make test-fast FILTER=dflash_target
make verify-fmt verify-clippy

Benchmark on Apple Silicon under the host GPU lock, arms interleaved, with uptime per table as in the section 7 run. Pass: batched drafting above classic batched decode at both 2 and 4 rows, text equal.

主要言語
Rust
スター
505
フォーク
81
平均マージ
14時間 2分
マージ済み PR(30日)
448

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

lablup/mlxcel のほかの issue

lablup/mlxcel の issue をすべて見る

似ている issue

Rust の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。