Introduction
The rapid evolution of deep learning has led to a highly fragmented hardware landscape. Developers must navigate a variety of specialized backends, including NVIDIA GPUs (CUDA), AMD GPUs (HIP), Intel CPUs (VNNI), and Cambricon MLUs (BANG). Achieving high performance across these platforms typically requires "writing once and optimizing everywhere," a process that is manually intensive and error-prone due to differences in memory hierarchies and instruction sets.
Existing transcompilation methods face a trilemma of scalability, accuracy, and human effort. Rule-based systems require extensive manual engineering. Symbolic synthesis ensures correctness but fails to scale to complex programs like attention mechanisms. Pure Large Language Model (LLM) approaches offer flexibility but often "hallucinate" critical indexing details, leading to functional failures.
Methodology: Neural-Symbolic Synthesis
QiMeng-Xpiler introduces a neural-symbolic framework that combines the generative capabilities of LLMs with the formal rigor of Satisfiability Modulo Theories (SMT) solvers. The system decomposes full-program translation into a series of manageable, verifiable transformation passes.
LLM-Assisted Transformation and RAG
Rather than attempting an end-to-end translation, QiMeng-Xpiler utilizes a chain of 11 specialized transformation passes, such as loop reordering, memory hierarchy conversion, and hardware-specific tensorization. To handle unfamiliar hardware targets like Cambricon's BANG C, the system employs Retrieval-Augmented Generation (RAG). A BM25-based search engine retrieves relevant snippets from hardware programming manuals, which are then integrated into meta-prompts to guide the LLM in generating accurate code sketches.
Symbolic Repair and Auto-Tuning
When generated code fails unit tests, the system initiates a symbolic repair process. It first performs bug localization—a binary search-like technique to identify the specific erroneous code segment. An SMT solver (Z3) is then used to mathematically derive the correct loop bounds or indexing logic, ensuring functional correctness.
To optimize performance, QiMeng-Xpiler employs a hierarchical auto-tuning strategy. It uses Monte Carlo Tree Search (MCTS) for inter-pass auto-tuning to find the optimal sequence of transformations, while intra-pass tuning uses brute-force search for parameters like tiling sizes.
Evaluation and Results
The framework was evaluated using 21 diverse deep learning operators (e.g., MatMul, Convolution, Self-Attention) across 168 test cases. Benchmarking spanned four major hardware platforms: NVIDIA A100, AMD MI200, Cambricon MLU, and Intel Gold 6348.
Key Findings
- High Accuracy: QiMeng-Xpiler achieved an average computation accuracy of 95%. In straightforward translation tasks like CUDA to HIP, it reached 100% accuracy.
- Superior Performance: The translated programs frequently outperformed vendor-optimized libraries (e.g., cuDNN, oneDNN), achieving up to a 2.0× speedup in specific kernels.
- Productivity Boost: The system significantly reduced the human effort required for cross-platform porting. For complex operators like Deformable Attention, it demonstrated a 96.0× productivity boost over manual optimization by human coders.
Conclusion
QiMeng-Xpiler demonstrates that a hybrid neural-symbolic approach can overcome the limitations of traditional transcompilers. By leveraging LLMs for high-level structural transformations and SMT solvers for low-level mathematical correctness, it provides a scalable and accurate solution for the heterogeneous hardware era. Future work will focus on improving the handling of complex control flows and irregular nested loops to further expand the system's reach.
Summary updated