FEMBA on the Edge: Physiologically-Aware Pre-Training, Quantization, and Deployment of a Bidirectional Mamba EEG Foundation Model on an Ultra-low Power Microcontroller
Organizations: Integrated Systems Laboratory, ETH Zürich, Zürich, Switzerland · DEI, University of Bologna, Bologna, Italy
Abstract
Objective: To enable continuous, long-term neuro-monitoring on wearable devices by overcoming the computational bottlenecks of Transformer-based Electroencephalography (EEG) foundation models and the quantization challenges inherent to State-Space Models (SSMs). Methods: We present FEMBA, a bidirectional Mamba architecture pre-trained on over 21,000 hours of EEG. We introduce a novel Physiologically-Aware pre-training objective, consisting of a reconstruction with low-pass filtering, to prioritize neural oscillations over high-frequency artifacts. To address the activation outliers common in SSMs, we employ Quantization-Aware Training (QAT) to compress the model to 2-bit weights. The framework is deployed on a parallel ultra-low-power RISC-V microcontroller (GAP9) using a custom double-buffered memory streaming scheme. Results: The proposed low-pass pre-training improves downstream AUROC on TUAB from 0.863 to 0.893 and AUPR from 0.862 to 0.898 compared to the best contrastive baseline. QAT successfully compresses weights with negligible performance loss, whereas standard post-training quantization degrades accuracy by approximately 30%. The embedded implementation achieves deterministic real-time inference (1.70~s per 5s window) and reduces the memory footprint by 74% (to 2MB), achieving competitive accuracy with up to \textbf{27} fewer FLOPs than Transformer benchmarks. Conclusion: FEMBA demonstrates that Mamba-based foundation models can be effectively quantized and deployed on extreme-edge hardware without sacrificing the representation quality required for robust clinical analysis. Significance: This work establishes the first full-stack framework for deploying large-scale EEG foundation models on ultra-low-power wearables, facilitating continuous, SSM based monitoring for epilepsy and sleep disorders.
Figures & tables
| Model | Architecture | Size | Datasets | Complexity | Deployment |
| EEGFormer | Transformer | 2.3M | TUAR / TUSL | No | |
| LaBraM | Transformer | 5.9M | TUAB | No | |
| LUNA | Transformer | 7M | TUAB / TUAR / TUSL | No | |
| FEMBA | Mamba-based | 7.8M | TUAB / TUAR / TUSL | Yes |
| Property | TUEG | TUAB | TUAR | TUSL |
| Number of Subjects | ||||
| Number of Channels | 22 | 22 | 22 | 22 |
| Sampling Rate | 256 Hz | 256 Hz | 256 Hz | 256 Hz |
| Hours of Recordings | ||||
| Training Samples | ||||
| Validation Samples |
| SSL Task | TUAR | TUSL | TUAB | ||||||
| AUROC | AUPRC | AUROC | AUPRC | Accuracy (%) | AUROC | AUPRC | |||
| Rec. – Random Masking | |||||||||
| Rec. – Clustered Random | |||||||||
| Rec. – Random w/ Lowpass | |||||||||
| Contrastive – Frequency | |||||||||
| Contrastive – Masking | |||||||||
| Model | Size | TUAR | TUSL | ||
| AUROC | AUC-PR | AUROC | AUC-PR | ||
| Supervised Models | |||||
| EEGNet [ 21 ] | - | ||||
| EEG-GNN [ 50 ] | - | ||||
| GraphS4mer [ 51 ] | - | ||||
| Self-supervised Models | |||||
| Model | Size | Bal. Acc. (%) | AUC-PR | AUROC |
| Supervised Models | ||||
| SPaRCNet [ 52 ] | 0.8M | 78.96 0.18 | 0.8414 0.0018 | 0.8676 0.0012 |
| ContraWR [ 53 ] | 1.6M | 77.46 0.41 | 0.8421 0.0140 | 0.8456 0.0074 |
| CNN-Transformer [ 54 ] | 3.2M | 77.77 0.22 | 0.8433 0.0039 | 0.8461 0.0013 |
| FFCL [ 55 ] | 2.4M | 78.48 0.38 | 0.8448 0.0065 | 0.8569 0.0051 |
| ST-Transformer [ 56 ] | 3.2M | 79.66 0.23 | 0.8521 0.0026 | 0.8707 0.0019 |
| Configuration | Method | AUROC | AUPR | Accuracy |
| FP32 (Baseline) | – | 0.89 | 0.89 | 81.84 |
| W8A8 | PTQ | 0.77 | 0.71 | 55.91 |
| QAT | 0.88 | 0.88 | 81.02 | |
| W4A8 | PTQ | 0.71 | 0.67 | 55.79 |
| QAT | 0.88 | 0.88 | 80.88 | |
| W2A8 | PTQ | 0.56 | 0.49 | 54.12 |
| Metric | INT8 (W8A8) | 2-bit (W2A8) |
| Total Cycles | 629.4 M | 625.9 M |
| Inference Time | 1.70 s | 1.69 s |
| Compute Utilization | 98.6% | 98.7% |
| Idle/Overhead | 0.5% | 0.5% |
| DMA/Compute Overlap | 99.4% | 99.5% |
| Layer | Cycles (M) | % Total | Overlap |
| patch_embed | 8.0 | 1.3% | 81.1% |
| pos_embed | 2.3 | 0.4% | 100.0% |
| mamba_blocks.0 | 310.3 | 49.3% | 100.0% |
| mamba_blocks.1 | 308.2 | 49.0% | 99.4% |
| global_pool | 0.5 | 0.1% | 100.0% |
| classifier | 0.1 | 0.01% | 41.9% |
| Operation | Cycles (M) | % | MACs (M) | MACs/Cyc |
| Input Projection | 71.7 | 23.2% | 189.7 | 2.65 |
| Sequence Reversal | 1.6 | 0.5% | — | — |
| Local Temporal Conv. | 8.8 | 2.8% | 1.0 | 0.11 |
| Selective SSM Scan | 199.5 | 64.6% | 63.1 | 0.32 |
| Output Projection | 24.3 | 7.9% | 94.9 | 3.91 |
| Sequence Reversal | 1.0 | 0.3% | — | — |
EEG Foundation Models
Electroencephalography (EEG) foundation models learn reusable representations of brain signals for transfer across people, tasks, and recording setups.
See all 100 papers