research26 min studyLesson 572 in Engineering

Expert capacity: distinguish a dropped branch from a rerouted token

Calculate assignment capacity and overflow while separating fixed buffers, padding, branch admission, rerouting, and dropless execution.

On this page

What you’ll understand

  • Compute capacity from an explicit assignment-count convention.
  • Distinguish requested, accepted, dropped, and rerouted assignments.
  • Evaluate quality and systems consequences of overflow policies.

A router can request more work from one expert than its buffer or schedule permits, even when total capacity looks generous. Overflow handling then becomes part of the model's forward computation. Dropping one selected branch, dropping every branch for a token, choosing another expert, and allowing variable-sized work are different algorithms. State which unit is bounded and which transformation happens when the bound is reached.

Capacity applies to assignments within a defined routing group

For T eligible tokens with exactly k distinct requested experts each, there are Tk requested assignments before overflow. Dividing by E experts gives the mean requested load. A teaching fixed-capacity rule can multiply that mean by a capacity factor and round upward. Real implementations may impose a minimum, alignment, per-rank scope, or a different normalization; inspect those details. Megatron-Core 0.15.0 documents a capacity expression using tokens per rank and top-k, whereas an aggregate expert-parallel batch would use a different T.

A total allocation of E times capacity does not ensure every expert fits. Load can concentrate on one destination while other slots stay empty. Padding reserves or computes space for missing assignments; it does not redistribute a busy expert's work. Capacity-factor comparisons must report the population used in the denominator and whether capacity is applied before or after exchange. A change in local batch size, group partition, or microbatch accumulation can alter overflow behavior without changing the global training-token count.

Arequested=Tk,nˉ=TkE,C=⌈c TkE⌉A_{\rm requested}=Tk,\qquad \bar n=\frac{Tk}{E},\qquad C=\left\lceil c\,\frac{Tk}{E}\right\rceil
T,E,k are positive integers with k≤E, and c>0 is a dimensionless capacity factor. C is assignments per expert in this stated fixed-group teaching convention, without a minimum or alignment rule. It must not be silently substituted for every framework's local capacity definition.↔ Scroll wide equations horizontally.

Overflow policies change the executed function

In a simple branch-dropping policy, an overflowing token-expert assignment contributes no expert result. A residual path may still carry the token representation, as in the original Switch architecture; the whole token is not necessarily removed from the sequence. Under top-two routing, a token can retain one branch while losing the other. Whether remaining weights are renormalized changes its output. Admission can prioritize token position, routing score, or randomized selection, producing different survivors even when accepted counts are identical.

Rerouting attempts a different expert and therefore changes expert identity, gate interpretation, communication, and potentially the learned function. It is not equivalent to padding spare capacity elsewhere. GShard's original top-two procedure also includes a stochastic second-route mechanism; do not label every top-two implementation deterministic selection of the two highest probabilities. Dropless methods instead allow requested work to be represented without token dropping, using variable work or suitable sparse kernels. MegaBlocks is one such design, but dropless execution still has finite memory and can suffer skew.

Dassign=∑e=1Emax⁡(0,ne−C),rassign=DassignTkD_{\rm assign}=\sum_{e=1}^{E}\max(0,n_e-C),\qquad r_{\rm assign}=\frac{D_{\rm assign}}{Tk}
n_e are pre-admission requested counts summing to Tk. This expression applies only to independent fixed-capacity branch dropping without rerouting, extra padding admissions, or priority-dependent changes to requested identities. The ratio counts assignments; it is not the fraction of unique tokens losing all expert work.↔ Scroll wide equations horizontally.

Measure admission quality as well as buffer utilization

Record requested and accepted counts, partial-token drops, complete-token branch loss, and padding separately. Slice those counters by sequence position or data group to detect a positional admission bias. Compare training quality at matched token budgets and meaningful compute boundaries; a faster step that skips more requested computation is not automatically a better sparse model. Reproduce the exact train and evaluation capacity policies because some APIs expose separate factors. A no-drop evaluation path can execute a function different from a dropping training path.

The queue lab represents one constrained work stream, not a routing batch. Reset, set λ=4 and μ=3, predict backlog six at t=2, then use four Steps to reach that time. Separately Reset, set λ=2 and μ=4, predict the initial backlog reaches zero at t=2, then use four Steps. The initial backlog is four, and these are fluid work units rather than token assignments. The instrument has no capacity cutoff, admission priority, or expert reassignment; calculate the discrete overflow on paper instead of interpreting a falling curve as rerouting.

Enough aggregate slots can still lose branches

A group has twelve tokens, four experts, top-two requested routing, and capacity factor one under the stated ceiling rule. Requested expert counts are [10,6,5,3]. Use independent branch dropping with no rerouting.

  1. There are 12×2=24 requested assignments, averaging six per expert, so C=6. Total allocated capacity is 24 slots.

  2. The first expert requests ten and exceeds capacity by four. Others do not overflow, leaving accepted counts [6,6,5,3] and four unused slots elsewhere.

  3. The assignment drop rate is 4/24=1/6≈16.67%. These counts do not reveal how many unique tokens lost all branches; that requires their individual routing identities.

The result

Exactly four assignments are dropped despite aggregate capacity equaling requested work. Assignment and token-level loss need different counters.

Explore the model

Interactive lab

Interactive lab · queue

A single constrained stream cannot use unrelated spare capacity

Reset, set λ=4 and μ=3, predict q(2)=6, then use four Steps. Separately Reset, set λ=2 and μ=4, predict q(2)=0, then use four Steps. The fluid model starts with four work units and has no token cutoff, rerouting, or expert buffer.

A single constrained stream cannot use unrelated spare capacityFluid backlog starts at 4 and follows max(0, 4 + (λ − μ)t). The separate M/M/1 residence-time formula assumes Poisson arrivals, exponential service and λ < μ. Current readings: Fluid backlog: 4; Net rate · λ − μ: −1 /s; M/M/1 mean residence: 1 s. All parameters are adjustable with the labeled controls below.02.557.51001.534.56Elapsed time · sFluid backlogλ < μ
Fluid backlogCurrent time
Fluid backlog
4
Net rate · λ − μ
−1 /s
M/M/1 mean residence
1 s
t = 0 s

Fluid backlog starts at 4 and follows max(0, 4 + (λ − μ)t). The separate M/M/1 residence-time formula assumes Poisson arrivals, exponential service and λ < μ. Parameter changes pause playback and recompute the model at the current elapsed time. Reset restores both parameters and returns time to zero. Playback starts paused. Adjust either parameter, then choose Play or Step.

Look forCapacity headroom and a mechanism that redistributes work are distinct.

Check your understanding

What does a 10% dropped-assignment rate establish for top-two routing?

Try it yourself

Eight tokens request top-two routing among four experts. With capacity factor 1.25 and counts [7,4,3,2], compute capacity and assignment drops under the same no-reroute teaching rule.

Take a moment to make a prediction or work it out on paper. Open a hint when you need one.

Give me a hint

Compute the sixteen assignments and round the mean times the capacity factor before clipping each expert.

Compare with the solution

Mean requested load is sixteen divided by four, or four. Capacity is ceil(1.25×4)=5. Only the first expert overflows, by two, giving fourteen accepted assignments and drop rate 2/16=12.5%. Spare slots at the other experts do not rescue those assignments under the stated policy.

Take it with you

  • Capacity must name the routing population and assignment unit.
  • Dropping, rerouting, padding, and dropless execution have different semantics.
  • Aggregate counts cannot identify complete-token versus partial-branch loss.

Read further

Original sources and deeper explanations to follow at your own pace.

Optional progress, saved in this browser when available. Revisit any lesson at any time.

Lesson not marked complete.