[SymTorch] Bridging the Gap: Automated Symbolic Distillation for Interpretable Deep Learning

SymTorch: A Framework for Symbolic Distillation of Deep Neural Networks

Summary
Problem
Method
Results
Takeaways
Abstract

SymTorch is an open-source library built on PyTorch that automates the symbolic distillation of deep neural networks into human-readable mathematical expressions using PySR. It handles complex engineering tasks like activation caching and GPU-CPU transfers, enabling researchers to replace opaque components with interpretable surrogates or accelerate inference.

Executive Summary

TL;DR: SymTorch is a groundbreaking library designed to peel back the "black box" of neural networks by distilling their weights and activations into clean, closed-form mathematical equations. By automating the integration of Symbolic Regression (SR) with PyTorch, it allows researchers to extract physical laws from GNNs, interpret LLM heuristics, and even accelerate inference by replacing heavy MLP layers with lean symbolic surrogates.

Background Positioning: This work sits at the intersection of Mechanistic Interpretability and Scientific Machine Learning (SciML). Unlike tools that merely assign importance scores (like SHAP), SymTorch aims to find the explicit functional mapping that a model has learned, pushing the boundary toward "white-box" AI.

The Motivation: From "Why" to "How"

Current interpretability methods often stop at identifying which neurons fire. But for a physicist or a safety researcher, the real question is: What exactly is that neuron calculating?

Manual symbolic regression is an engineering nightmare, involving tedious data caching, device management (GPU/CPU), and model serialization. SymTorch solves this by providing a developer-friendly wrapper that treats any nn.Module as a candidate for mathematical distillation.

Methodology: The "Secret Sauce"

The core workflow of SymTorch revolves around the SymbolicModel entry point. It captures activations via hooks, processes them through PySR (a high-performance SR tool using genetic algorithms), and maintains a Pareto front of equations—balancing accuracy against mathematical complexity.

1. The Wrapper Architecture

SymTorch wraps around existing components (GNN edges, Transformer MLPs, or entire PINNs). It automates the "Distill-Replace-Evaluate" cycle.

SymTorch Workflow

2. Handling High Dimensions

For LLMs, SR's exponential cost is a bottleneck. SymTorch introduces a PCA-based framework to compress high-dimensional MLP activations (e.g., 1536-D) into a tractable subspace (e.g., 32-D) before symbolic fitting.

LLM Surrogate Framework

High-Impact Case Studies

A. Discovering Physical Laws (GNNs)

By training a Graph Neural Network on particle dynamics and distilling the Edge Model, SymTorch successfully recovered Newton's Gravitational Law and Spring forces. The "Edge Messages" in a GNN were proven to be linear transformations of true physical forces—an insight that only symbolic regression could explicitly confirm.

B. Accelerating LLMs

In a proof-of-concept, the authors replaced MLP layers in Qwen2.5-1.5B with symbolic expressions.

  • Result: 8.3% increase in token throughput.
  • Trade-off: A perplexity increase from 10.62 to 13.76.
  • Insight: Most of the accuracy loss came from PCA compression, not the symbolic approximation itself, suggesting future potential for optimized dimensionality reduction.

Performance Comparison

C. Debugging LLM Arithmetic

Why does Llama-3 fail at 3-digit multiplication? SymTorch revealed that the LLM learns an "approximate" function with systematic errors. For example, in temperature conversion, the model learns something close to but with "noise" variables that lead to drift in high-precision scenarios.

Critical Analysis & Conclusion

The Takeaway

SymTorch is more than an interpretability tool; it is a bridge to a new category of Hybrid Neuro-Symbolic models. It empowers researchers to verify if a model has truly "learned" physics or is simply memorizing patterns.

Limitations & Future Work

  1. Search Complexity: SR is still computationally expensive (7-8 hours for 3 MLP blocks).
  2. Expressivity: Simple equations struggle with highly non-linear, high-dimensional manifolds.
  3. Future Path: The authors suggest exploring learned linear projections (instead of PCA) and domain-specific symbolic priors to improve accuracy.

By commoditizing the symbolic regression workflow, SymTorch sets the stage for a future where we don't just trust our models—we can read them.

Find Similar Papers

Try Our Examples

  • Search for recent studies on symbolic regression techniques specifically optimized for high-dimensional feature spaces in Large Language Models.
  • Which paper originally proposed using Graph Neural Networks to discover symbolic physics laws, and how does SymTorch extend this methodology?
  • Explore research papers that utilize symbolic surrogates to replace traditional MLP layers for inference acceleration or model compression.
Contents
[SymTorch] Bridging the Gap: Automated Symbolic Distillation for Interpretable Deep Learning
1. Executive Summary
2. The Motivation: From "Why" to "How"
3. Methodology: The "Secret Sauce"
3.1. 1. The Wrapper Architecture
3.2. 2. Handling High Dimensions
4. High-Impact Case Studies
4.1. A. Discovering Physical Laws (GNNs)
4.2. B. Accelerating LLMs
4.3. C. Debugging LLM Arithmetic
5. Critical Analysis & Conclusion
5.1. The Takeaway
5.2. Limitations & Future Work