From 1.8T to 30B: Knowledge Distillation for Lightweight Deployment

How MeeDoo-OnE is distilled from 1.8 trillion parameters to deployable 30B-120B student models using logit distillation, feature matching, MoE collapse, and quantization-aware training.

Abstract

A 1.8-trillion-parameter model that requires 3.57 TB of storage in BF16 is not deployable outside of large GPU clusters. To make MeeDoo-OnE capabilities available in practical deployment scenarios — single-GPU inference, edge servers, cost-sensitive applications — we distill its knowledge into a family of smaller dense student models ranging from 30B to 120B parameters. This article describes the four-method distillation framework (logit KL, feature MSE, MoE-to-dense collapse, and quantization-aware training), the weight quantization strategies that reduce the student footprint further, and the inference infrastructure (speculative decoding, continuous batching) that delivers production-quality throughput. The end result is a 30B student that fits on a single GPU in FP4 and delivers quality within 90% of the 1.8T teacher.

The Problem: 1.8T Is Not Deployable

The MeeDoo-OnE teacher model has 1.79 trillion parameters. In BF16 (2 bytes per parameter), this requires 3.57 TB of GPU memory just to store the weights — before accounting for KV cache, activations, or optimizer states. Even with aggressive INT4 quantization (0.5 bytes per parameter), the model still requires 0.89 TB, which spans 11 GPUs. This is feasible for research and large-scale API serving but impractical for:

  • Single-tenant enterprise deployments
  • Edge and on-premise inference
  • Cost-sensitive applications where GPU count directly determines cost
  • Latency-sensitive applications where multi-GPU communication adds overhead

The solution is knowledge distillation: training smaller dense models that absorb the knowledge of the 1.8T teacher, combined with weight quantization to further reduce memory, and efficient inference techniques (speculative decoding, continuous batching) to maximize throughput.

Distillation Framework

MeeDoo-OnE uses a multi-method distillation framework that combines four complementary techniques. Each targets a different aspect of the teacher knowledge:

Method 1: Logit Distillation (KL Divergence)

The student model is trained to match the teacher output probability distribution (logits) using Kullback-Leibler divergence. This is the most direct form of distillation: the student learns not just the correct answer but the full distribution of the teacher beliefs, including uncertainty and alternative predictions.

# Logit distillation with temperature scaling
# L_logit = T^2 * KL(softmax(teacher_logits / T) || softmax(student_logits / T))
T = 2.0  # temperature softens the distribution
teacher_probs = F.softmax(teacher_logits / T, dim=-1)
student_log_probs = F.log_softmax(student_logits / T, dim=-1)
kl_loss = F.kl_div(student_log_probs, teacher_probs, reduction="batchmean")
logit_loss = T * T * kl_loss  # T^2 scaling to preserve gradient magnitude

The temperature T=2.0 softens the teacher distribution, revealing more of the "dark knowledge" — the relative probabilities of incorrect tokens — that a hard one-hot label would hide. The T squared scaling preserves gradient magnitude: since softmax with high temperature produces flatter distributions (smaller gradients), the T squared factor compensates.

Method 2: Feature Distillation (MSE)

The student hidden states are aligned with the teacher hidden states using mean squared error. Since the teacher has 84 layers and the student has fewer, we match every 4th teacher layer, giving 21 matched layer pairs out of 84.

# Feature distillation: match hidden states at aligned layers
# Teacher: 84 layers, Student: 21 matched (every 4th)
# L_feature = MSE(teacher_hidden[::4], student_hidden)

matched_teacher_layers = list(range(0, 84, 4))  # [0, 4, 8, ..., 80] = 21 layers
feature_loss = 0
for t_idx, s_idx in zip(matched_teacher_layers, student_layer_indices):
    t_hidden = teacher_hidden_states[t_idx]  # [batch, seq, 7168]
    s_hidden = student_hidden_states[s_idx]  # [batch, seq, student_dim]
    s_projected = feature_projector[s_idx](s_hidden)  # project to 7168
    feature_loss += F.mse_loss(s_projected, t_hidden)
feature_loss /= len(matched_teacher_layers)

A linear projector maps the student hidden dimension to the teacher hidden dimension (7168) before computing MSE. This projector is discarded after training; it exists only to enable the alignment loss during distillation.

Method 3: MoE-to-Dense Collapse

The teacher is a mixture-of-experts model with 48 routed experts per layer. The student is a dense model with a single SwiGLU feed-forward layer. The MoE-to-dense collapse technique initializes the student feed-forward weights by averaging the 48 experts:

# MoE to dense collapse: average 48 experts -> 1 dense SwiGLU
# Option A: uniform average of all 48 experts
dense_weight = sum(expert_weights) / 48

# Option B: keep the single most-activated expert (top expert)
# Based on expert activation frequency during teacher inference
top_expert_idx = activation_frequency.argmax()
dense_weight = expert_weights[top_expert_idx]

# Option C: weighted average by activation frequency
weights = activation_frequency / activation_frequency.sum()
dense_weight = sum(w * ew for w, ew in zip(weights, expert_weights))

The weighted average (Option C) typically produces the best initialization, as it preserves the relative importance of frequently-activated experts. The student then fine-tunes from this initialization, learning to compensate for the lost expert specialization through its dense layers.

Method 4: Quantization-Aware Distillation

For students that will be deployed in INT8 or INT4, quantization-aware distillation trains the student with simulated quantization during the distillation process. This ensures the student learns weights that are robust to quantization noise:

# Quantization-aware training (QAT) during distillation
# Simulate INT8 quantization in the forward pass
def quantize_aware(weight, num_bits=8):
    scale = weight.abs().max() / (2**(num_bits-1) - 1)
    quantized = torch.round(weight / scale) * scale
    return quantized + (weight - weight.detach())  # straight-through estimator

# In the student forward pass:
student_logits = student(quantize_aware(student_weights))

The straight-through estimator ensures that gradients flow through the non-differentiable rounding operation, allowing the student to learn weights that minimize both the distillation loss and the quantization error simultaneously.

Combined Loss

The total distillation loss is a weighted combination of all methods:

L = 1.0 * KL_logits       # logit distillation (primary)
  + 0.5 * MSE_features     # feature distillation (structural)
  + 0.1 * CE_labels        # supervised cross-entropy (ground truth)
  # Temperature: T = 2.0

The logit loss dominates (weight 1.0) because it captures the richest signal. The feature loss (weight 0.5) provides structural regularization. The cross-entropy loss (weight 0.1) ensures the student does not forget the ground truth labels, preventing overfitting to teacher quirks.

Student Model Variants

Three student variants are produced, targeting different deployment scenarios:

Model Parameters BF16 GPUs FP8 GPUs INT4 GPUs
Teacher (MeeDoo-OnE)1.8T412111
Student-Large120B321
Student-Medium70B211
Student-Small30B111 (FP4)

The Student-Small (30B) is the flagship deployment model: it fits on a single 96 GB GPU in FP4 (30B * 0.5 bytes = 15 GB weights, leaving 81 GB for KV cache and activations), enabling true single-GPU deployment with substantial context capacity.

Weight Quantization

For both the teacher (when serving) and the student models, weight quantization provides significant memory reduction. MeeDoo-OnE supports three quantization levels:

INT8: Per-Channel Symmetric

# INT8 per-channel symmetric quantization
# scale = max(|w|) / 127, per output channel
scale = weight.abs().max(dim=-1).values / 127.0  # [out_features]
quantized = torch.round(weight / scale.unsqueeze(-1)).clamp(-128, 127).to(torch.int8)
# Dequantize: weight = quantized * scale

Certain parameters are kept in FP16 because they are precision-sensitive:

  • Embeddings: quantization noise in embeddings propagates to all tokens
  • Router weights: small perturbations can change expert selection
  • EnCodec codebook: discrete codebook entries must remain exact
  • Shared experts: always active, so any noise affects every token

INT4: Per-Channel Symmetric

# INT4 per-channel symmetric quantization
# scale = max(|w|) / 7 (range: -8 to 7, but symmetric uses -7 to 7)
scale = weight.abs().max(dim=-1).values / 7.0
quantized = torch.round(weight / scale.unsqueeze(-1)).clamp(-8, 7).to(torch.int8)
# Pack two INT4 values per byte for storage

FP8: Blackwell Native

On Blackwell GPUs, FP8 is the preferred quantization format because it is native to the hardware — no dequantization overhead during matrix multiplication. Dynamic FP8 uses E4M3 for activations (computed on-the-fly) and FP8 weights, providing a 2x memory reduction with near-zero quality impact.

Precision Bytes/Param 1.8T Memory GPUs (96GB)
BF162.03.57 TB41
INT8 / FP81.01.79 TB21
INT40.50.89 TB11

Approximately 5% of parameters are kept in FP16 (embeddings, router, codebook, shared expert), so the actual memory reduction is slightly less than the theoretical 4x for INT4. In practice, INT4 achieves approximately 3.7x reduction versus BF16.

Speculative Decoding

Speculative decoding provides 2-3x inference speedup without any quality degradation. The technique uses a small draft model to propose tokens that are verified by the larger target model in a single forward pass.

# Speculative decoding
# Draft model proposes 4 tokens, target model verifies

draft_tokens = draft_model.generate(prompt, max_tokens=4)
# draft_tokens: [t1, t2, t3, t4] with probabilities [p1, p2, p3, p4]

# Target model verifies in single forward pass
target_logits = target_model.forward(concat(prompt, draft_tokens))
target_probs = softmax(target_logits)

for i, (dt, dp) in enumerate(zip(draft_tokens, draft_probs)):
    tp = target_probs[i, dt]
    # Accept with probability min(1, tp/dp)
    if random() < min(1.0, tp / dp):
        accepted.append(dt)
    else:
        # Reject: sample from adjusted distribution (tp - dp) normalized
        new_token = sample(adjusted_dist(target_probs[i], dp))
        accepted.append(new_token)
        break  # stop at first rejection
else:
    # All 4 accepted: get a bonus token from target model
    bonus = sample(target_probs[-1])
    accepted.append(bonus)

The key insight is that the target model verifies all 4 draft tokens in a single forward pass (parallel verification), so the cost of verification is one forward pass regardless of how many tokens are proposed. If all 4 are accepted, a bonus 5th token is obtained for free. The rejection sampling ensures that the output distribution is mathematically identical to sampling from the target model alone — there is zero quality degradation.

MeeDoo-OnE has a built-in draft model through its MTP (Multi-Token Prediction) head, so speculative decoding requires no separate draft model. The MTP head shares the backbone hidden states, making it essentially free in terms of memory and very cheap in compute.

Continuous Batching

Continuous batching (also known as dynamic batching or in-flight batching) dramatically improves throughput by processing requests with different sequence lengths simultaneously, without padding to the longest sequence:

  • Max batch size: 32 concurrent requests
  • Max tokens in flight: 512K (sum across all requests)
  • Dynamic admission: new requests are admitted as soon as compute and memory allow
  • No padding: each request is processed at its actual length
  • Per-request sampling: temperature, top-p, and top-k are independent per request

Continuous batching provides 5-10x throughput improvement over static batching, where requests must wait for a batch to fill and all sequences are padded to the longest one. The paged KV cache (described in the context article) is essential for continuous batching, as it allows the KV cache for each request to grow and shrink independently.

Inference GPU Requirements

Configuration GPUs Nodes Concurrent Requests
Teacher BF16416~16
Teacher FP8213~10
Teacher INT4112~7
Student-Large INT821~12
Student-Medium INT811~8
Student-Small FP411~6

With continuous batching, the concurrent request count increases 5-10x, bringing the Student-Small to 30-60 concurrent requests on a single GPU.

Latency Targets

Configuration TTFT Throughput With Speculative
INT4~5s120-200 tok/s150-400 tok/s
FP8~8s80-150 tok/s120-300 tok/s
BF16~12s50-100 tok/s80-200 tok/s

These targets assume the Student-Small (30B) on a single 96 GB GPU with 2M token context. The INT4 configuration with speculative decoding achieves 150-400 tokens per second, which is suitable for real-time interactive applications.

MTP for Built-In Speculative Decoding

The MTP (Multi-Token Prediction) head, described in the architecture overview, serves double duty during inference. Trained during the main training run to predict 2-3 future tokens, it acts as a built-in draft model for speculative decoding. This eliminates the need to train, deploy, and maintain a separate draft model:

  • No additional GPU memory for a draft model
  • No latency for draft model forward passes (shares hidden states)
  • No quality mismatch between draft and target (same backbone)
  • 2-3x speedup on generation throughput

Conclusion

The journey from a 1.8-trillion-parameter research model to a deployable 30B student involves a carefully orchestrated pipeline of distillation and quantization. The four-method distillation framework (logit KL, feature MSE, MoE collapse, quantization-aware) transfers the teacher knowledge comprehensively — not just the output predictions but the internal representations and the expert specialization. Weight quantization (INT8, INT4, FP8) further compresses the student to fit within single-GPU memory budgets. Speculative decoding via the MTP head and continuous batching via the paged KV cache deliver production-grade throughput.

The result is a family of deployable models that inherit the capabilities of the 1.8T teacher: the Student-Small (30B) in FP4 on a single GPU delivers quality within 90% of the teacher at 150-400 tokens per second, making frontier-level AI accessible without a data center. The Student-Medium (70B) and Student-Large (120B) fill the gap for applications that can afford 1-2 GPUs and require higher quality. This is how MeeDoo-OnE goes from a research breakthrough to a practical deployment.

#distillation#quantization#deployment#inference#meedoo-one