Manuscript Offprint

arXiv:2610.34422

From GPU to TPU with Coding Agents: What Works, What Fails, and What It Costs?

Hui Sun, Anderson Uchôa, Wesley K. G. Assunção

Open access. PaperVantage converted this article to text, so layout and figures may differ from the original.

Hui Sun

North Carolina State University

Raleigh, NC, USA

hsun26@ncsu.edu

Anderson Uchôa

Federal University of Ceará

Itapajé, Ceará, Brazil

andersonuchoa@ufc.br

Wesley K. G. Assunção

North Carolina State University

Raleigh, NC, USA

wguezas@ncsu.edu

Abstract—A coding agent can migrate a machine learning workload, report success, and still change how the model trains. Rising compute costs, limited accelerator capacity, and vendor dependence are pushing organizations toward alternatives to graphics processing units (GPUs); a key question is whether agent-generated migrations to tensor processing units (TPUs) can be trusted and at what cost. We build a dataset of 148 PyTorch ML research projects and use Claude Code to migrate ten of them from NVIDIA GPUs to Google Cloud TPUs. We independently assess whether each migration runs, preserves numerical behavior, executes on the intended hardware, maintains the project's goal, and delivers acceptable performance. We also examine failures, human effort, and costs. Eight projects meet our project-goal criterion, and migrations require 2.4 human interventions on average. Of 70 execution attempts, 53 fail (76%), and 26 of these failures (49%) raise no error. The most frequent cause is repeated compilation and other execution inefficiencies, while interactions with third-party libraries can silently change the computation: in one four-chip migration, the agent reports success despite a change in gradient clipping that reduces accuracy from 86.53% to 84.89%. Execution costs vary widely: in one workload, TorchTPU, a PyTorch execution backend for TPUs, trains 1.86 times faster and 25% cheaper per run than the GPU. For practitioners, these findings motivate independent reference runs, verification under the intended hardware configuration, and workload-specific acceptance and stopping criteria that account for both computational and human costs.

Index Terms—software migration, coding agents, large language models, machine learning systems, hardware accelerators, TPU, software verification, empirical study

I. INTRODUCTION

As AI applications become more widely deployed [1], organizations face growing concerns about computing costs [2], energy efficiency [3], [4], and dependence on hardware vendors whose capacity may be constrained [3], [5], [6]. Migrating machine learning (ML) workloads from GPUs to alternative accelerators such as TPUs offers greater deployment flexibility, but introduces engineering challenges involving software compatibility, behavioral preservation, and operational costs. The hard part of such a move is not the hardware but the engineering: a field study of deploying large models on a non-GPU accelerator concludes that “the total cost of ownership is dominated by engineering effort (patching, tuning, operating) rather than by acquiring the hardware” [7].

Coding agents promise to cut this effort. Google used a multi-agent system to migrate production TensorFlow models to JAX, achieving a 6.4–8× speedup over manual migration [8], and has announced Cloud TPU Nexus, a multi-agent system that automates PyTorch model migration from GPUs to TPUs, tuning compiler flags and kernels to reach most of hand-tuned performance in under a day [9]; other work uses agents to deploy models onto edge NPUs [10], [11]. Research tools, in contrast, mostly target single kernels and operators or framework translation, including work from Amazon [12], [13], Google [14]–[16], and AMD [17], [18], and cross-vendor kernel generation [19], [20]. However, reducing the effort required to adapt code does not establish whether an agent-generated migration can be trusted or whether its operational benefits justify the migration effort.

For engineering teams, adopting an agent-generated migration therefore raises a practical decision: what evidence is sufficient to accept the migrated workload, and at what cost? Both are harder than they appear. In one of our migrations, the agent moved a fine-tuning project to a four-chip TPU; the program ran to completion without any error and the agent reported success, yet accuracy dropped from 86.53% to 84.89%, below even the baseline method of the original paper, because the project's pinned training library clipped gradients before averaging them across chips (Section IV-B).

This failure illustrates a practical risk: a migration may pass execution checks while silently changing the behavior of an ML workload. Traditional repository-level migrations are commonly validated through compilation and existing test suites [21]–[23]. Such tests are often unavailable in ML research projects: among the 148 repositories we collected, only seven contained author-written tests. Even when a reference execution is available, comparing outputs across accelerators is challenging because legitimate numerical differences can arise from floating-point precision and operation order [16].

Moreover, agent-reported success is insufficient evidence: previous studies have documented agents claiming successful outcomes that independent assessments did not confirm [24]–[26], including an accelerator deployment in which the target NPU remained inactive [11]. Verification also has a cost: repeated training and evaluation runs consume accelerator resources, while stopping too early risks rejecting a viable migration. Organizations must therefore balance migration reliability, verification effort, and computational cost rather than treating successful execution as the sole acceptance criterion.

We investigate these challenges through an empirical study of coding-agent-driven GPU-to-TPU migration. We selected ten PyTorch research projects from a corpus of 148 repositories that modify or fine-tune foundation models. Of these, 10 have recorded migration attempts, and 9 produced completed TPU evaluation results. Research repositories provide a useful setting because their associated papers report quantitative outcomes against which migrated executions can be examined, although they do not capture all the operational requirements of production systems. Using Claude Code, we examine migrations from NVIDIA GPUs to Google Cloud TPUs, primarily through PyTorch/XLA, and additionally investigate TorchTPU in a case study.

We retain PyTorch while adapting the execution backend, supporting code, and dependencies when required. To evaluate migration reliability, we use five consistency dimensions (Section III-B): executability (L0), numerical agreement (L1), execution integrity (L2), preservation of the project's goal (L3), and performance (L4). We distinguish verification outcomes from quantitative measurements and examine evidence from execution logs, numerical comparisons, runtime telemetry, and manual code inspection, rather than relying solely on the agent's assessment, since even state-of-the-art LLMs cannot reliably judge whether two programs are functionally equivalent [27]. We answer three research questions:

• RQ1 (Consistency): Is the migrated project consistent with the original? Eight of ten projects reached L3 under our human assessment, with an average of 2.4 human interventions per migration. However, agent-reported outcomes were not always supported by independent checks, showing that successful execution alone is insufficient evidence of correctness.

• RQ2 (Failure causes): Why do migrations fail, and which failures go unnoticed? Overall, 49% of failures raised no error. The most frequent cause involved lazy-tensor execution, including repeated recompilation and host synchronization. Library interactions could also silently alter computation, while the agent's diagnoses sometimes obscured the underlying cause.

• RQ3 (Cost and failing fast): Is the migration worth it, and does the agent stop attempts that cannot succeed early? Agent token costs ranged from US2toUS2 to US23 per project, while a completed TPU run cost 0.47–3.6× its GPU counterpart, excluding failed attempts and verification. The agent stopped excessively slow executions but not silent behavioral drift, while fixed thresholds sometimes flagged acceptable differences as failures.

Two case studies show that hardware configuration and backend choice can change the outcome of the same migration (Sections IV-B and IV-C). On four chips, the migrated LoRA+silently lost 1.64% accuracy while the agent reported success; with TorchTPU, its GPT-2 experiment trained 1.86 times faster and 25% cheaper than on the GPU, with accuracy within 0.16% of the GPU's.

This paper makes the following contributions to software engineering practice: (1) Migration reliability and failures: empirical evidence from coding-agent-driven GPU-to-TPU migrations, using the L0–L4 assessment to identify discrepancies between agent-reported and independently inspected outcomes, silent failures, and their root causes; (2) Migration effort and cost: reference data on token usage, migration attempts, human interventions, computational costs, and stopping behavior; (3) Actionable lessons: recommendations for practitioners and tool builders on reference baselines, hardware- and dependency-aware verification, workload-specific acceptance criteria, and cost-aware stopping (Section IV-D); and (4) Replication package: screening data for 148 projects, migration instructions, and complete agent attempt trajectories [28].

References (51)