Math Neurosurgery: Isolating Language Models' Math Reasoning Abilities Using Only Forward Passes

Bryan R. Christ, Zachary Gottesman, Jonathan Kropko, Thomas Hartvigsen

Introduction

As Large Language Models (LLMs) demonstrate increasingly sophisticated mathematical reasoning, a fundamental question remains: where does this knowledge reside? It is unclear whether mathematical ability is localized within specific "modules" or if it is inextricably tangled with general language skills like reading comprehension. Previous attempts to map these capabilities often relied on computationally expensive gradient-based methods or failed to distinguish between domain-specific reasoning and the general linguistic processing required to parse a prompt.

Researchers have introduced MathNeuro, a gradient-free, forward-only method designed to perform "neurosurgery" on LLMs. By isolating the specific parameters responsible for math reasoning, this approach allows for the targeted deletion or enhancement of mathematical skills without compromising general language performance.

Methodology

MathNeuro identifies task-specific parameters by building upon the Wanda pruning framework. The process follows three distinct stages:

  1. Importance Calculation: The model performs forward passes on a math-specific dataset ($D_{math}$) and a general language dataset ($D_{non-math}$). Importance scores ($S_{ij}$) are calculated by multiplying weight magnitudes by activation values: $S_{ij} = \sum_{k=1}^{N} |W_{ij}| \cdot \|X_j^k\|_2$.
  2. Skill Isolation: To separate math reasoning from general reasoning, the method identifies parameters important for math and subtracts those that are also critical for general language. This results in a "disjoint set" of math-specific parameters.
  3. Intervention: Once identified, these parameters can be manipulated. Pruning involves setting them to zero to "lobotomize" the skill, while Scaling involves multiplying them by a constant (e.g., 1.1) to amplify performance.
The MathNeuro pipeline for isolating math-specific parameters.

Because this method is "forward-only," it avoids the massive memory and compute overhead associated with backpropagation, making it highly efficient.

Experimental Setup

The researchers evaluated MathNeuro across several prominent model architectures, including Phi 1.5 (1B), Llama 3.2 (1B & 3B), Gemma 2 (2B), and Llama 3.1 (8B).

To ensure the identified parameters represented broad reasoning rather than dataset-specific patterns, the team tested generalization across multiple benchmarks:

  • Math Tasks: GSM8K (grade school word problems) and MATH (competition-level).
  • General Language Tasks: RACE (reading comprehension) and MMLU (broad general knowledge).
  • Generalization Sets: Unseen tasks such as HellaSwag, PIQA, and MATHQA were used to verify the surgical precision of the interventions.

Key Results and Discussion

The study revealed that math-specific parameters are distributed roughly evenly throughout the model's decoder blocks, rather than being concentrated in specific "logic layers." Despite this distribution, these parameters represent a tiny fraction of the model—only 1.5% to 1.8% of total weights—yet they account for nearly all mathematical performance.

Surgical Precision

When the identified math parameters were pruned, math scores plummeted to near zero. Crucially, performance on general language benchmarks like MMLU and RACE remained largely unaffected, dropping no more than they would from a random perturbation of equivalent size. This confirms that MathNeuro successfully isolates reasoning from general comprehension.

Impact of parameter pruning on math vs. general knowledge accuracy.

Performance Boosting

Beyond deletion, MathNeuro can enhance capabilities. By scaling the identified parameters by a factor of 1.1, the researchers observed performance gains of 4-17% on GSM8K and 5-35% on the MATH benchmark. This improvement occurred without any additional training or fine-tuning.

Data Efficiency

MathNeuro is remarkably robust regarding data requirements. The method can successfully identify critical parameters using as few as five samples, and in some instances, a single sample was sufficient to perform effective surgery.

Conclusion

MathNeuro demonstrates that mathematical reasoning in LLMs is a distinct, isolatable capability that can be manipulated with high precision using only forward passes. While current work focused on models up to 8B parameters and used grid searches for optimal scaling factors, the underlying "disjoint set" logic offers a promising path for future research. This framework could potentially be extended to isolate other specialized skills, such as coding or formal logic, across even larger frontier models.

Summary updated

BibTeX
@inproceedings{christ2025math,
  author = {Bryan R. Christ and Zachary Gottesman and Jonathan Kropko and Thomas Hartvigsen},
  title = {{Math Neurosurgery: Isolating Language Models' Math Reasoning Abilities Using Only Forward Passes}},
  booktitle = {Annual Meeting of the Association for Computational Linguistics},
  year = {2025},
}
Figure