refactor: Move the remaining sliding-window families onto scheduler-owned layer state

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

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

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

評価

難易度
5/5
見積もり時間
1週間以上
初心者へのやさしさ
10/100
issue の種類
リファクタリング
明瞭さ
おおむね明確
活発さ
活発
技術スタック
rust

調査の方向性

Start by reading the design in docs/adr/0010-scheduler-owned-sequence-state.md and the Gemma 3 / Qwen 3.5 migration in PR #3305, which is not yet on main — the layer-state traits described only exist on branch refactor/issue-3254-scheduler-owned-state. Then read ModelOwnedSequenceState in src/models/model_owned.rs and pick one family, e.g. src/models/ministral3.rs, to see how the wrapper currently owns its full/sliding caches. Done means the grep in the acceptance criteria returns nothing for that file, a bit-exact snapshot round trip passes on a tiny fixture, and a paged-backend scheduler test passes; the issue asks for all ten families in a single PR, so this is not a starting point for a first contribution.

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

説明

area:architecture area:models priority:medium status:ready type:refactor

Part of #3259

Follows #3254 (PR #3305), which introduced scheduler-owned layer state for Gemma 3 and Qwen 3.5 and recorded the design in ADR docs/adr/0010-scheduler-owned-sequence-state.md. PR #3305 is open at filing time: the ADR, LayerStateKind, LayerState, LayerStateEncoding, LayerStateSnapshotSpec, the four layer-state methods on LanguageModel (layer_state_kinds, make_layer_state, layer_state_snapshot_spec, forward_layer_state), src/server/prompt_cache/state_snapshot.rs, models::pooled_model::Pooled and qwen3_5_layer_state::LentCaches exist on branch refactor/issue-3254-scheduler-owned-state and reach main only when PR #3305 merges.

Problem / Background

The remaining full + sliding families keep per-sequence layer state inside the model wrapper (ModelOwnedSequenceState from src/models/model_owned.rs). Eight of the ten have no snapshot hooks at all, so they get no prefix reuse, truncation or ring checkpoints, and none of them can take padded prefill.

Recorded reason (ADR 0010 audit): one-line wrapper comments ("uses internal cache management for sliding window attention", "owns the mixed full/sliding caches") and docs/CONTINUOUS_BATCHING.md "Mixed full/sliding cache families". Kolibri-1, MiMo and Muse Glimmer state the heterogeneous-cache reason in their module docs. Step 3.5 records none.

Goal

Migrate these families onto scheduler-owned layer state, as defined below: kolibri1 (src/models/kolibri1.rs, src/models/kolibri1_lm.rs), muse_glimmer (src/models/muse_glimmer.rs, src/vision/muse_glimmer_vlm.rs), mimo_v2_flash (src/models/mimo_v2_flash.rs), gpt_oss (src/models/gpt_oss.rs), ministral3 (src/models/ministral3.rs), exaone4 (src/models/exaone4.rs), mellum (src/models/mellum.rs), laguna (src/models/laguna.rs), step3p5 (src/models/step3p5.rs, and the step3p7 VLM wrapper in src/vision/step3p7.rs), limite (src/models/limite_wrapper.rs, src/models/limite_layers.rs).

Definition of "migrate"

Report LanguageModel::layer_state_kinds(), implement forward_layer_state, name a LayerStateSnapshotSpec, delete the wrapper's ModelOwnedSequenceState and its per-family snapshot hooks, forward the four layer-state methods through every VLM wrapper, and move model-level tests onto models::pooled_model::Pooled.

What migrating involves

  • Every family is Full / Sliding { window }, the Gemma 3 shape, so each uses the Windowed encoding. Kolibri-1 and Muse Glimmer already donate snapshots and must keep their tensor names (Muse Glimmer writes full / sliding, not standard / rotating).
  • The other eight have no snapshot hooks and gain prefix reuse, truncation and ring checkpoints for the first time. Their supports_snapshot_reuse() flips to true only after the bit-exact round trip passes for that family; a family that fails it stays off and the issue records why.
  • Padded prefill is disabled for all of them because rotating caches did not implement the pad trim in their wrappers. LayerState::rewind_padded_prefill covers a sliding layer, so this issue decides per family whether to enable it, with the #1755 pad-trim test (src/server/batch/scheduler_model_owned_pad_trim_tests.rs) as the gate.
  • MiMo V2 Flash is supports_batching() == false. Decide whether it becomes batching here or stays single-sequence on scheduler-owned state.
  • GPT-OSS has a pipeline stage executor with a pointer-keyed cache store, and Laguna's DFlash path keeps independent FP16 caches. Both stay as they are.
  • The gemma3::Cache enum (src/models/gemma3.rs) that Kolibri-1 and AFMoE share can be deleted once AFMoE (#3324) and Kolibri-1 are both migrated.

Scope

In scope: the ten families and wrappers listed under Goal, their tests, and the deletion of gemma3::Cache if #3324 has merged by then.

Out of scope: GPT-OSS's pipeline stage executor cache store, Laguna's DFlash FP16 caches, and AFMoE (#3324).

Implement all families in one PR, run the local gate once at the end, and keep pushes to a minimum.

Acceptance Criteria

  • rg 'ModelOwnedSequenceState' src/models/kolibri1.rs src/models/muse_glimmer.rs src/models/mimo_v2_flash.rs src/models/gpt_oss.rs src/models/ministral3.rs src/models/exaone4.rs src/models/mellum.rs src/models/laguna.rs src/models/step3p5.rs src/models/limite_wrapper.rs returns nothing for the text path.
  • A snapshot written by the generic path has the tensor names, shapes and scalars the family wrote before (a test compares both encoders and pins the names).
  • Bit-exact round trip on a tiny fixture: prefill P with a fixed partition, snapshot, restore into a fresh pool sequence, decode 16 tokens, equal to a cold run with the same partition.
  • A scheduler test under the paged decode override (--decode-storage-backend paged) passes for the family.
  • No decode regression: B=1 and B=4 decode tok/s at 256 and 8192 prompt tokens, main against the branch, interleaved with a null arm, recorded in docs/benchmark_results/.
  • /v1/cache/stats shows snapshot hits for each newly enabled family in a two-turn server test.
  • The per-family padded-prefill and MiMo V2 Flash batching decisions are recorded in the PR, with the reason for any family whose snapshot reuse stays off.
  • Integrated: the server and CLI paths for every family run through the scheduler-owned state, with no model-owned copy left behind.

Verification

cargo fmt --all -- --check
cargo clippy --workspace --all-targets --features metal,accelerate -- -D warnings
cargo test --workspace --profile test-fast --features metal,accelerate --no-fail-fast -- --test-threads=1
rg 'ModelOwnedSequenceState' src/models/kolibri1.rs src/models/muse_glimmer.rs src/models/mimo_v2_flash.rs src/models/gpt_oss.rs src/models/ministral3.rs src/models/exaone4.rs src/models/mellum.rs src/models/laguna.rs src/models/step3p5.rs src/models/limite_wrapper.rs
主要言語
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 を短くまとめたダイジェスト。