Vibecoding an FPGA for LLM Inference

Overview

Recent advancements in AI-assisted coding have enabled developers to bridge the gap between high-level intent and low-level hardware implementation. By utilizing AI agents to write C++ and Verilog, a developer successfully programmed an AWS F2 FPGA instance to serve an LLM, achieving a 33x performance improvement over the baseline through an iterative, agent-driven optimization loop.

The "Vibecoding" Methodology

"Vibecoding" in this context refers to using large language models to manage complex, low-level hardware design tasks through natural language guidance rather than manual coding. The project involved a cloud-based agent running for several days, processing roughly 3 million lines of code and 30 million lines of output files. The human operator provided high-level steering—such as "time to be more creative" or "let's go for 2x faster"—while the agent handled the technical implementation of hardware logic, memory management, and timing constraints.

Performance Optimization

The project began with a baseline speed of 6.43 tokens per second. Through 14 distinct optimization steps, the system reached 213.13 tokens per second. Key improvements included:

  • Host Overhead Reduction: Streamlining register mapping and eliminating redundant SDK calls.
  • Burst Attention: Reading the KV cache in bursts to maintain exact summation order.
  • Parallel Routing: Implementing a parallel MoE router with optimized tie-breaking.
  • Speculative Decoding: Using host-side CPUs to draft tokens for FPGA verification.
  • Memory Port Doubling: Increasing memory ports to improve throughput, despite resulting congestion challenges.

Human-AI Collaboration

While the AI agent performed the bulk of the implementation, human intervention remained critical for setting constraints and defining "correctness." The developer noted that while the agent was capable of generating design ideas independently, human guidance was essential for:

  • Defining Iteration Speed: The developer successfully redirected the agent away from time-consuming cycle-accurate simulations toward faster, iterative loops of linting and synthesis.
  • Establishing Numerics: By enforcing a strict bit-exact rule, the human operator prevented the agent from adopting aggressive, lower-precision shortcuts that would have compromised output accuracy.

Community Insights

Discussion within the developer community highlights both the potential and the limitations of this approach:

  • Scalability Concerns: Commenters noted that while FPGAs offer bespoke performance, they face significant manufacturing and economic hurdles compared to mass-produced GPUs. As one user remarked, "even if you could make an FPGA that could do inference better than current GPUs it was economically possible to make them at scale."
  • The New "Hello World": Implementing transformer architectures is increasingly viewed as the modern benchmark for AI-assisted coding, with some developers already applying these techniques to create custom DSLs, RISC-V implementations, and even retro-gaming hardware.
  • Efficiency vs. Cost: While the project demonstrated impressive power-to-performance ratios, some observers questioned the $10,000 token budget as an excessive cost for a proof-of-concept, suggesting that such experiments remain largely in the domain of research and curiosity rather than immediate production deployment.

Sources