Restore dynamic_full full-layer cache guard for assisted/contrastive decoding - #47153
Restore dynamic_full full-layer cache guard for assisted/contrastive decoding#47153qflen wants to merge 1 commit into
Conversation
zucchini-nlp
left a comment
There was a problem hiding this comment.
Huh, great catch, and thanks for the test!
| needs_config = any( | ||
| x in ("mamba", "conv", "linear_attention", "minimax_m3_sparse") | ||
| for x in (getattr(text_config, "layer_types", []) or []) |
There was a problem hiding this comment.
not really a fan of enlisting layer types here, but since it was there prev, fine. We'll have to put this somewhere on config/gen_config at some point i think, as a single property
|
The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update. |
|
What is wrong with CI 馃槶 |
|
lol |
|
@zucchini-nlp since I opened this, #47347 (Inkling) reworked This PR withholds the config under The two edits touch different lines, so it merges cleanly and this PR's own checks stay green, which is why only the merge queue catches it. I'll reduce this to just the regression test. Otherwise, feel free to close it (and the issue). |
503cc99 to
a98dc67
Compare
CI recapDashboard: View test results in Grafana |
|
ahh, right, that makes sense, didn't notice the changes from Inkling release! I will close the PR in that case as I think the regression test won't be necessary, thanks a lot for your efforts 鉂わ笍 |
Fixes #46629
_prepare_cache_for_generationused to withhold the model config fromDynamicCachewhencache_implementation="dynamic_full", the mode forced by assisted / prompt-lookup / contrastive decoding (which roll the cache back withcrop(), unsupported by sliding-window layers).#46600 started passing the config unconditionally, so sliding-window models (Gemma, Mistral, Phi-3, ...) now build
DynamicSlidingWindowLayers in that mode andcrop()raises once generation runs past the window:It also dropped the guard because MiniMax-M3 sparse layers need their dedicated
MiniMaxM3VLSparseCacheLayer(built only when the config is passed).So instead of a plain revert, restore the guard but keep passing the config for the layer types that require it, now including
minimax_m3_sparse(non-sliding and croppable, so it does not reintroduce the crash):The list stays minimal on purpose:
DeepSeek's
heavily_compressed_attention/compressed_sparse_attentionare left out because those models also carrysliding_attentionlayers, so forcing the config back for them would rebuild the sliding layers and reintroduce the crash. Only non-sliding, croppable layer types that need their own cache class belong here.Regression test added (
test_assisted_generation_sliding_window_model): a tiny sliding-window Gemma2 run under assisted + prompt-lookup decoding, which raises onmainand passes with the fix.Before / after on a tiny sliding-window Gemma2 (CPU, no downloads)
Gemma2withsliding_window=4, generating past the window under assisted and prompt-lookup decoding:cc @ArthurZucker (#46600 author), @zucchini-nlp