AI Completes a Year of Kernel Porting in 72 Hours

    An engineering experiment shows an AI coding agent porting nearly all low-level kernel code for a large model onto a newly released accelerator in about 72 hours, work that typically takes dozens of senior engineers 6 to 12 months. This article explains why kernel-layer adaptation is the real barrier in heterogeneous compute ecosystems, outlines a closed-loop pipeline for automated kernel porting (contract definition, layered generation, automated verification), interprets the reported 8% to 12% performance gap, and covers the impact on multi-hardware ecosystems, engineering best practices, and current limitations.

    Background: A Year of Low-Level Adaptation Compressed into 72 Hours

    A research team recently published the results of an engineering experiment: using an AI coding tool with long-context reasoning and code generation capabilities, the model autonomously completed nearly 100% of the low-level kernel code porting with almost no line-by-line human intervention, running a large-scale model directly on a newly released accelerator card. An adaptation cycle that originally required dozens of senior engineers and 6 to 12 months was compressed to roughly 72 hours.

    The news triggered strong reactions in the developer community not because “generating code” is new, but because it targets the most expensive, most tedious, and hardest-to-replace segment of the heterogeneous computing ecosystem: kernel-layer adaptation. To understand its significance, one fact must be clear first—when switching to a new chip, the time-consuming part is never installing the driver, but re-“translating” the upper-layer framework’s operators into instruction sequences that the target hardware can execute efficiently.

    Why the Kernel Layer Becomes an Ecosystem Barrier

    1. Misalignment Across the Three-Layer Software Stack

    A typical AI software stack can be roughly divided into three layers:

    • Upper framework layer: model structures, automatic differentiation, and distributed strategies, with relatively good cross-platform portability;
    • Middle operator/graph compilation layer: operator fusion, memory planning, and scheduling strategies, strongly tied to the hardware;
    • Low-level kernel layer: directly manipulating registers, shared memory, synchronization primitives, and the memory hierarchy, almost entirely bound to a specific architecture.

    The barrier is not in the upper layer but in the lower two. Upper-layer code can smooth over differences through abstract interfaces, but low-level kernels must precisely match the target hardware’s execution model: the organization of threads and thread blocks, memory coalescing rules, on-chip cache and shared memory capacity, and the depth of asynchronous copies and pipelines. If any one assumption fails, performance drops off a cliff.

    2. The Real Cost of Manual Porting

    The traditional process is roughly: engineers read the hardware programming manual, list the operators, write equivalent implementations one by one against the semantics, and then iterate repeatedly through numerical consistency tests and performance profiling. This process has three inherent flaws:

    • Extremely heavy context load: engineers must simultaneously hold the hardware manual, framework source code, operator semantics, and precision requirements;
    • Long feedback cycles: a full compile-run-profile loop often takes hours;
    • Dense long-tail operators: high-frequency operators are only a minority, yet they consume a large amount of finishing time.

    These three points determine that adaptation work is “labor-intensive, long-cycle, and error-prone,” and also make it naturally suited to automated compression.

    Technical Path for Automated Kernel Porting

    Handing the above process to an AI coding tool is essentially not “letting it write code,” but rebuilding a closed-loop pipeline.

    1. Semantic Anchoring: Fix the Contract First, Then Generate the Implementation

    Before generation, the non-negotiable constraints must be defined; otherwise all subsequent optimization loses its criteria:

    1. Operator contract (illustrative)
    2. - Shapes, data types, and memory layouts of input/output tensors
    3. - Numerical tolerances: relative and absolute error thresholds
    4. - Boundary conditions: empty tensors, unaligned addresses, extreme shapes
    5. - Performance targets: throughput floor and latency ceiling

    2. Layered Generation: From Runnable to High-Performance

    Chasing extreme performance in one shot often fails; a more reliable approach is to proceed in stages:

    1. Correctness first: generate a plain, semantically clear implementation and pass the numerical consistency test;
    2. Structural optimization: introduce tiling, vectorized memory access, double buffering, and pipelining;
    3. Hardware specialization: perform targeted tuning for the target architecture’s memory hierarchy and synchronization primitives;
    4. Regression hardening: commit each version of the implementation along with benchmark data to prevent later changes from introducing regressions.

    3. Automated Verification: Let the Machine Judge Correctness

    Whether automation holds depends on whether verification is also automated. At minimum, three types of gates are required:

    • Numerical consistency: comparison against a reference implementation across multiple random and boundary inputs;
    • Stress and stability: out-of-bounds memory and race detection under large tensors and long-running workloads;
    • Performance regression: throughput and latency on a fixed benchmark set must not fall below baseline thresholds.

    A skeletal pipeline is illustrated below:

    1. for op in operator_registry:
    2. impl = generator.propose(op.contract, target_arch)
    3. if not numerical_check(impl, op.contract, tol=op.tol):
    4. impl = generator.repair(impl, failure_report)
    5. impl = autotune(impl, op.shapes, budget="72h")
    6. if perf(impl) < op.baseline * 0.9:
    7. impl = generator.optimize(impl, profile=profile(impl))
    8. registry.commit(impl, metrics=bench(impl))

    Interpreting the Performance Gap Reasonably

    Public benchmarks show that the ported implementation’s latency on the new hardware is about 8% to 12% behind a highly hand-optimized mature solution. This number needs to be viewed in the right frame of reference:

    • It is not “a generation behind,” but “usable and near-optimal,” already meeting the service-level requirements of most commercial production environments;
    • The source of the gap is explainable: hand-written solutions are often extremely specialized for specific shapes, while automated implementations favor generality and robustness;
    • The gap can converge: feeding profiling data back into the generation stage for secondary tuning of hot operators is a common industry practice;
    • More importantly, the change in magnitude: from “half a year” to “three days,” the number of engineering iterations increases by two orders of magnitude, so long-term performance is more likely to overtake a one-off hand-written version.

    Direct Impact on the Multi-Hardware Ecosystem

    When low-level adaptation shifts from “labor-intensive” to “compute-intensive,” the center of gravity in the competitive landscape moves:

    1. The cost function of migration decisions is rewritten. In the past, “leaving a mature ecosystem was hard” because of the sunk adaptation hours; when that cost drops by two orders of magnitude, selection can be driven more by unit compute cost, supply stability, and energy efficiency.
    2. The barrier shifts from “code assets” to “verification assets.” What is truly scarce is no longer hand-written kernels, but trusted benchmark sets, precision specifications, and regression systems.
    3. Long-tail coverage speed becomes a new variable. If hardware vendors can provide standardized programming interfaces and complete manuals, combined with automated tools, ecosystem completion will accelerate significantly.

    Recommendations for Engineering Implementation

    • Build a unified abstraction layer: describe operator semantics with an intermediate representation to shield hardware differences and avoid coupling business code to a specific architecture;
    • Establish benchmarks and precision baselines: without baselines, automation cannot judge what “better” means;
    • Use containerized environments to pin toolchain versions and ensure cross-machine reproducibility;
    • Use logging services and monitoring/alerting systems to track the success rate, failure clustering, and performance drift of long-running tasks;
    • Restructure the human-machine division of labor: engineers shift from “writing kernels” to “defining contracts, reviewing generated results, and handling long-tail exceptions”;
    • On platforms such as Baidu AI Cloud, elastic validation clusters can be built by combining general capabilities like container platforms, object storage, and monitoring/alerting, turning large-scale parallel compilation and benchmarking into an on-demand scaling pipeline.

    Limitations and Risks

    Automation is not omnipotent. Scenarios that still require manual backstops include: operators with extremely high numerical stability requirements, extreme optimizations that depend on proprietary hardware features, and the early stages of new architectures lacking complete documentation. In addition, the maintainability of generated code, license compliance, and supply chain security all require review steps in the process rather than default trust.

    Conclusion

    Completing a year of adaptation work in 72 hours, what is truly compressed is not coding time but the information cost of “translating hardware semantics.” When this cost approaches zero, competition in the compute ecosystem will shift from “whose software accumulation is thicker” to “whose verification system is more trustworthy and whose iteration speed is faster.” For developers, what is worth investing in now is not memorizing more instruction sets, but laying the three foundations of contracts, benchmarks, and automated verification.