“한 번 작성해 어디서나 실행한다”는 목표는 tensor program에서 어렵습니다. Source code가 architecture description의 일부이기 때문입니다. CUDA kernel은 SIMT index, shared-memory staging, synchronization, NVIDIA-specific instruction을 드러냅니다. Cambricon BANG C는 다른 SIMD model로 work를 mapping합니다. CPU VNNI와 AMD HIP도 vector width, memory behavior, intrinsic contract가 다릅니다. Syntax만 바꾸면 compile되면서 틀린 값을 계산하는 code가 나올 수 있습니다.
Rule-based translator는 작성자가 encode한 범위에서는 신뢰할 수 있지만 source-target pair마다 expert rule이 필요합니다. Symbolic synthesis는 equivalent code를 탐색할 수 있으나 accelerator program 전체에서는 search space가 너무 커집니다. Large language model은 더 넓은 syntax와 API를 다루지만 output이 probabilistic합니다. 원문의 CUDA-to-BANG motivating experiment에서 zero-shot GPT-4는 모든 경우에 compilation error를 냈습니다. Few-shot prompting은 compile 성공을 늘렸지만 output의 92.3%에 computation error가 있었습니다[1].
QiMeng-Xpiler는 불완전한 두 도구를 결합합니다. LLM이 큰 structural change를 제안하고 unit test가 failure를 찾으며 symbolic synthesis가 localized region을 고칩니다. Outer search는 transformation과 tuning parameter를 고릅니다. Neural generation을 correctness authority가 아니라 search-space reducer로 사용합니다.
Architecture change를 드러내는 11개 pass
Transcompiler는 migration을 11개 transformation으로 나눕니다. Loop recovery는 병렬 built-in을 sequential loop로 돌리고 loop binding은 loop를 target 병렬 variable에 mapping합니다. Split, fuse, reorder, expansion, contraction은 iteration을 재구성합니다. Cache 및 pipeline pass는 memory movement를 바꿉니다. Tensorization은 loop body를 special instruction으로 치환하고 detensorization은 source intrinsic을 ordinary operation으로 풉니다.
이 vocabulary는 병렬 execution, memory hierarchy, tensor instruction이라는 세 semantic gap을 분리합니다. Single prompt가 세 가지를 한꺼번에 풀면 buffer를 옮기면서 index도 바꾸는 오류가 생기기 쉽습니다. Pass는 change type을 제한하고 unit-test boundary를 작게 만듭니다. 현재 step에 필요한 API와 constraint만 요청할 수 있어 target-manual retrieval도 유효해집니다.
각 pass에서 system은 LLM으로 source에 computation 및 hardware information을 annotation합니다. Programming manual을 BM25로 검색하고 선택한 내용을 predefined meta-prompt에 넣습니다. Generated candidate를 test하고 성공하면 다음 pass로, 실패하면 repair로 보냅니다.

Pass decomposition은 intermediate program graph도 만듭니다. 한 sequence는 detensorize, loop reorganization, target tensorize 순서를 쓸 수 있고 다른 sequence는 source 형태를 더 유지할 수 있습니다. Compiler는 첫 plausible route에 고정되지 않고 candidate를 측정합니다.
작은 구간에만 적용하는 symbolic repair
SMT solver가 unconstrained behavior에서 200-line tensor operator 전체를 synthesize하기는 어렵습니다. QiMeng-Xpiler는 LLM candidate와 error를 localization hint로 씁니다. 관련 buffer와 expression을 추출해 code sketch를 만들고 example을 만족하는 작은 hole만 solver가 채우게 합니다. Repaired snippet을 candidate에 다시 붙여 test합니다.
이 division of labor가 원문의 중심 주장입니다. LLM은 proof 없이 broad target-specific structure를 제공합니다. Solver는 exhaustive reasoning이 가능한 bounded algebraic 또는 indexing relation을 처리합니다. Test가 둘을 연결합니다. Ablation에서도 SMT를 빼면 difficult direction의 computation 정확도가 크게 떨어졌고 LLM self-debugging을 더해도 gap을 회복하지 못했습니다. HIP-to-BANG C에서 no-SMT variant는 약 52.4%였고 full system은 86.9%였습니다.
다만 “correctness”라는 표현에는 조건이 필요합니다. Implementation은 hardware에서 unit-test set을 통과한 output을 correct로 판정합니다. SMT repair는 localized sketch를 example에 맞게 constraint할 뿐 모든 형태, aliasing pattern, floating-point corner, race에 대한 whole-program equivalence를 증명하지 않습니다. Production compiler는 test-suite success와 formal guarantee를 구분하고 deployed 형태마다 validation을 유지해야 합니다.
Undefined behavior도 경계입니다. Source kernel이 undocumented warp property나 우연히 stable한 race에 의존하면 semantic preservation 자체가 명확하지 않습니다. Manual과 compiler 버전이 intrinsic behavior를 바꾸기도 합니다. Generated artifact를 source revision, target toolchain, hardware, retrieved documentation, prompt, test, search seed와 묶어야 합니다.
Code generation을 넘어선 transformation search
Functionally correct tensor code도 느리면 쓸 수 없습니다. QiMeng-Xpiler는 hierarchical auto-tuning을 사용합니다. Intra-pass search는 tile size 같은 parameter를 열거합니다. Inter-pass search는 Monte Carlo tree search로 transformation sequence를 고릅니다. Candidate execution의 latency reward를 ancestor로 backpropagate해 다음 exploration을 유도합니다.
Compilation은 empirical optimization job이 됩니다. Target이 source와 다른 caching, loop restructuring, tensorization order를 필요로 한다는 점을 탐색할 수 있습니다. 동시에 result는 search에 사용한 benchmark 형태와 device에 의존합니다. Representative 형태 8개에서 tuning한 program이 새로운 batch, sequence length, sparsity pattern, thermal state에도 optimal이라는 보장은 없습니다.
비용은 작지 않습니다. Studied CUDA-to-BANG C operator 6개는 compilation에 1.2시간에서 7.8시간, 평균 3.7시간이 걸렸습니다. Complex matrix multiplication은 auto-tuning 비중이 컸고 special intrinsic이 많으면 generation과 repair도 늘었습니다. Just-in-time compilation이 아니라 offline kernel migration pipeline에 맞는 방식입니다.
Search budget은 product decision입니다. Trial을 늘리면 performance를 개선할 수 있지만 accelerator time과 LLM service capacity를 사용합니다. Expected invocation volume에 따른 stopping rule이 필요합니다. 수백만 번 실행할 kernel은 수 시간 search가 합리적이지만 드물게 쓰는 operator는 portable framework fallback이 더 쌀 수 있습니다.
네 programming model에서 본 결과
평가는 Intel Gold 6348 VNNI, NVIDIA A100 CUDA, AMD MI200 HIP, Cambricon MLU BANG C를 포함합니다. Matrix multiplication, convolution, activation, pooling, elementwise, LLM operation 6개 group의 operator 21개를 사용했습니다. GPT, LLaMA-2, BERT, ResNet, MobileNet 등에서 뽑은 형태 8개씩 총 168 case이며 source는 7줄에서 214줄입니다.
보고한 translation direction에서 compilation success는 거의 100%, computation 정확도는 86.9%에서 100%였습니다. CUDA C-to-HIP은 두 metric 모두 100%로 selected suite의 HIPIFY 85.7%보다 높았습니다. C-to-CUDA computation 정확도는 98.2%로 PPCG보다 약 50 percentage point 높았습니다. 더 어려운 CUDA-to-BANG direction은 91.7%였습니다.
남은 failure를 무시할 수는 없습니다. 평균 95%는 연구 결과로 인상적이지만 tested case 스무 개 중 하나가 functional criterion을 통과하지 못했다는 뜻입니다. Transcompiler는 나머지 5%를 조용히 배포해서는 안 됩니다. Explicit unresolved state, minimized failing test, manual repair path가 필요합니다. Output은 engineering candidate이지 자동으로 releasable kernel이 아닙니다.
Performance는 네 direction에서 manually optimized PyTorch backend의 평균 0.78배였습니다. Handwritten library는 assembly, deeper software pipeline, aggressive unrolling, carefully constructed shared-memory movement의 이점을 유지했습니다. 체계 사이에서 번역한 FlashAttention variant는 전용 implementation의 0.61배에서 0.81배였습니다. Compiler는 porting cost를 줄이지만 vendor kernel team의 가치를 없애지 않습니다.
Deformable Attention case는 productivity를 수치화했습니다. Transcompilation은 GPU에서 34.3배, MLU에서 96.0배의 measured development productivity를 보였습니다. MLU output에는 debugging이 더 필요했고 junior programmer는 3시간, senior programmer는 0.5시간을 추가로 썼습니다. Generation을 완료로 보지 않고 human completion을 계산했다는 점이 운영 관점에서 중요합니다.
Release를 위한 세 gate
첫째는 functional coverage입니다. Destination-specific limit, odd 형태, boundary tile, alignment, accumulation precision, concurrent execution을 test해야 합니다. Exact output이 비싼 경우 metamorphic relation을 더할 수 있습니다. Source backend와 differential testing에는 tolerance와 adversarial value가 모두 필요합니다.
둘째는 performance coverage입니다. Average normalized speed는 특정 operator나 형태의 큰 regression을 숨길 수 있습니다. Shape별 latency distribution, memory consumption, compilation resource, fallback을 기록해야 합니다. Threshold를 못 맞추면 generated kernel을 받아들이기보다 vendor library나 source-체계 service를 유지할 수 있습니다.
셋째는 reproducibility와 audit입니다. Transformation과 repair를 intermediate code 및 test outcome과 함께 replay할 수 있어야 합니다. LLM, manual, compiler, device가 바뀌면 relevant validation subset을 다시 실행해야 합니다. 그렇지 않으면 productivity gain 뒤에 provenance를 복원할 수 없는 opaque binary가 남습니다.
QiMeng-Xpiler의 재사용할 insight는 LLM output이 스스로 trustworthy해졌다는 것이 아닙니다. Probabilistic generator가 symbolic work를 적용 가능한 크기로 줄이고 structured pass와 empirical search가 하나의 큰 translation을 auditable decision으로 바꾼다는 점입니다. 체계 coverage는 넓어졌지만 reported 정확도와 speed는 human review, strong test, optimized-library fallback이 system의 일부로 남아야 하는 이유를 동시에 보여 줍니다.
출처와 저작권 안내
이 글은 Silicon & Systems가 작성한 편집 분석으로, method와 measurement, limitation을 우리 표현으로 다시 썼습니다. 원문의 문장, 표, 도판은 재수록하지 않았고 도판은 이 글을 위해 새로 만들었습니다. 전체 논문은 USENIX OSDI 2025 발표 페이지에서 확인할 수 있습니다. 저작권은 저자에게 있습니다. 2025.