What Extreme Optimization of Domestic AI Compute Really Means

    As core operators approach hardware limits, the conversation should move beyond a single utilization percentage to a more fundamental question: why squeezing more out of existing hardware often beats adding more of it. Using attention and matrix multiplication in LLM inference as the thread, this article builds a framework for judging whether an operator is near its limit, explains why widening the fusion scope is considered low-hanging fruit, contrasts in-house vendor tuning with on-site external support in terms of knowledge retention, and closes with a reusable engineering checklist.

    When multiple core operators are optimized to near the hardware’s theoretical limit, the discussion should not stop at a percentage figure. It should return to a more fundamental question: why, when compute supply is tight, the payoff from fully utilizing existing hardware often exceeds that of adding more hardware. This article uses two core operator families in large-model inference, attention and matrix multiplication, as its thread. It first establishes a framework for measuring how close an optimization is to the limit, then explains why expanding the fusion scope is often treated as low-hanging fruit, then compares vendor in-house work with on-site external support in terms of knowledge retention, and finally offers a reusable engineering checklist.

    First, Define What “Hardware Limit” Actually Means

    In engineering practice, “approaching the hardware limit” almost never means the peak floating-point throughput is 100% occupied. It means a roofline-style upper bound is being approached. For an operator, that bound is set by two lines: a compute bound equal to the chip’s peak throughput, and a memory bound equal to memory bandwidth multiplied by the operator’s arithmetic intensity (how many floating-point operations accompany each byte moved). Achievable performance is the smaller of the two, multiplied by an efficiency factor that reflects scheduling, synchronization, and pipeline bubbles.

    So when someone says an operator reaches more than 90% utilization, three things need to be clarified:

    • What the denominator is. Is it an MFU-style metric against peak compute, or bandwidth utilization against the memory bound? The two cannot be mixed.
    • Whether the shape is fair. Sequence length, batch size, whether a causal mask is enabled, and whether prefill and decode are measured separately or combined can all shift the number substantially.
    • Whether end-to-end overhead is included. Timing only the operator kernel is a different measurement from end-to-end latency that includes launch, synchronization, and memory allocation.

    Once the measurement basis is aligned, a counterintuitive but common conclusion emerges: in most scenarios that “look compute-starved,” the real bottleneck is data movement and synchronization waits, not the multiply-add units.

    Where the Optimization Room Is in Attention Operators

    Take attention with low-rank compression as an example. Its computation graph includes projection, cache writes, scoring, masking, normalization, and weighted summation. A naive implementation writes intermediate results back to memory repeatedly, creating a large amount of redundant reads and writes, while the tiling strategy determines how efficiently on-chip cache is reused.

    The core optimization moves are usually four:

    1. Tile sizing and pipeline scheduling. Align matrix-multiply block sizes with on-chip storage capacity and vector unit width so that load, compute, and write-back overlap, reducing pipeline bubbles.
    2. Keeping intermediates on chip. Leave normalization statistics and local maxima in on-chip registers or near-memory space instead of round-tripping to memory.
    3. Masking and variable-length handling. Skip entire blocks of invalid computation for causal masks, and pack variable-length inputs compactly to reduce the share of ineffective work.
    4. Precision and accumulation strategy. Adjust accumulation precision and order within acceptable error bounds in exchange for higher vector throughput.

    An easily overlooked fact here: different teams make different choices in tile shape, mask handling, and cache layout, yet all can approach the same bound, which shows this path has multiple equivalent optima. It also explains why two independently written operators can perform similarly while looking nothing alike: they converged on the same roofline bound rather than copying each other.

    The illustrative tiling schedule can be abstracted as:

    1. # Pseudocode: tiling + on-chip reuse + invalid block skipping
    2. for q_block in split(queries, BLOCK_Q):
    3. acc = zeros_like(q_block) # accumulator stays on chip
    4. for kv_block in split(keys_values, BLOCK_KV):
    5. if skip_due_to_causal_mask(q_block, kv_block):
    6. continue # skip the whole block, save invalid compute
    7. s = matmul(q_block, kv_block.T) # three-stage overlap of load-compute-write-back
    8. s = apply_mask(s)
    9. acc = fused_softmax_accumulate(acc, s) # intermediates never land in memory
    10. write_back(acc)

    Fusion Scope: The Real Low-Hanging Fruit

    Performance discussions in the industry concentrate heavily on general matrix multiplication and attention kernels. But the inference path contains many unremarkable stages: positional encoding, normalization, activation functions, residual addition, quantization and dequantization, tensor layout conversion, sampling, and post-processing. Individually each has a tiny share of compute, yet together they add extra memory round-trips and kernel launch overhead.

    Widening the fusion scope pays off in three ways:

    • Eliminating redundant memory access. Folding elementwise operations into adjacent compute kernels keeps intermediate tensors from being written back.
    • Reducing launch and synchronization counts. Fewer kernels means lower scheduling overhead and less idle waiting.
    • Improving tail effects. Small operators often lack parallelism at the end of long sequences; after fusion, the larger kernel’s parallelism covers them.

    A practical approach is to build an operator-level profile first: measure each operator’s time, memory traffic, and launch count, then rank by “time share divided by optimization difficulty” and tackle the stages that are not expensive in time but clearly redundant in memory traffic first. In practice, the return on this kind of change is often higher than continuing to squeeze large kernels that have already been tuned repeatedly.

    Where the Gains Come From Once the Limit Is Near

    When core operators are already close to the bound, the marginal return of shaving more percentage points in the same place decays quickly. More effective directions at that point are:

    • An end-to-end view. Measure prefill and decode separately to identify resource contention and switching costs between stages.
    • Memory and concurrency configuration. Cache capacity, concurrent batch size, and memory allocation strategy often affect overall throughput more than single-operator tuning.
    • Coordinating numerical and parallel strategies. How tensor parallelism and pipeline parallelism are split changes operator shapes on each card, which in turn affects achievable efficiency.
    • Building observability. Collect per-stage metrics through unified monitoring, alerting, and logging so performance regressions are caught in CI.

    Two Optimization Paths and How They Differ in Knowledge Retention

    In one path, the chip or framework vendor’s engineering team does the work directly, tuning layer by layer against real workloads and contributing the implementations back to the open community. In the other, an external support team works on site, delivers usable results, but is constrained by commercial and compliance terms, so the results rarely flow back publicly. Both paths improve performance; the difference is whether the knowledge accumulates.

    The value of the first path is not a single optimization result but turning methodology into a public asset: tuning patterns, tiling experience, and lists of counterexamples get reused by those who come later, forming a positive feedback loop. The second path tends to leave the same class of problem being solved repeatedly across different projects. For a compute ecosystem still growing, reusable public knowledge raises the overall baseline more than a handful of isolated performance records. That is also why open sharing matters so much: it converts one team’s results into capability for the whole ecosystem.

    What the cloud side can take on is providing a standardized runtime environment and toolchain support: container platforms host reproducible build and runtime environments, object storage holds datasets and operator artifacts, and logging plus monitoring and alerting provide per-stage performance profiles. Baidu AI Cloud positions itself in these general capabilities so that optimization work focuses on the algorithms and operators themselves rather than environment setup.

    A Reusable Practice Checklist

    1. Align the measurement basis before discussing optimization; make the metric denominator and measurement scope explicit.
    2. Use roofline analysis to identify the bottleneck type, and avoid piling on compute where the workload is memory-bound.
    3. Build an operator-level profile and pick the fusion low-hanging fruit first.
    4. Align tile sizes with on-chip capacity to guarantee three-stage pipeline overlap.
    5. Keep intermediates on chip as much as possible to reduce memory round-trips.
    6. Skip invalid computation by whole blocks, and handle variable lengths and masks.
    7. Bring performance regression into continuous integration with monitoring and alerting thresholds configured.
    8. Document tuning experience and contribute it back to the community as an accumulating public asset.

    Closing

    Pushing multiple core operators close to the hardware bound marks a turning point in essence: the returns from relying on peak compute expansion alone are diminishing, while memory efficiency, fusion depth, and scheduling quality become the new main battleground. For domestic AI compute, this means two things hold at once: there is still considerable headroom in the hardware’s potential, and the key to releasing it is turning optimization methods into open, reusable public knowledge. The more thoroughly a team consolidates its experience, the faster the whole ecosystem’s baseline rises, and the more real engineering foundation AI accessibility has.