LLM AI Infra Interview Questions: Attention, Memory, Parallelism, and Inference Optimization
This article breaks down high-frequency AI Infra interview questions for large language models, covering attention efficiency, GPU memory budgeting, distributed parallelism, inference acceleration, long-context engineering, and a unified evaluation framework. It explains the core trade-offs among throughput, latency, memory, and accuracy, along with practical answers, common pitfalls, and sample scheduling logic to help candidates reason through system design decisions.
LLM AI Infra Interview Questions: Attention, Memory, Parallelism, and Inference Optimization
Every long-context question-answer session and every smooth multi-turn conversation you see is backed by an “efficiency war” around the attention mechanism. Early models were limited to windows of a few thousand tokens, while mainstream models today have generally pushed the context window to the tens of thousands or even hundreds of thousands of tokens. This leap is not simply a matter of scaling up parameters; it is the result of coordinated advances in operators, memory management, parallel strategies, and scheduling systems. For AI Infra roles, interviews do not really test your ability to recite terminology. They test whether you can make explainable trade-offs among throughput, latency, memory, and accuracy.
1. Attention Efficiency: From Quadratic Complexity to Practical Engineering
The first high-frequency question almost always revolves around attention. In a standard implementation, both computation and memory overhead grow quadratically with sequence length. The core goal of long-context optimization is therefore to “avoid explicitly materializing the full attention matrix.”
A solid answer should cover three main lines of work:
- Chunked computation with online normalization: split the computation into blocks and merge statistics on the fly, reducing memory usage from quadratic to linear;
- Sparse and local windows: assume that most attention weights concentrate on nearby positions and a few key tokens, then approximate global interaction with a fixed window plus a small number of global tokens;
- Low-rank and linearization: replace softmax with kernel approximations or state compression to reduce complexity to linear, at the cost of accuracy and representational power.
Follow-up questions usually focus on how backpropagation recomputes values, numerical stability at chunk boundaries, and how different approaches perform on long-text retrieval tasks. Truly understanding the topic means being able to explain why saving memory does not necessarily save time.
2. Memory and Parallelism: Fitting the Model onto Limited Devices
The second section is about the memory budget. A reusable estimate is that GPU memory is mainly consumed by five parts: parameters, gradients, optimizer states, activations, and temporary buffers. Under mixed-precision training, optimizer states are often several times the size of the parameters, which is the primary reason memory becomes tight.
Accordingly, your answer should present a layered strategy:
- Data parallelism combined with optimizer state sharding, reducing redundant replicas to shards;
- Tensor parallelism that splits the matrix multiplications within a single layer, with communication concentrated inside the layer and high sensitivity to high-bandwidth interconnects;
- Pipeline parallelism that splits by layers and requires handling bubbles and scheduling;
- Sequence and context parallelism that split the long-sequence dimension, specifically serving very long inputs;
- Activation recomputation and offloading, trading compute for memory or moving cold data to host memory and the storage tier.
A common trap question is “how to locate the memory bottleneck.” A qualified answer first uses allocator statistics and snapshots to identify the source of peak usage, then determines whether it is fragmentation, caching, or actual usage, rather than blindly reducing the batch size.
3. Inference Acceleration: Two Separate Sets of Metrics for Throughput and Latency
Inference interviews must first distinguish between the prefill and decode phases: the former is compute-intensive and parallelizable, while the latter is memory-access-intensive and serial per token. The metrics should also be discussed separately, because time to first token, per-token latency, and overall throughput often cannot be achieved simultaneously.
The standard toolbox includes:
- Key-value cache management: use paged block management for the cache to reduce fragmentation and support prefix sharing across multiple requests;
- Continuous batching: dynamically swap requests in and out at iteration granularity, significantly improving device utilization;
- Quantization and sparsification: apply different bit widths to weights, activations, and the cache separately, with attention to accuracy regression evaluation;
- Speculative decoding: a small model or draft mechanism guesses multiple tokens first, then the large model verifies them;
- Operator fusion and custom kernels: reduce the number of memory accesses, which is key to speeding up the decode phase.
The scheduling logic can be understood schematically as follows:
# Pseudocode: iteration-level continuous batchingwhile queue or running:for seq in running:if seq.finished:release_kv_cache(seq)running += admit(queue, max_budget=KV_BUDGET)step(running) # advance all active sequences by one token in a single forward pass
4. Long Context and Distributed Stability
Long context also requires answering engineering questions: how positional encodings extrapolate, how the cache is sharded and migrated, and how retrieval augmentation combines with a long window. For stability, you should be able to explain that failures are the norm in large-scale training, requiring periodic checkpoints, fast restarts, slow-node detection, and elastic fault tolerance. On the data side, the focus is on how data mixtures, deduplication, and ordering affect convergence.
5. A Unified Evaluation Framework
It is advisable to converge all answers with one set of metrics: throughput, time to first token, per-token latency, peak memory, effective context length, accuracy loss, and cost per unit. In practice on platforms such as Baidu AI Cloud, this is often combined with container platform scheduling, object storage for checkpoints, logging services, and monitoring and alerting to achieve full-link observability, turning “it runs” into “measurable, optimizable, and reproducible.” In an interview, opening with metrics and closing with trade-offs is more persuasive than piling up terminology.
