Porting Mamba (selective-scan SSM) into a sovereign sequence-mixing engine
Ran Tao (Octoryn Research)
Abstract
An independently implemented selective-scan state-space (Mamba-style, 130M-class) forward pass, built without the reference SSM GPU kernel library, reproduces a HuggingFace transformers f16 prefill-logit reference at cosine 0.999997, argmax 8/8 across two prompts. A kill-selectivity control removing input-dependent selection collapses parity to cosine -0.73 (0/8), showing selectivity is load-bearing, not incidental. This is the engine's first non-attention (state-space) sequence-mixing paradigm. Scope: an f16 logit-parity smoke test, not a benchmark; no quality, throughput, or quantized claim.
1. Contribution
Claimed. This report documents a correctness-validation result: a hand-written, independently implemented selective-scan state-space version of a 130M-class Mamba model reproduces a reference HuggingFace transformers f16 prefill-logit forward pass at cosine similarity 0.999997, with argmax matching on 8/8 checks across two prompts. The implementation covers the selective scan with input-dependent step, input, and output projections, plus causal 1D convolution, softplus, and SiLU gating — with no attention, KV cache, or rotary position embedding. A kill-selectivity negative control that removes the input-dependent selection collapses parity to cosine -0.73, argmax 0/8, demonstrating that the selective mechanism — not incidental numerical proximity — drives the match. A linkage check confirms the build carries no dependency on the reference SSM GPU kernel library and no vendor BLAS. This is the engine's first non-attention paradigm, so the engineering altitude is paradigm coverage and faithful reproduction, not a novel algorithm.
NOT claimed. This is a logit-parity smoke test, not a benchmark. It does not establish generation quality (parity of next-token logits is not text quality), throughput or latency competitiveness (the scan runs sequentially and is not compared to a fused GPU kernel), correctness at quantized precision (only f16 was tested), or coverage of larger Mamba variants, Mamba-2/SSD, or hybrid state-space plus attention models (e.g. Jamba). The sample is small (two prompts) and single-run.
2. Methods
| Field | Value |
|---|---|
| Model | Mamba, 130M-class |
| Hardware | Consumer AMD RDNA2-class GPU (16 GB class) |
| Stack | Independent sovereign engine build (recent stack versions) |
| Oracle / baseline | HuggingFace transformers (recent version) |
| Procedure | f16 prefill-logit comparison versus oracle on identical input ids |
| Precision | f16 |
| Metric + gate | per-position cosine similarity and argmax match; reported 8/8 across two prompts |
| Stimulus / inputs | two prompts (exact text not recorded); coherent output observed |
3. Results
| Measurement | Value |
|---|---|
| f16 logit parity (cosine) | 0.999997 |
| argmax match | 8/8 (two prompts) |
| Output coherence | coherent (qualitative) |
| Sovereignty (linkage check) | no reference SSM GPU kernel library, no vendor BLAS |
4. Ablations / Negative controls
| Control | Manipulation | Result | Interpretation |
|---|---|---|---|
| Kill-selectivity | force a constant step parameter (removes input-dependent selection) | cosine -0.73, argmax 0/8 FAIL | The selective mechanism is load-bearing; the f16 match is not coincidental. |
5. Threats to Validity / Limitations
- Sample size. Two prompts across a handful of token positions (8 argmax checks total) is a correctness smoke test, not a benchmark-scale evaluation. No claim about distributional behavior follows.
- Single run, no variance. Parity is reported as point values; no repetition, seed sweep, or variance is recorded.
- Precision ceiling. Only f16 was validated. Quantized correctness (8-bit / 4-bit) is untested and explicitly out of scope.
- Parity is not quality. Cosine 0.999997 on logits demonstrates faithful numerical reproduction of the reference forward pass; it says nothing about generation quality, long-context behavior, or downstream task performance.
- Baseline weakness. The oracle is the reference library's own sequential fallback (it falls back to a sequential scan when the fused GPU kernel is absent), so this validates against reference semantics but not against fused-kernel numerics. Throughput is not compared against any fused kernel.
- Provenance gaps. Exact build identifiers, library versions, and exact prompt text are not recorded, weakening exact reproducibility.
- Scope. A single 130M-class Mamba model only; no larger Mamba, Mamba-2/SSD, or hybrid state-space plus attention coverage. An
experimentalevidence level is retained as appropriate for a single-configuration parity result.
6. Reproducibility / Provenance
- Implementation. Hand-written selective scan with causal 1D convolution, softplus for the step parameter, and SiLU gating; no attention, KV cache, or rotary position embedding. The recurrence follows the standard published selective state-space formulation.
- Oracle caveat. Validate the oracle first: the reference must be exercising its sequential-scan fallback (no fused SSM GPU kernel present) for its semantics to match the on-box sequential scan.
- Sovereignty check. A dynamic-linkage inspection shows the GPU runtime and system libraries only — no vendor BLAS or deep-learning primitives library, and no dependency on the reference SSM kernel package.
- Build. Compiled with the AMD HIP toolchain targeting an RDNA2-class architecture. Exact build identifiers and run commands are not recorded.
- Versions. Oracle and engine stack are recent versions; precise version fingerprints are omitted.
Claim boundary
The author's explicit scope — what this work does and does not establish — carried over from the Octoryn Research publishing model.
Proves
- A hand-written, independently implemented selective-scan SSM (130M-class Mamba) reproduces a HuggingFace f16 prefill-logit reference at cosine 0.999997, with argmax matching on 8/8 checks across two prompts.
- A kill-selectivity negative control collapses parity to cosine -0.73 (0/8), showing the selective mechanism is load-bearing and the f16 match is not coincidental.
- The engine now spans both attention and state-space sequence-mixing paradigms, implemented independently of the reference SSM kernel library.
Does not prove
- Generation quality, long-context behavior, or downstream task performance; logit parity is not a quality claim.
- Correctness at quantized precision, since only f16 was tested.
- Throughput or latency competitiveness of the sequential scan versus a fused GPU kernel.
- Coverage of larger Mamba variants, Mamba-2/SSD, or hybrid state-space plus attention models such as Jamba.
Applies when
- f16 prefill-logit parity for a 130M-class Mamba model on a consumer AMD RDNA2-class GPU versus a HuggingFace transformers reference using identical input ids.
Does not apply when
- Quantized precision, generation or throughput claims, other state-space model variants, or benchmark-scale evaluation.
- The reference is not exercising its sequential-scan fallback path.
Authors
- Ran Tao — Investigation, Writing
Cite this
Citation
Tao, R., Octoryn Research. (2026). Porting Mamba (selective-scan SSM) into a sovereign sequence-mixing engine (TR-2026-0008). Octopus Research Institute.
BibTeX
@techreport{oritr20260008,
title = {Porting Mamba (selective-scan SSM) into a sovereign sequence-mixing engine},
author = {Tao, Ran and {Octoryn Research}},
institution = {Octopus Research Institute},
year = {2026},
note = {Permanent ID TR-2026-0008. Not peer reviewed.}
}Disclosures
- Funding
- Hardware and infrastructure provided by Octoryn / Octopus Core Pty Ltd.
- Conflicts of interest
- Octoryn ships commercial inference and governance tooling; findings are reported independently.
