Repository navigation
refactor(llama4): move Llama 4 onto scheduler-owned layer state with chunked layers - #3642
Merged
Merged
Conversation
inureyes
force-pushed
the
refactor/issue-3326-llama4-scheduler-owned-state
branch
from
December 1, 2026 15:18
4e98c24 to
1b545e2
Compare
inureyes
marked this pull request as ready for review
December 1, 2026 15:18
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.
Summary
Closes #3326
Migrates
Llama4Wrapper(src/models/llama4.rs) onto scheduler-owned layer state (ADR 0010, epic #3259) as the first consumer ofLayerStateKind::Chunked { chunk }andLayerState::Chunked.Changes
LayerStateEncoding::Chunked { standard, chunked }insrc/lib/mlxcel-core/src/cache/layer_state_request.rsand wiredLayerState::matches_kind(checkingcache.chunk_size == chunk) plusas_chunked/as_chunked_mutinsrc/lib/mlxcel-core/src/cache/layer_state.rs.KvSnapshotNames(src/models/kv_snapshot.rs) and implemented the chunked arms ofStatePolicy::{snapshot, restore, truncatable_to, restore_truncated, state_checkpoint, restore_from_checkpoint}andcheck_kv_tensorsinsrc/server/prompt_cache/state_snapshot.rs.Llama4LayerCache(implemented for bothLlama4CacheandLayerState), removedModelOwnedSequenceStateand per-family snapshot/sequence hooks fromLlama4Wrapper, implementedlayer_state_kinds,make_layer_state,layer_state_snapshot_spec, andforward_layer_state, and keptsupports_paged_decode_backend() == true.supports_padded_prefill() == false):LayerState::rewind_padded_prefillandLayerState::rewind_decode_appendscontinue to return an error forLayerState::Chunkedrather than enabling a chunk-boundary rewind in this refactor.last_row_logitsonPooled<M>(src/models/pooled_model_language_model.rs) and moved Llama 4 model-level tests ontoPooled<Llama4Wrapper>.src/models/llama4_layer_state_tests.rs,src/server/prompt_cache/state_snapshot_tests.rs,src/server/batch/scheduler_model_owned_cache_tests.rs,src/lib/mlxcel-core/src/cache/layer_state_tests.rs).Validation
cargo fmt --all -- --check: passed.cargo clippy --profile test-fast --features metal,accelerate -p mlxcel-core --lib --tests -- -D warnings: passed (0 warnings).cargo clippy --profile test-fast --features metal,accelerate --lib --tests -- -D warnings: 0 warnings in all changed files (1 pre-existingclippy::manual_containsonmaininsrc/models/lfm3_omni_config.rs:184).cargo test --profile test-fast --features metal,accelerate -p mlxcel-core --lib layer_state::tests -- --test-threads=1: 9 passed.cargo test --profile test-fast --features metal,accelerate --lib llama4::tests -- --include-ignored --test-threads=1: 25 passed.cargo test --profile test-fast --features metal,accelerate --lib state_snapshot::tests -- --test-threads=1: 10 passed.cargo test --profile test-fast --features metal,accelerate --lib kv_snapshot::tests -- --test-threads=1: passed.cargo test --profile test-fast --features metal,accelerate --lib llama4_runs_under_paged_decode_override_with_scheduler_owned_state -- --test-threads=1: passed.cargo test --profile test-fast --features metal,accelerate --lib llama4_helpers -- --test-threads=1: 9 passed (3 ignored serial MLX tests).cargo test --profile test-fast --features metal,accelerate --lib snapshot_forwarding_tests -- --test-threads=1: 2 passed.rg 'ModelOwnedSequenceState' src/models/llama4.rs: 0 matches.python3 scripts/ci/check_cross_repo_refs.py: passed.Unmeasured
test-fastprofile only; cold release builds are deferred to post-wave / release validation).