Repository navigation
feat: hybrid-SSM cache carve-out tests and multimodal digest plumbing - #182
Merged
Merged
Conversation
Foundation for #124 (steps a and b). Step a documents and regression-tests the existing hybrid-SSM/recurrent carve-out from the unified paged cache: a model that overrides supports_batching() to false allocates ModelOwned sequence state, which both CachePool::detach and CachePool::detach_paged reject, so a recurrent sequence can never be donated to the prompt-cache store and every adopt attempt misses. The same flag forces effective_decode_storage_backend to Dense, so --decode-storage-backend paged is silently ignored for these families and their output stays bit-identical to the dense path. New tests: cache_pool_model_owned_recurrent_sequence_is_never_detachable (cache layer) and all_hybrid_ssm_model_types_round_trip (drift guard over the authoritative model-type list). Step b plumbs the resolved multimodal digest into the scheduler's prompt-cache key. The chat route now builds the PromptCacheRequestContext after request preparation so the digest sees the post-resolution image/audio bytes, the context carries an mm_digest field, and compose_prompt_cache_key folds it into the bucket via PromptCacheKey::new_full instead of the hardcoded empty digest. Text-only requests hash to MultimodalDigest::empty(), so the composed key is byte-identical to the pre-change path. Multimodal requests still bypass adopt and donate at the is_multimodal gate, so this step is behavior-neutral; lifting that gate to enable image/audio prefix sharing is step c.
be-free-snowboy
pushed a commit
to freestylejs/snowbrain-mlxcel
that referenced
this pull request
Oct 27, 2026
…lablup#182) Part of lablup#124 (steps a and b). SSM/recurrent carve-out from the unified paged cache is documented and regression-tested (the ModelOwned backend rejects both detach paths, so a recurrent sequence can never be donated). The resolved multimodal digest is plumbed into the prompt-cache key; text-only requests stay byte-identical and multimodal still opts out until step c.
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
Foundation for #124 (Hybrid SSM exclusion and multimodal adopt policy under the unified cache). Implements steps a and b of the agreed decomposition; the VLM-sharing enablement is the separate step c.
(a) Hybrid-SSM / recurrent carve-out: documented + regression-tested
The carve-out from cross-request block sharing is enforced by the sequence-state backend, not an ad-hoc check. A recurrent/hybrid family overrides
supports_batching()tofalse, which routes the defaultsequence_state_layout()toSequenceStateBackend::ModelOwned. AModelOwnedsequence is rejected by bothCachePool::detachandCachePool::detach_paged(both returnNone), so the scheduler can never donate it to the prompt-cache store, its store stays empty, and every adopt attempt misses. The same flag forceseffective_decode_storage_backendtoDense, so--decode-storage-backend pagedis silently ignored for these families and their decode output stays bit-identical to the dense path.hybrid_ssm.rsmodule doc now spells out this two-mechanism guarantee and completes the coverage table (previously 7 of the 12 authoritativemodel_typeentries).cache_pool_model_owned_recurrent_sequence_is_never_detachable(mlxcel-core) proves a model-owned recurrent sequence is non-detachable on both paths.all_hybrid_ssm_model_types_round_tripiteratesHYBRID_SSM_MODEL_TYPESitself so the list can never drift from the detector.(b) Multimodal digest plumbed into the prompt-cache key (behavior-neutral)
PromptCacheRequestContextgains anmm_digestfield. The chat route builds the context afterprepare_chat_request_with_cacheso the digest is computed over the resolved (post base64 / file / URL) image and audio bytes, andcompose_prompt_cache_keyfolds it into the bucket viaPromptCacheKey::new_fullinstead of the hardcodedMultimodalDigest::empty().MultimodalDigest::empty(), so the composed key is byte-identical to the pre-change path.is_multimodalgate, so this step changes no runtime behavior. It only makes the key collision-safe so step c can lift that gate and share image/audio prefixes without a text/image bucket collision.compose_prompt_cache_key_folds_request_multimodal_digestverifies, through the real key-composition seam, that text / image / different-image payloads land in distinct buckets and the text path matches an explicit empty digest.Validation
cargo fmt --all -- --check: cleancargo clippy --all-targets --features metal,accelerate -- -D warnings(cold): cleancargo test --features metal,accelerate: mlxcel 3048 passed, mlxcel-core 844 passed, 0 failedFollow-up
Step c (lift the
is_multimodalgate, sliceInputEmbeddingsto the adopted suffix, keep MRoPE aligned, real-model VLM cold-vs-adopt parity) lands in a separate PR.Part of #124