TL;DR
AI coding agents excel at making migrated code look functional, but they frequently fail to maintain true semantic and numerical equivalence during complex codebase conversions. To expose this gap, the authors introduce T2J-Bench, a rigorous framework that evaluates PyTorch-to-JAX conversions across specification, numerical precision, and training behaviors, revealing that state-of-the-art agents are systematically overconfident and bottlenecked by flawed self-validation.
What Problem Does This Paper Address?
Large Language Model (LLM) coding agents have evolved from simple autocompletion tools into full-scale collaborators capable of refactoring entire repositories. However, evaluating their success on complex tasks like framework conversion (e.g., translating a machine learning codebase from PyTorch to JAX) remains fundamentally broken.
Current evaluation methods are largely "outcome-driven"—they only check if the code runs or if it outputs a similar final loss value. This surface-level validation creates a dangerous illusion of correctness: two codebases can easily match on a single forward pass loss while diverging wildly in their gradients, optimizer states, or short-horizon training dynamics. Furthermore, agents suffer from "shape-versus-semantics substitution," trusting their own local smoke tests and declaring victory on broken codebases that violate the underlying mathematical contracts users actually care about.
Methods
The authors propose T2J-Bench, a benchmark that reframes codebase conversion as a transfer task under a fixed observational equivalence contract. Instead of checking if the code looks right or merely executes, a strict, external verifier evaluates the converted codebase through three progressive stages:
- Spec Stage: Checks interface admissibility (e.g., matching model weights, batch schemas, and public entry points).
- Numeric Stage: Compares precise mathematical outputs, including forward losses, gradients, and objective-specific tensors.
- Behavioral Stage: Probes short-horizon training dynamics under fixed random seeds to ensure the optimization trajectory matches the source.
The workflow is guided by a "minimum constraint prompt" ($p^*$) that establishes the required training interface without leaking the internal mechanics of the evaluator.
Datasets
The authors introduce a new evaluation dataset consisting of 45 distinct datapoints derived from LLaMA-Factory-style PyTorch training pipelines. It spans 15 diverse model families (all under 7B parameters) and covers three core reinforcement learning and fine-tuning paradigms: Supervised Fine-Tuning (SFT), Direct Preference Optimization (DPO), and Proximal Policy Optimization (PPO).
Key Insights and Ideas
- The Overconfidence Gap: Every single tested agent was profoundly overconfident. While agents self-reported a success rate of over 90%, the actual pass rate measured by the rigorous external evaluator ranged from 0% to 29%—a massive gap of 66.6 to 97.8 percentage points. They mistake a successful "smoke test" (the code didn't crash) for semantic correctness.
- Compute Buys Activity, Not Correctness: One might assume that giving agents more tokens or longer reasoning traces would fix these bugs. It doesn't. A massive 4.7× spread in token budget yielded only a meager 2.2× improvement in actual pass rates. In fact, failed attempts often consumed more tokens because agents got trapped in futile self-correction loops driven by misaligned local validation.
- Seam Errors Over Algorithmic Flaws: Surprisingly, the hardest failures aren't caused by models getting the math wrong. Instead, they are dominated by "seam errors"—type confusions, device mismatches (e.g., splitting tensors across CUDA devices incorrectly), and unsupported dtypes crossing the boundary between JAX and PyTorch.
Key Results
Across 355 blind conversion attempts using frontier LLM backbones (such as Claude, Gemini, and Qwen) and native coding agents, codebase conversion remains far from solved:
- The strongest controlled model baseline (Claude Opus 4.7) achieved an overall pass rate of just 28.9% at
pass@1and 46.7% atpass@3. - This low performance stands in stark contrast to the Spec stage, where the best systems successfully matched interfaces up to 91.1% of the time. The massive drop-off occurs at the Numeric stage, proving that numerical precision is the primary bottleneck.
Limitations and Future Work
- Scope Constraints: T2J-Bench is currently limited to PyTorch-to-JAX conversions within LLaMA-Factory-style architectures. The failure modes identified might not perfectly map to other framework pairs or repository structures.
- Finite Contracts: The benchmark certifies equivalence under a bounded set of tests and horizons; codebases could still diverge under longer training runs or outside the observed interface.
- Future Directions: The authors suggest that instead of scaling up backbone model sizes, future efforts should focus on equipping coding agents with explicit "seam discipline" (e.g., a single conversion layer with a typed contract) and internalizing a source-comparison loop rather than relying on self-consistent local smoke tests.
Summary updated