Large Language Model Architectures and Parameter Scale Explained: Dense vs. MoE, Attention, and Context Length
This article breaks down the main dimensions that define modern large language model architectures: network topology (dense vs. Mixture of Experts), attention and position encoding mechanisms, and the distinction between total and activated parameter counts. It explains how sparse MoE layers work, the engineering trade-offs they introduce, why compact dense models remain attractive, and how long-context techniques shift the bottleneck to KV cache and bandwidth. Readers will also find practical guidance on estimating memory usage and making model selection decisions based on real workload constraints.
1. Introduction: Why Model Architecture Needs a Fresh Look
Early on, model capability was often judged by parameter count alone. That comparison no longer explains real-world performance differences. A model with a very large total parameter count that activates only a small subset per token can have far lower inference cost than a smaller dense model. Conversely, dense architectures still hold advantages in training stability and engineering simplicity.
Understanding modern LLMs therefore requires looking at three dimensions at once:
- Network topology: dense or sparse Mixture of Experts (MoE);
- Attention and position encoding: full attention, grouped-query attention, sliding windows, and related variants;
- Parameter scale vs. activated scale: total parameters, activated parameters per token, and context length.
The sections below walk through the model shapes commonly seen in the industry, keeping the analysis neutral and generic.
2. The Rise of Sparse Mixture of Experts
2.1 How It Works
The core idea of MoE is to split the feed-forward layers into multiple parallel “expert” subnetworks, then let a router network pick a few experts for each input token. Pseudocode:
# Pseudocode: forward pass of an MoE layerlogits = router(hidden_states) # compute routing scorestopk_idx = topk(logits, k=2) # pick 2 experts per tokenweights = softmax(gather(logits, topk_idx))output = 0for expert_id in unique(topk_idx):mask = (topk_idx == expert_id)output[mask] += weights[mask] * experts[expert_id](hidden_states[mask])
The point of this design: total parameters can be very large, while per-token compute depends only on the number of activated experts. Common industry configurations activate 2 to 8 experts per token, with activated parameters typically accounting for 10% to 30% of the total.
2.2 Engineering Challenges
Sparse architectures are not free. The main issues come down to three:
- Load imbalance: routing can send a large share of tokens to a few experts, leaving some devices idle. A common mitigation is an auxiliary load balancing loss.
- Communication overhead: when experts sit on different devices, extra All-to-All communication is required, which is sensitive to network bandwidth.
- Training instability: routing is a discrete decision and can collapse early in training, requiring careful learning rate and initialization strategies.
3. Dense Architectures and the Return of “Small Activation” Models
Alongside the sparse route, another approach keeps the architecture dense but holds total parameters to a smaller range, improving per-parameter efficiency through high-quality data and training strategy. The advantages:
- Deterministic inference path, predictable latency, and easier quantization and operator fusion;
- Memory footprint roughly linear in parameter count, which makes capacity planning simple;
- Lower deployment barrier for on-device or single-GPU scenarios.
This has produced a range of “lightweight, instant response” models. They typically push activated parameters down to a low range in exchange for high throughput and low latency, which suits tasks such as classification, extraction, and rewriting that do not demand deep reasoning.
4. Attention Mechanisms and the Evolution of Long Context
Beyond parameter scale, long-context capability is the other main axis of architectural competition. Common combinations include:
| Technique | Purpose | Typical trade-off |
|---|---|---|
| Grouped-query attention (GQA) | Shrink the KV cache | Slightly reduced expressiveness |
| Sliding window attention | Lower long-sequence complexity | Long-range dependencies need extra mechanisms |
| Position encoding extrapolation | Support lengths beyond training | Extrapolation quality depends on training strategy |
| Sparse/linear attention | Reduce theoretical complexity | Uneven engineering and ecosystem maturity |
One point worth stressing: context window length is a capability ceiling, not an effective utilization rate. Effective context in practice is usually well below the advertised number, which ties directly to the length distribution of training data and attention decay characteristics.
5. Reading Parameter Scale in Layers
For any given model, it helps to interpret scale in layers:
- Total parameters: set the upper bound on knowledge capacity and the weight footprint in memory;
- Activated parameters: determine per-token compute complexity and are the key driver of inference cost;
- Context-related overhead: the KV cache grows with sequence length and concurrency, and is often the real memory bottleneck on the serving side;
- Training compute investment: determined jointly by parameter count, data volume, and training steps, and cannot be inferred from parameter count alone.
A practical estimation approach:
Weight memory ≈ parameters × bytes per parameter (~2 bytes for FP16)KV cache ≈ layers × 2 × sequence length × hidden dimension × concurrency × bytes
The implication: in long-context, high-concurrency scenarios, optimizing the KV cache (quantization, paged management, prefix reuse) often pays off more than simply shrinking parameter count.
6. Practical Guidance for Model Selection
- Tier by task: route requests by complexity, sending simple tasks to low-activation models and complex reasoning to large sparse models;
- Unify the cost metric: measure “blended cost per million tokens” rather than unit price, factoring in cache hit rate and retry rate;
- Load test capacity first: run long-context and concurrency tests against real traffic distributions, and watch memory and latency curves;
- Build observability: use logging services and monitoring/alerting to track time to first token, throughput, and failure rate continuously;
- Scale elastically: on container platforms, scale by queue length and memory watermark to avoid wasting static resources.
7. Conclusion
Architectural competition among modern LLMs is essentially a rebalancing of capacity, compute, and bandwidth. Sparse MoE trades activated parameters for capacity, compact dense models trade engineering determinism for deployment efficiency, and long-context techniques relocate the serving-side resource bottleneck. For developers, the valuable thing is not memorizing the parameter table of a specific model, but building a reusable analysis framework: look at topology first, then activation, then memory and bandwidth, and make verifiable, rollback-ready technical decisions under concrete business constraints.
