File size: 1,819 Bytes
9f3ece2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
a20d541
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9f3ece2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
a20d541
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# MoE Architecture

The MoE model is the main scaling direction for code completion. The strongest
current structure is sparse FFN experts with shared attention and optional
multi-token prediction heads.

## Recommended Structure

- Decoder-only Transformer.
- RMSNorm before attention and FFN.
- RoPE positional encoding.
- Grouped-query attention.
- SwiGLU experts.
- Top-2 routing during training.
- Shared expert for common syntax and indentation.
- Router z-loss and auxiliary load-balancing loss.
- QK norm for long-context attention stability.
- Expert-choice telemetry from the first step, not after loss diverges.
- Optional multi-token prediction heads with low loss weight.

## Best Current Shape

Use shared attention and sparse FFN. Keep early layers mostly dense/shared so
the model learns lexical syntax before specializing.

- Early blocks: dense FFN or shared expert heavy.
- Middle blocks: sparse MoE every other block.
- Late blocks: sparse MoE with stricter router stability checks.
- Expert count: start with 8 experts for smoke, then 16-32 for H100 ablation.
- Routing: top-2 with capacity factor 1.25 during training.
- Inference ablation: top-1 only after top-2 training is stable.

For code completion, the highest-value specialization is not one expert per
language. Better targets are syntax/indentation, FIM reconstruction,
repository-context patterns, generated-code continuation, and real-code APIs.

## Routing Metrics

Log:

- Per-layer expert load.
- Per-expert token fraction.
- Dropped-token count.
- Router entropy.
- Auxiliary loss.
- Domain-to-expert correlation.

## Failure Modes

- Expert collapse.
- Router churn.
- Synthetic Python overfitting.
- MTP loss overpowering next-token loss.
- Shared expert absorbing too much load.
- Dropped tokens above 1% for sustained windows.