It Takes Two to Entangle

Zhanghan Wang, Ding Ding, Hang Zhu, Haibin Lin, Aurojit Panda

TL;DR

GraphGuard is a static verification tool designed to automatically detect implementation bugs in distributed deep learning models by checking "model refinement." By using iterative term rewriting, it verifies whether a sequential model's outputs can be mathematically reconstructed from its distributed counterpart, catching subtle parallelization errors in minutes before deployment.

What Problem Does This Paper Address?

To train and run modern large language models (LLMs), developers must distribute model state and computation across multiple GPUs using complex parallelization strategies (e.g., Tensor, Sequence, or Expert Parallelism).

Translating a standard sequential model specification into a distributed implementation is highly error-prone. Programmers must manually insert communication and transformation operations. Subtle mistakes—such as incorrect padding, wrong scaling factors, or mismatched offsets—can easily be introduced. Crucially, these bugs often do not alter the shapes of intermediate tensors, meaning they completely bypass standard framework type-checkers and only manifest as silent accuracy degradation during training.

An example of a sequential model ($G_s$) and its distributed implementation ($G_d$) across two ranks.

Methods

The authors introduce GraphGuard, a tool that frames verification as a model refinement problem: Can the sequential model’s outputs be reconstructed from the distributed model’s outputs using only "clean" operations? Clean operations are restricted to simple tensor rearrangements (slicing, concatenation, transposing) and collective communication reductions (like reduce-sum).

GraphGuard avoids the state-explosion problem common in formal verification through several key techniques:

  • Iterative, Operator-by-Operator Verification: Instead of analyzing the entire computation graph at once, GraphGuard processes each operator in the sequential graph inductively in topological order. This ensures that verification runtime scales linearly with model complexity.
  • E-Graphs and Equality Saturation: GraphGuard utilizes the egg Rust library to efficiently explore equivalent tensor expressions using a library of 92 pre-defined mathematical lemmas for PyTorch's ATen IR.
  • SMT-LIB Integration: Because deep learning frameworks use symbolic scalars to represent dynamic shapes and offsets, GraphGuard couples its E-graph rewriting with an SMT solver to reason about symbolic inequalities (e.g., checking if an index falls within a sliced tensor's boundaries).

Datasets

As a static analysis tool, GraphGuard is evaluated on model computation graphs (workloads) rather than traditional datasets. The authors evaluated GraphGuard using the forward passes of several state-of-the-art model architectures and frameworks:

  • Megatron-LM: GPT
  • vLLM: Qwen2
  • Hugging Face Transformers: A regression model with MSE loss
  • Transformers-Neuron (AWS): Llama-3
  • ByteDance Internal Framework: A proprietary transformer-based LLM (evaluated on forward, backward, and optimizer graphs)

Key Insights and Ideas

  • The Power of Refinement Over Equivalence: Previous verification tools tried to prove full semantic equivalence between models, which is computationally intractable for large graphs. GraphGuard succeeds by asking a simpler question: can we map the distributed outputs back to the sequential ones?
  • Locality of Parallelization: The core insight enabling scalability is that programmers rarely change the fundamental order of operations when distributing a model. Because $G_d$ mirrors the step-by-step logic of $G_s$, GraphGuard can isolate its search to small subgraphs matching individual sequential operators.
  • Actionable Bug Localization: Because the tool checks the graph operator-by-operator, when verification fails, GraphGuard doesn't just say "there is a bug"—it points directly to the exact sequential operator where the output mapping broke down.

Key Results

  • Real-World Bug Detection: GraphGuard successfully detected and localized 6 real-world parallelization bugs. This included an incorrect offset in Rotary Position Embeddings (RoPE) under Sequence Parallelism and an auxiliary loss scaling bug in Mixture-of-Experts (MoE) training.
The sub-graphs analyzed by GraphGuard to isolate and localize a real-world RoPE offset bug.
  • High Efficiency: GraphGuard is fast enough to be integrated into standard CI/CD pipelines. It verified state-of-the-art models like GPT, Qwen2, and Llama-3 in times ranging from 6 to 167 seconds (under 3 minutes).
End-to-end verification times across different model architectures.
  • Excellent Scalability: Verification time scales linearly with the number of model layers, and remains highly practical even when scaling up the simulated GPU parallelism degree.

Limitations and Future Work

  • Incompleteness (False Alarms): GraphGuard is sound but incomplete. If a developer or an optimizing compiler applies aggressive optimizations like kernel fusion or operator reordering to the distributed model without modifying the sequential specification, GraphGuard may generate a false positive, reporting a correct implementation as buggy.
  • Graph Capture Restrictions: The tool relies on TorchDynamo to capture computation graphs. Due to current limitations in framework graph-capturing, GraphGuard cannot yet verify Data Parallelism (DP) or Pipeline Parallelism (PP), as these strategies often utilize hidden contiguous buffers or produce disconnected graphs during capture. Verifying these strategies remains an open avenue for future work.

Summary updated

BibTeX
@inproceedings{wang2026it,
  author = {Zhanghan Wang and Ding Ding and Hang Zhu and Haibin Lin and Aurojit Panda},
  title = {{It Takes Two to Entangle}},
  booktitle = {ASPLOS},
  year = {2026},
  doi = {10.1145/3779212.3790178},
}
Figure