potentialpaper

T2J: Leveraging Developer Bug-Fixing Behaviors to Evaluate and Improve LLM-Based PyTorch-to-JAX Translation

Hung D Phan, Son Le Vu, Ali Jannesari

Edit this page

Or clone it with git

Run in a terminal:

Needs Git LFS. To push, use an API key from your profile as the password.

Or let your agent set it up

It checks and sets up everything: signing in, git, the clone, credentials and an SSH key.

Abstract. While Large Language Models (LLMs) have shown strong performance in code-to-code translation for widely-used programming languages, their application to PyTorch-to-JAX translation remains challenging. Although both frameworks are implemented in Python, they differ fundamentally in design principles, execution models, and ecosystem maturity, with JAX being relatively new and underrepresented in public code repositories. Moreover, the lack of parallel PyTorch-JAX datasets and the limitations of existing evaluation metrics hinder effective cross-framework translation. In this work, we propose \ourtool, a prompt augmentation framework aimed at improving LLM-based PyTorch-to-JAX translation. First, we construct two PyTorch code datasets, the problem solving code dataset collected from \textit{TorchLeet} \citep{torchleet2025} repository and the Github code dataset collected from \textit{CodeParrot} benchmark \citep{codeparrot2022}, leveraging the cheap LLM 4o-mini to generate initial translations. Second, we employ two professional developers to iteratively fix the generated JAX code until it is functionally equivalent to the original PyTorch code, resulting in a curated \textit{fixed-bug dataset} that captures common translation errors and their corresponding fixes. Third, we design augmented prompts that incorporate structured guidance from the fixed-bug dataset to improve translation quality of lightweight LLMs as GPT-4o-mini. Finally, we take advantages of using LLM as a judge and using LLM to measure the scale of each bug fixing step to propose three evaluation metrics for Pytorch-to-JAX code translation: \ourtoolnospace_CodeTrans_Score, \ourtoolnospace_FixCost_Score, and \ourtoolnospace_Comparison_Score. Our results demonstrate that \ourtool significantly improves GPT-4o-mini performance by up to \textbf{10%} in CodeBLEU, \textbf{50%} in \ourtoolnospace_FixCost_Score, \textbf{1.33 point} in \ourtoolnospace_CodeTrans_Score (as scale of 0-4), and \textbf{100%} in \ourtoolnospace_Comparison_Score. T2J's generated code can improve 2.5 faster in running time compared to the baseline's output execution. Replication package is available at: \url{https://tinyurl.com/yradutma}.

Are you an author? Claim this paper to see who's reading it, with views and other statistics, and to write about it here.

Claim this paper
How does this paper connect to your work? Write how you built on it, compared with it or reproduced it, or add a summary, a critique or errata.
Or make it interactive:
Start writing

add · history

No versions are recorded yet: its preprint, the venues it went to and what they decided, the camera-ready. Missing a version?

We don't know of a submission of this paper to a venue with open reviews. Missing a submission?

Loading the discussion…