CUDA Does Not Own Silicon Speed in Memory-Bound Decode

Back to blog
Mehran Mozaffari·

CUDA Does Not Own Silicon Speed in Memory-Bound Decode

NVIDIA's proprietary software moat does not guarantee superior execution speed on its own silicon once batch size collapses to one. We have spent years treating CUDA as an unassailable performance ceiling, operating under the assumption that running non-NVIDIA machine learning frameworks through cross-platform graphics layers on GeForce silicon guarantees an automatic performance penalty. Recent empirical data decisively upends that belief: Apple's MLX framework, running on Omarchy Linux via a Vulkan compute backend inside the omarchy-mlx fork, clocked 124 tok/s on an NVIDIA GeForce RTX 5060 Ti 16 GB executing 4-bit quantized Qwen3-4B-Instruct-2507. On the exact same silicon and model, llama.cpp using its mature, native CUDA backend topped out at ~101 tok/s.

Screenshot of https://joshuawarren.com/blog/mlx-vulkan-beats-llama-cpp-cuda-on-rtx-5060-ti-egpu/
Joshua Warren's original benchmark analysis comparing MLX Vulkan against llama.cpp CUDA on an RTX 5060 Ti eGPU. (1) Original benchmark title and setup

When an LLM decodes autoregressively for a single user, it cannot form the dense, massive matrix multiplications that fill thousands of CUDA cores. Instead, every generated token forces the entire model's weights to stream sequentially across the memory bus for a series of lightweight matrix-vector multiplications (gemv). In this regime, runtime dispatch mechanics govern throughput far more than proprietary micro-architectural hardware instructions do. If your runtime introduces microsecond-level synchronization bubbles between compute kernels, your raw memory bandwidth and compute headroom are wasted while the GPU execution pipelines sit drained.

By running an Apple-designed tensor engine on Linux over an open graphics standard and beating hand-tuned CUDA, omarchy-mlx reveals a vital operational reality: CUDA has no intrinsic architectural magic at the hardware execution layer. When arithmetic intensity drops, execution speed becomes an exercise in pipeline synchronization, queue batching, and command buffer packing. An open graphics runtime that manages hardware pipeline barriers intelligently can outrun native vendor tooling on the vendor's home turf.

The Presumption of Native Hardware Dominance in Autoregressive Steps

Engineers instinctively assume that proprietary, vendor-curated compilers must outperform open graphics abstractions on native silicon. That assumption holds true in compute-bound regimes—like prefill processing, high-concurrency batch serving, or distributed training—where hand-tuned assembly, warp-level matrix primitives, and vendor libraries like cuBLAS extract every cycle from tensor cores. But autoregressive generation completely transforms the execution profile into a relentless sequence of microscopic dispatches that complete in mere microseconds.

Optimized Vulkan compute outpaces default CUDA in single-batch decode
Optimized Vulkan compute outpaces default CUDA in single-batch decode

timeline
    title Decode Throughput on NVIDIA RTX 5060 Ti (Qwen3-4B 4-bit)
    section Runtime Iterations
        llama.cpp Vulkan : 85 tok/s (conservative global barrier model)
        omarchy-mlx Baseline : 99 tok/s (coarse VK_PIPELINE_STAGE_ALL_COMMANDS_BIT)
        llama.cpp CUDA : ~101 tok/s (standard sequential stream execution)
        omarchy-mlx PR 604 : 124 tok/s median (131 tok/s from token 6 via compute barriers)

In standard CUDA implementations without graph capture, each individual kernel dispatch passes through CPU-side driver validation, event scheduling, and stream serialization. While individual CUDA kernel launches are low-latency by historical API standards, executing hundreds of micro-dispatches per token accumulates host submission latency that rapidly overtakes compute time. Without CUDA Graphs to record the execution DAG into a single executable object, standard CUDA streams spend measurable wall-clock time waiting on CPU front-end interactions and stream transitions.

Conversely, graphics runtimes like Vulkan were explicitly architected to manage massive command streams with direct, low-level hardware queue control. When an implementation uses conservative synchronization to preserve correctness across diverse GPUs—as llama.cpp's Vulkan backend did at 85 tok/s—it forces extensive execution pipeline bubbles. But when Vulkan command buffers are constructed to expose direct dependency chains, open graphics compute bypasses host-side serialization altogether. Host dispatch serialization easily erodes vendor micro-architectural advantages when kernels execute faster than the driver can schedule them.

Inside PR 604: Erasing Two Milliseconds of Pipeline Stalls

The raw mechanical volume of compute dispatches required to decode an LLM autoregressively is staggering. In omarchy-mlx, generating a 256-token sequence of Qwen3-4B required 90,003 compute dispatches packed across 1,525 command buffer submissions. To manage data hazards across these dispatches, the runtime's custom dependency tracker elided 10,678 redundant barriers, yet still issued 82,238 pipeline barriers across the run—averaging roughly 321 hardware synchronization boundaries per generated token.

Prior to PR 604, the Vulkan backend maintained memory consistency between these dependent tensor dispatches by inserting pipeline barriers flagged with VK_PIPELINE_STAGE_ALL_COMMANDS_BIT. This flag operated as a sledgehammer: it commanded the NVIDIA hardware scheduler to drain every active execution stage across the entire GPU before proceeding to the next kernel. Because autoregressive decode issues hundreds of dependent operations per token, these coarse flushes introduced cumulative idle bubbles into the GPU front-end. PR 604 replaced these global barriers with targeted compute-to-compute barriers using VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT.

By narrowing the barrier scope strictly to compute stages, the runtime stopped forcing unnecessary synchronization against transfer, raster, and host stages. The impact was immediate: per-token latency plummeted from 9.72–9.79 ms down to 7.62–7.77 ms, directly erasing approximately 2.0 ms of idle pipeline stalls per token. GPU busy time dropped from 9.643 ms to 7.773 ms, vaulting throughput from 99 tok/s to 124 tok/s (a 25.8% increase, hitting 131 tok/s from token 6 onward).

This execution speed depends heavily on two runtime configurations running on NVIDIA driver 615.78.08. First, MLX_OMARCHY_VRAM_ACTIVATIONS=1 guarantees that intermediate tensor activations remain resident in device local VRAM across dispatches. Second, MLX_OMARCHY_BATCH_WORK=40000 sets an aggressive aggregation threshold, buffering up to 40,000 work items before committing command buffers to the hardware queue. By batching submissions and stripping out full pipeline drains, omarchy-mlx demonstrated that fine-grained barrier hygiene unlocks the true speed of modern silicon.

The Draw-Call Lesson: How Graphics APIs Solved Driver Submission Latency

Every architectural bottleneck machine learning runtimes face today was fought and settled by real-time graphics engines a decade ago. In the DirectX 11 and OpenGL era, rendering complicated scenes stalled because the CPU spent excessive clock cycles serializing state checks, compiling driver structures, and dispatching individual draw calls down a single driver thread. Modern graphics APIs like Vulkan and Mantle eliminated that ceiling by stripping away driver-side babysitting: developers gained explicit multi-threaded command recording, upfront pipeline state objects, and direct command buffer submission to hardware queues. Autoregressive inference on small-parameter models has hit that identical boundary, and machine learning is undergoing the same transition to explicit command recording that rescued real-time rendering.

mindmap
  root((Execution Model Parallels))
    Graphics API Evolution
      Implicit driver state tracking
      Explicit command buffer recording
      Targeted subpass barriers
      Pre-baked render passes
    LLM Runtime Architectures
      Sequential CUDA stream dispatch
      MLX OMARCHY BATCH WORK aggregation
      Compute-only pipeline barriers
      Pre-recorded CUDA graphs

When an inference runtime decodes autoregressively, each token generation step decomposes into a flurry of microscopic matrix-vector multiplications, elementwise scaling, and activation evaluations that each complete in sub-microsecond intervals. Under legacy driver-managed models, the host CPU spends more time validating parameters and managing stream dependencies than the hardware spends executing arithmetic.

By utilizing Vulkan command buffers, runtimes can record thousands of fine-grained tensor dispatches upfront across worker threads and commit them in aggregated batches. Instead of relying on implicit driver synchronization that flushes GPU stages to prevent memory hazards, the runtime commands the hardware queue directly through explicit compute barriers. Just as pre-recorded render passes eliminated per-frame CPU draw-call bottlenecks, low-level explicit graphics primitives allow ML runtimes to bypass the driver overhead that otherwise cripples sequential kernel execution.

Testing the Moat Claim Against Prefill Throughput and Hazard Fragility

Proclaiming that CUDA's software moat has dissolved overstates an isolated win in single-stream decode. What the empirical data proves is narrow: in memory-bound, single-batch, 4-bit decode on a small 4B model, an optimized Vulkan compute runtime can match or surpass default CUDA streams by eliminating barrier stalls. What the data does not show is competitive parity across high-token prefill, multi-tenant serving, or compute-dense tensor-core execution.

As soon as an inference workload shifts from decode to context prefill or continuous batching, execution flips from being memory-bandwidth-bound to compute-bound. In that regime, raw throughput depends on extracting peak FLOPs from specialized hardware units via warp-level matrix-multiply-accumulate instructions and asynchronous memory transfers (cp.async). Native CUDA engines like TensorRT-LLM and vLLM lean heavily on cuBLAS, CUTLASS, and custom FlashAttention kernels to saturate hardware tensor cores. Generic SPIR-V shaders emitted for cross-platform Vulkan backends lack equivalent low-level compiler specialization, causing performance to diverge sharply during prompt ingestion.

Beyond arithmetic limits, the mechanical design of omarchy-mlx introduces severe operational fragility:

  1. Host Submission Bottlenecks: Issuing ~321 barriers per token across 90,003 dispatches per 256 tokens generates an enormous host submission volume. While NVIDIA's proprietary Linux driver processes command buffer submissions with low overhead, non-NVIDIA or mobile drivers (like AMD RADV or Intel ANV) often carry higher per-barrier costs that will rapidly starve the GPU.
  2. Memory Hazard Liabilities: Narrowing the synchronization scope via PR 604 to VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT relies entirely on a custom dependency tracker that pruned 10,678 barriers. If the runtime introduces asynchronous KV-cache paging, host memory copies, or dynamic control flow, treating all dependencies as compute-to-compute introduces silent, non-deterministic data corruption.
  3. Fragile Tuning Thresholds: The architecture relies on hand-tuned values like MLX_OMARCHY_BATCH_WORK=40000. Set that batch size too low, and driver submission overhead spikes; set it too high, and the GPU stalls waiting on CPU command buffer completion.

To verify where a deployment sits, profile the pipeline directly: run Vulkan validation layers alongside Nsight Systems to measure inter-kernel barrier drain durations against CUDA graph replay latency. That trace will reveal whether you are bound by genuine memory bandwidth or merely compensating for runtime pipeline stalls.

The Architectural Decision: Where Vulkan Displaces CUDA and Where It Breaks

Adopting an open graphics compute runtime over proprietary vendor tooling is an architectural tradeoff between hardware reach and operational surface area. I reach for Vulkan compute when building local, single-user desktop applications that must run across heterogeneous hardware—NVIDIA GPUs, AMD cards, Intel Arc silicon, and Apple unified memory—without requiring four separate vendor-locked compiler toolchains. When single-batch autoregressive decode latency is the primary metric, a clean Vulkan implementation with compute-scoped barriers provides high throughput while avoiding vendor lock-in.

That calculus inverts in server-side production deployments. When managing high-throughput inference endpoints that demand continuous batching, PagedAttention, speculative decoding, and tensor parallelism, leaving the CUDA ecosystem remains unviable. Platforms like vLLM and TensorRT-LLM integrate deep scheduling systems that coordinate distributed memory topologies across NVLink and host buses. Forcing an open graphics runtime into that environment requires rebuilding serving primitives, custom memory allocators, and multi-stream synchronization logic entirely from scratch.

Teams must recognize the true maintenance cost of bypassing the vendor stack: choosing a downstream fork like omarchy-mlx replaces vendor lock-in with a recurring engineering debt. You inherit the ongoing responsibility of maintaining custom SPIR-V kernels, tracking hardware synchronization hazards, tuning fragile command buffer batch limits, and backporting upstream operator modifications. Until unified intermediate representations bridge the gap for distributed serving and compute-dense prefill, Vulkan represents a sharp tool for edge execution, not a wholesale replacement for enterprise CUDA infrastructure.

Resources

Updated 2026-11-20 by Mehran Mozaffari.

Related posts