refactor: Move the SSM and convolution hybrids onto scheduler-owned layer state
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 5/5
- 見積もり時間
- 1週間以上
- 初心者へのやさしさ
- 8/100
調査の方向性
Read ADR docs/adr/0010-scheduler-owned-sequence-state.md and the layer-state API from PR #3305 first; the issue depends on that branch reaching main. Then trace one family through src/models/mamba.rs and src/server/prompt_cache/hybrid_ssm.rs, but settle the Falcon-H1/Inkling composite-vs-split layer decision before editing all twelve families. Done when the rg ModelOwnedSequenceState ... check is empty, encoder-comparison and bit-exact restore tests pass, and each family passes the --decode-storage-backend paged scheduler test.
索引モデルが 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
The SSM and convolution hybrids keep per-sequence layer state inside the model wrapper (ModelOwnedSequenceState from src/models/model_owned.rs), each with its own snapshot hooks or none, so the scheduler cannot own, report, snapshot or restore their state through the generic path.
Recorded reason (ADR 0010 audit): module docs for LFM2, PLaMo 2, Falcon-H1 and Granite MoE Hybrid say the convolution and SSM state is recurrent, not per-token positional, so the model owns its mixed cache. Jamba, Mamba, Mamba 2 and Nemotron-H carry one-line comments to the same effect and are in HYBRID_SSM_MODEL_TYPES (src/server/prompt_cache/hybrid_ssm.rs). RWKV-7, RecurrentGemma and Z1T have one-line comments. Inkling records none.
Goal
Migrate these families onto scheduler-owned layer state, as defined below: lfm2 (src/models/lfm2.rs, and src/vision/lfm2_vl.rs), plamo2 (src/models/plamo2.rs, and src/vision/plamo2_vl.rs), falcon_h1 (src/models/falcon_h1.rs), granitemoehybrid (src/models/granitemoehybrid.rs), jamba (src/models/jamba.rs), mamba (src/models/mamba.rs), mamba2 (src/models/mamba2.rs), nemotron_h (src/models/nemotron_h.rs, and its omni VL wrapper src/vision/nemotron_h_nano_omni_vl.rs), rwkv7 (src/models/rwkv7.rs), recurrent_gemma (src/models/recurrent_gemma.rs), z1t (src/models/z1t.rs), inkling (src/models/inkling.rs, and src/vision/inkling_vl.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
- Layers are
Recurrent, orFull/Slidingbeside it. Falcon-H1 and Inkling hold both attention KV and recurrent state in one layer, which oneLayerStateper layer cannot express today: decide between a composite variant and splitting the layer into two entries (which breaks the one-entry-per-layer rule the storage report relies on). The same representation question arises for DeepSeek V4 and IQuest-Coder Loop in #3329; whichever lands first settles it for both, and neither waits on the other. - Nemotron-H's cache vector skips MLP and MoE blocks, so its vector index is not its layer index. Migrating it means
LayerStateKind::Nonefor those blocks. - LFM2, PLaMo 2, Falcon-H1, Granite MoE Hybrid, Nemotron-H and Inkling implement
trim_stateby trimming KV and resetting recurrent state. The engine's generic pad trim refuses a recurrent layer, so each either keeps declining padded prefill or the reset is expressed as a per-kind rule. - Each family has its own snapshot tensor names; each needs a
LayerStateEncodingentry that reproduces them. - RWKV-7, RecurrentGemma and Z1T have no snapshot hooks and gain exact-prefix reuse.
- Jamba and Nemotron-H have pipeline stage executors, which keep their own stores.
- Inkling's MTP hooks (
src/models/inkling_mtp_target.rs) reach state byOption<SequenceId>.InklingMtpTargetAdapterandInklingVLMtpTargetAdapterhave to carry the borrowed layer state for a tick, asQwen35MtpTargetAdapter(src/models/qwen3_5_mtp_target.rs) does after #3254, instead of looking the sequence up in a model-owned map.
Scope
In scope: the twelve families and four VLM wrappers listed under Goal, their encodings, the Falcon-H1 / Inkling per-layer representation decision, the Inkling MTP adapter change, and tests.
Out of scope: the Jamba and Nemotron-H pipeline stage executor stores; KV-block reuse for these families (stays declined).
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/lfm2.rs src/models/plamo2.rs src/models/falcon_h1.rs src/models/granitemoehybrid.rs src/models/jamba.rs src/models/mamba.rs src/models/mamba2.rs src/models/nemotron_h.rs src/models/rwkv7.rs src/models/recurrent_gemma.rs src/models/z1t.rs src/models/inkling.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/. -
detect_hybrid_ssmand theHYBRID_SSM_MODEL_TYPESgate keep declining KV-block reuse for every family here. - 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/lfm2.rs src/models/plamo2.rs src/models/falcon_h1.rs src/models/granitemoehybrid.rs src/models/jamba.rs src/models/mamba.rs src/models/mamba2.rs src/models/nemotron_h.rs src/models/rwkv7.rs src/models/recurrent_gemma.rs src/models/z1t.rs src/models/inkling.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
-
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 ·
-
Link Checker Reportオープンautomated issue report
難易度 1/5 1時間未満 初心者へのやさしさ 76/100
ratatui/awesome-ratatui#598 ·
メンテナーはふだん 1 日以内に返信
-
release
難易度 1/5 1時間未満 初心者へのやさしさ 75/100
github/gh-aw-mcpg#17603 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
メンテナーはふだん 1 日以内に返信
-
C-Bug S-Needs-Triage
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
bevyengine/bevy#26718 ·
メンテナーはふだん 2 日以内に返信