Whole-repository migration · Execution-grounded evaluation

T2J-BENCHBenchmarking Coding Agents on Execution-Grounded
PyTorch-to-JAX Repository Migration

Tao Feng1,2,* Jiefeng Chen2,* Linxin Song3 Yufan Zhuang2 Yue Huang4 Bhavana Dalvi Mishra2 Chi Wang5 Xiangru Tang2 Jieyu Zhao3 Ge Liu1 Tomas Pfister2 Jinsung Yoon2
1 University of Illinois Urbana-Champaign2 Google Cloud AI Research3 University of Southern California4 University of Notre Dame5 Google DeepMind

* Equal contribution

Can coding agents migrate a whole ML repository
and preserve how it actually behaves?

63Repository migrations
18Model families
45 / 18Training / serving tasks
20Off-the-shelf configurations

The benchmark

Beyond code translation.
Preserving executable behavior.

Migrating PyTorch to JAX is a structural rewrite: stateful modules become pure, compilable functions with explicit parameters and state. T2J-BENCH tests whether that rewrite preserves the original system.

T2J-BENCH pipeline: curate 63 training and serving tasks, migrate PyTorch repositories and checkpoints to native JAX/Flax, then evaluate Spec, Numeric, and Behavioral equivalence in an isolated torch-free verifier.
Whole-repository migration, from model code and checkpoint conversion to end-to-end execution. Click the figure for the full-resolution PDF.
The central challenge

A repository can satisfy its interface and still diverge in forward numerics, gradients, optimizer trajectories, or decode behavior. T2J-BENCH measures those differences by running the code.

Task coverage

One migration contract.
Two sides of the ML lifecycle.

Every task starts with a self-contained PyTorch source repository and raw checkpoint. Agents deliver native JAX/Flax code, a torch-free checkpoint converter, and an executable training or serving path.

Training migration45 tasks

15 families × 3 methods

Preserve forward passes, losses, gradients, LoRA adapters, optimizer state, and the data pipeline.

SFTDPOPPO

24 text · 21 vision-language tasks

Explore the 15 model families
BLOOMFalconLlama 3MistralPhi-4Qwen2Qwen3StarCoder2Gemma 3InternVLLLaVA-NeXTPaliGemmaQwen2-VLQwen3-VLQwen2-Omni
Serving migration18 tasks

6 families × 3 engine modes

Preserve paged KV caches, prefill and decode behavior, sampling, and multi-request scheduling.

CoreRagged batchChunked prefill

15 text · 3 vision-language tasks

Explore the 6 model families
Llama 3Qwen2Qwen3GPT-OSSGemma-4Qwen2.5-VL

18 distinct families across both classes; three families appear in both. Evaluated modalities are text and vision, with no graded audio modality.

Execution-grounded evaluation

Run it. Compare it. Verify independence.

Each candidate runs in a separate, offline verifier with PyTorch removed. Ground truth is recorded from the original PyTorch repository; the reference JAX solution is evaluated as a candidate.

01 / Spec

Is it a genuine migration?

Check structure, public interfaces, and framework independence. Hidden PyTorch dependencies cannot earn equivalence credit.

02 / Numeric

Do the numbers agree?

Compare module outputs, composed forward passes, losses, gradients, and step-wise computations against frozen references.

03 / Behavioral

Does the system behave the same?

Evaluate training dynamics, held-out behavior, and paged decode execution under a uniform runtime budget.

R = sspec × (0.5 snum + 0.5 sbeh)

A spec-gated reward in [0, 1], with continuous, threshold-free numeric and behavioral similarity.

7 evaluation levels

L0–L6 cover independence and structure through end-to-end execution.

3 random seeds

Each configuration is evaluated across all 63 tasks; results are seed averages.

0.980 oracle reward

A known-good JAX solution establishes task solvability and remaining headroom.

Main results

High spec scores still leave
a substantial behavior gap.

The strongest of twenty off-the-shelf configurations reaches 0.676 reward. TwinHarness raises its matched Claude-Code / opus-5 baseline from 0.649 to 0.723, while the oracle reaches 0.980.

Claude-Code / opus-5
0.649
Best off-the-shelf
0.676
TwinHarness / opus-5
0.723
Reference JAX oracle
0.980

Full benchmark results

21 agent configurations + reference oracle

Three-seed mean scores on all 63 tasks. Reward shows sample standard deviation; higher is better. Train and Serve are subset rewards.
HarnessModelReward ↑SpecNumericBehaviorTrainServe
TwinHarness Oursopus-50.723 ± 0.0220.9310.7300.7920.7640.622
OpenCodeopus-50.676 ± 0.0140.9270.6700.7410.7470.499
Claude-Codeopus-50.649 ± 0.0080.9240.6180.7280.7250.457
OpenHandsopus-50.622 ± 0.0290.9070.6180.6810.7090.403
OpenCodegemini-3.7-flash0.526 ± 0.0330.8830.5920.5350.5950.351
OpenCodesonnet-50.472 ± 0.0420.7600.4670.5540.3900.677
OpenCodeglm-5.20.470 ± 0.0510.7320.4950.5440.4910.418
OpenHandsgemini-3.8-flash0.443 ± 0.0160.8280.5550.4350.5250.235
OpenHandsgemini-3.7-flash0.416 ± 0.0300.8510.5370.3770.4880.234
Claude-Codesonnet-50.408 ± 0.0320.7320.4240.4790.3290.605
OpenHandssonnet-50.401 ± 0.0230.7550.4280.4590.3210.602
Terminus-2gemini-3.8-flash0.369 ± 0.0150.7930.4960.3530.4530.160
OpenCodegemini-3.8-flash0.361 ± 0.0130.6330.4230.3810.4480.144
Terminus-2gemini-3.7-flash0.358 ± 0.0120.7860.4790.3310.4420.147
OpenHandsglm-5.20.247 ± 0.0260.5720.2790.2790.2230.306
Gemini-CLIgemini-3.7-flash0.102 ± 0.0200.3460.1200.1110.0810.155
Gemini-CLIgemini-3.8-flash0.087 ± 0.0120.3240.1000.1020.0690.131
OpenHandsgemini-3.1-pro0.086 ± 0.0310.3640.1080.0920.0400.203
OpenCodegemini-3.1-pro0.064 ± 0.0230.3550.0690.0830.0340.139
Gemini-CLIgemini-3.1-pro0.057 ± 0.0320.3450.0660.0680.0270.133
Terminus-2gemini-3.1-pro0.006 ± 0.0040.2230.0080.0080.0010.019
Reference JAX oracle—0.9801.0000.9980.9610.9730.997
+11.4%

Matched-baseline reward gain

TwinHarness improves Claude-Code / opus-5 by 0.074 absolute reward, from 0.649 to 0.723.

0.257

Remaining oracle gap

Even the best evaluated configuration leaves considerable room for more faithful migrations.

Uneven gains

Aggregate progress has limits

OpenCode / sonnet-5 leads serving reward at 0.677. TwinHarness does not lead every task subtype.

TwinHarness

Use the source as
an executable specification.

A reference-grounded diagnose–migrate–verify loop turns the task-visible PyTorch implementation into structured feedback for the next edit.

TwinHarness diagnose, migrate, and verify loop, comparing task-visible PyTorch behavior with the evolving JAX candidate and carrying diagnostic evidence across iterations.
Repository state and diagnostic evidence are maintained separately. Checks record what is established, violated, or not yet established.
A strict information boundary

TwinHarness uses the task specification, visible PyTorch source, released checkpoint, and candidate execution. It does not access hidden tests, frozen reference outputs, reference JAX solutions, verifier code, or benchmark rewards.

Structured refinement

Better feedback makes
the next iteration count.

With Claude-Code / opus-5, TwinHarness improves from 0.662 after one round to 0.723 after two. Ordinary continuation improves from 0.649 to 0.658.

With OpenCode, second-round regressions affect 2 of 63 tasks under TwinHarness versus 22 under ordinary continuation. Each method starts from its own first-round candidate.

One- versus two-round reward comparison for base agents and TwinHarness with Claude-Code and OpenCode, using opus-5.
Gains emerge through iteration; they are not uniform at every round budget.

Citation

BibTeX

@article{t2jbench2026,
  title={T2J-BENCH: Benchmarking Coding Agents on Execution-Grounded PyTorch-to-JAX Repository Migration},
  author={Feng, Tao and Chen, Jiefeng and Song, Linxin and Zhuang, Yufan and Huang, Yue and Mishra, Bhavana Dalvi and Wang, Chi and Tang, Xiangru and Zhao, Jieyu and Liu, Ge and Pfister, Tomas and Yoon, Jinsung},
  journal={arXiv preprint arXiv:2605.29054},
  year={2026}
}