The Value of Hand-Written Kernels in the LLM Era: Technical Evolution and Engineering Practice
This article traces a capability-transfer path from supercomputing competitions to machine learning systems, then explains why hand-written operators still matter when code generation becomes strong: hidden objective functions, high verification cost, and profiling-driven optimization as a search problem. It covers a four-layer optimization methodology (bottleneck classification, data layout and memory coalescing, pipeline overlap, precision and numerical strategy), engineering essentials for attention kernels, low-precision matrix multiplication, and expert-parallel communication libraries, a layered design for inference serving with prefill/decode disaggregation, and the team infrastructure needed to scale tuning work. It closes with a neutral reading of the recent debate about AI-generated kernels.
1. From Supercomputing Competitions to ML Systems: A Capability Transfer Path
The career path in the source material is a fairly typical case of high-performance computing capability transferring into machine learning systems: an undergraduate background in information and computing science, experience leading a supercomputing team, a top Linpack performance award and a strong overall standing at an international student supercomputing competition, building an inference framework for general-purpose LLMs under the guidance of a university faculty member, a systems paper accepted at a top-tier international operating systems conference, and then joining an LLM R&D team to work on ML infrastructure and systems, with low-level optimization of the main attention operator, a low-precision matrix multiplication operator library, and an expert-parallel communication library.
The takeaway for developers is that three capabilities trained through supercomputing competitions carry over directly to today’s AI infrastructure work.
- Hardware awareness: understanding the relative cost of compute, memory access, and interconnect, and knowing that the bottleneck is usually not “computing fast” but “moving data.”
- Systematic tuning: locating bottlenecks layer by layer, from a single-GPU kernel to multi-GPU communication, rather than changing code on intuition.
- Engineering delivery: producing reproducible, measurable performance results within limited time and power budgets.
2. Why Hand-Written Kernels Still Matter in the AI Era
The source material quotes a widely discussed statement: the author expects that in another six months to a year, AI-generated operators will likely match or exceed the level of hand-written ones, and that he will shift to a role of “directing agents.” He then clarified that the article was meant as a farewell to the hand-written kernel stage rather than an expression of job anxiety, and suggested that writing kernels, and programming in general, may in the future be closer to a recreational activity than a productive one.
Setting aside the emotional reading, there is a serious technical judgment worth unpacking here: when code generation becomes strong enough, human value shifts from “writing” to “defining and verifying.” But the operator layer will not disappear for that reason, for three reasons.
- The implicit parts of the objective function are hard to fully describe in natural language. A high-performance kernel often has to satisfy throughput, tail latency, numerical stability, power, and occupancy constraints at the same time, and these constraints usually come from real production workloads that are difficult to write into a prompt.
- Verification costs far more than generation. Producing a kernel that runs is fast; proving it correct and non-regressing across all shapes, all precisions, and all hardware requires a complete comparison and benchmarking system.
- Performance optimization is a search problem, not a writing problem. Real gains come from profiling-driven iteration, and every step requires a person to set a hypothesis, design an experiment, and judge whether the result is trustworthy.
So the more accurate conclusion is this: hand-writing shifts from being the primary production method to being a fallback capability and a basis for judgment on the critical path, while AI coding tools take on breadth of coverage and first-draft generation.
3. A General Methodology for Operator Optimization
Whether the target is an attention kernel, a low-precision matrix multiplication, or a communication operator, the optimization flow can be abstracted into four layers.
Layer one: identify the bottleneck type. Metrics such as achieved memory bandwidth, compute unit utilization, cache hit rate, and interconnect link utilization tell you whether the workload is memory-bound, compute-bound, or communication-bound. Illustrative decision logic:
# Pseudocode: rules of thumb for classifying the bottleneckratio = achieved_flops / peak_flopsbw_ratio = achieved_bandwidth / peak_bandwidthif bw_ratio > 0.7 and ratio < 0.2:bottleneck = "memory_bound" # prioritize data reuse and layout optimizationelif ratio > 0.5:bottleneck = "compute_bound" # prioritize instruction-level and precision strategyelse:bottleneck = "latency_or_comm" # prioritize pipeline overlap and communication scheduling
Layer two: data layout and coalesced access. Most of the gains come from reusing the same data multiple times: tiling, staging in shared memory, vectorized loads and stores, and coalesced access to reduce round trips to global memory.
Layer three: pipeline overlap. Split data movement, computation, and write-back into multiple pipeline stages so that movement and computation run in parallel at different stages, using multi-buffering to hide latency.
Layer four: precision and numerical strategy. Low-precision matrix multiplication combined with an appropriate accumulation precision and scaling strategy can substantially raise throughput within acceptable error; the key is to establish a clear error-evaluation criterion rather than looking only at the final metric.
4. Engineering Essentials: Attention and Low-Precision Matrix Multiplication
The difficulty in the main attention module is memory capacity and bandwidth: a naive implementation explicitly materializes an intermediate matrix whose size grows quadratically with sequence length. The common industry approach uses tiling and online normalization to compute exact attention without ever writing that matrix to memory, reducing the memory footprint to linear scale. Engineering work also has to handle variable-length sequences, causal masks, key-value cache layouts with different page sizes, and the small-batch, high-concurrency characteristics of the decode phase.
For low-precision matrix multiplication, the key point is that format conversion and quantization overhead must not eat up the compute gains. Viable strategies include maintaining scaling factors per block, performing the necessary type conversions inside the operator, and designing dedicated paths for small and tall-skinny matrices to avoid the resource waste caused by one uniform large kernel.
For the expert-parallel communication library, the key point is overlapping communication with computation: plan the granularity and ordering of each layer’s All-to-All sensibly, control the amount of data per transfer, avoid having too many small messages so that launch overhead dominates, and ensure fault tolerance and recoverability when the load is imbalanced.
5. Layered Design for Inference Serving Systems
The prefill/decode disaggregation idea mentioned in the source material has become a common paradigm for LLM serving systems: the prefill phase is compute-intensive and aims for high compute utilization, while the decode phase is memory-intensive and sensitive to latency and concurrency. Placing the two in separate resource pools and connecting them through intermediate state allows each to choose its own parallelism and batching strategy, improving throughput and latency at the same time.
A practical layered reference:
- Access layer: authentication, rate limiting, routing, and canary rollout.
- Scheduling layer: request queuing, priority, batch assembly, and timeout control.
- Execution layer: kernel libraries, memory and cache management, parallelism strategy.
- Observability layer: structured logs collected by the logging service, with monitoring and alerting tracking latency percentiles, failure rate, and resource watermarks.
6. Turning Individual Skill into Team Capability
Heroic individual tuning does not scale. A team needs three pieces of infrastructure: first, a unified benchmark covering multiple shapes, multiple precisions, and multiple hardware platforms with reproducible results; second, automated correctness comparison that does element-wise checks against a high-precision reference implementation and reports the error distribution; third, a regression gate that blocks a merge if either performance or accuracy degrades.
# Minimal local loop for benchmarking and correctness checkingrun_bench --shapes 1x128,8x2048 --dtype fp8 --repeat 50run_check --reference high_precision --tol 1e-2
7. How to Read the Controversy
The discussion around that long post was heated because it touched a real anxiety among practitioners: where human scarcity lies as AI coding tools keep getting stronger. The follow-up clarification already addressed this, stating that the main point was a farewell to a particular technical stage and that the personal judgments in the post do not represent the position of the author’s organization. For developers, the more useful reading is to treat it as a reminder: move effort away from the parts that can be generated automatically and toward problem definition, constraint modeling, verification systems, and system-level tradeoffs, while keeping a hands-on feel for low-level principles so that trustworthy judgments can be made on the critical path. The idea that the most advanced intelligence is supplied to everyone in an open and inexpensive way translates, in engineering terms, into continuously lowering the cost per inference, and that still requires a great deal of solid low-level optimization work.
