Repository navigation
fix(zamba2): tolerate missing optional mamba kernel symbols - #3768
Merged
Merged
Conversation
The legacy Zamba2 monkeypatch read selective_state_update, mamba_chunk_scan_combined, mamba_split_conv1d_scan_combined and is_torchdynamo_compiling unconditionally. Current transformers releases no longer expose them, so loading a Zamba2 model raised AttributeError before any quantization work started. Probe the optional symbols with getattr, log the missing capabilities explicitly, and fall back to the Torch/upstream path. Newer transformers mixers no longer expose cuda_kernels_forward/torch_forward; leave their forward untouched because they already select kernels internally. Add symbol-guard, fallback, and real-model regression tests.
Qubitium
marked this pull request as ready for review
November 11, 2026 09:32
Qubitium
approved these changes
Nov 11, 2026
Qubitium
left a comment
Collaborator
There was a problem hiding this comment.
Reviewed the fallback and legacy mixer paths. 16 focused tests and 411 model-plan tests pass; a tiny Zamba2 forward returns finite logits.
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.
TL;DR
Zamba2 no longer assumes the optional mamba kernel symbols exist.
getattrprobing disables the fast path explicitly, and the upstreamforwardis left in place when the legacy mixer methods are gone.Problem
Zamba2QModel.monkey_patchreadselective_state_update,mamba_chunk_scan_combined,mamba_split_conv1d_scan_combined,causal_conv1d_fn,causal_conv1d_update, andis_torchdynamo_compilingunconditionally fromtransformers.models.zamba2.modeling_zamba2.Current transformers releases only export
causal_conv1d_fn/causal_conv1d_update; the other symbols are gone. Loading a Zamba2 model therefore raisesAttributeErrorbefore quantization starts, and two tests intests/test_zamba2_support.pyfail.Fix
getattr(..., None)and record missing capabilities.is_torchdynamo_compilingthe same way.cuda_kernels_forwardandtorch_forward. Newer transformers mixers select kernels inside their ownforward, so patching them would replace a valid implementation with calls to methods that no longer exist.Tests
test_zamba2_missing_fast_path_kernels_are_detectedtest_zamba2_dense_mixer_falls_back_when_kernels_are_missingtest_zamba2_mixer_without_legacy_paths_keeps_upstream_forwardtest_zamba2_real_model_monkey_patch_tolerates_missing_kernelsValidation
pytest tests/test_zamba2_support.py -q→ 10 passed on both supported accelerator backends.pytest tests/test_zamba_support.py -q→ 6 passed.ruff checkandruff format --checkpass.Reviewer notes
This is a localized bug fix (optional-symbol gating inside one monkeypatch), so no Mermaid logic-flow page is added; the logic-flow skill excludes localized bug fixes. No quantization math, packed layout, or kernel-selection semantics are changed.