Parallel-SFT: Improving Zero-Shot Cross-Programming-Language Transfer for Code RL

Zhaofeng Wu, Shiqi Wang, Boya Peng, Anuj Kumar Goyal, Melanie Kambadur, Sebastian Ruder, Yoon Kim, Chloe Bi

TL;DR

While large language models (LLMs) can learn to improve their coding skills via reinforcement learning (RL) in a high-resource language like Python, these gains completely fail to transfer to lower-resource languages like Go or Ruby. To fix this, the authors introduce Parallel-SFT, a method that trains models on functionally equivalent code across multiple languages during the supervised fine-tuning stage. This simple alignment step restructures the model's latent space to focus on what the code does rather than how it's written, enabling seamless zero-shot cross-language transfer during subsequent RL.

What Problem Does This Paper Address?

When humans learn a new algorithm in Python, they can easily implement it in C++ or Java because the underlying logic is universal. Ideally, LLMs should do the same. However, the authors discover that when a model undergoes Reinforcement Learning (RL) to optimize code generation in a specific "source" programming language (PL), the performance gains are strictly locked to that language. When evaluated on a different "target" language, the performance flatlines or even degrades—a phenomenon known as negative transfer.

Failure of naive cross-programming-language transfer during RL training.

The root cause lies in how LLMs are pretrained. Unlike natural language data, which features abundant "incidental bilingualism" (e.g., Wikipedia articles discussing the same topic in different languages), code repositories are almost exclusively monolingual and highly domain-specialized (e.g., C for systems programming, JavaScript for web development). This lack of overlapping context causes the LLM to build fragmented, syntax-heavy representation spaces for different programming languages, preventing algorithmic improvements learned in one language from propagating to others.

Methods

To bridge this gap, the authors propose Parallel-SFT, a post-training strategy designed to align the representation spaces of different programming languages before RL training begins.

Overview of the Parallel-SFT pipeline compared to single-language and non-parallel baselines.

The method consists of two main phases:

  1. Parallel Data Construction: The authors took Python coding problems and used a powerful teacher model (Llama-4-Maverick 400B) to translate the solutions into seven other languages (C, C++, Java, C#, JavaScript, Bash, Lua). Crucially, they executed these translated programs against rigorous test suites to ensure absolute functional equivalence.
  2. Supervised Fine-Tuning (SFT): They fine-tuned Llama-3.1-8B on these "parallel programs"—forcing the model to map the exact same natural language problem description to multiple syntactically distinct but functionally identical code implementations.

Following Parallel-SFT, the model undergoes standard RL training (using the GRPO algorithm) on a single, high-resource source language (like C++ or Python) and is evaluated zero-shot on unseen target languages.

Datasets

  • SFT Training: Built by translating Python solutions from the APPS and CodeContests datasets into parallel multi-PL equivalents. This was mixed into a modified version of the Tulu 3 SFT mixture (replacing its original coding instances with the new parallel dataset).
  • RL & Evaluation:
  • CodeForces: Used for the code generation task.
  • CodeForces Submissions: A dataset of human code submissions used for the code validation task (predicting whether a given piece of code correctly solves a problem).

Key Insights and Ideas

  • The "Semantic Hub" in Middle Layers: Probing the model's internal representations revealed that Parallel-SFT induces an inverted U-shape in representation similarity across the model's layers. The initial and final layers remain specialized in language-specific syntax, but the middle layers act as a language-independent "semantic hub" that reasons about program functionality.
  • Functionality-Centric Latent Space: By training on parallel code, the model learns to cluster programs based on what they achieve rather than their surface-level syntax tokens. This tight clustering allows policy improvements discovered during RL in Python to naturally map over to Go or Ruby in the latent space.
Representation alignment metrics across model layers, showing that Parallel-SFT peaks in the middle layers.

Key Results

The authors evaluated Parallel-SFT against a monolingual baseline and a standard multi-PL baseline (which saw all languages but not as parallel pairs solving the same problem).

  • Outperforming the Oracle: In code generation, when performing RL on Python, the Parallel-SFT model didn't just beat the baselines on unseen target languages (Go, PHP, Ruby)—it actually outperformed the oracle model that was trained directly on those target languages.
  • Robust Practical Transfer: In code validation (a task where the input code is highly language-dependent), Parallel-SFT consistently yielded the highest zero-shot accuracy gains across the board throughout the RL training timeline.
Main results showing zero-shot transfer performance for code generation and code validation.

Limitations and Future Work

While Parallel-SFT shows remarkable transfer capabilities, the authors note several areas for expansion:

  • Scale and Complexity: Due to compute constraints, experiments were restricted to non-reasoning 8B models. Testing this approach on larger reasoning models (like o1-style architectures) or complex coding agents remains an open question.
  • Hyperparameter Optimization: The exploration did not exhaustively tune SFT data formatting, mixing ratios, or curriculum learning schedules, which could yield further performance boosts.
  • Typological Similarities: Future iterations could explicitly leverage structural similarities between specific programming languages to optimize the transfer pathways.

Summary updated

Abstract

Modern language models demonstrate impressive coding capabilities in common programming languages (PLs), such as C++ and Python, but their performance in lower-resource PLs is often limited by training data availability. In principle, however, most programming skills are universal across PLs, so the capability acquired in one PL should transfer to others. In this work, we propose the task of zero-shot cross-programming-language transfer for code RL. We find that, for Llama-3.1, RL training for code generation in a source PL fails to improve, and sometimes even degrades, the performance on other target PLs. To address this, we hypothesize that effective RL transfer requires a generalizable SFT initialization before RL. We thus propose **Parallel-SFT**, an SFT strategy that incorporates "parallel programs" -- functionally equivalent code implemented in multiple PLs -- into the data mixture. We demonstrate that this improves transferability: when we subsequently perform RL on our Parallel-SFT model, we observe better generalization to unseen PLs. Analysis of the model internal representations reveals that Parallel-SFT leads to a more functionality-centric latent space, where equivalent programs across PLs are more tightly clustered, which we hypothesize to contribute to the improved transferability.
BibTeX
@inproceedings{wu2026parallel,
  author = {Zhaofeng Wu and Shiqi Wang and Boya Peng and Anuj Kumar Goyal and Melanie Kambadur and Sebastian Ruder and Yoon Kim and Chloe Bi},
  title = {{Parallel-SFT: Improving Zero-Shot Cross-Programming-Language Transfer for Code RL}},
  booktitle = {Annual Meeting of the Association for Computational Linguistics},
  year = {2026},
  doi = {10.18653/v1/2026.findings-acl.1324},
}

Loading related content...

Figure