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

Đang mở
#3,469 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
5/5
Thời gian dự kiến
Hơn một tuần
Mức phù hợp với người mới
35/100
Loại issue
Tính năng
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
rust

Hướng nghiên cứu

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.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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.

Ngôn ngữ chính
Rust
Star
505
Fork
81
Merge trung bình
14 giờ 2 phút
Pull request đã merge (30 ngày)
448

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của lablup/mlxcel

Tất cả issue của lablup/mlxcel

Issue tương tự

Thêm issue về Rust

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.