> ## Documentation Index
> Fetch the complete documentation index at: https://docs.sglang.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Parameter Tuning

This page assumes a server that already runs. It answers two questions: which parameter to change for a goal, and
what each parameter does and costs on Ascend. Full launch scripts, multi-node topology, and the settings a
deployment shape requires — the PD roles, the KV-transfer backend and rendezvous store, the network interfaces —
belong to the per-model **Best Practices** pages.

Which script you start from decides how much of this page you need. With a best-practice page for your model, adopt
its script as the baseline: most of the batch checklist is already set, so the work reduces to diffing the script and
moving the one knob your workload needs. Without one, start from a minimal launch (see the
[Model Tutorials](https://docs.sglang.io/docs/hardware-platforms/ascend-npus/model-deployment/tutorials) index) and build up with the same
workflow — switches first, then knobs.

[How to Tune](#how-to-tune) is the workflow. [Parameter Reference](#parameter-reference) is the complete inventory,
one row per parameter. [Tuning by Goal](#tuning-by-goal) says where to start for a goal, and
[Feature Compatibility](#feature-compatibility) checks a combination before you launch it.

> [!NOTE]
>
> Flag names and values change across releases: the best-practice pages pin the scripts of the image they were
> validated on, while this page tracks current builds. If a flag here is rejected or has no effect on your build,
> trace how the name evolved in the repository — an AI assistant pointed at the codebase is a fast way — and check
> [Supported Features](https://docs.sglang.io/docs/hardware-platforms/ascend-npus/reference/support_features.md) for per-flag support status.

## How to Tune

**1. Measure a baseline**

Pick the target metric — TTFT, TPOT, throughput, or memory headroom — and benchmark the current configuration before
changing anything. Record the seed, input/output lengths, and concurrency with every run.

Follow one measurement protocol across runs: flush the prefix cache, keep warmup identical, repeat the same benchmark
a few times to learn its noise floor, and treat any difference inside that spread as noise rather than a win.
[Performance Testing](https://docs.sglang.io/docs/hardware-platforms/ascend-npus/evaluation/performance_testing.md) has the command and how to
read Mean TTFT/Mean TPOT; [Profiling](https://docs.sglang.io/docs/hardware-platforms/ascend-npus/optimization/profiling.md) gives a
kernel-level view.

**2. Batch-enable the add-on switches**

Add every switch from the [batch checklist](#batch-checklist) whose *Applies when* matches your model and role. If
you started from a best-practice script, diff the list against it and add only what is missing.

**3. Verify the batch in three checks, in order**

1. The server starts.
2. The [accuracy evaluation](https://docs.sglang.io/docs/hardware-platforms/ascend-npus/evaluation/accuracy_evaluation.md) passes — mandatory
   after speculative decoding.
3. The benchmark improves or holds.

If a check fails, remove the added switches one at a time; nearly every failure is a precondition violation stated in
that switch's row.

**4. Tune the knobs top-down, one at a time**

Fix the topology first — parallelism, PD disaggregation, and the communication buffers that go with them — then the
load-shape parameters that consume memory ([`--chunked-prefill-size`](#batching-graphs-and-memory),
[`--cuda-graph-max-bs-decode`](#batching-graphs-and-memory), speculative depth), and size
[`--mem-fraction-static`](#batching-graphs-and-memory) last, because activation and graph buffers come out of the same
budget.

Choices at one level bound what the levels below can reach: graph-level tuning cannot compensate for a wrong TP/EP
split. Re-measure after every change, keep the better configuration, record every configuration you benchmark so the
results stay comparable, and keep the previous one so you can roll back.

### Batch checklist

The switches to add in step 2, each linking to its section in [Parameter Reference](#parameter-reference):

| Switch | Applies when |
| - | - |
| [`SGLANG_NPU_USE_MLAPO=1`](#model-specific-switches-and-host) | DeepSeek-style MLA |
| [`SGLANG_USE_FIA_NZ=1`](#model-specific-switches-and-host) | DeepSeek-style MLA |
| [`SGLANG_NPU_USE_MULTI_STREAM=1`](#model-specific-switches-and-host) | MoE models with shared experts — the DeepSeek, GLM, Qwen-MoE, and LongCat code paths all read it |
| [`SGLANG_USE_AG_AFTER_QLORA=1`](#model-specific-switches-and-host) + `--enable-attn-tp-input-scattered` | Model with `q_lora_rank`; practically prefill-only |
| [`SGLANG_ENABLE_OVERLAP_PLAN_STREAM=1`](#speculative-decoding-and-quantization) | Speculative decoding on, no LoRA |
| [`--enable-dp-lm-head`](#parallelism) | Attention DP on |
| [`PYTORCH_NPU_ALLOC_CONF=expandable_segments:True`](#batching-graphs-and-memory) | Always |
| [Host OS settings](#model-specific-switches-and-host): governor `performance`, `vm.swappiness=0`, `kernel.numa_balancing=0`, `kernel.sched_migration_cost_ns=50000` | Always (commands run as root) |
| [`SGLANG_SET_CPU_AFFINITY=1`](#model-specific-switches-and-host) | Always |
| [Speculative decoding](#speculative-decoding-and-quantization) | Model ships an MTP head (`NEXTN`), or you supply an external draft model (`EAGLE3`); verify accuracy after enabling |

> [!TIP]
>
> Fusion and stream-overlap switches are the largest unconditional wins on MoE models. Allocator and host settings are
> smaller but apply to every deployment. Speculative decoding is the single largest lever, but only while acceptance
> holds.

To match the *Applies when* column against your model, read its `config.json`: MLA models carry `kv_lora_rank` (with
`q_lora_rank` additionally gating the gather-after-Q switch), MoE models with shared experts carry `n_shared_experts`,
and a NextN/MTP head appears as `num_nextn_predict_layers`.
[Supported Models](https://docs.sglang.io/docs/hardware-platforms/ascend-npus/reference/support_models.md) lists the validated model families,
and each model's best-practice page shows which of these switches its script sets.

The remaining switches are conditional — also on/off, but the payoff depends on the workload, so they are not part of
the batch. Enable one only when evidence from benchmarks, metrics, or the traffic shape says its condition holds; the
condition and the failure are in the row's trade-offs.

| Conditional switch | Enable when |
| - | - |
| [`SGLANG_SCHEDULER_SKIP_ALL_GATHER=1`](#parallelism) | DP load is balanced — uneven load desyncs silently |
| [`--enable-eplb`](#moe-dispatch-and-communication) | Expert-load metrics show imbalance |
| [`--disable-radix-cache`](#batching-graphs-and-memory) | Requests share no prefixes |
| [`--deepep-dispatcher-output-dtype int8`](#moe-dispatch-and-communication) / [`DEEP_NORMAL_MODE_USE_INT8_QUANT=1`](#moe-dispatch-and-communication) | Prefill dispatch traffic dominates — typically multi-node; the accuracy budget allows a small loss |
| [`TASK_QUEUE_ENABLE=2`](#batching-graphs-and-memory) | The role captures no graphs |
| [`HCCL_OP_EXPANSION_MODE=AIV`](#moe-dispatch-and-communication) | Never on Atlas A2 systems with DeepEP |

## Parameter Reference

Every tuning parameter on Ascend, in five groups. Unless a row says otherwise, the **Reference** value comes from the
published DeepSeek V3.2 PD configuration on 32 NPUs: a starting point from that validated deployment, not a flag
default. On a single mixed node there are no roles to split — start from the raw defaults and let
[Tuning by Goal](#tuning-by-goal) drive the changes.

> [!TIP]
>
> Three shapes, three readings. **Range** rows give what raising and lowering buys, with the failure mode at each end.
> **Discrete** rows give the valid values and the pick. **Switch** rows give the condition to enable, and the cost of
> enabling it anyway.

**Reading the tables.** `—` means do not set the flag. A trailing parenthetical narrows when a value applies: a model
list, as in `1` (DeepSeek R1), or a condition, as in `on (long-context prefill)`. Raw defaults for most flags are in
[Supported Features](https://docs.sglang.io/docs/hardware-platforms/ascend-npus/reference/support_features.md), and most environment variables
in [Ascend NPU Environment Variables](https://docs.sglang.io/docs/hardware-platforms/ascend-npus/reference/environment_variables.md).

Two groups are omitted, and both are copied from your model's best-practice script rather than tuned here. Setup
settings have nothing to size, and a wrong rank or an unreachable interface hangs startup: `HCCL_SOCKET_IFNAME` /
`GLOO_SOCKET_IFNAME`, `--nnodes`, `--node-rank`, `--dist-init-addr`. The other group is what those scripts pin per
model, hardware series, or build: the `ZBAL_*` / `ZBCCL_*` KV-transfer switches, `ASCEND_USE_FIA`,
`GDN_ATTN_BACKEND_TRITON`, the DeepSeek V4 `SGLANG_OPT_*` group, and the speculative-decoding switches they set
(`SGLANG_ENABLE_SPEC_V2`, `SGLANG_SPEC_ENABLE_OVERLAP_REFLOW`, `FORCE_DRAFT_MODEL_NON_QUANT`).

### Parallelism

<table>
  <thead>
    <tr>
      <th>Parameter</th>
      <th>Purpose</th>
      <th>Trade-offs</th>
      <th>Reference</th>
    </tr>
  </thead>

  <tbody>
    <tr>
      <td>`--tp-size` (`--tp` in published scripts)</td>
      <td>Shards the model's weights across devices, which communicate via HCCL all-reduce. The primary way to fit
      models larger than a single device.</td>
      <td>**Discrete.** Up: less weight per device, at more all-reduce per step. Down: less
      communication, until the model stops fitting per node. Sweep the divisors of the world size and take the
      smallest TP that fits per node.</td>
      <td>`32`</td>
    </tr>

    <tr>
      <td>`--dp-size`</td>
      <td>Replicates the model across device groups to serve more requests in parallel.</td>
      <td>**Discrete.** Cannot be combined with attention DP, and model replication is single-node only;
      both are enforced at startup.</td>
      <td>— (attention DP is used instead)</td>
    </tr>

    <tr>
      <td>`--attn-dp-size` / `--attention-data-parallel-size`</td>
      <td>Runs attention data-parallel inside the TP group, the axes combining as
      `tp_size = attn_tp_size × attn_dp_size × attn_cp_size`. Each DP group serves its own requests with its own KV
      cache and attention weights, TP-sharded over the remaining `tp/attn_dp` ranks; FFN/MoE stay TP/EP-sharded. The
      published scripts write the deprecated equivalent `--enable-dp-attention --dp-size 8`.</td>
      <td>**Discrete.** Up: more independent decode instances, so higher throughput and lower TPOT under
      concurrency. Down: each group's attention TP widens and per-request attention runs faster — raise the value only
      while attention is not the bottleneck. Must divide the TP size; sweep the divisors (`2`, `4`, `8` on TP `8`).</td>
      <td>Decode `8`</td>
    </tr>

    <tr>
      <td>`--attn-cp-size`</td>
      <td>Splits one long sequence across devices for the prefill phase, cutting per-rank prefill work on long inputs.
      It only shards context when `--enable-prefill-cp` is also set.</td>
      <td>**Discrete.** Up: less prefill work per rank on long inputs, at more inter-device communication.
      Down: less communication, at more per-rank prefill work. Must divide `--tp-size`, and with attention DP
      `tp_size % (attn_dp_size × attn_cp_size)` must be `0` as well.</td>
      <td>Prefill `32`</td>
    </tr>

    <tr>
      <td>`--enable-prefill-cp`</td>
      <td>Enables context parallelism for the prefill phase.</td>
      <td>**Switch.** On: long-context prefill, together with `--attn-cp-size` and `--cp-strategy` —
      without this flag `--attn-cp-size` shards nothing, and without a strategy startup fails with
      `--cp-strategy must be set when --enable-prefill-cp is enabled.` Off: nothing lost for decode, which is the
      separate `--dcp-size` axis that no published Ascend configuration sets.</td>
      <td>on (long-context prefill)</td>
    </tr>

    <tr>
      <td>`--cp-strategy`</td>
      <td>Sharding strategy for prefill CP. Mandatory whenever prefill CP is on.</td>
      <td>**Discrete.** `zigzag` gives each rank early and late blocks; `interleave` assigns token indices
      modulo the CP size. Model-specific: V3.2 requires `interleave` and rejects `zigzag` at startup, MiMo V2 requires
      `zigzag`; where the CP and TP groups coincide, `Glm5Next` uses `interleave` and `Qwen4Exp` uses `zigzag`. Take
      it from this row — the pinned v0.5.18 script says `zigzag`, which current builds reject.</td>
      <td>V3.2 `interleave`</td>
    </tr>

    <tr>
      <td>`--ep-size` / `--ep` / `--expert-parallel-size`</td>
      <td>Distributes MoE experts across devices and routes tokens via all-to-all dispatch. V3.2 has 256 routed
      experts at TP `32`, so each rank hosts `256 / 32 = 8`.</td>
      <td>**Discrete.** Defaults to `1`. With any all-to-all backend available on Ascend (`deepep`,
      `ascend_fuseep`, `ascend_ops`) the final EP size is forced to TP, so under those backends the flag is not a
      free choice.</td>
      <td>`32`</td>
    </tr>

    <tr>
      <td>`--moe-dense-tp-size`</td>
      <td>TP size for the dense FFN layers of MoE models (`first_k_dense_replace`).</td>
      <td>**Discrete.** Unset, `1`, or the full TP size. Leave it unset for normal TP-sharded dense FFN;
      set `1` under attention DP, where each DP group already holds the full dense weights, or under prefill CP where
      `cp = tp` leaves attention unsharded too. Do not set it to the TP size to match TP: that gathers attention
      inputs across ranks before the dense FFN runs.</td>
      <td>`1`</td>
    </tr>

    <tr>
      <td>`--enable-dp-lm-head`</td>
      <td>Shards the LM head vocabulary across the attention-TP group inside each DP rank.</td>
      <td>**Switch.** On: attention DP with `--attn-dp-size` above `1`, which it requires — it removes an
      all-gather of logits across DP ranks. Off: no effect without attention DP.</td>
      <td>on</td>
    </tr>

    <tr>
      <td>`--load-balance-method`</td>
      <td>Routes requests across DP ranks.</td>
      <td>**Discrete.** `auto` resolves per role, to `follow_bootstrap_room` on PD prefill and
      `round_robin` on decode and non-PD; the explicit choices are `round_robin`, `total_tokens`, `total_requests`,
      and `follow_bootstrap_room`. Keep `auto` on PD prefill — an explicit `round_robin` drops the bootstrap-room
      routing PD needs. No effect when `dp_size × attn_dp_size == 1`.</td>
      <td>`auto`</td>
    </tr>

    <tr>
      <td>`SGLANG_SCHEDULER_SKIP_ALL_GATHER=1`</td>
      <td>Skips the scheduler's cross-DP-rank metadata all-gather on every step — prefill, mixed, and decode.</td>
      <td>**Switch.** On: every DP rank runs the same forward mode with the same token counts, as under
      balanced or round-robin load. Off: uneven load silently desyncs MoE dispatch and graph buckets, and there is no
      code guard that rejects it today.</td>
      <td>`1`</td>
    </tr>
  </tbody>
</table>

### Batching, graphs, and memory

<table>
  <thead>
    <tr>
      <th>Parameter</th>
      <th>Purpose</th>
      <th>Trade-offs</th>
      <th>Reference</th>
    </tr>
  </thead>

  <tbody>
    <tr>
      <td>`--chunked-prefill-size`</td>
      <td>Maximum tokens per prefill chunk. Chunking interleaves prefill with decode for better mixed-workload
      concurrency.</td>
      <td>**Range.** Up: higher prefill throughput, but decode stalls longer between chunks. Down: fairer
      interleaving, at more per-chunk overhead paid more often. `-1` disables chunking entirely — preferred on
      dedicated prefill nodes with long contexts, where there is no decode to interleave. The default follows device
      memory: `4096` up to 32 GB, `8192` between 32 GB and 160 GB, `16384` at 160 GB and above.</td>
      <td>`-1`</td>
    </tr>

    <tr>
      <td>`--max-prefill-tokens`</td>
      <td>Maximum input tokens admitted into one prefill batch.</td>
      <td>**Range.** Up: more concurrent long requests co-batch per forward, at activation memory — large
      values need an explicit `--mem-fraction-static`, since the heuristic otherwise reserves about 1.5 MB per token
      when chunking is off (with chunking on, the reserve follows `--chunked-prefill-size`). Down: a smaller
      activation reserve, at fewer long requests admitted per forward. With chunking disabled the first request may
      exceed the limit, bounded only by KV capacity; with chunking on, each forward is bounded by
      `--chunked-prefill-size`.</td>
      <td>`68000`</td>
    </tr>

    <tr>
      <td>`--max-running-requests`</td>
      <td>Global concurrency cap.</td>
      <td>**Range.** Up: more concurrent requests and higher throughput, but per-request latency rises and
      the KV pool must fit the concurrency. Down, as far as `1`: the whole node is dedicated to each request for
      maximum per-request prefill throughput. Under attention DP the per-rank concurrency is
      `max_running_requests / attn_dp_size`, and the default derives from KV capacity.</td>
      <td>Prefill `1` · Decode `32`</td>
    </tr>

    <tr>
      <td>`--min-free-slots-delay`</td>
      <td>Holds fresh prefill admissions until at least N running-request slots free up, so they are admitted as one
      batch instead of one at a time. Per-DP-rank local: a rank with free slots does not wait for a congested peer.
      Useful when a single admission is disproportionately expensive, as with speculative decoding plus a separate
      draft prefill pass.</td>
      <td>**Range.** Up: fewer, larger admissions and fewer prefill/decode interleaves, at later TTFT for
      the held requests. Down to `1`, which disables it. Capped by `--max-running-requests`,
      and unsupported with pipeline parallelism. Unset, DFLASH speculative deployments auto-enable a formula — so
      admission changes with no flag at all, and setting the flag is how you take control of it.</td>
      <td>— (DFLASH auto-enables it; not set in the published configurations)</td>
    </tr>

    <tr>
      <td>`--enable-prefill-delayer`</td>
      <td>Delays admitting a prefill batch for a bounded number of forward passes so decode keeps making progress
      under attention DP, where prefill bursts otherwise stall decode. Sized by
      `--prefill-delayer-max-delay-passes` (`30`), `--prefill-delayer-queue-min-ratio`,
      `--prefill-delayer-max-delay-ms`, and `--prefill-delayer-token-usage-low-watermark`; the env spellings
      `SGLANG_SCHEDULER_DECREASE_PREFILL_IDLE` and `SGLANG_PREFILL_DELAYER_MAX_DELAY_PASSES` are deprecated aliases of
      the first two flags.</td>
      <td>**Range.** Up (more passes, a higher `--prefill-delayer-max-delay-ms`, a lower
      `--prefill-delayer-queue-min-ratio`): buys decode TPOT and pays TTFT. Down: shorter TTFT, at more decode stalls
      behind prefill bursts. Not for dedicated prefill or pure-decode roles.</td>
      <td>off in V3.2 · `--prefill-delayer-max-delay-passes` `50`–`500` on Kimi K2.6, MiniMax M2.5, Qwen3.6</td>
    </tr>

    <tr>
      <td>`--disable-radix-cache`</td>
      <td>Turns off prefix caching, which otherwise reuses the KV of shared prompt prefixes.</td>
      <td>**Switch.** On: requests share no prefixes, as on dedicated prefill nodes and random-input
      benchmark traffic. Off: chat workloads with shared system prompts, where prefix reuse cuts TTFT. PD decode
      forces prefix caching off unless the experimental `--disaggregation-decode-enable-radix-cache` is set.</td>
      <td>on</td>
    </tr>

    <tr>
      <td>`--cuda-graph-bs-decode`</td>
      <td>Explicit list of decode batch sizes to capture with NPU Graph (Ascend's CUDA Graph equivalent, via
      `torch.npu.NPUGraph`), which captures and replays the decode step to remove kernel-launch overhead.</td>
      <td>**Discrete.** The listed buckets still pass through the
      [alignment filter](#graph-batch-size-alignment). Omit the flag to capture an automatically bucketed list.</td>
      <td>—</td>
    </tr>

    <tr>
      <td>`--cuda-graph-max-bs-decode`</td>
      <td>Largest decode batch size captured, per DP rank. Set it near the typical per-rank batch, not the peak — see
      [From an observed symptom](#from-an-observed-symptom) for where to read the observed value.</td>
      <td>**Range.** Up: larger batches stay captured, at more capture time and memory. Down: batches
      above the value run uncaptured and pay kernel-launch overhead again. Set it to at least the
      [alignment](#graph-batch-size-alignment) and to a multiple of it, or startup aborts when no bucket survives
      (`capture_bs=[]`).</td>
      <td>`4`</td>
    </tr>

    <tr>
      <td>`TASK_QUEUE_ENABLE`</td>
      <td>torch\_npu host-side task-submission pipelining.</td>
      <td>**Discrete.** `0` off · `1` submissions are queued to a dedicated thread (default) · `2`
      additionally spin-polls empty queues for lower launch latency. `ASCEND_LAUNCH_BLOCKING=1` silently forces the
      value to `0`. Level `2` always fails during NPU Graph capture
      (`Do not support TASK_QUEUE_ENABLE = 2 during NPU graph capture`), so only roles that capture no graphs may use
      it.</td>
      <td>Prefill `2` · Decode `0` · Mixed node `1`</td>
    </tr>

    <tr>
      <td>`--disable-overlap-schedule`</td>
      <td>Turns off the overlap scheduler, enabled by default, which prepares the next batch on the CPU while the
      current one runs on the NPU.</td>
      <td>**Switch.** On (disabling): rarely necessary; it is auto-disabled for pipeline parallelism.</td>
      <td>—</td>
    </tr>

    <tr>
      <td>`STREAMS_PER_DEVICE`</td>
      <td>Size of the per-device stream pool.</td>
      <td>**Discrete.** Only `8` and `32` are valid; other values are reset to `32`. Keep the default
      unless profiling indicates a need for `8`.</td>
      <td>`32`</td>
    </tr>

    <tr>
      <td>`--mem-fraction-static`</td>
      <td>Fraction of NPU memory reserved for model weights and the KV cache pool.</td>
      <td>**Range.** Up: more KV cache and more concurrent requests, until out-of-memory errors return
      during serving or graph capture. Down: headroom for activations and graph buffers, at fewer concurrent
      requests — too low and startup computes a KV pool of zero, reporting
      `Not enough memory. Please try to increase --mem-fraction-static.` Raise it gradually while monitoring; see
      [Troubleshooting](#troubleshooting) for both failure messages.</td>
      <td>Prefill `0.73` · Decode `0.79`</td>
    </tr>

    <tr>
      <td>`PYTORCH_NPU_ALLOC_CONF`</td>
      <td>Allocator configuration. `expandable_segments:True` maps physical pages on demand instead of reserving the
      address space up front, resisting allocator fragmentation — the main defense against fragmentation-driven
      out-of-memory errors on MoE-scale models. `pin_memory_expandable_segments:True` does the same for pinned host
      memory, which helps when large pinned allocations (HiCache host pool, KV cache offload) fail intermittently.</td>
      <td>**Switch.** On: `expandable_segments:True` always — it is resilience, not speed. Add
      `pin_memory_expandable_segments:True` only when pinned allocations actually fail: it changes memory usage, so
      validate it on your workload, and it requires CANN 8.5.0 / driver 25.5.0 or newer (the driver check is waived on
      Ascend 950 and newer, otherwise the setting is reset to `False` with a one-time warning).</td>
      <td>`expandable_segments:True` (the pin option is not used in the published configurations)</td>
    </tr>
  </tbody>
</table>

### MoE dispatch and communication

<table>
  <thead>
    <tr>
      <th>Parameter</th>
      <th>Purpose</th>
      <th>Trade-offs</th>
      <th>Reference</th>
    </tr>
  </thead>

  <tbody>
    <tr>
      <td>`--moe-a2a-backend`</td>
      <td>All-to-all backend for MoE dispatch/combine. `deepep` has separate prefill and decode dispatch paths;
      `ascend_fuseep` fuses dispatch, GEMM, and combine into one kernel; `ascend_ops` is the NPU-only MC2 and
      all-to-all path, configured with `--moe-ascend-ops-config`.</td>
      <td>**Discrete.** EPLB requires `deepep` — there is no startup guard, so a wrong backend fails
      silently. `ascend_fuseep` gives `SGLANG_DEEPEP_NUM_MAX_DISPATCH_TOKENS_PER_RANK` different semantics (see its
      row).</td>
      <td>`deepep`</td>
    </tr>

    <tr>
      <td>`--deepep-mode`</td>
      <td>Selects the DeepEP dispatch path.</td>
      <td>**Discrete.** `normal` favors high throughput and large token counts, so it suits prefill;
      `low_latency` suits small, graph-compatible decode batches; `auto` decides per batch.</td>
      <td>Prefill `normal` · Decode `low_latency`</td>
    </tr>

    <tr>
      <td>`SGLANG_DEEPEP_NUM_MAX_DISPATCH_TOKENS_PER_RANK`</td>
      <td>Per-rank dispatch buffer capacity, in tokens, for DeepEP low-latency decode. Size it to the actual
      per-iteration maximum — see [Sizing the DeepEP dispatch buffer](#sizing-the-deepep-dispatch-buffer).</td>
      <td>**Range.** Up: headroom against the runtime dispatch failure, but low-latency dispatch pads to
      the configured value every iteration, so an oversized buffer adds padding cost on every step. Down: less padding
      paid every step; below the per-iteration maximum, dispatch fails at runtime. See
      [Sizing the DeepEP dispatch buffer](#sizing-the-deepep-dispatch-buffer) for the default, the hard cap, and the
      `ascend_fuseep` override.</td>
      <td>Decode `8`</td>
    </tr>

    <tr>
      <td>`--deepep-dispatcher-output-dtype int8`</td>
      <td>Quantizes DeepEP normal-mode dispatch activations to INT8, reducing communication volume.</td>
      <td>**Switch.** On: DeepEP normal-mode prefill, especially multi-node, when the accuracy budget
      allows the small loss the traffic saving costs. Prefer this flag over the legacy variable below.</td>
      <td>Prefill `int8`</td>
    </tr>

    <tr>
      <td>`DEEP_NORMAL_MODE_USE_INT8_QUANT=1`</td>
      <td>Legacy spelling of the INT8 dispatch switch, consumed by the Ascend DeepEP library.</td>
      <td>**Switch.** Set it when the legacy pybind dispatch-buffer path is in play: that path selects
      the dtype from this variable inside the DeepEP runtime. The published pinned-image scripts still set it; on
      current builds, prefer the flag above.</td>
      <td>Prefill `1` (legacy fallback)</td>
    </tr>

    <tr>
      <td>`DEEPEP_NORMAL_LONG_SEQ_PER_ROUND_TOKENS` /
      `DEEPEP_NORMAL_LONG_SEQ_ROUND` (+ `DEEPEP_NORMAL_COMBINE_ENABLE_LONG_SEQ`)</td>
      <td>Pipelines DeepEP normal-mode dispatch on long sequences: a prefill round's tokens cross the wire in
      `DEEPEP_NORMAL_LONG_SEQ_ROUND` chunks of `DEEPEP_NORMAL_LONG_SEQ_PER_ROUND_TOKENS` each, overlapping
      communication with compute; `DEEPEP_NORMAL_COMBINE_ENABLE_LONG_SEQ=1` pipelines the combine phase the same way.
      Consumed by the Ascend DeepEP library; defaults `8192` / `1` / `0` (see
      [Ascend NPU Environment Variables](https://docs.sglang.io/docs/hardware-platforms/ascend-npus/reference/environment_variables.md)).</td>
      <td>**Range.** Up (more tokens per round, fewer rounds): fewer per-round setups, at a larger
      in-flight buffer and coarser overlap — the single-round default is `8192` × `1`. Down (the published prefill
      scripts use `1024`–`4096` tokens × `6`–`72` rounds): finer overlap and a smaller in-flight buffer, at more
      per-round setup. The combine switch pays off wherever the dispatch pipeline does.</td>
      <td>Prefill `1024` × `10`–`72`, combine `1` (DeepSeek R1, GLM-5.1, and other prefill-heavy best practices; not
      set in the V3.2 configuration)</td>
    </tr>

    <tr>
      <td>`--enable-eplb`</td>
      <td>Redistributes experts across devices from measured load: it records expert-load statistics on every forward
      pass and evaluates a rebalance every `--eplb-rebalance-num-iterations` iterations (default `1000`).</td>
      <td>**Switch.** On: expert-distribution metrics show unbalanced load — see
      [Troubleshooting](#troubleshooting) for how to measure it; `--ep-num-redundant-experts` adds actual
      replication. Off: without imbalance it is pure statistics overhead.
      Requires the `deepep` backend (`ascend_fuseep` is not supported) and `TP = EP = world size`, and there is no
      startup guard for the backend mismatch: a wrong topology raises
      `NPU EPLB migration requires TP size = EP size = WORLD size.`</td>
      <td>on (when expert load is uneven)</td>
    </tr>

    <tr>
      <td>`DEEPEP_HCCL_BUFFSIZE`</td>
      <td>HCCL buffer size in MB for the default HCCL group and for the MoE groups that DeepEP dispatch/combine run
      on. Falls back to `HCCL_BUFFSIZE` when unset (built-in default `200`).</td>
      <td>**Range.** Up: headroom for prefill bulk transfers, at HBM cost. Down: HBM saved — decode needs
      less than prefill.</td>
      <td>Prefill `1200` · Decode `400`</td>
    </tr>

    <tr>
      <td>`HCCL_BUFFSIZE`</td>
      <td>HCCL buffer size in MB for the default communication group — the collectives outside the MoE
      dispatch/combine path, such as the TP/DP all-reduce and all-gather volume. Built-in default `200`; the MoE
      all-to-all buffer is sized separately by `DEEPEP_HCCL_BUFFSIZE`, which falls back to
      this value.</td>
      <td>**Range.** Up: headroom for the default group's collectives, at HBM cost. Down: HBM reclaimed
      on a node whose bulk traffic runs on the MoE buffers anyway — published PD prefill roles shrink it to
      single-digit MB.</td>
      <td>often unset · PD prefill `8` (GLM-5.1, Kimi K2.6) · their decode roles `600` (GLM-5.1) · other deployments
      `64`–`1200`</td>
    </tr>

    <tr>
      <td>`HCCL_OP_EXPANSION_MODE`</td>
      <td>Where HCCL communication-algorithm expansion and scheduling run: `AIV` moves them onto AI Vector cores,
      keeping the AI Cores free for compute; `AI_CPU` (the default) leaves them on the AI CPU.</td>
      <td>**Discrete.** `AIV` gains are workload-dependent. Never set it on Atlas A2 systems with
      DeepEP — vendor docs report unknown-operator errors.</td>
      <td>`AIV` (Qwen, DeepSeek R1, Kimi, and MiMo best practices; not set in the V3.2 configuration)</td>
    </tr>
  </tbody>
</table>

### Speculative decoding and quantization

<table>
  <thead>
    <tr>
      <th>Parameter</th>
      <th>Purpose</th>
      <th>Trade-offs</th>
      <th>Reference</th>
    </tr>
  </thead>

  <tbody>
    <tr>
      <td>`--speculative-algorithm`</td>
      <td>Drafts several tokens per step so one target forward verifies them, reducing per-token latency.
      `NEXTN` (an alias of `EAGLE`) reuses the model's own MTP head; `EAGLE3` takes an external draft model via
      `--speculative-draft-model-path`.</td>
      <td>**Discrete.** Verified on NPU: `NEXTN`, `EAGLE`, `EAGLE3`, `DFLASH`, `DSPARK`;
      `STANDALONE` and `UNO` are unverified, and `NGRAM` is CUDA/CPU/XPU-only (any plugin-registered name is
      accepted). For non-greedy requests, target verification applies request-level `temperature`, `top_k`, and
      `top_p`; `--speculative-use-rejection-sampling` supports linear candidates only, requires
      `--speculative-eagle-topk 1`, and is incompatible with non-default accept thresholds and deterministic
      inference.</td>
      <td>`NEXTN`</td>
    </tr>

    <tr>
      <td>`--speculative-num-steps`</td>
      <td>Draft forward passes per iteration.</td>
      <td>**Range.** Up: a longer acceptance length and more verified tokens per target forward, at more
      draft latency and compute per step. Down: cheaper steps, at less acceptance. The payoff depends on the
      acceptance rate, so re-run the
      [accuracy evaluation](https://docs.sglang.io/docs/hardware-platforms/ascend-npus/evaluation/accuracy_evaluation.md) and the benchmark.</td>
      <td>Prefill `1` · Decode `3` (prefill stays shallow: draft steps add latency and prefill gains little
      acceptance length)</td>
    </tr>

    <tr>
      <td>`--speculative-eagle-topk`</td>
      <td>Tree width of the draft. Not a tunable value on Ascend: the KV-cache page size is 128 and the `ascend`
      attention backend does not implement tree drafts, so a larger value is rejected.</td>
      <td>**Discrete.** Keep it at `1`; rejection sampling requires `1` as well.</td>
      <td>`1`</td>
    </tr>

    <tr>
      <td>`--speculative-num-draft-tokens`</td>
      <td>Draft tokens verified per iteration.</td>
      <td>**Range.** Up: a higher potential acceptance length and throughput, at higher compute cost per
      step. Down: cheaper steps, at less throughput. With `topk 1` it is forced to `num-steps + 1`, and a different
      value is overridden with a warning.</td>
      <td>Prefill `2` · Decode `4`</td>
    </tr>

    <tr>
      <td>`--speculative-draft-model-quantization`</td>
      <td>Quantization of the draft model when the target model is quantized.</td>
      <td>**Discrete.** Unset: the draft inherits the target quantization. `unquant`: the draft stays in
      BF16.</td>
      <td>`unquant` (with a quantized target; not set in the published configuration)</td>
    </tr>

    <tr>
      <td>`SGLANG_ENABLE_OVERLAP_PLAN_STREAM=1`</td>
      <td>Runs speculative batch-preparation kernels (draft-extend metadata, KV-location planning) on a dedicated
      stream, overlapping them with other work instead of running them serially.</td>
      <td>**Switch.** On: speculative decoding is on and LoRA is not — it is incompatible with LoRA under
      every LoRA-compatible speculative algorithm (EAGLE/NEXTN/EAGLE3, DFLASH, DSPARK).</td>
      <td>`1`</td>
    </tr>

    <tr>
      <td>`--quantization modelslim`</td>
      <td>Loads ModelSlim W4A4/W8A8/W4A8 (and MXFP8/MXFP4) pre-quantized weights, auto-detecting the method from the
      model's `quant_model_description.json`. Weight memory drops by approximately 50% (W8) or 75% (W4) versus BF16.</td>
      <td>**Switch.** On: you have a pre-quantized checkpoint and the accuracy budget allows a small loss
      — re-run the [accuracy evaluation](https://docs.sglang.io/docs/hardware-platforms/ascend-npus/evaluation/accuracy_evaluation.md). The flag
      loads pre-quantized checkpoints only; to quantize your own with msModelSlim, see
      [Quantization on Ascend](https://docs.sglang.io/docs/hardware-platforms/ascend-npus/optimization/quantization.md). Community formats
      (AWQ, GPTQ, Auto-round, Compressed-tensors) depend on the availability of Ascend custom kernels.</td>
      <td>`modelslim`</td>
    </tr>
  </tbody>
</table>

### Model-specific switches and host

<table>
  <thead>
    <tr>
      <th>Parameter</th>
      <th>Purpose</th>
      <th>Trade-offs</th>
      <th>Reference</th>
    </tr>
  </thead>

  <tbody>
    <tr>
      <td>`SGLANG_NPU_USE_MLAPO=1`</td>
      <td>Fuses MLA pre-processing (QKV-A/Q-B projections, RMSNorms, RoPE, KV-cache write, and the W\_kc absorb) into
      one kernel, and repacks the weights once per layer on the first forward.</td>
      <td>**Switch.** On: DeepSeek-style MLA and similar architectures — it reduces decode and
      target-verify latency on DSA models, and also accelerates prefill on non-DSA MLA. Off: layouts outside
      ModelSlim W8A8 and the MLAProlog set (BF16/FP16, partial INT8, dynamic INT8, MXFP8) run on the unfused path
      anyway, so there is nothing to gain. A layout mismatch under a selected MLAProlog fails at the first forward.</td>
      <td>`1` (DeepSeek R1, Kimi K2.6)</td>
    </tr>

    <tr>
      <td>`SGLANG_USE_FIA_NZ=1`</td>
      <td>Stores the KV cache in the FIA NZ layout for more efficient memory access.</td>
      <td>**Switch.** On: DeepSeek-style MLA. Independent of `SGLANG_NPU_USE_MLAPO` — either can be used
      alone.</td>
      <td>`1` (DeepSeek R1)</td>
    </tr>

    <tr>
      <td>`SGLANG_NPU_USE_MULTI_STREAM=1`</td>
      <td>Runs shared experts and routed experts concurrently on separate NPU streams, overlapping shared-expert
      compute with expert dispatch. Not DeepSeek-only: the GLM, Qwen-MoE, and LongCat code paths read it too.</td>
      <td>**Switch.** On: MoE models with shared experts (`n_shared_experts`) — set by the DeepSeek R1,
      DeepSeek V4-Flash, GLM-5.1/5.2, and Kimi K2.6 best practices. Off: the Qwen3-Next best practice pins it to
      `0`.</td>
      <td>`1` (DeepSeek R1, DeepSeek V4-Flash, GLM-5.1/5.2, Kimi K2.6)</td>
    </tr>

    <tr>
      <td>`SGLANG_USE_AG_AFTER_QLORA=1` + `--enable-attn-tp-input-scattered`</td>
      <td>Delays the attention all-gather until after the low-rank Q projection (`q_lora_rank`), so fewer bytes are
      gathered.</td>
      <td>**Switch.** On: models with `q_lora_rank`, practically prefill-only — it requires the
      scattered-input layout (`--enable-attn-tp-input-scattered`), without which the variable has no effect, and that
      layout is used in extend forwards only and is disabled when attention DP is on.</td>
      <td>`1` (DeepSeek R1 prefill)</td>
    </tr>

    <tr>
      <td>`SGLANG_NPU_DISABLE_ACL_FORMAT_WEIGHT`</td>
      <td>By default, linear, MoE, quantized, and MLA QKV weights are cast to the ACL FRACTAL\_NZ format (enum 29);
      setting `1` keeps the ND layout when a feature requires it. The KV-cache NZ layout is controlled separately by
      `SGLANG_USE_FIA_NZ`.</td>
      <td>**Switch.** On: only when a feature requires the ND layout. Off: keeps the NZ layout. Never set
      it for FP4/MXFP4 models — setting it makes the weight-preparation path return early, which also skips the NZ
      cast those kernels require and can corrupt results.</td>
      <td>— (keep the NZ layout)</td>
    </tr>

    <tr>
      <td>`--tokenizer-worker-num`</td>
      <td>Number of parallel tokenizer worker processes (default `1`).</td>
      <td>**Range.** Up: tokenization parallelizes across worker processes. Down: keep `1` for native
      gRPC and elastic EP, which require it.</td>
      <td>`1`</td>
    </tr>

    <tr>
      <td>Host OS settings</td>
      <td>CPU governor `performance`
      (`echo performance | sudo tee /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor`) locks all cores at the
      maximum frequency, removing DVFS-induced latency jitter; `vm.swappiness=0` reduces the chance of kernel swapping
      (fewer page faults on host memory used by NPU buffers); `kernel.numa_balancing=0` stops page migration between
      NUMA nodes; `kernel.sched_migration_cost_ns=50000` discourages moving inference threads between cores.</td>
      <td>**Switch.** On: always — these remove host-side scheduling jitter, with no value to size and no
      performance downside. Run the commands as root (or with `sudo`) and export the variables in the launch shell.</td>
      <td>always set</td>
    </tr>

    <tr>
      <td>`SGLANG_SET_CPU_AFFINITY=1`</td>
      <td>Binds each TP rank's scheduler process to dedicated CPU cores, avoiding cross-core migration overhead.</td>
      <td>**Switch.** On: always, alongside the host OS settings.</td>
      <td>`1`</td>
    </tr>
  </tbody>
</table>

### Graph batch-size alignment

Decode buckets are filtered against a batch-size alignment. The alignment is `attn_tp_size` whenever a gathered
buffer is in use — attention DP, any MoE all-to-all backend, or an explicit `--moe-dense-tp-size` — and `1` otherwise.
Two-batch overlap (two micro-batches per step, planned on Ascend; see
[Supported Features](https://docs.sglang.io/docs/hardware-platforms/ascend-npus/reference/support_features.md) for availability on your build)
doubles the alignment, and context parallelism can raise it further. A bucket survives when batch size × per-request
decode tokens is a multiple of the alignment; with speculative decoding the draft tokens already supply part of that
multiple, so buckets below the alignment can survive. Buckets that miss the alignment are dropped, and startup aborts
if none survive.

In practice, set [`--cuda-graph-max-bs-decode`](#batching-graphs-and-memory) to at least the alignment and to a
multiple of it whenever attention DP, an all-to-all backend, or `--moe-dense-tp-size` is in play. A dense model with
plain TP has no such constraint.

Two defaults follow from this area. NPU prefill graphs are off by default, so no prefill graph flag is needed. And do
not use the deprecated `--disable-cuda-graph` on a mixed node: it also disables decode graphs there — use
`--cuda-graph-backend-decode=disabled` to disable only decode graphs. A dedicated prefill role that captures no graphs
may still carry it, as the published prefill scripts do; there it is redundant and harmless.

### Sizing the DeepEP dispatch buffer

Size [`SGLANG_DEEPEP_NUM_MAX_DISPATCH_TOKENS_PER_RANK`](#moe-dispatch-and-communication) to the maximum number of tokens one
rank dispatches per decode iteration: running requests per rank × `--speculative-num-draft-tokens` with speculative
decoding, or just the running requests per rank without it.

The published value `8` leaves headroom over its benchmark load: 8 concurrent requests over DP 8 is one request per
rank, which is `1 × 4 = 4` dispatched tokens per iteration, half the buffer. Serving the full
`--max-running-requests 32` cap would need `(32 / 8) × 4 = 16`, so raise the value when you serve more concurrency than
the benchmark did.

The default is `128` when unset. DeepEP enforces a hard cap of `1024`, but the `ascend_fuseep` path bypasses that check
and, with its default `--fuseep-mode 2`, treats the variable as received-token capacity instead — the DeepEP formula
does not carry over.

## Tuning by Goal

Where to start for common goals, ordered by expected impact. Each goal is a thin index into
[Parameter Reference](#parameter-reference): the entries name the parameters with the largest expected effect, and the
full constraint and failure modes live in each row's trade-offs. Turn on every applicable switch from the
[batch checklist](#batch-checklist) first, and check the enable condition of any workload-dependent switch you add.

Almost every parameter moves more than one goal, directly or indirectly. A smaller prefill chunk buys TTFT and costs
prefill throughput; a higher graph batch cap buys throughput and costs memory. So no goal can list every parameter
that acts on it: each list below is a starting point, not a closed set. Expect a change made for one goal to move the
others, and expect knobs listed under one goal to move another.

For a target held under a budget on another metric — output throughput within a TPOT cap, say — sweep the knob that
sets the budget first, pin it where the constrained metric sits just inside its bound, and only then sweep the
maximizing knob.

### Lower decode latency (TPOT)

On MLA and DeepSeek-style MoE models, enable the MLAPO and multistream-MoE switches from the
[batch checklist](#batch-checklist) first; the knobs below come after them.

1. [Speculative decoding](#speculative-decoding-and-quantization) (`--speculative-num-steps`,
   `--speculative-num-draft-tokens`) — one target forward verifies several draft tokens. Watch the
   `accept len:` / `accept rate:` fields: acceptance drifts with output content, and at very high concurrency the
   verification overhead can cost throughput instead.
2. [`--cuda-graph-max-bs-decode`](#batching-graphs-and-memory) — remove kernel-launch overhead.
3. [`--attn-dp-size`](#parallelism) — more independent decode instances.
4. [`SGLANG_SCHEDULER_SKIP_ALL_GATHER=1`](#parallelism) — further reduction, only with balanced DP load.
5. [`--enable-prefill-delayer`](#batching-graphs-and-memory) — on mixed workloads with attention DP, bounded prefill
   delays keep decode fed when it would otherwise stall behind prefill bursts (it pays TTFT for TPOT).

**Cross-goal.** The delayer pays TTFT, a higher graph cap costs memory, and verification spends compute that high
concurrency cannot repay — the [TTFT](#lower-time-to-first-token-ttft), [OOM](#resolve-out-of-memory-errors), and
[throughput](#higher-throughput) goals read these knobs from the other side.

### Higher throughput

1. [`--attn-dp-size`](#parallelism) — more independent decode instances.
2. [`--max-running-requests`](#batching-graphs-and-memory) — more concurrent requests per node.
3. [`--tokenizer-worker-num`](#model-specific-switches-and-host) — parallelize tokenization across worker processes.
4. [`--mem-fraction-static`](#batching-graphs-and-memory) — more KV cache, while monitoring for out-of-memory errors.

Check the load supply before sizing server-side knobs. Client concurrency, `--max-running-requests`, and the batch the
server actually forms are three different numbers: requests above the capacity cap only queue, and the effective batch
is what the `Decode batch` lines report per rank. Sweep client concurrency against a fixed server configuration first;
once the server saturates, more concurrency buys queueing and TTFT, not throughput.

**Cross-goal.** More concurrency raises TPOT, and the memory fraction that buys KV is the same budget the
[OOM](#resolve-out-of-memory-errors) goal spends.

### Lower time to first token (TTFT)

1. [`--chunked-prefill-size`](#batching-graphs-and-memory) on mixed workloads — short requests are not delayed behind a
   single long prefill.
2. Prefix caching — leave [`--disable-radix-cache`](#batching-graphs-and-memory) unset, so shared prompt prefixes reuse KV.
3. [`--attn-cp-size`](#parallelism) for long inputs — one sequence split across devices.

**Cross-goal.** A smaller chunk interleaves more fairly but lowers prefill throughput, and context parallelism adds
inter-device traffic — the [throughput](#higher-throughput) and [TPOT](#lower-decode-latency-tpot) goals read the same
knobs from the other side.

### Resolve out-of-memory errors

Decide first whether the hardware can hold the model at all: get the checkpoint's total size from its download page,
or run `du -sh` on the weights directory, and compare it against your total device memory. If the cards and machines
should hold the weights with room to spare, the shortage is in the memory budget rather than the hardware.

1. Lower [`--mem-fraction-static`](#batching-graphs-and-memory) — leave room for activations and graph buffers, at less KV
   cache and fewer concurrent requests.
2. Add [`expandable_segments:True`](#batching-graphs-and-memory) — mitigates the allocator fragmentation that drives
   out-of-memory errors on MoE-scale models.
3. Load a [`--quantization modelslim`](#speculative-decoding-and-quantization) checkpoint — W8/W4 weights cut weight memory by approximately
   50%/75%, at a small accuracy loss.
4. Scale out — a wider [`--tp-size`](#parallelism) or [`--ep-size`](#parallelism).

If startup instead fails with `Not enough memory … increase --mem-fraction-static`, the KV pool is too small: see
[Troubleshooting](#troubleshooting).

**Cross-goal.** KV headroom is taken from concurrency, quantization from accuracy, and a wider TP from all-reduce
bandwidth — every fix here is a cost booked under another goal.

### Serve long contexts

1. [`--enable-prefill-cp`](#parallelism) + [`--attn-cp-size`](#parallelism) +
   [`--cp-strategy`](#parallelism) — shard one sequence's KV and attention across devices.
2. [`--max-prefill-tokens`](#batching-graphs-and-memory) — let concurrent long requests co-batch in one forward.
3. [`--chunked-prefill-size -1`](#batching-graphs-and-memory) on a dedicated prefill group — the entire sequence prefilled
   in one pass.

**Cross-goal.** Context parallelism adds inter-device traffic, and an unchunked prefill keeps decode waiting wherever
the two share a node — long-context settings are the most likely to shift [TPOT](#lower-decode-latency-tpot).

### From an observed symptom

The goals above start from what you want; this table starts from what you see on a running deployment. Utilization
and communication shares come from [Profiling](https://docs.sglang.io/docs/hardware-platforms/ascend-npus/optimization/profiling.md); batch
numbers come from the recurring `Decode batch` log line — `#running-req:` per rank, or `sglang:num_running_reqs` on
`/metrics`. Because the goals are coupled, a symptom usually points at a knob filed under a different goal — follow
the row, not the section.

| Observation | Inspect first |
| - | - |
| Batches smaller than expected, devices underutilized | Client concurrency (the benchmark's load supply), [`--max-running-requests`](#batching-graphs-and-memory), admission gating ([`--min-free-slots-delay`](#batching-graphs-and-memory)) |
| Long decode stalls adjacent to prefills | [`--chunked-prefill-size`](#batching-graphs-and-memory), admission timing ([`--enable-prefill-delayer`](#batching-graphs-and-memory), [`--min-free-slots-delay`](#batching-graphs-and-memory)) |
| Ranks unevenly busy | [`--load-balance-method`](#parallelism), the [Parallelism](#parallelism) rows, prefix-cache distribution across DP ranks |
| Communication dominates while operators run small | Parallel granularity: [`--tp-size`](#parallelism), [`--moe-dense-tp-size`](#parallelism), [`--enable-dp-lm-head`](#parallelism) — confirm with a profile first |
| Long inputs run out of memory | The KV budget, temporary activation space, and graph capture range — see [Resolve out-of-memory errors](#resolve-out-of-memory-errors) |
| Throughput improved but TTFT worsened | Queueing and admission delay — the trade-off the change was expected to pay. Re-read the row of the knob you moved. |

### Tune a PD-disaggregated or multi-node deployment

PD disaggregation itself is a deployment decision rather than a knob: the role flags, the KV-transfer backend, the
rendezvous store, the bootstrap port, and the router belong to setup, and the per-model best-practice page owns them
(for DeepSeek V3.2, see the
[best-practice page](https://docs.sglang.io/docs/hardware-platforms/ascend-npus/model-deployment/best-practices/deepseek_v3_2.md)). Under
disaggregation every row of [Parameter Reference](#parameter-reference) can take a different value per role; the
published V3.2 configuration splits them like this:

| Knob | Prefill role | Decode role |
| - | - | - |
| [`--mem-fraction-static`](#batching-graphs-and-memory) | `0.73` | `0.79` |
| [`TASK_QUEUE_ENABLE`](#batching-graphs-and-memory) | `2` (level 2 fails under graph capture, and this role captures none) | `0` |
| [`--deepep-mode`](#moe-dispatch-and-communication) | `normal` | `low_latency` |
| [`DEEPEP_HCCL_BUFFSIZE`](#moe-dispatch-and-communication) | `1200` | `400` |
| [`SGLANG_DEEPEP_NUM_MAX_DISPATCH_TOKENS_PER_RANK`](#moe-dispatch-and-communication) | — | `8` |
| [`--deepep-dispatcher-output-dtype`](#moe-dispatch-and-communication) | `int8` | — |
| [`--speculative-num-steps`](#speculative-decoding-and-quantization) / [`--speculative-num-draft-tokens`](#speculative-decoding-and-quantization) | `1` / `2` | `3` / `4` |
| NPU Graph capture | off (prefill graphs are off by default) | [`--cuda-graph-max-bs-decode 4`](#batching-graphs-and-memory) |
| [`--attn-dp-size`](#parallelism) + [`--enable-dp-lm-head`](#parallelism) | — | `8` + on |
| [`--moe-dense-tp-size`](#parallelism) | `1` (with `cp = tp`, attention is no longer TP-sharded, so the dense FFN can stay unsharded too) | `1` (each DP group already holds the full dense weights) |
| Prefill CP ([`--enable-prefill-cp`](#parallelism), [`--attn-cp-size`](#parallelism), [`--cp-strategy`](#parallelism)) | on (`32`, `interleave`) | — |
| [`--chunked-prefill-size`](#batching-graphs-and-memory) / [`--max-prefill-tokens`](#batching-graphs-and-memory) / [`--max-running-requests`](#batching-graphs-and-memory) | `-1` / `68000` / `1` | — / — / `32` |
| [`--disable-radix-cache`](#batching-graphs-and-memory) | on (random-input benchmark traffic) | on (redundant: PD decode disables prefix caching anyway) |

The roles differ because their workloads differ: prefill is throughput-bound on large token counts (bulk dispatch
buffers, un-chunked batches, no graphs worth capturing), while decode is latency-bound (small graph-captured batches,
the low-latency dispatch path, deeper speculation). Both roles load the same ModelSlim W8A8 checkpoint; only the budget
each leaves for KV cache differs, which is why their memory fractions differ. Decode also sets
`SGLANG_ENABLE_OVERLAP_PLAN_STREAM=1` and `SGLANG_SCHEDULER_SKIP_ALL_GATHER=1`, whose preconditions are in their rows.

Roles also differ in knobs this configuration does not set: published prefill roles tune the DeepEP long-sequence
dispatch pipeline and shrink `HCCL_BUFFSIZE` (see [MoE dispatch and communication](#moe-dispatch-and-communication)), and
several models add [`--enable-prefill-delayer`](#batching-graphs-and-memory) — those rows carry the per-role values.

For a multi-node deployment that is not disaggregated, the extra knobs are the communication ones —
[`DEEPEP_HCCL_BUFFSIZE`](#moe-dispatch-and-communication) and INT8 dispatch on prefill
([`--deepep-dispatcher-output-dtype`](#moe-dispatch-and-communication)).

## Feature Compatibility

Check a combination here before you launch it. This table lists feature-to-feature interactions: pairs where enabling
one feature changes what another can do. **Blocked** means it fails at startup, hangs, or silently produces wrong
results. Preconditions tied to a single knob — graph capture versus the task-queue level, or the graph batch-size
alignment — are stated with that knob's row, and absence from this table means no known conflict, not a guarantee.
For per-flag support status, see [Supported Features](https://docs.sglang.io/docs/hardware-platforms/ascend-npus/reference/support_features.md).

| Combination | Status | Consequence and fix |
| - | - | - |
| [Attention DP](#parallelism) + `--dp-size` greater than 1 | Blocked | Model replicas cannot be combined with attention DP, and `--dp-size` greater than 1 is single-node only. |
| [EPLB](#moe-dispatch-and-communication) + `ascend_fuseep` backend | Blocked | EPLB requires `deepep`. There is no startup guard, so a wrong backend fails silently. |
| [EPLB](#moe-dispatch-and-communication) + topology where TP, EP, and world size are not all equal | Blocked | Migration raises `NPU EPLB migration requires TP size = EP size = WORLD size.` |
| [HCCL expansion mode](#moe-dispatch-and-communication) + `HCCL_OP_EXPANSION_MODE=AIV` on Atlas A2 systems with DeepEP | Blocked | Vendor docs report unknown-operator errors; leave it unset on that combination. |
| LoRA + [`SGLANG_ENABLE_OVERLAP_PLAN_STREAM=1`](#speculative-decoding-and-quantization) | Blocked | The speculative plan stream is incompatible with LoRA under any LoRA-compatible speculative algorithm (EAGLE/NEXTN/EAGLE3, DFLASH, DSPARK). |

## Troubleshooting

| Symptom | Likely Cause | Fix |
| - | - | - |
| Startup fails with `Not enough memory. Please try to increase --mem-fraction-static.` | The KV pool computed to zero (or negative) capacity once weights were loaded | Raise [`--mem-fraction-static`](#batching-graphs-and-memory) in small steps. If the weights alone consume the budget (BF16), the hardware is the limit — scale out or load a ModelSlim checkpoint |
| Out of memory during serving or graph capture | `--mem-fraction-static` leaves no headroom for activations or graph buffers, or the weights are BF16 | Lower [`--mem-fraction-static`](#batching-graphs-and-memory). If the model is BF16, the hardware is the limit — load a ModelSlim W8A8/W4A4 checkpoint, or scale out (see [Quantization on Ascend](https://docs.sglang.io/docs/hardware-platforms/ascend-npus/optimization/quantization.md) to quantize your own) |
| NPU Graph capture aborts with `Do not support TASK_QUEUE_ENABLE = 2 during NPU graph capture` | Level-2 task queue is incompatible with graph capture | Set [`TASK_QUEUE_ENABLE`](#batching-graphs-and-memory)=`0` (or `1`) on the role that captures graphs |
| NPU Graph capture aborts with an `AssertionError` whose message is `capture_bs=[]` | Every decode bucket missed the batch-size alignment, so the capture list is empty | Raise [`--cuda-graph-max-bs-decode`](#batching-graphs-and-memory) to at least the alignment and to a multiple of it, or narrow the alignment by removing attention DP or the MoE all-to-all backend — see [Graph batch-size alignment](#graph-batch-size-alignment) |
| DeepEP dispatch fails at runtime | Per-rank dispatch tokens exceed the buffer | Size [`SGLANG_DEEPEP_NUM_MAX_DISPATCH_TOKENS_PER_RANK`](#moe-dispatch-and-communication) to the actual per-iteration maximum — see [Sizing the DeepEP dispatch buffer](#sizing-the-deepep-dispatch-buffer) |
| Intermittent pinned host memory allocation failures | Pinned host pool fragmentation | Append `pin_memory_expandable_segments:True` to [`PYTORCH_NPU_ALLOC_CONF`](#batching-graphs-and-memory) — see its row for the CANN and driver requirement |
| Expert hotspots or uneven load across NPUs | Static expert placement | Measure the imbalance with `--expert-balancedness-report-mode server_log` (or `prometheus`), or record the raw per-expert distribution with `--expert-distribution-recorder-mode` plus the `/start_expert_distribution_record` / `/dump_expert_distribution_record` endpoints; then enable [`--enable-eplb`](#moe-dispatch-and-communication). It requires the `deepep` backend and `TP = EP = world size`, and `--ep-num-redundant-experts` adds actual replication |
| Startup fails with `--cp-strategy must be set when --enable-prefill-cp is enabled.` | Prefill CP enabled without a strategy | Add [`--cp-strategy`](#parallelism) `interleave` for DeepSeek V3.2, or `zigzag` for MiMo V2 |
| A benchmarked change moved nothing | The flag did not take effect on this build, the target path stayed off, or the difference is inside the benchmark's noise floor | Confirm the change in the startup log (the launch echoes the resolved arguments, and feature switches log their own enable lines), confirm the path actually engaged (for speculative decoding, the `accept len:` field), and compare against the noise floor measured per [How to Tune](#how-to-tune) |

## See Also

* [Performance Testing](https://docs.sglang.io/docs/hardware-platforms/ascend-npus/evaluation/performance_testing.md) — Benchmark commands
  (bench\_serving, Evalscope, AISBench) and how to read TTFT/TPOT
* [Accuracy Evaluation](https://docs.sglang.io/docs/hardware-platforms/ascend-npus/evaluation/accuracy_evaluation.md) — Validate output quality
  after quantization or speculative decoding
* [Profiling](https://docs.sglang.io/docs/hardware-platforms/ascend-npus/optimization/profiling.md) — Find kernel-level bottlenecks
* [Ascend NPU Environment Variables](https://docs.sglang.io/docs/hardware-platforms/ascend-npus/reference/environment_variables.md) — Reference
  for all Ascend NPU-related environment variables
* **Best Practices** (sidebar section) — One validated configuration with benchmarks per model
* **Model Tutorials** (sidebar section) — Step-by-step deployment guides per model
* [Glossary](https://docs.sglang.io/docs/hardware-platforms/ascend-npus/reference/glossary.md) — Ascend hardware and feature terminology
* [Supported Models](https://docs.sglang.io/docs/hardware-platforms/ascend-npus/reference/support_models.md) — Model families and hardware
  support
* [Supported Features](https://docs.sglang.io/docs/hardware-platforms/ascend-npus/reference/support_features.md) — Per-flag defaults and support
  status


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.