Phantora: Maximizing Code Reuse in Simulation-based Machine Learning System Performance Estimation

Jianxing Qin (Duke University), Jingrong Chen (Uber), Xinhao Kong (NVIDIA), Yongji Wu (University of California, Berkeley), Tianjun Yuan (Duke University), Liang Luo (Meta), Zhaodong Wang (Meta), Ying Zhang (Meta), Tingjun Chen (Duke University), Alvin R. Lebeck (Duke University), Danyang Zhuo (Duke University)

23rd USENIX Symposium on Networked Systems Design and Implementation (NSDI '26) · Day 3 · When ML Meets Its Network

Overview

Predicting the performance of large-scale machine learning systems—particularly those training massive Large Language Models (LLMs)—is a critical yet expensive task. Real-world cluster tuning consumes vast computational resources, and hardware procurement decisions must often be made long before physical GPUs or specialized network interface cards (NICs) arrive. Existing simulation methodologies attempt to circumvent these physical costs through trace-based analysis or mocked framework environments. However, these traditional approaches suffer from a fundamental maintenance bottleneck: they require engineers to manually reimplement complex framework features, parallelization strategies, and scheduling logic.

Watch on YouTube · Slides

Visual summary for Phantora: Maximizing Code Reuse in Simulation-based Machine Learning System Performance Estimation by Jianxing Qin, Jingrong Chen, Xinhao Kong, Yongji Wu, Tianjun Yuan, Liang Luo, Zhaodong Wang, Ying Zhang, Tingjun Chen, Alvin R. Lebeck, Danyang Zhuo
Visual summary for Phantora: Maximizing Code Reuse in Simulation-based Machine Learning System Performance Estimation by Jianxing Qin, Jingrong Chen, Xinhao Kong, Yongji Wu, Tianjun Yuan, Liang Luo, Zhaodong Wang, Ying Zhang, Tingjun Chen, Alvin R. Lebeck, Danyang Zhuo

Key moments

  1. 0:00 Introduction and motivation for ML system performance estimation
  2. 2:00 Limitations of trace-based and mock-framework simulation methods
  3. 5:30 Overview of Phantora's hybrid simulation architecture
  4. 8:00 Handling past events and rollbacks in distributed simulation
  5. 10:00 CUDA library behavior emulation and user integration
  6. 12:00 Case study: tuning Megatron under limited VRAM settings
  7. 13:00 Evaluation results, accuracy, and scaling performance
  8. 14:30 Future directions, conclusion, and open source availability

Phantora: Maximizing Code Reuse in Simulation-based Machine Learning System Performance Estimation

Speakers: Jianxing Qin (Duke University); Jingrong Chen (Uber); Xinhao Kong (NVIDIA); Yongji Wu (University of California, Berkeley); Tianjun Yuan (Duke University); Liang Luo (Meta); Zhaodong Wang (Meta); Ying Zhang (Meta); Tingjun Chen (Duke University); Alvin R. Lebeck (Duke University); Danyang Zhuo (Duke University)

Conference: USENIX NSDI

YouTube: https://www.youtube.com/watch?v=i65xrWAUvE8

Overview

Predicting the performance of large-scale machine learning systems—particularly those training massive Large Language Models (LLMs)—is a critical yet expensive task. Real-world cluster tuning consumes vast computational resources, and hardware procurement decisions must often be made long before physical GPUs or specialized network interface cards (NICs) arrive. Existing simulation methodologies attempt to circumvent these physical costs through trace-based analysis or mocked framework environments. However, these traditional approaches suffer from a fundamental maintenance bottleneck: they require engineers to manually reimplement complex framework features, parallelization strategies, and scheduling logic.

In this talk, the researchers introduce Phantora, a hybrid simulation system designed to maximize code reuse by directly executing unmodified machine learning frameworks on top of a simulated infrastructure. Developed as a collaborative effort between Duke University, Meta, Uber, NVIDIA, and UC Berkeley, Phantora intercepts deep learning operators and communication primitives, routing them through a concurrent simulation engine while running actual framework code. This approach eliminates the need for separate workload extractors or mocked frameworks, drastically reducing engineering overhead while capturing intricate, framework-specific performance characteristics.

Background

▶ Watch: Introduction and motivation for ML system performance estimation (0:00)

As modern AI workloads scale across thousands of accelerators, evaluating performance optimization strategies introduces an enormous configuration space. Practitioners must balance batch sizes per GPU, complex hybrid parallelization strategies (such as tensor parallelism, pipeline parallelism, and sequence parallelism), and framework-specific optimizations like selective activation recomputation in Megatron-LM. Simple analytical calculations, such as the classical Roofline model, are insufficient to capture the non-trivial performance interactions among these knobs.

To address this, the systems community has historically relied on two primary simulation paradigms:

  1. Trace-based simulation: Running the actual ML system on a real GPU cluster with profilers enabled to capture distributed compute and communication traces. While accurate, collecting traces is cost-prohibitive, and modifying raw traces to simulate different cluster topologies (e.g., scaling from 64 to 128 GPUs with altered partition strategies) is notoriously difficult.
  2. Mocked framework simulation (e.g., CI): Using abstract workloads combined with a customized scheduler that mimics framework behavior without executing real GPU math.

To make workloads configurable, trace-based tools rely on workload extractors that translate concrete traces into abstract layers and communication patterns. Conversely, mocked frameworks push this trade-off to an extreme by completely replacing the runtime. Both paradigms force developers into a continuous cycle of reimplementation whenever frameworks like PyTorch, Megatron-LM, or DeepSpeed introduce new optimizations, features, or operators. Phantora departs from this paradigm by asking a foundational question: Can we directly reuse framework code for simulation, thereby eliminating reimplementation entirely?

Key Findings

▶ Watch: Overview of Phantora's hybrid simulation architecture (5:30)

Phantora demonstrates that direct framework reuse via hybrid simulation is not only feasible but yields exceptionally high fidelity with minimal user friction. The primary findings and capabilities demonstrated by the authors include:

  • High Fidelity Against Public Benchmarks: When evaluated against PyTorch Titan public performance benchmarks scaling up to 128 GPUs (using H100, H200, and A100 hardware profiles), Phantora achieved an average estimation error of just 2.9%, with a maximum error of 8.5%.
  • Dramatic Hardware Reduction: Performance estimations that previously required reserving and running jobs on a real 128-GPU cluster can now be executed using a single physical GPU in a matter of minutes.
  • Transparent Feature Support: Because Phantora executes unmodified framework code, it natively supports complex memory-saving optimizations—such as gradient accumulation and selective activation recomputation—without requiring custom simulation stubs.
  • Linear Scalability: Simulation execution times scale linearly with cluster size, taking approximately 1 minute per simulated GPU per training iteration up to 256 GPUs, with single-iteration simulation times peaking at around 20 seconds for smaller configurations.

Technical Deep Dive

▶ Watch: CUDA library behavior emulation and user integration (10:00)

The core architectural innovation of Phantora lies in its hybrid execution model, which interposes a transparent simulation shim between unmodified machine learning frameworks and the underlying hardware libraries.

System Architecture

Phantora’s architecture replaces native GPU runtime libraries with custom shim layers while keeping the upper-level software stack entirely intact:

  • Framework Layer: Unmodified frameworks like PyTorch, Megatron-LM, DeepSpeed, or PyTorch Titan run alongside a slightly modified training script that initializes the simulation context.
  • Operator Tracing: Inside PyTorch, the Phantora Tracer captures PyTorch operators and translates them into computation events.
  • Shim Libraries: Original CUDA and NCCL (NVIDIA Collective Communications Library) libraries are replaced by custom shims (phara and Phantora-NCCL). These shims intercept all compute and communication calls, preventing them from executing actual hardware operations. Instead, they forward the metadata to a concurrently running Phantora Simulator.

Simulator Engine Components

The backend simulator consists of three core subsystems:

  1. Event Queue & Virtual Clocks: Manages discrete simulation events, maintains virtual clocks acting as synchronized work clocks across all simulated ranks, and handles explicit synchronization barriers for collective communications.
  2. Kernel Profiler: Computes execution times by profiling operators on a single physical GPU. Performance-critical parameters—such as tensor shapes and kernel configurations—are cached. Subsequent identical operator signatures hit the cache, avoiding redundant profiling overhead.
  3. Network Simulator: A standard flow-level network simulator implementing max-min fairness algorithms to resolve exact completion times for network flows passing through shared switches and links.

The Past Event Problem and Optimistic Rollback

Integrating a loosely synchronized, event-driven simulator with a distributed real-time system introduces a race condition termed the past event problem.

When multiple ranks execute independently, Rank 0 might initiate a communication event at time $t_1$ and query the simulator for its completion time ($t_1'$). The simulator calculates $t_1'$ assuming isolated network conditions. However, if another rank (Rank 1) subsequently initiates a overlapping communication at time $t_2$ (where $t_2$ falls between $t_1$ and $t_1'$), and both ranks share physical network links, Rank 1's traffic interferes with Rank 0's flow, invalidating the previously computed completion time $t_1'$.

Because Phantora runs real-time framework code transparently, the simulator cannot predict when future ranks will issue network operations. To resolve this efficiently without halting execution, Phantora adopts an optimistic execution and rollback strategy:

  1. The simulator proceeds optimistically, returning estimated completion times based on currently known states.
  2. When a late-arriving network event is detected in the past ($t_2$), the simulator rolls back its internal state to $t_2$.
  3. It recalculates the completion times for all affected flows (both Rank 0 and Rank 1) utilizing recorded throughput history, making the rollback computationally lightweight.
  4. Finally, it traces down the dependency graph to adjust dependent start and completion times. (The authors note that control-flow divergence due to operator duration shifts is assumed negligible, which holds true for standard deep learning training loops).

CUDA Behavioral Emulation

Achieving transparent execution required extensive emulation of CUDA runtime semantics:

  • VRAM Tracking: Implements virtual memory tracking across cudaMalloc and cudaFree to accurately reflect hardware capacity limits and PyTorch's internal caching allocator behavior without manual intervention.
  • Asynchronous Programming: Emulates CUDA streams, events, and synchronization primitives to preserve precise dependency graphs and capture execution overlaps (such as computation-communication overlapping).
  • NCCL Collective Emulation: Accurately models complex synchronization semantics for NCCL setup routines and all collective communication primitives.

Experimental Setup & Results

▶ Watch: Case study: tuning Megatron under limited VRAM settings (12:00)

The authors evaluated Phantora using prominent large-scale training frameworks, specifically focusing on Megatron-LM and PyTorch Titan.

  • Hardware Environments: Benchmarking and profiling were executed using single NVIDIA H200, H100, and A100 GPUs. Simulated clusters scaled up to 256 GPUs.
  • Validation Datasets: Validations were cross-referenced against public PyTorch Titan performance benchmark reports across distributed configurations up to 128 GPUs.
  • Headline Numbers:
  • Accuracy: Achieved an average prediction error of 2.9% and a maximum error of 8.5% compared to published hardware runs.
  • Simulation Speed: Maximum simulation time capped at 20 seconds per iteration for baseline evaluations, scaling linearly to approximately 1 minute per GPU per iteration for a 256-GPU cluster.
  • VRAM and Throughput Case Studies: Using Megatron-LM under constrained VRAM settings, Phantora successfully generated performance curves comparing gradient accumulation against selective activation recomputation. The system accurately replicated VRAM savings and identified optimal batch sizes and accumulation steps using a single physical GPU.

Practical Implications

▶ Watch: Future directions, conclusion, and open source availability (14:30)

For infrastructure teams, MLOps engineers, and model builders, Phantora removes significant operational friction in cluster planning and hyperparameter tuning.

  • Reduced Infrastructure Overhead: Teams no longer need to allocate multi-node GPU clusters merely to benchmark new training configurations or evaluate cluster scaling bottlenecks.
  • Zero Framework Maintenance Debt: Because Phantora operates as a shim layer over unmodified framework binaries, infrastructure groups are decoupled from framework release cycles. When developers update PyTorch or Megatron-LM, Phantora continues to function without requiring manual parser updates or rule rewrites.
  • Exploratory Hardware and System Design: Beyond tuning existing software configurations, the hybrid simulation approach opens avenues for co-designing novel parallelization strategies, fault-tolerance mechanisms, and evaluating emerging interconnect topologies (such as optical circuit switches).
  • Limitations: A fundamental challenge highlighted by the authors is value-dependent performance. In workloads like reinforcement learning, system execution times heavily depend on dynamic token generation lengths or variable sequence responses. Because these values are unknown prior to execution, perfect transparency must occasionally be traded for approximation—such as user-annotated statistical distributions sampled during simulation runs.

Key Takeaways

  • Eliminating Reimplementation: Phantora introduces a hybrid simulation technique that executes unmodified ML frameworks (PyTorch, Megatron-LM, DeepSpeed) directly atop a simulation engine, eliminating framework reimplementation overhead.
  • Optimistic Rollback Engine: To handle distributed race conditions caused by unpredictable real-time network interactions, Phantora employs an optimistic execution model with lightweight history-based rollbacks.
  • High Fidelity: Achieves an average prediction error of only 2.9% compared to published 128-GPU PyTorch Titan benchmarks.
  • Extreme Efficiency: Scales simulation to hundreds of GPUs (up to 256 tested) while requiring only a single physical GPU for profiling and evaluation.
  • Comprehensive CUDA Emulation: Transparently emulates complex GPU behaviors, including VRAM tracking, PyTorch caching allocators, CUDA streams/events, and NCCL collectives.
  • Open Source: The system is fully open-sourced, encouraging community adoption and contributions for additional hardware profiles and validation traces.

About the Speaker(s)

Jianxing Qin is a Ph.D. student at Duke University advised by Professor Danyang Zhuo, focusing on machine learning systems, networking, and performance modeling. The research presented is a collaborative initiative spanning multiple academic institutions (Duke University, UC Berkeley) and industry leaders (Meta, Uber, NVIDIA), reflecting deep practical interest across both systems research and production infrastructure deployment.

Reviews

→ Top-rated talks at 23rd USENIX Symposium on Networked Systems Design and Implementation (NSDI '26)

All talks from 23rd USENIX Symposium on Networked Systems Design and Implementation (NSDI '26)