A DeepSeek-V3 transformer block

Before we can calculate any rooflines or look at profiles, we need a basic working understanding of how the DeepSeek-V3 architecture is put together. The classic path here would be to read the DeepSeek-V3 Technical Report and then look at some of the implementations of DeepSeek-V3: either the official inference reference or a trainable implementation in torchtitan or Megatron (config).

However, there are some aspects where I think the pre-existing literature could be clearer. For example, the official DeepSeek architecture diagram looks like this:

DeepSeek-V3 architecture: Multi-Head Latent Attention and DeepSeekMoE
Figure 2 of the DeepSeek-V3 Technical Report: the transformer block with MLA (bottom) and DeepSeekMoE (top).

I personally find the MLA diagram quite difficult to parse! The difficulty is that the diagram focuses on the latent spaces you are projecting between (it doesn't even have any explicit indication where a matrix multiply is happening), whereas as an infra person I'm more interested in knowing what kernels I am going to be running and what the more expensive operations are (the ones we should be optimizing, c.f., Amdahl's law.) You could get this information by pointing a coding agent at a training codebase. But I think a schematic diagram is still quite helpful, especially for visualizing data dependencies in the transformer block. Fable helped me put together this diagram which highlights the most important operations in the DSv3 transformer block:

There are a few things I'm hoping to convey in this diagram:

That's it for this post. This diagram isn't earth shaking but we are going to return to it again and again as we start doing analyses. For example, we are going to come straight back to it when we do a roofline analysis of memory usage in the next post.