Apple MLX Outruns NVIDIA CUDA on an RTX 5060 Ti via Vulkan Barrier Optimization
Running on an M1 Max MacBook Pro over USB4 eGPU, omarchy-mlx improved Qwen3-4B decode speed by 25.8% using refined Vulkan pipeline barriers, surpassing llama.cp
In an unexpected cross-ecosystem performance milestone, Apple’s native machine learning framework, MLX, running over Linux and the Vulkan graphics API, has managed to outpace NVIDIA’s proprietary CUDA framework on NVIDIA's own silicon. According to a technical breakdown published by developer Joshua Warren, tweaking the fine-grained pipeline synchronization in an omarchy-mlx build on an NVIDIA GeForce RTX 5060 Ti—connected via USB4 as an external GPU (eGPU) to a 16-inch M1 Max MacBook Pro—dramatically accelerated language model decoding speeds.

Image source: https://joshuawarren.com/blog/mlx-vulkan-beats-llama-cpp-cuda-on-rtx-5060-ti-egpu
While achieved under a specific hardware and software configuration, this development highlights how granular rendering pipeline control can dramatically impact real-world AI inference throughput when bridging disparate software stacks and hardware architectures.
The Convergence of Apple MLX and Vulkan
To understand the significance of this optimization, it helps to examine the underlying technologies. MLX is an open-source machine learning framework built by Apple specifically to optimize workflows on Apple Silicon's unified memory architecture and neural engines. Meanwhile, Vulkan is a cross-platform graphics and compute application programming interface (API) designed to provide high-performance, low-overhead access to modern GPUs across various operating systems.
The test environment setup is unorthodox. Running Apple's proprietary framework on Omarchy Linux via a Vulkan backend, the workload was offloaded not to Apple's integrated GPU, but to an external NVIDIA GeForce RTX 5060 Ti 16GB graphics card housed in an eGPU enclosure connected to the MacBook Pro via USB4.
When executing the Qwen3-4B large language model in 4-bit quantization under this cross-platform setup, conventional expectations would lean toward NVIDIA's native parallel computing platform, CUDA, running through llama.cpp to hold the performance crown. However, by refining how pipeline synchronization is handled, the MLX framework eclipsed CUDA's performance on the exact same hardware.
Pipeline Barrier Optimization: Eliminating Shader Stalls with One Change
Autoregressive decoding in large language models consists of a lengthy, sequential chain of short, dependent compute kernels. Across a 256-token inference run of Qwen3-4B, the Vulkan backend dispatches tens of thousands of tasks across numerous command buffer submissions.
Previously, the framework used a full GPU pipeline barrier (VK_PIPELINE_STAGE_ALL_COMMANDS_BIT) whenever dependent compute shaders needed to synchronize data. While safe, this forced the GPU pipeline to stall across all stages even when the only requirement was a compute shader reading data written by a preceding compute shader. Multiplying those micro-stalls across hundreds of barriers per token introduced nearly two milliseconds of overhead on every single generation step.
Pull Request 604 in the omarchy-mlx repository solved this by replacing the heavy global pipeline barrier with a narrow, targeted compute-to-compute barrier.
- Conditional Granularity: The framework now emits a lighter memory barrier (
SHADER_WRITEtoSHADER_READ | SHADER_WRITE) only when specific conditions are met—ensuring compute dispatches that do not involve host writes or recent data transfers can skip the heavy pipeline drain. - Reduced Overhead: Keeping the exact same hardware, build configuration, and model while trimming unnecessary shader wait states cut 1.87 milliseconds of GPU busy time per token.
25.8% Speed Boost and Verified Performance Metrics
The optimization yielded quantifiable performance gains. On the exact same RTX 5060 Ti 16GB discrete GPU setup, the median decode speed for 4-bit Qwen3-4B jumped from 99 tokens per second (tok/s) to 124 tok/s—a 25.8% improvement.
- Benchmark Comparison:
omarchy-mlxVulkan (Compute barrier, 256-token median): 124 tok/sllama.cppCUDA (Same card): ~101 tok/somarchy-mlxVulkan (Full barrier, median): 99 tok/sllama.cppVulkan (Same card): 85 tok/s
The optimized configuration won all five interleaved A/B test pairs, producing bit-identical output tokens on every execution. Mid-stream token decode speeds from token 6 onward reached 131 tok/s, while per-token latency dropped from roughly 9.7 ms down to 7.6 ms.
Verified Limitations and Scope
This optimization is not a universal drop-in patch for all NVIDIA GPUs or typical Apple consumer workflows.
The documented gains are specific to discrete GPUs running under Omarchy Linux and the omarchy-mlx build with an eGPU connection. Apple integrated GPUs and software Vulkan backends retain the full barrier approach by default, and behavior can be toggled via environment variables (MLX_OMARCHY_COMPUTE_BARRIER=0 or 1).
By demonstrating that an Apple machine-learning framework running over Linux and Vulkan can outrun CUDA on NVIDIA's own silicon through careful pipeline synchronization, this achievement underscores how software-level systems engineering can unlock unexpected efficiencies across heterogeneous computing environments.
Sources
- Joshua Warren Blog: 124 tok/s: MLX over Vulkan beats llama.cpp CUDA on an RTX 5060 Ti eGPU