← Microsoft Interview Insights

Microsoft·Software Engineer·Onsite - System Design / Architecture·Senior

Senior
Apr 2026

Summary

Microsoft system design round for a software engineer role, pretty deep in the weeds on LLM inference infrastructure. The whole session was basically one big question about building ChatGPT, and they pushed hard on the low-level details.

Questions Asked (4)

Q1

How many GPUs would you need to serve a 400B-parameter model in bf16 precision, and how do you think about memory requirements across weights, activations, and KV cache?

System DesignTechnical Trade-offs
Author's notes

I knew the weight math going in: 400B params times 2 bytes per bf16 parameter gets you around 800GB just for weights, so you're already looking at 10+ A100s before you even think about activations or KV cache.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by calculating the memory required for weights alone (400B params × 2 bytes = 800 GB), then discuss how to distribute across GPUs (e.g., 10×80GB A100s). Next, explain that activations and KV cache add significant overhead, especially for long sequences and large batches, so you need to account for them in your total memory budget and possibly use techniques like tensor parallelism or quantization.

Pro tip: Mention that in practice, you also need memory for the optimizer states during training, but for inference, the KV cache can dominate for long contexts—so consider paged attention or other optimizations. This shows you understand real-world deployment nuances.

1. Calculate weight memory

Compute the memory needed to store the model weights in bf16: 400B parameters × 2 bytes = 800 GB. This is the baseline memory requirement.

2. Determine GPU count for weights

Divide the weight memory by the available memory per GPU, accounting for overhead. For example, with 80GB GPUs, you need at least 10 GPUs just for weights, but you'll need more for activations and KV cache.

3. Estimate activation memory

Activations depend on batch size and sequence length. For inference, activations are typically small compared to weights, but for large batches or long sequences, they can be significant. Mention that activation memory scales with batch size × sequence length × hidden size × number of layers.

4. Estimate KV cache memory

KV cache size = 2 (key and value) × batch size × sequence length × hidden size × number of layers × bytes per element. For long contexts, this can exceed weight memory. Provide a rough calculation for a typical scenario.

5. Sum and add overhead

Total memory = weights + activations + KV cache + overhead (e.g., CUDA context, fragmentation). Then determine the number of GPUs by dividing total memory by per-GPU memory, rounding up. Discuss trade-offs like using more GPUs for parallelism or techniques like quantization to reduce memory.

Key Points to Mention

  • Weight memory calculation: 400B params × 2 bytes = 800 GB in bf16.
  • KV cache formula and its dependence on batch size, sequence length, and model dimensions.
  • Activation memory is usually smaller for inference but can grow with batch size and sequence length.
  • Parallelism strategies: tensor parallelism, pipeline parallelism, and how they affect memory per GPU.
  • Memory optimization techniques: quantization (e.g., int8), paged attention, and offloading.
  • Real-world considerations: overhead from CUDA context, memory fragmentation, and the need for headroom.

AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.

Q2

When serving a large model, how do you decide between replicating model shards for throughput versus sharding across more GPUs for capacity?

System DesignTechnical Trade-offs
Author's notes

Basically a capacity planning trade-off question.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by clarifying the workload characteristics (model size, sequence length, latency SLOs, throughput targets) and hardware constraints. Then explain that the decision hinges on whether the bottleneck is compute/memory bandwidth (favor replication) or model capacity (favor sharding). Finally, propose a hybrid approach with dynamic scaling based on real-time metrics.

Pro tip: Emphasize that the optimal strategy often involves a mix: shard the model to fit in memory, then replicate those shards to increase throughput, and use continuous profiling to adjust the replication factor. Mention that Microsoft's DeepSpeed and ZeRO can automate some of these trade-offs.

1. Clarify Requirements and Constraints

Ask about model size, latency SLOs, throughput targets, and available GPU memory. Determine if the model fits on a single GPU or requires sharding.

2. Identify the Bottleneck

Analyze whether the system is limited by compute/memory bandwidth (throughput-bound) or by model capacity (memory-bound). Use profiling to confirm.

3. Evaluate Replication vs. Sharding

If throughput-bound, replicate shards to increase parallel processing. If memory-bound, shard across more GPUs to fit the model. Consider communication overhead.

4. Consider Hybrid and Dynamic Strategies

Propose a hybrid approach: shard the model to fit in memory, then replicate those shards for throughput. Use autoscaling to adjust replication factor based on load.

5. Monitor and Iterate

Implement monitoring for latency, throughput, and GPU utilization. Continuously tune the sharding and replication strategy based on real-world performance.

Key Points to Mention

  • Model parallelism (sharding) vs. data parallelism (replication)
  • Memory bandwidth and compute utilization as key metrics
  • Communication overhead in distributed training/inference
  • Latency vs. throughput trade-offs
  • Dynamic scaling and autoscaling based on workload
  • Frameworks like DeepSpeed, ZeRO, or Megatron for efficient sharding

AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.

Q3

If you offload the KV cache to Redis instead of keeping it in GPU memory, how does the inference service interact with Redis? Walk through the key design, eviction policy, latency budget, and how you maintain consistency across turns in a multi-turn conversation.

System DesignTechnical Trade-offsAPI & Integrations
Author's notes

This was the part that got me.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by framing the problem: offloading KV cache to Redis trades GPU memory for network latency, enabling larger batch sizes and longer contexts. Then walk through the interaction flow: how the inference service reads/writes KV cache to Redis, the eviction policy (e.g., LRU with TTL), latency budget considerations (e.g., pipelining, compression), and consistency mechanisms (e.g., versioning, session affinity) to maintain multi-turn coherence.

Pro tip: Emphasize that Redis is not just a cache but a state store; use Redis transactions or Lua scripts to atomically update KV pairs and avoid race conditions across concurrent requests in the same session.

1. Clarify requirements and constraints

Ask about scale (QPS, context length), latency SLA, and consistency needs. This shows you tailor the design to real constraints rather than over-engineering.

2. Design the interaction flow

Describe how the inference service fetches KV cache from Redis before each forward pass and writes updated KV after generation. Mention batching, pipelining, and async I/O to hide latency.

3. Define eviction and memory management

Explain eviction policy: LRU with TTL based on session inactivity, and possibly tiered storage (GPU -> Redis -> disk). Discuss memory limits and eviction impact on hit rate.

4. Analyze latency budget and optimizations

Break down latency: network RTT, serialization, Redis ops. Propose optimizations: compression, local caching, Redis pipelining, and using Redis modules like RedisAI or RedisGears for in-place computation.

5. Ensure consistency across turns

Use session IDs to key KV cache, versioning to detect stale data, and atomic operations (MULTI/EXEC or Lua) to update cache. Discuss handling failures: retries, fallback to recomputation, and idempotency.

Key Points to Mention

  • KV cache structure: keyed by session ID and layer/token position, stored as serialized tensors or bytes.
  • Redis data structures: use Hashes or Strings for KV pairs, and Redis Streams for session event ordering.
  • Eviction policy: LRU with TTL, and consider Redis maxmemory-policy allkeys-lru.
  • Latency budget: aim for <10ms Redis round-trip; use pipelining and compression to reduce payload size.
  • Consistency: use session affinity to route requests to the same inference worker, and versioning to avoid stale reads.
  • Failure handling: fallback to recomputing KV cache from scratch if Redis is unavailable, and use write-through caching.

AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.

Q4

What are the trade-offs between keeping the KV cache in GPU memory versus storing it remotely?

Technical Trade-offsSystem Design
Author's notes

Covered latency, memory capacity, and cost.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by defining the KV cache and its role in LLM inference, then systematically compare GPU memory and remote storage across dimensions like latency, cost, scalability, and reliability. Conclude with a balanced perspective on when each approach is appropriate, emphasizing hybrid solutions.

Pro tip: Quantify trade-offs with concrete numbers (e.g., microseconds vs milliseconds, dollars per GB) and mention real-world systems like vLLM or Microsoft's DeepSpeed to show practical awareness.

1. Define the KV Cache and Its Purpose

Briefly explain that the KV cache stores key-value tensors from attention layers to avoid recomputation during autoregressive generation, and that its size grows with sequence length and batch size.

2. Analyze GPU Memory Trade-offs

Discuss benefits: ultra-low latency, high bandwidth, and simplicity. Drawbacks: limited capacity, high cost, and reduced batch sizes or model sizes due to memory pressure.

3. Analyze Remote Storage Trade-offs

Discuss benefits: virtually unlimited capacity, lower cost per GB, and easier scaling across multiple GPUs or nodes. Drawbacks: network latency, bandwidth bottlenecks, and added complexity for serialization and consistency.

4. Compare on Key Dimensions

Systematically compare latency, throughput, cost, scalability, reliability, and operational complexity. Highlight that remote storage introduces network overhead but enables larger models and longer contexts.

5. Conclude with Hybrid Approaches

Suggest that optimal solutions often combine both: keep frequently accessed or recent KV pairs on GPU and offload older or less-used ones to remote storage, balancing performance and cost.

Key Points to Mention

  • Latency and bandwidth differences between GPU HBM and network storage
  • Cost implications: GPU memory is expensive and limited, while remote storage is cheaper and scalable
  • Impact on batch size and model size: GPU memory constraints limit both
  • Scalability and multi-node inference: remote storage enables distributed serving
  • Reliability and fault tolerance: remote storage may introduce single points of failure
  • Hybrid strategies like paged attention or offloading to CPU/remote memory

AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.