Manuscript Offprint

arXiv:2608.25124

FABRICA: Agentic CUDA-to-CSL Translation and Optimization for Wafer-Scale Systems

Yuebo Luo, Eliu Huerta, Venkatram Vishwanath, Caiwen Ding, Rajeev Thakur, Le Chen

Yuebo Luo*, Eliu Huerta†‡, Venkatram Vishwanath†, Caiwen Ding*, Rajeev Thakur†, Le Chen†

*University of Minnesota, Twin Cities, Minneapolis, MN, USA

†Argonne National Laboratory, Lemont, IL, USA

‡The University of Chicago, Chicago, IL, USA

{luo00466, dingc}@umn.edu, {elihu, venkat, thakur, lechen}@anl.gov

Abstract—Porting GPU kernels across architectures requires architectural remapping, not syntax substitution. CUDA encodes decomposition, locality, and synchronization through threads, blocks, and memory accesses; the Cerebras Software Language (CSL) requires explicit placement, distributed SRAM, fabric communication, event-driven tasks, and host/device contracts. We present FABRICA-BENCH, 49 paired CUDA-to-CSL tasks, and FABRICA, an agentic framework combining target knowledge, execution, failure-directed repair, and correctness-gated optimization. On a fixed 28-task Level 1–3 core comparison with Claude Opus 4.8, FABRICA raises success from 6/28 to 26/28; 22 successful programs match or beat their CSL references. Across the 49-task coverage evaluation, 38 tasks produce a correct program; the final three tasks are evaluated over three seeds and pass 8/9 runs. For 27 generated/reference pairs with device-internal timing, geometric-mean speedup is 3.75×3.75 \times on the SDK simulator and 3.47×3.47 \times on WSE-3 hardware. With the executable workflow fixed, Claude Opus 4.8 passes 26/28 core tasks while the best open-weight model passes 2/28; retrieved Cerebras knowledge separately raises success from 1/15 to 7/15 on a Level 1–3 panel. These results identify base-model capability, target knowledge, execution feedback, and same-target measurement as central to cross-architecture kernel generation.

Index Terms—agentic systems, code translation, CUDA, Cerebras Software Language, wafer-scale computing, kernel optimization

I. INTRODUCTION

Recently, due to the rapid development of Artificial Intelligence (AI), the scaling up of Machine Learning (ML) applications, and AI infrastructure, AI-infra has been recognized as the pivotal backbone of the industry. GPUs such as Nvidia's draw researchers' interest, with CUDA programming [1] as a key initiative to drive AI-infra forward. CUDA programs reflect Nvidia GPUs' architecture through grids, blocks, threads, memory spaces, etc., framing a hierarchical, sophisticated system task to develop high-performance GPU kernels. As a potential alternative that specializes in inference service end, accelerator programs supported by their custom system languages present different challenges in both algorithm design and cross-architecture mapping. Porting CUDA kernels to Cerebras Software Language (CSL) [2], [3] programs is therefore a hardware/software co-design task.

Unlike Nvidia GPUs, the Cerebras Wafer-Scale Engine (WSE) [4], a very different class of AI accelerator, places its kernels on a physical PE mesh with distributed SRAM, fabric routes, and event-activated tasks. A complete CSL kernel bundle couples layout parameters, data output, input, and its movement. Translation therefore turns virtual GPU work into explicit spatial data accesses and dataflow largely customized for inference of large language models (LLMs).

Regardless of their relatively low cost and accessibility for large data center operations, CSL programming resources are particularly scarce compared to CUDA, which already enjoys an enormous developer community and abundant codebases to learn and implement. That imbalance has given rise to emerging coding agent systems [5]–[7], and their corresponding benchmarks [8], and it is also why those systems do not yet reach a machine like the WSE.

Three obstacles follow, and they organize this paper. First, there is almost nothing to learn CSL from. The public corpus is essentially the official Cerebras SDK examples and tutorials plus a handful of third-party skill notes, with no community codebase behind it; a single generation attempt from a frontier model therefore succeeds on only 6 of our 28 Level 1–3 core tasks. Second, today's coding agents were built for CUDA and carry very little CSL knowledge into the task. In our runs, they recover local arithmetic and individual CSL calls but cannot assemble parameters, tasks, queues, colors, collectives, exports, and transfers into one program that runs: across eleven models, Claude configurations pass 24–26 of the 28 core tasks, open-weight models pass at most 2 on that same set; on a separate 12-task probe, one open model passes one task and the other five pass none. Both sets span Levels 1–3. Moreover, 130 of 189 classified repairs are local CSL implementation fixes rather than algorithmic ones. Third, no benchmark measures any of this. KernelBench [8] supplies workload semantics with no wafer-scale target, and the SDK examples supply native spatial mechanisms with no paired CUDA input, so there is no way to tell whether an agent has actually learned to map one architecture onto the other. Fig. 1 shows why that mapping is so hard to learn: the two sides differ not only in how a kernel runs but in what a developer can even measure, so the tools and the performance vocabulary an agent absorbed from CUDA have no counterpart on the WSE.

We therefore present FABRICA-BENCH and FABRICA, each part answering one obstacle. FABRICA-BENCH contains 49 paired CUDA and CSL tasks, each with a reference implementation, a task description, and uniform, fair metrics for measuring how well LLMs and agentic frameworks perform; Fig. 2

Figure

Fig. 1. CUDA and Cerebras expose different execution and observation models. Translation reconstructs source intent and synthesizes target placement, storage, communication, and tasks; optimization consumes architecture-specific evidence rather than applying a syntax dictionary.

places it against KernelBench and the Cerebras SDK examples, which each supply only half of what such a benchmark needs. FABRICA, our CUDA-to-CSL translation and optimization framework, is shown end to end in Fig. 3: it carries a task all the way to a finished kernel, first translating the CUDA and then optimizing the CSL against both the fabric simulator and a real WSE cluster. It gives substantial new capability to frontier and open-source models alike, and leaves abundant room for post-training on the very large volume of execution traces it generates along the way.

This paper makes three contributions:

• A benchmark for cross-architecture translation. FABRICA-BENCH pairs 49 CUDA kernels with validated CSL implementations across multiple operation families and WSE execution structures, scoring each by compiling, running, and numerically checking the generated program rather than by comparing text, with held-out inputs and safeguards that keep a model from gaming the score.

• A training-free, knowledge-supported agentic framework. FABRICA retrieves from a consolidated knowledge base of SDK documentation, tutorials, skill notes, and experience gathered from its own earlier knowledge-free attempts. With Sonnet 4.6, the reviewer, and a 20-attempt budget fixed, retrieved Cerebras material raises success from 1/15 to 7/15 on a communication-weighted Level 1–3 panel; a longer repair loop alone does not recover the missing target idioms. Correct programs then enter a cycle-gated optimization loop (Fig. 3).

• An evaluation on real Cerebras tooling. Correctness rises from 6/28 to 26/28 on the fixed Level 1–3 core set. Across the 49-task coverage evaluation, 38 tasks yield a correct program, and the final three tasks pass 8/9 seed runs. For 27 timing-comparable generated/reference pairs, the geometric-mean speedup is 3.75×3.75 \times on the simulator and 3.47×3.47 \times on WSE-3 hardware (Fig. 5). In the preliminary cross-model study, the three Claude models pass 24–26/28 core tasks, compared with 1–2/28 for the two open-weight models evaluated on the same set.

References (23)