/** * import/foreign/falcon_mamba.ts — weight port for the Mamba-1 / S6 family: * Falcon-Mamba (`FalconMambaForCausalLM`, `model_type: "falcon_mamba"`) and the * original Mamba (`MambaForCausalLM`, `model_type: "mamba"` — `state-spaces/mamba-*`). * They share one tensor layout and one config vocabulary, so one rule table and one * `describe` serve both ({@link mamba1Adapter}). * * Source layout confirmed against `tiiuae/falcon-mamba-7b`'s published * `config.json`, `model.safetensors.index.json` (643 tensors = 10 per layer × 64 * + 3 globals) and the safetensors header of shard 1, plus * `transformers/models/falcon_mamba/modeling_falcon_mamba.py`: * * backbone.embeddings.weight [vocab, d_model] * backbone.layers.{N}.norm.weight [d_model] * backbone.layers.{N}.mixer.in_proj.weight [2*d_inner, d_model] * backbone.layers.{N}.mixer.conv1d.weight [d_inner, 1, d_conv] * backbone.layers.{N}.mixer.conv1d.bias [d_inner] * backbone.layers.{N}.mixer.x_proj.weight [dt_rank + 2*d_state, d_inner] * backbone.layers.{N}.mixer.dt_proj.weight [d_inner, dt_rank] * backbone.layers.{N}.mixer.dt_proj.bias [d_inner] * backbone.layers.{N}.mixer.A_log [d_inner, d_state] * backbone.layers.{N}.mixer.D [d_inner] * backbone.layers.{N}.mixer.out_proj.weight [d_model, d_inner] * backbone.norm_f.weight [d_model] * lm_head.weight [vocab, d_model] * * Conventions that line up with `Mamba1Block` as-is, so most rules are copies: * • `in_proj` rows are `[x, gate]` (`hidden_states, gate = …chunk(2, dim=1)`), * and `Mamba1Block.forward` also takes the first half as `x` and the second * as the gate `z`. * • `x_proj` rows are `[dt, B, C]`, matching the block's split order. * • `A = -exp(A_log)` in both — `selective_scan.ts` computes * `a_cont = -exp(clamp(a_log, -10, 5))`. * • `dt_proj.bias` is added inside `softplus(dt + bias)` upstream; here it is * the `dt_proj` linear's bias and the scan applies `softplus` afterwards — * algebraically the same value. * • Linear weights are `[out, in]` row-major on both sides (no transpose). * * Fidelity caveats recorded on the plan rather than hidden: * • (Falcon-Mamba only) the dt/B/C norms below. Plain Mamba has none, so its port * is exact. * • `use_bias: false` upstream, so `in_proj` / `x_proj` / `out_proj` ship no * bias; this engine's blocks always own one, and they are filled with zeros * (an exact no-op, not an approximation). * • Falcon-Mamba RMS-normalises `dt`, `B` and `C` inside the mixer. Those * norms are `FalconMambaWeightlessRMSNorm` with `persistent=False` buffers, * so they contribute NO tensors to the checkpoint — nothing is dropped from * the file — but this engine's S6 scan has no such normalisation step, so a * ported model is not numerically identical to the original. * • `tie_word_embeddings: false`, so `lm_head.weight` is a real stored tensor. * `HybridMambaModel` always ties its LM head to the embedding table, so that * tensor has no target and is reported as unmapped. */ import { type ForeignMambaAdapter } from "./adapter.js"; /** A Mamba-1 family adapter: the shared rule table under one checkpoint family's identity. */ export declare function mamba1Adapter(identity: { id: string; label: string; modelTypes: readonly string[]; architectures: readonly string[]; }): ForeignMambaAdapter; export declare const falconMambaAdapter: ForeignMambaAdapter; export declare const mambaAdapter: ForeignMambaAdapter; //# sourceMappingURL=falcon_mamba.d.ts.map