Add Jamba attention+Mamba interleave adapter (JambaForCausalLM)#1535
Merged
Conversation
…-1 selective-param norms for SSM reconstruction and eager_scan.
Collaborator
|
This looks great, thanks for putting it together @udapy! |
Author
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.
Description
Adds TransformerBridge support for
JambaForCausalLM(AI21 Jamba family).input_layernorm→ mixer →pre_ff_layernorm→ FFN).Fixes #1468
// summary
BlockBridge—input_layernorm+pre_ff_layernorm, realhook_resid_midattnormixerperlayers_block_type(attention/mamba)SSMMixerBridge(Mamba-1) under canonical.mixer(HF.mamba) sofind_ssm_mixer/compute_ssm_*/eager_scanresolvedt_layernorm/b_layernorm/c_layernormmapped;SSMMixerBridgeapplies them on reconstruction +eager_scan(stock Mamba-1 unchanged)AttentionBridge(maintain_native_attention=True)GatedMLPBridgeifnum_experts≤1;MoEBridge(optional dense+router children) ifnum_experts>1past_key_values/DynamicCache—is_stateful=Falsesupports_fold_ln=False,weight_processing_conversions={}(heterogeneous layers + native attn)verify_modelsapplicable_phases=[1,2,3,4]Key design decision: no
is_statefulis_stateful=True, the bridge’s stateful loop uses the pure-Mambacache_paramsconvention.past_key_values/DynamicCache.is_stateful=Falsekeeps greedy generation on the HF-compatible path.Key design decision: Jamba-aware
SSMMixerBridgex_proj; Jamba norms dt/B/C afterx_projbeforedt_proj.compute_ssm_state/compute_ssm_effective_attention/eager_scanare shaped correctly but numerically wrong for Jamba.getattr/ cache keys: only mixers that expose those LNs take the Jamba path; pureMambaForCausalLMstays on the old path (validated; mamba integration tests pass).File Changes (14 Files)
Local Verification
P3 on Reasoning-3B is below 100 only from
weight_magnitudesafter limited weight processing (supports_fold_ln=False); forward/hook/grad checks in P2 are 100. P4 is a GPT-2 perplexity quality metric, not a logit-parity check.Integration coverage: HF logit parity (
max_diff == 0on programmatic configs), independent attn vs Mamba ablation,find_ssm_mixer/ssm_layers, post-LN state reconstruction,eager_scanvs fused, greedy generate parity.Local suite: 46 Jamba unit+integration tests passed; stock Mamba adapter integration (54) still passes after
ssm_mixerchange.Expected warnings (not regressions)
hook_attn_*aliases do not resolve (optionalattnabsent) — same class of warning as other hybrids with optional attention.CI Notes
Integration tests are not marked slow — they use programmatic configs with no Hub download (same as GraniteMoeHybrid) and run in normal CI via make integration-test.
Not in scope
supports_fold_ln=Falseby design)feed_forwardlayersnum_experts=1)Type of change
Checklist:
Related