Repository navigation
refactor: move SSM and convolution hybrids onto scheduler-owned layer state - #3647
Merged
Merged
Conversation
… state Move all 12 SSM and convolution hybrid families (lfm2, plamo2, falcon_h1, granitemoehybrid, jamba, mamba, mamba2, nemotron_h, rwkv7, recurrent_gemma, z1t, inkling) and their VLM wrappers (lfm2_vl, plamo2_vl, granite4_vision, nemotron_h_nano_omni_vl, inkling_vl) from ModelOwnedSequenceState onto scheduler-owned LayerState per ADR 0010 (#3328, epic #3259). - Add LayerStateKind::FullAndRecurrent and LayerState::KvAndRecurrent for parallel KV+SSM/conv layers (Falcon-H1, Inkling) while preserving the one-entry-per-layer pool invariant, plus non-snapshot transient slots on RecurrentState for Inkling verify-block tails. - Extend LayerStateEncoding and StatePolicy with RecurrentHybrid (supporting skip_empty_index for Nemotron-H) and LiveWindowAndRecurrent (supporting Inkling trim_front live windows) preserving legacy snapshot tensor names, shapes, and scalars. - Add LanguageModel::rewind_layer_state_decode_appends and update Engine::verify_rounds_unsupported to check keeps_state_outside_kv_slice() so Inkling prompt-lookup verify rewind runs on scheduler-owned state. - Add shared zero-copy LayerStateCodec / LentStates lending adapter in src/models/ssm_layer_state.rs and enforce fail-closed refusal of SequenceId and id-less multi-row batches on legacy KVCache-slice entry points. - Keep all 12 families (including lfm2 and inkling variants) listed in HYBRID_SSM_MODEL_TYPES so KV-block APC reuse remains disabled. - Add encoder-parity and pinned-name snapshot tests, 16-step bit-exact snapshot round-trip tests on tiny fixtures, and BatchScheduler tests under DecodeStorageBackend::Paged.
inureyes
force-pushed
the
refactor/issue-3328-ssm-conv-layer-state
branch
from
December 1, 2026 15:57
8b4da5e to
769e55f
Compare
inureyes
marked this pull request as ready for review
December 1, 2026 15:58
2 of 8 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #3328
Summary
Moves all 12 SSM and convolution hybrid model families (
lfm2,plamo2,falcon_h1,granitemoehybrid,jamba,mamba,mamba2,nemotron_h,rwkv7,recurrent_gemma,z1t,inkling) and their VLM wrappers (lfm2_vl,plamo2_vl,granite4_vision,nemotron_h_nano_omni_vl,inkling_vl) fromModelOwnedSequenceStateonto scheduler-ownedLayerStateper ADR 0010 (epic #3259).Key Changes
mlxcel-core): AddedLayerStateKind::FullAndRecurrentandLayerState::KvAndRecurrent { kv, recurrent }for parallel KV+SSM/conv layers (Falcon-H1, Inkling) while preserving the one-entry-per-layer pool invariant, plus non-snapshot transient slots onRecurrentStatefor Inkling verify-block tails.state_snapshot.rs): AddedLayerStateEncoding::RecurrentHybrid(withskip_empty_indexfor Nemotron-H MLP/MoE blocks) andLayerStateEncoding::LiveWindowAndRecurrent(withKVCache::seq_len()validation for Inklingtrim_frontlive windows), preserving exact legacy tensor names, shapes, and scalars.LanguageModel::rewind_layer_state_decode_appends, updatedEngine::verify_rounds_unsupportedto checkkeeps_state_outside_kv_slice(), and threaded&mut [LayerState]throughInklingMtpTargetand its scheduler/burst callers.src/models/ssm_layer_state.rs): Introduced zero-copyLayerStateCodec/LentStateslending between poolLayerStateslices and each family's typed per-layer caches, plus fail-closed refusal ofSequenceIdand id-less multi-row batches on legacyKVCache-slice entry points.hybrid_ssm.rs): Addedlfm2,lfm2_vl,lfm2-vl,lfm2_moe,inkling, andinkling_mm_modeltoHYBRID_SSM_MODEL_TYPESso KV-block APC reuse remains declined for all 12 families.Verification
rg 'ModelOwnedSequenceState'across all 12 model files: 0 matches.cargo test --profile test-fast --features metal,accelerate --lib --no-fail-fast -- --test-threads=1 lfm2 plamo2 falcon_h1 granitemoehybrid granite4_vision jamba mamba mamba2 nemotron_h rwkv7 recurrent_gemma z1t inkling hybrid_ssm snapshot_forwarding_tests state_snapshot ssm_layer_state_tests scheduler_runs_migrated_ssm_hybrids_under_paged_decode_override: 601 passed, 0 failed (10 ignored). Includes new encoder-parity and pinned-name snapshot tests, 16-step bit-exact snapshot round-trip tests on tiny fixtures,hybrid_ssmopt-out tests, andBatchSchedulertests underDecodeStorageBackend::Paged.cargo test --profile test-fast --features metal,accelerate -p mlxcel-core --lib layer_state::tests: 9 passed, 0 failed.cargo fmt --all -- --check: passed.cargo clippy --profile test-fast --features metal,accelerate --lib --tests -- -D warnings -A clippy::manual_contains: passed (0 warnings across all modified files;manual_containssuppresses one pre-existing lint in untouchedsrc/models/lfm3_omni_config.rsunder rustc 1.97).python3 scripts/ci/check_cross_repo_refs.py: passed.Unmeasured
cargo build --releaseis excluded by the worktree watchdog guard and no local release binary/checkpoints were run here. Needs measurement during release/post-merge validation on real checkpoints.