It’s late, your eyes are a bit heavy, and you’re probably wondering why we’re still throwing more parameters at Large Language Models (LLMs) when our GPUs are already screaming. The paper "Non-Expanding Gated Continued Fraction Architecture for Feedforward Layers" offers a refreshing alternative: what if we could make models significantly smaller and faster without losing the "magic" of their performance?
TL;DR
The authors propose replacing the bulky, parameter-heavy feedforward layers in LLMs with a lean architecture inspired by the mathematical concept of continued fractions. By avoiding the usual "hidden state expansion" and using a clever log-exponential trick to stabilize training, they achieved up to 50% parameter savings and higher throughput while maintaining or even improving accuracy across Transformers, Mamba, and Mixture-of-Experts (MoE) models.
What Problem Does This Paper Address?
In almost every modern AI architecture—from the ubiquitous Transformer to the newer Mamba state-space models—the Feedforward Network (FFN) is the biggest "parameter hog." Traditionally, these layers take an input, blow it up to 2x or 4x its original size (the "expansion factor"), apply a non-linearity, and then shrink it back down.
While effective, this expansion is expensive in terms of memory and computation. Previous attempts to use "Continued Fraction" networks (CoFrGeNets) showed promise for parameter efficiency, but they were notoriously finicky to train, often requiring complex "incremental" training schedules to prevent the math from exploding (specifically, the division operations). This paper aims to make these efficient layers a stable, "drop-in" replacement for any standard LLM.
Methods
The authors introduce CoFrGeNet-FNG (Non-expanding Gated). Here’s the recipe:
- Non-Expanding Gating: Instead of expanding the hidden dimension, they use a gated linear unit (GLU) style setup that stays within the original embedding size. This keeps the parameter count low.
- The "Ladder" Structure: They use continued fractions—a mathematical way of representing numbers as a nested "ladder" of divisions (e.g., $a_0 + 1/(a_1 + 1/(a_2 + \dots))$). In this architecture, the $a_k$ terms are linear functions of the input.
- The Log-Exp Trick: Division is a nightmare for gradients because it can lead to "poles" (dividing by zero) or massive spikes. The authors bypassed this by rewriting the division $A/B$ using logarithms and exponentials: $$\text{sgn}(A)\text{sgn}(B) \cdot \exp(\log|A| - \log|B|)$$ This simple change makes the math "smooth" enough for standard optimizers like AdamW to handle without special training tricks.
Datasets
The models were put through the ringer on several massive datasets:
- Pre-training: OpenWebText (OWT), GneissWeb 35B (GW), and a 2-trillion token mix (Docling) for the more modern Llama and Mamba variants.
- Evaluation: The GLUE benchmark for general language understanding, and a suite of zero-shot tasks including OpenQA, PIQA, ARC-Easy, HellaSwag, and WinoGrande.
Key Insights and Ideas
- Arithmetic Intensity over Raw Count: Even if the new layer has a few more parameters than previous "continued fraction" versions, it’s actually faster. Why? Because it uses a single ensemble of ladders. The hardware only has to read the input once, leading to better "arithmetic intensity"—a fancy way of saying the GPU spends more time calculating and less time waiting for data to move.
- Stability is a Drop-in Feature: By fixing the division problem with the log-exp trick, the authors turned a "research curiosity" into a practical tool. You don't need a special training recipe anymore; you just swap the layer and hit "train."
- MoE Synergy: The savings are most dramatic in Mixture-of-Experts models. Since MoEs use many "experts" (which are just FFNs), replacing them with these leaner continued fraction layers cuts the model size nearly in half.
Key Results
- Parameter Efficiency: Dense models (like GPT-2 and Llama-3) saw a 33% reduction in parameters. Mixture-of-Experts (Llama-MoE) reached 50% savings.
- Performance: Despite being smaller, the CoFrGeNet-FNG variants often outperformed the original, larger models. For example, on the Llama-3.2B architecture, the continued fraction version showed better zero-shot accuracy on several benchmarks (see Table 4 in the paper).
- Speed: Throughput (tokens per day) was consistently higher. For Llama-3, the CoFr variant processed 306B tokens/day vs the original's 235B.
- Convergence: As shown in Figure 2, the new architecture actually converges to a lower loss faster than the original Llama-MoE.
Limitations and Future Work
- Standard LLM Woes: The authors note that their models are still susceptible to the usual suspects: prompt injection and hallucinations. Changing the FFN doesn't magically solve the "truthfulness" problem.
- Implementation Gaps: To get the absolute maximum speed, the authors suggest writing custom Triton kernels (specialized GPU code), which they haven't done yet.
- Scale: While they tested on 3B-class models, the behavior on 70B+ or trillion-parameter models remains an open question.
- Interpretability: Continued fractions are mathematically "neat." The authors hope this might eventually lead to models that are easier to audit or understand internally than standard "black box" MLPs.
Summary updated