refactor: Move Llama 4 onto scheduler-owned layer state with chunked layers
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 5/5
- 見積もり時間
- 1週間以上
- 初心者へのやさしさ
- 10/100
調査の方向性
Start with ADR docs/adr/0010-scheduler-owned-sequence-state.md and PR #3305's branch refactor/issue-3254-scheduler-owned-state, since the interfaces this issue builds on (LayerStateKind, LayerState, LayerStateEncoding, state_snapshot.rs) are not on main yet. Then read src/models/llama4.rs alongside the Gemma 3 / Qwen 3.5 migration as the worked example, and src/models/kv_snapshot.rs for the snapshot_chunked / restore_chunked / truncate_chunked helpers. Done means the acceptance-criteria checks pass: no ModelOwnedSequenceState in llama4.rs, bit-exact snapshot round trip, paged-decode scheduler test, and recorded decode benchmarks.
索引モデルが issue の本文から書いたものです。
説明
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
Llama 4 keeps per-sequence layer state inside the model wrapper (ModelOwnedSequenceState from src/models/model_owned.rs, holding Llama4Cache in src/models/llama4.rs), and the chunked-attention arms of the generic layer state are unused and partly unimplemented.
Recorded reason (ADR 0010 audit): the wrapper manages Llama4Cache internally for the interleaved-GQA attention pattern, and the post-pad trim reaches only CachePool caches; lifting it needs trim_state with a chunk-boundary rewind (#1335, #1755).
Goal
Migrate llama4 (src/models/llama4.rs) onto scheduler-owned layer state, as defined below, with its chunked layers expressed as LayerStateKind::Chunked { chunk }.
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
- First user of
LayerStateKind::Chunked { chunk }andLayerState::Chunked(src/lib/mlxcel-core/src/cache/layer_state.rs). Add the chunked arms tosrc/server/prompt_cache/state_snapshot.rs(today they returnfalse/ refuse) usingkv_snapshot::{snapshot_chunked, restore_chunked, chunked_truncatable_to, truncate_chunked}(src/models/kv_snapshot.rs), and aWindowed-styleLayerStateEncodingentry that carries thechunkedname. LayerState::rewind_padded_prefillandLayerState::rewind_decode_appendsreturn an error for a chunked layer today. Implement the chunk-boundary rewind there, or keep padded prefill declined and say so.supports_paged_decode_backend()istrueand must stay so.- The pipeline stage executor for Llama 4 keeps its own cache store.
Scope
In scope: src/models/llama4.rs, the chunked arms in src/lib/mlxcel-core/src/cache/layer_state.rs and src/server/prompt_cache/state_snapshot.rs, a chunked LayerStateEncoding entry, and tests.
Out of scope: the Llama 4 pipeline stage executor's cache store.
Acceptance Criteria
-
rg 'ModelOwnedSequenceState' src/models/llama4.rsreturns 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/. - Truncation is offered only while the front is untrimmed (
start_position == 0), with a test on each side of the chunk boundary. -
supports_paged_decode_backend()still returnstruefor Llama 4. - The PR states whether padded prefill is enabled via a chunk-boundary rewind or stays declined.
- Integrated: the server and CLI paths for Llama 4 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/llama4.rs
- 主要言語
- Rust
- スター
- 505
- フォーク
- 81
- 平均マージ
- 14時間 2分
- マージ済み PR(30日)
- 448
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
lablup/mlxcel のほかの issue
-
area:core priority:high status:ready type:security
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
メンテナーはふだん 1 日以内に返信
-
priority:medium status:ready type:security
難易度 4/5 3〜5日 初心者へのやさしさ 45/100
メンテナーはふだん 1 日以内に返信
-
area:models modeltype:text priority:medium status:in-progress type:bug
難易度 4/5 3〜5日 初心者へのやさしさ 57/100
メンテナーはふだん 1 日以内に返信
-
area:models priority:low status:ready type:test
難易度 4/5 3〜5日 初心者へのやさしさ 48/100
メンテナーはふだん 1 日以内に返信
-
area:models modeltype:omni priority:medium status:ready type:bug
難易度 4/5 3〜5日 初心者へのやさしさ 48/100
メンテナーはふだん 1 日以内に返信
似ている issue
-
area:ui effort:medium enhancement P7 source:agent
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
メンテナーはふだん 1 日以内に返信
-
marketing
難易度 2/5 1〜3時間 初心者へのやさしさ 85/100
メンテナーはふだん 1 日以内に返信
-
documentation priority: low tech-debt
難易度 2/5 1〜3時間 初心者へのやさしさ 64/100
nledford/Ladderback#1823 ·
メンテナーはふだん 1 日以内に返信
-
psmux-resurrect: restoring a session with a numeric name puts its windows into the wrong session (`new-window -t 4` is read as window 4)対応中かも @ealwanlee が今日担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 88/100
psmux/psmux-plugins#47 ·
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 87/100
メンテナーはふだん 1 日以内に返信