Fine-Tuning Qwen3-27B for C-to-Rust Code Translation: A Three-Stage Curriculum of Pretraining, Debugging-Aware SFT, and Task-Specific SFT

📅 2026-08-13
📈 Citations: 0
Influential: 0
📄 PDF
🤖 AI Summary
This study addresses the challenges of non-idiomatic syntax, semantic inequivalence, and limited debugging capabilities in general-purpose large language models for C-to-Rust translation. We propose a three-stage progressive fine-tuning curriculum tailored for Qwen3-27B, integrating Rust continued pre-training, debug-aware learning, and task-specific supervised fine-tuning. Furthermore, we introduce SACTOR, a structure-aware verification framework that combines static analysis with FFI-based end-to-end testing to ensure translation correctness. Experimental results demonstrate that our approach significantly improves translation success rates and code idiomaticity while effectively reducing unsafe code usage. The proposed method comprehensively outperforms existing baseline models across all evaluated metrics, establishing a new state-of-the-art for automated C-to-Rust translation.
📝 Abstract
Translating C code into safe, idiomatic Rust is a longstanding software-engineering goal because it can eliminate entire classes of memory-safety vulnerabilities while preserving the functional behavior of legacy systems. Large language models (LLMs) have shown promise for this task but typically underperform when applied off-the-shelf, since general-purpose pretraining rarely emphasizes idiomatic Rust generation, cross-language semantic equivalence, or the ability to reason about and repair compiler/runtime feedback. In this report we describe a three-stage fine-tuning curriculum applied to Qwen3-27B that is designed to progressively specialize the model for the C-to-Rust (C2Rust) translation task: (1) continued pretraining on Rust-centric corpora to strengthen the model's prior over idiomatic Rust syntax and standard-library usage; (2) supervised fine-tuning (SFT) on the microsoft/Verus_Training_Data dataset to instill debugging and self-repair behavior over Rust code; and (3) task-specific SFT on paired C/Rust solutions derived from LeetCode problems to teach direct semantic translation. We evaluate the resulting model using the agentic, static-analysis-guided verification framework of SACTOR, which performs structure-aware, two-phase (unidiomatic to idiomatic) translation with foreign-function-interface (FFI)-based end-to-end (E2E) testing. We report success rate, idiomaticity (Clippy lint counts, unsafe-code fraction), and failure-mode analyses, and compare our fine-tuned model against baseline Qwen3-27B and other LLMs evaluated under the same framework.
Problem

Research questions and friction points this paper is trying to address.

C-to-Rust translation
idiomatic Rust generation
cross-language semantic equivalence
debugging and self-repair
Innovation

Methods, ideas, or system contributions that make the work stand out.

Three-Stage Curriculum Fine-Tuning
Debugging-Aware SFT
C-to-Rust Translation
Idiomatic Rust Generation
Agentic Verification Framework