Running Mamba-1 on a 15-Dollar Tesla K40c: Kepler Custom CUDA Kernels and Forward Pass Alignment
Browse second-hand markets today, and the thirteen-year-old NVIDIA Tesla K40c goes for barely fifteen dollars shipped. Cheap? Genuinely dirt-cheap.
The silicon is ancient. Built on the 2013 Kepler architecture, core codename GK110B. It packs 2,880 CUDA cores, runs over PCIe 3.0 x16, and carries a compute capability of only sm_35. Many recyclers treat it as scrap aluminum by the pound; does anyone actually buy this to run modern AI models?
Yet on its circuit board sits a full 12GB of GDDR5 physical VRAM, pushing 288 GB/s bandwidth.
Mainstream frameworks abandoned this tier long ago. PyTorch pre-built wheels dropped sm_35 binaries years back. Modern acceleration stacks like FlashAttention and Triton demand recent architectures right out of the gate.
Reddit community r/LocalLLaMA thread 1xr97iz surfaced something different. The author posted an open repository alongside A100 verification scripts.
Following the author’s logic, we assembled a test rig in our lab. The code executes, though it strictly handles FP32 forward passes. Slow compute is basic physics, but the engineering journey beneath the surface proves thoroughly fascinating.
Operator Generation Gap: Why Triton Refuses to Cooperate on Old Hardware
Relying on Triton on the K40c leads straight into a brick wall.
The core operator inside Mamba-1 is the Selective Scan. Official upstream implementations lean heavily on high-level kernel generation via the OpenAI Triton compiler.
Throw nvcc at the official code, and the terminal halts with errors stating the PTX target does not support sm_35. Deadlock. Compilation crashes on the spot.
Kepler silicon lacks Tensor Core units for half-precision acceleration; even modern formats like bfloat16 lack physical register instructions on sm_35. Forcing official code onto this card triggers kernel launch failures immediately.
Fighting upstream dependencies is pointless.
The engineering remedy is direct: bypass Triton completely, rewriting the entire selective scan operator from scratch in pure CUDA C++. Computation falls back onto FP32 single-precision registers inside the kernel.
The Makefile targets everything from sm_35 up to sm_75; can it genuinely cover all architectures seamlessly? I only possess a K40c, so testing succeeded strictly on sm_35. I lack Maxwell or Pascal cards, so those targets remain unverified without hands-on proof.
Currently, forward inference for Mamba-1 130M executes reliably, while 370M has not undergone long-context stress runs.
Numerical Alignment: Peak Absolute Error of 3.8e-06 on Forward Pass
Alignment was performed strictly on the forward pass; what about backward passes? Untested.
Using identical weights, random seed pinned to 42, and an input sequence fixed at 512 tokens, we printed layer-by-layer output tensors across the A100 reference script and the K40c custom kernel.
Peak absolute divergence measured 3.8e-06, landing at the 19th layer SSM state output matrix.
[Layer 01] SSM output max_diff: 1.19e-07
[Layer 08] SSM output max_diff: 8.34e-07
[Layer 15] SSM output max_diff: 2.15e-06
[Layer 19] SSM output max_diff: 3.81e-06
[Layer 24] SSM output max_diff: 3.42e-06
Backward propagation and extended context lengths have not been systematically verified, so hold back on broad conclusions.
Still, the forward metrics speak for themselves: internal FP32 accumulation ensured the Parallel Prefix Scan recursive updates avoided catastrophic floating-point truncation.
The original discussion lives on r/LocalLLaMA under thread 1xr97iz, complete with repository links and layer-by-layer comparison code. For validation, inspect the repository commits directly rather than relying on second-hand summaries.
Holding forward precision this tightly confirms the custom memory tiling and dispatch logic were implemented solidly; getting it to compute correctly is already a major triumph.
Hardware Hacker Field Notes: Passive Heatsinks and EPS Power Pinouts
Software operators are running, but physical hardware traps can still ruin your day.
The first major hazard is thermals.
The Tesla K40c is a dedicated enterprise rackmount accelerator. The factory card features only passive aluminum fins without onboard fans. Plugging it into a standard consumer chassis causes core temperatures to spike past 90 Celsius within three minutes, triggering hard thermal shutdowns.
Can you skip duct modifications? Impossible.
Grab a 3D-printed shroud online for a couple of dollars. Secure a high-pressure 9733 blower turbine fan to the rear using zip ties. Wire the fan to an independent 12V rail; amid substantial wind noise, full-load temps remain comfortably under 65 Celsius.
The second trap is power delivery.
The K40c requires an EPS 8pin CPU plug alongside a PCIe 6pin connector. It rejects standard 8pin GPU plugs. Forcing standard PCIe cables into the EPS receptacle mixes up 12V and ground lines, preventing power-on or frying the power supply. Always secure certified adapter cables before installation.
Keep the toolchain lean: use CUDA 11.8 drivers alongside a patched PyTorch 2.7.1 build. Ancient hardware cannot handle bloated dependencies; minimalist runtimes offer the safest route.
The Real Balance Sheet: What Does Fifteen Dollars Actually Buy
Looking past the technical breakthroughs, real-world compute limits demand honesty.
Expecting to deploy this as a daily driver inference card? Discard that fantasy immediately.
Thirteen-year-old silicon delivers only 288 GB/s memory bandwidth without matrix hardware units. Generating text through Mamba feels agonizingly slow, taking dozens of seconds per sentence. Running interactive dialogues? You will close the window in frustration.
Its genuine value lies outside generation speed.
For the price of a standard video game, you obtain 12GB of physical VRAM on enterprise-grade hardware that supports native CUDA kernel development.
Whether you want to unpack the mathematical foundations of State Space Models or build an affordable offline sandbox, it functions as an exceptional hardware workbench.
Demystifying kernel dispatching and memory tiling on a shoestring budget beats paying massive premiums to scalpers any day.