Skip to content

vLLM-Ascend for RL

Overview

vLLM is commonly used as the rollout engine in reinforcement learning (RL) and post-training workflows. A training framework generates samples with vLLM-Ascend, updates the policy from those samples, and then synchronizes the new weights back to the rollout engine. See the upstream vLLM RLHF guide for integrations with RL frameworks.

RL workloads commonly need the following capabilities:

  • release NPU memory while a colocated trainer is running;
  • update model weights without restarting the rollout engine;
  • pause generation while weights are being updated;
  • return token log probabilities and, for supported MoE workflows, expert routing decisions;
  • accept and return token IDs without redundant tokenization; and
  • produce reproducible results across different batch compositions.

This page describes how these features fit together on Ascend. Follow the linked feature guides and examples for complete configuration details.

Enable RL mode

vLLM-Ascend provides a unified RL configuration under additional_config.rl_config. Set its enabled field to true for both same-NPU and cross-NPU deployments:

vllm serve Qwen/Qwen3-0.6B \
    --additional-config '{"rl_config": {"enabled": true}}'

The master switch applies the common RL defaults: it disables FRACTAL_NZ, enables the development endpoints, and removes expandable_segments from PYTORCH_NPU_ALLOC_CONF. The optional fields are:

Field When to enable it
sleep_mode_extra_cleanup Release HCCL process groups and ACL graph workspaces during sleep in a same-NPU deployment
enable_training_consistency Select the FA3 attention backend for training-inference consistency
enable_batch_invariant Enable batch-invariant kernels and deterministic communication settings

All optional fields default to false and are ignored unless enabled is true. See Additional Configuration for field definitions, prerequisites, and migration from legacy settings.

Choose a deployment mode

Deployment mode Memory management Weight transfer backend
Trainer and rollout engine share NPUs Enable sleep mode so the rollout engine can release NPU memory ipc
Trainer and rollout engine use different NPUs Pause generation during the update; sleep mode is normally unnecessary hccl

The exact lifecycle is framework-dependent. In particular, level 2 sleep discards the weights. Wake the weights allocation before loading or transferring new weights, then wake kv_cache after the update. See Sleep Mode for the two-phase wake-up sequence.

Engine lifecycle

Sleep mode

Sleep mode lets a colocated rollout engine release NPU memory without exiting. Level 1 offloads model weights to CPU and discards the KV cache. Level 2 discards both model weights and KV cache and is appropriate when new weights will be loaded before inference resumes.

For online control, enable the development endpoints and start the server with sleep mode enabled:

VLLM_WORKER_MULTIPROC_METHOD=spawn \
vllm serve Qwen/Qwen3-0.6B \
    --enable-sleep-mode \
    --additional-config '{"rl_config": {"enabled": true}}'

The sleep level is a query parameter; a JSON request body is ignored:

# Release memory.
curl -X POST "http://127.0.0.1:8000/sleep?level=1"
curl http://127.0.0.1:8000/is_sleeping

# Restore all tagged allocations.
curl -X POST http://127.0.0.1:8000/wake_up

For level 2 sleep, wake the tags in the order documented in Sleep Mode:

curl -X POST "http://127.0.0.1:8000/sleep?level=2"
curl -X POST "http://127.0.0.1:8000/wake_up?tags=weights"
# Load or transfer the new weights here.
curl -X POST "http://127.0.0.1:8000/wake_up?tags=kv_cache"

To release HCCL process groups and ACL graph workspaces as well, enable extra cleanup:

VLLM_WORKER_MULTIPROC_METHOD=spawn \
vllm serve Qwen/Qwen3-0.6B \
    --enable-sleep-mode \
    --additional-config '{"rl_config": {"enabled": true, "sleep_mode_extra_cleanup": true}}'

Extra cleanup reduces sleep-time NPU memory use, but HCCL groups must be restored and ACL graphs must be recaptured during wake-up. RL mode removes expandable_segments from PYTORCH_NPU_ALLOC_CONF because it is incompatible with the sleep-mode memory pool. The former top-level enable_sleep_mode_extra_cleanup option has been removed.

Weight transfer

vLLM-Ascend exposes the following Ascend-specific weight-transfer backends:

Backend Use case Transport
ipc Trainer and rollout engine use the same physical NPU NPU IPC handles
hccl Trainer and rollout engine use separate NPUs HCCL collectives
sparse_hccl Replace selected checkpoint weight values on separate NPUs HCCL collectives

The table describes transport choices. Sparse transfer requires the trainer and rollout engine to start from the same checkpoint.

Start an HCCL-enabled server with:

vllm serve Qwen/Qwen3-0.6B \
    --weight-transfer-config '{"backend": "hccl"}' \
    --additional-config '{"rl_config": {"enabled": true}}'

For same-NPU transfer, use the ipc backend. On Ascend, vLLM-Ascend maps this user-facing backend name to NPUIPCWeightTransferEngine:

VLLM_ALLOW_INSECURE_SERIALIZATION=1 \
vllm serve Qwen/Qwen3-0.6B \
    --weight-transfer-config '{"backend": "ipc"}' \
    --additional-config '{"rl_config": {"enabled": true}}'

VLLM_ALLOW_INSECURE_SERIALIZATION=1 is required by the HTTP NPU IPC example because it serializes IPC handles. Only enable it in a trusted environment.

The control flow is:

  1. initialize the transfer engine;
  2. pause generation;
  3. start the weight update;
  4. transfer one or more groups of weights;
  5. finish the weight update;
  6. resume generation.

The repository contains runnable examples for weight transfer:

Weight updates require weight_nz_mode=0. RL mode applies this setting automatically. For direct reload of MoE models, set enable_fused_mc2=0. Use layerwise reload with fused MC2 or MegaMoE.

Direct weight reload

Use the vLLM main revision in .github/vllm-main-verified.commit and set VLLM_RELOAD_MODE=direct before starting the rollout server to reload unquantized BF16 Qwen weights in place. The default is layerwise. Direct reload preserves the weight addresses used by captured decode graphs, so the server can replay those graphs after a successful update.

VLLM_RELOAD_MODE=direct \
vllm serve Qwen/Qwen3-0.6B \
    --dtype bfloat16 \
    --weight-transfer-config '{"backend": "hccl"}' \
    --additional-config '{"rl_config": {"enabled": true}}'

For an online transfer, pause generation and send the full checkpoint using the transfer lifecycle above.

For a disk reload, start the server on localhost with VLLM_SERVER_DEV_MODE=1 to enable the /collective_rpc endpoint.

VLLM_SERVER_DEV_MODE=1 VLLM_RELOAD_MODE=direct \
vllm serve Qwen/Qwen3-0.6B \
    --host 127.0.0.1 \
    --dtype bfloat16 \
    --additional-config '{"rl_config": {"enabled": true}}'

Pause generation, then call reload_weights on every worker. The checkpoint must have the same model architecture and weight layout and be readable by all workers.

curl -fsS -X POST http://127.0.0.1:8000/collective_rpc \
    -H 'Content-Type: application/json' \
    -d '{"method":"reload_weights","kwargs":{"weights_path":"/path/to/updated-checkpoint","is_checkpoint_format":true}}'

Resume generation after the update succeeds. If an update fails after some weights have been replaced, keep generation paused and restore a complete checkpoint before serving requests.

For packed IPC on shared NPUs, size the trainer's packed_buffer_size_bytes to fit the largest checkpoint tensor. Leave additional NPU memory for the trainer to stage an input tensor. If memory is tight, use unpacked IPC or move the trainer to a separate NPU and use HCCL.

Sparse HCCL

For sparse checkpoint updates, follow the upstream Sparse NCCL guide for patch semantics and the update lifecycle. On Ascend, select sparse_hccl and enable RL mode:

vllm serve /path/to/checkpoint \
    --weight-transfer-config '{"backend": "sparse_hccl"}' \
    --additional-config '{"rl_config": {"enabled": true}}'

Run rlhf_sparse_hccl.py to initialize the trainer and send sparse checkpoint updates. Its TP2 launch commands explicitly enable expert parallelism. Reserve a separate NPU for the trainer; the transfer group size is 1 + TP * DP, with no additional EP factor. Pipeline parallelism is currently unsupported.

Sparse HCCL requires unquantized ND weights and static expert placement with EPLB disabled. FRACTAL_NZ, fused MC2 expert weight lists, draft models, and packed sparse updates are unsupported. Updates apply in place: after a failed update, keep generation paused until the baseline is restored or the engine restarts.

Speculative draft weight updates

Target and draft weights are updated in separate sessions. The current draft weight-update support is:

Transfer backend Deployment Draft weight updates NZ mode
hccl Trainer and rollout server use separate NPUs Supported; E2E coverage for MTP, EAGLE3, DFlash and DSpark Unsupported
NPU IPC (ipc in server configuration) Trainer and rollout server share NPUs Not validated Unsupported

Draft updates require --pipeline-parallel-size 1 and weight_nz_mode=0. RL mode disables NZ automatically. Use HCCL for the workflow below.

Start an HCCL-enabled server with compatible target and draft checkpoints:

ASCEND_RT_VISIBLE_DEVICES=0 VLLM_WORKER_MULTIPROC_METHOD=spawn \
vllm serve /path/to/target-checkpoint \
    --speculative-config '{"method": "eagle3", "model": "/path/to/eagle3-draft-checkpoint", "num_speculative_tokens": 2}' \
    --pipeline-parallel-size 1 \
    --weight-transfer-config '{"backend": "hccl"}' \
    --additional-config '{"rl_config": {"enabled": true}}'

Replace the method and draft checkpoint with a compatible mtp, eagle3, dflash or dspark configuration. Reserve a separate NPU for the trainer.

The control flow is:

  1. initialize the HCCL transfer engine;
  2. pause generation;
  3. start the draft weight update;
  4. transfer the draft weights;
  5. finish the weight update;
  6. resume generation only after success.

After a failed update, keep generation paused and restart the affected workers with complete, known-good checkpoints before resuming.

The repository contains runnable tests for draft weight transfer:

Pause and resume generation

With rl_config.enabled=true, the server exposes /pause and /resume. These are development endpoints and must not be exposed to untrusted networks. Pause parameters are query parameters:

# Drain in-flight requests and clear caches before the update.
curl -X POST \
    "http://127.0.0.1:8000/pause?mode=wait&clear_cache=true"

# Transfer weights here.

curl -X POST http://127.0.0.1:8000/resume

The pause modes are:

Mode Behavior
abort Abort in-flight requests immediately; this is the default
wait Wait for in-flight requests to complete before pausing
keep Freeze requests so they continue after /resume

clear_cache is deprecated and is ignored for mode=keep. A kept request can therefore contain tokens and KV-cache entries produced with the old weights and continue with the new weights after resume. Use abort or wait when a rollout must not span weight versions.

See the upstream Async RL guide for the API lifecycle.

Weight checker

The Weight Checker helps validate the weight-transfer path during development. It computes SHA-256 digests for model parameters on each rank, resets the parameters, and checks whether transferring the original weights back restores the same digests. See the upstream Weight Checker guide for the full API.

All three operations use POST /weight_checker:

Action Purpose Request body Response
checksum Compute the current digest of each checked parameter without changing it. Save the result as the baseline before resetting weights. {"action":"checksum"} {"checksums": {key: sha256_hex}}
reset Zero the checked parameters to test the transfer path. The model cannot serve valid requests until its weights are restored. {"action":"reset"} {"status":"reset"}
compare Compute current digests and compare them with the baseline supplied by the caller. {"action":"compare","baseline":{key: sha256_hex}} {"match":bool,"mismatches":[key]}

A checksum key has the form dp{dp}:pp{pp}:pcp{pcp}:tp{tp}:{tensor_name}, so each shard is checked separately. Expert-parallel ranks are identified by their DP/PCP/TP coordinates; there is no separate ep field. The server does not retain the baseline between requests: save the checksum response and pass its checksums object to compare.

The standard check transfers the same original weights after reset and expects compare to report a full match. An old baseline should not match weights changed by a real training step. This procedure validates the weight-transfer path, not the correctness of newly trained weights.

Example

Use an installed vLLM-Ascend environment with compatible vLLM, CANN and TorchNPU, including the compiled Ascend custom operators. The paired vLLM must provide the Weight Checker API and the weight-transfer trainer API used below. Use the dependency versions selected by your vLLM-Ascend checkout; changing only PYTHONPATH does not install its custom operators.

This example needs two available NPUs, curl, jq, and the full Qwen/Qwen3-0.6B checkpoint. The server and trainer must resolve the same checkpoint revision. Device IDs 0 and 1 below are examples; replace them consistently with two available physical devices. Do not use dummy weights or change the model's layer count for this checkpoint round trip.

In terminal 1, start the server on physical NPU 0 and wait until curl -fsS http://127.0.0.1:8000/health succeeds:

ASCEND_RT_VISIBLE_DEVICES=0 VLLM_SERVER_DEV_MODE=1 \
vllm serve Qwen/Qwen3-0.6B \
    --weight-transfer-config '{"backend": "hccl"}' \
    --additional-config '{"rl_config": {"enabled": true}}'

In terminal 2, save the following as weight_checker_trainer.py. It uses the same trainer API as rlhf_http_hccl.py, but waits for the reset and leaves generation paused after the transfer. Do not run that standalone example in the middle of this procedure: it requests generation before the transfer and resumes before checksum comparison.

import torch
import torch_npu  # noqa: F401
from transformers import AutoModelForCausalLM
from vllm.distributed.weight_transfer.base import ModuleSource
from vllm.distributed.weight_transfer.clients import HTTPVLLMWeightSyncClient
from vllm.distributed.weight_transfer.factory import WeightTransferTrainerFactory
from vllm.utils.network_utils import get_ip, get_open_port

from vllm_ascend.distributed.weight_transfer import register_engine
from vllm_ascend.distributed.weight_transfer.hccl_engine import HCCLTrainerInitInfo


def main():
    # Both devices are visible here: logical NPU 1 is the trainer's device.
    torch.accelerator.set_device_index("npu:1")
    model = AutoModelForCausalLM.from_pretrained(
        "Qwen/Qwen3-0.6B", dtype=torch.bfloat16
    ).to("npu:1")
    max_tensor_bytes = max(p.numel() * p.element_size() for p in model.parameters())
    register_engine()
    engine = WeightTransferTrainerFactory.trainer_init(
        HCCLTrainerInitInfo(
            rank=0,
            master_address=get_ip(),
            master_port=get_open_port(),
            world_size=2,  # One trainer and one inference worker.
            packed=True,
            packed_buffer_size_bytes=max(max_tensor_bytes + 128 * 2**20, 2**30),
        ),
        client=HTTPVLLMWeightSyncClient(base_url="http://127.0.0.1:8000"),
        source=ModuleSource(model),
    )
    try:
        input(
            "Trainer ready. Complete pause/checksum/reset in terminal 3, "
            "then press Enter here to restore the original weights: "
        )
        # Owns START -> transfer -> FINISH, including worker RPCs.
        engine.send_weights()
        print("Transfer complete. Keep generation paused and compare in terminal 3.")
    finally:
        engine.shutdown()


if __name__ == "__main__":
    main()

Run it with both devices visible, and wait for the Trainer ready prompt before resetting the server. Leave this terminal waiting at the prompt:

ASCEND_RT_VISIBLE_DEVICES=0,1 python weight_checker_trainer.py

In terminal 3, pause generation and save the original checksums:

URL=http://127.0.0.1:8000

curl -fsS -X POST "$URL/pause?mode=abort"
curl -fsS -X POST "$URL/weight_checker" \
    -H 'Content-Type: application/json' \
    -d '{"action":"checksum"}' > baseline.json

jq -e '.checksums | length > 0' baseline.json

The final command should print true. baseline.json contains the actual parameter names and SHA-256 digests. Its response has this shape (the values below are placeholders):

{
  "checksums": {
    "dp0:pp0:pcp0:tp0:<parameter_name>": "<SHA-256 hex digest>"
  }
}

Reset the weights while generation remains paused:

curl -fsS -X POST "$URL/weight_checker" \
    -H 'Content-Type: application/json' \
    -d '{"action":"reset"}'

Expected response:

{"status":"reset"}

Before restoring the weights, verify that comparison detects the reset. Save a reusable comparison request so that the same baseline is used for both checks:

jq '{action: "compare", baseline: .checksums}' baseline.json > compare-request.json
curl -fsS -X POST "$URL/weight_checker" \
    -H 'Content-Type: application/json' \
    --data-binary @compare-request.json > after-reset.json
jq -e '.match == false and (.mismatches | length > 0)' after-reset.json

The final command should print true. Now press Enter in terminal 2 to transfer the original checkpoint weights, and wait for Transfer complete and a successful trainer exit. This step must not perform a training update or resume generation.

Back in terminal 3, compare the restored weights with the saved baseline:

curl -fsS -X POST "$URL/weight_checker" \
    -H 'Content-Type: application/json' \
    --data-binary @compare-request.json > after-restore.json
cat after-restore.json

Expected response after a successful restore:

{"match":true,"mismatches":[]}

If match is false, inspect mismatches and restore the weights before serving requests. Resume generation only after a full match:

jq -e '.match == true and (.mismatches | length == 0)' after-restore.json && \
    curl -fsS -X POST "$URL/resume"

Finally, verify that generation works again:

curl -fsS "$URL/v1/completions" \
    -H 'Content-Type: application/json' \
    -d '{"model":"Qwen/Qwen3-0.6B","prompt":"The capital of France is","max_tokens":16,"temperature":0}'

Automated checks

Run these commands from the repository root in the installed environment:

bash format.sh ci
python -m pytest -q \
    tests/ut/worker/test_worker_weight_checker.py \
    tests/ut/distributed/weight_transfer/test_hccl_engine.py
ASCEND_RT_VISIBLE_DEVICES=0,1 VLLM_RL_TEST_DEVICE_INDEX=0 \
python -m pytest -sv -ra \
    tests/e2e/pull_request/two_card/rlhf/state_transitions/test_weight_checker.py

The unit tests cover worker integration and mocked HCCL behavior. The E2E suite needs two NPUs and the full Qwen/Qwen3-0.6B checkpoint. It covers checksum/reset/reload, packed and unpacked IPC/HCCL transfers, and TP=2/DP=2 rank coverage. Its shared helpers live under tests/e2e/common/rlhf/. VLLM_RL_TEST_DEVICE_INDEX is a logical index into the visible device list; the trainer uses the next device. Check the pytest summary for skipped cases before claiming the full suite passed.

Basic and TP/DP checksum cases use eager mode. Transfer cases use the shared RLHF helper's FULL_DECODE_ONLY configuration with capture size 1. Other graph configurations require separate validation.

Operational constraints

  • Stay paused from checksum through compare. Weights are invalid between reset and the transfer, and EPLB may move experts while serving. The worker methods do not enforce the pause; the caller must do so.
  • Before reset, confirm that a recovery path is available: a working weight-transfer configuration or a checkpoint that reload_weights can restore. In RL mode, rl_config.enabled=true disables FRACTAL_NZ by setting weight_nz_mode=0. In a non-RL deployment where weight_nz_mode remains enabled, the weight-update transaction cannot start; checkpoint reload may be needed to recover after reset.
  • If the transfer or comparison fails, keep generation paused and restore the weights before resuming. The engine must be awake: sleep levels 1 and 2 release weight memory.
  • reset is a destructive development operation. Keep development endpoints within a trusted access boundary and do not expose them to the public internet.

Limitations

In addition to the upstream limitations:

  • Weights held as buffers rather than parameters, such as some quantization repacking paths, are invisible to the checker.
  • MoE weights padded beyond the checkpoint shape may report false mismatches; validate the behavior with the target model before relying on compare.
  • Ascend 310P has not yet been verified with the Weight Checker.

Training data returned by the engine

Token log probabilities

Set logprobs and, when needed, prompt_logprobs on the completions request:

curl http://127.0.0.1:8000/v1/completions \
    -H "Content-Type: application/json" \
    -d '{
        "model": "Qwen/Qwen3-0.6B",
        "prompt": "Your prompt here",
        "max_tokens": 32,
        "temperature": 1.0,
        "logprobs": 1,
        "prompt_logprobs": 1
    }'

prompt_logprobs is not available for streaming completion requests. See the upstream Sampling Parameters documentation for the corresponding engine-level options.

Router Replay (R3)

For supported MoE workflows, start the server with routed-expert capture:

vllm serve Qwen/Qwen3-30B-A3B --enable-return-routed-experts

For a non-streaming completion response, choices[].routed_experts is a base64-encoded NumPy array, not an inline tensor. After decoding, its shape is (num_tokens - 1, num_layers, num_experts_per_tok). The final sampled token has no routing record because it has not passed through the model yet. The field is null when capture is disabled or the request is aborted before a forward pass.

Enable this option only when the trainer consumes and replays the captured expert choices. See the upstream routed experts example for decoding and replay logic.

Sampling Mask (Distribution Replay)

During RL rollout inference, top-k/top-p/min-p sampling truncates the model's distribution. Sampling Mask returns the retained token IDs for each generated position, so training can normalize policy probabilities over the same support used during rollout. See the upstream Sampling Mask (Distribution Replay) guide for training-side usage.

--return-sampling-mask enables the feature and is disabled by default. --logprobs-mode processed_logprobs is required. The following example also uses --tokens-only to expose the token-in/token-out API and skip tokenizer initialization. Use --enable-scale-out instead to expose the same endpoint while retaining the normal serving setup and tokenizer. See Tokens in, tokens out for serving details.

vllm serve Qwen/Qwen3-0.6B \
    --tokens-only \
    --return-sampling-mask \
    --logprobs-mode processed_logprobs

With sampling-mask capture enabled, requests must use temperature > 0 and top_k > 0. Send pre-tokenized input to /inference/v1/generate:

curl -sS -X POST http://127.0.0.1:8000/inference/v1/generate \
    -H 'Content-Type: application/json' \
    -d '{
        "token_ids": [785, 6722, 315, 9625, 374],
        "sampling_params": {
            "temperature": 1.0,
            "top_k": 20,
            "top_p": 0.95,
            "max_tokens": 2,
            "logprobs": 1
        },
        "output_mode": "tokens",
        "stream": false
    }'

Each choice returns one support set per generated token. The following tested Qwen3-0.6B response excerpt omits metadata, ranks, and top_logprobs:

{
  "finish_reason": "length",
  "token_ids": [12095, 11],
  "sampling_mask": [
    [220, 264, 279, 304, 320, 510, 1112, 1181, 1304, 2130,
     2598, 7407, 7436, 9625, 12095, 21718, 24209, 30743, 32671, 55201],
    [11, 13, 323, 382]
  ],
  "logprobs": {
    "content": [
      {"token_id": 12095, "logprob": -0.2592906951904297},
      {"token_id": 11, "logprob": -0.7923774719238281}
    ]
  }
}

Basic distribution replay needs the complete mask and the sampled token's old logprob. During training, apply the saved mask to the current policy's logits to compute that token's new logprob. Old logprobs for every candidate token are not required.

The sampled token belongs to its corresponding support. Mask size is independent of logprobs, and top-k ties can retain more than top_k tokens. With stream=true, concatenate token and mask chunks by choice index and token position.

For an MTP-capable model, speculative decoding is supported with fixed verification boundaries. Add the following configuration to the server command:

--speculative-config '{"method":"mtp","num_speculative_tokens":2,"enable_adaptive_verification":false}'

Each committed token receives the processed target-model support at its position. The mask does not record draft or acceptance probabilities.

On Ascend, supports are packed on the NPU and decoded on the CPU using the exact bitmask fallback. This preserves the complete support but adds transfer, CPU decoding, and response-size overhead. The adapter requires the upstream request-major sampling-mask interface.

Diffusion models, custom logits processors, adaptive verification, and the batch-sharded LM-head gather path are not supported for this feature. Sampling masks contain neither probability values nor RNG state; they do not force a token sequence as Trace Replay does.

Deterministic rollouts

Batch invariance reduces output differences caused by changes in batch shape or request order. On Atlas A2 and A3, build vLLM-Ascend with COMPILE_CUSTOM_KERNELS=1, then enable batch invariance through the unified RL configuration:

vllm serve Qwen/Qwen3-8B \
    --additional-config '{"rl_config": {"enabled": true, "enable_batch_invariant": true}}' \
    --compilation-config '{"cudagraph_mode": "PIECEWISE"}'

RL mode disables FRACTAL_NZ. When batch invariance is enabled, worker initialization also sets HCCL_DETERMINISTIC=strict and LCCL_DETERMINISTIC=1. See Batch Invariance for supported hardware, models, and limitations.

Tokens in, tokens out

The experimental token-in/token-out (TITO) endpoint accepts pre-tokenized prompts and, by default (output_mode="tokens"), returns generated token IDs. Apply tokenization and any chat template on the client before sending token_ids. Choose one of two serving modes:

# Dedicated token-only serving: skips tokenizer initialization.
vllm serve Qwen/Qwen3-0.6B --tokens-only

# Enable TITO while retaining the normal serving setup and tokenizer.
vllm serve Qwen/Qwen3-0.6B --enable-scale-out

--tokens-only uses token output and does not support stop strings; use sampling_params.stop_token_ids instead. A normal server started without either flag returns HTTP 403 for TITO requests, with a message to enable --enable-scale-out.

Send a non-streaming request to /inference/v1/generate:

curl http://127.0.0.1:8000/inference/v1/generate \
    -H "Content-Type: application/json" \
    -d '{
        "request_id": "rollout-001",
        "token_ids": [151644, 8948, 198],
        "output_mode": "tokens",
        "sampling_params": {
            "temperature": 1.0,
            "max_tokens": 2,
            "logprobs": 1
        }
    }'

The following non-streaming response excerpt illustrates the structure for a request that reaches the two-token limit. Token IDs and logprob values are illustrative, not captured model output; other response fields are omitted:

{
  "request_id": "generate-tokens-rollout-001",
  "model": "Qwen/Qwen3-0.6B",
  "output_mode": "tokens",
  "choices": [
    {
      "index": 0,
      "logprobs": {
        "content": [
          {
            "token_id": 123,
            "logprob": -0.5,
            "rank": 1,
            "top_logprobs": [
              {"token_id": 123, "logprob": -0.5, "rank": 1}
            ]
          },
          {
            "token_id": 456,
            "logprob": -0.7,
            "rank": 1,
            "top_logprobs": [
              {"token_id": 456, "logprob": -0.7, "rank": 1}
            ]
          }
        ]
      },
      "finish_reason": "length",
      "stop_reason": null,
      "token_ids": [123, 456],
      "routed_experts": null
    }
  ],
  "prompt_logprobs": null,
  "usage": {
    "prompt_tokens": 3,
    "completion_tokens": 2,
    "total_tokens": 5
  }
}

In token output mode, choices[].logprobs.content contains an integer token_id, its logprob and rank, and top_logprobs for each generated position. Non-streaming responses include usage without requiring stream_options.include_usage. Here, three prompt tokens and two completion tokens give five total tokens; stop_reason is null because generation reached max_tokens.

Set stream=true to receive server-sent events (SSE), ending with data: [DONE]. To cancel an in-flight request, send a POST to /inference/v1/abort_requests with a JSON body containing request_ids, a list of IDs returned by the server (including the generate-tokens- prefix), rather than the original client-supplied IDs.

For the full protocol and the text output mode, which requires a tokenizer, see the upstream TITO guide. The Tokens API RFC provides design background.

Tool calling for agentic RL

Agentic rollout environments can use the standard OpenAI-compatible tool-call API. For a model with a supported parser:

vllm serve Qwen/Qwen3-8B \
    --enable-auto-tool-choice \
    --tool-call-parser hermes

The environment supplies tools in /v1/chat/completions, executes returned tool calls, appends tool results to the conversation, and submits the next turn. See upstream Tool Calling for request examples and the supported parser/model combinations.

Data-parallel request routing

vLLM's OpenAI serving layer recognizes the X-data-parallel-rank header and passes its integer value to the scheduler. A DP-aware external router can use this header to target a rank:

curl http://127.0.0.1:8000/v1/completions \
    -H "Content-Type: application/json" \
    -H "X-data-parallel-rank: 2" \
    -d '{
        "model": "Qwen/Qwen3-0.6B",
        "prompt": "Your prompt here",
        "max_tokens": 32
    }'

vLLM-Ascend does not provide a vllm serve router command or a --dp-routing-config option. Configure the vLLM data-parallel deployment and an external router separately. See upstream Data Parallel Deployment for the supported load-balancing modes.

Trace Replay

Trace replay forces the engine to emit a predetermined token sequence during decoding while computing real logprobs from the model's unmodified logit distribution. When using the normal vllm serve command with the token-in/token-out endpoint, enable the scale-out endpoints:

vllm serve Qwen/Qwen3-8B \
    --enable-scale-out \
    --enable-trace-replay

--enable-scale-out registers the /inference/v1/generate endpoint for a normal serving process. --enable-trace-replay opts the server into accepting trace replay requests.

Send requests to /inference/v1/generate:

curl http://127.0.0.1:8000/inference/v1/generate \
    -H "Content-Type: application/json" \
    -d '{
        "request_id": "rollout-001",
        "token_ids": [151644, 8948, 198],
        "sampling_params": {
            "trace_decode_token_ids": [15, 284, 1026, 374],
            "logprobs": 1
        }
    }'

The output tokens will always be [15, 284, 1026, 374]. The logprobs reflect the model's true probability for each forced token under the current inference configuration.

Configuration checklist

Setting When to use it Purpose
rl_config.enabled=true All RL deployments Apply RL defaults: disable NZ, enable development endpoints, and remove expandable_segments
--enable-sleep-mode Trainer and rollout engine share NPUs Enable the CaMemAllocator memory pool
VLLM_WORKER_MULTIPROC_METHOD=spawn Sleep mode Use the supported worker start method
rl_config.sleep_mode_extra_cleanup=true Optional for sleep mode Release HCCL and ACL graph resources at the cost of slower wake-up
rl_config.enable_training_consistency=true Training-inference consistency Select FA3; requires the flash_attn_npu_v3 package
rl_config.enable_batch_invariant=true Reproducible rollouts Enable batch-invariant kernels and deterministic communication settings
VLLM_RELOAD_MODE=direct Full-checkpoint reload of unquantized BF16 Qwen weights Refill weights in place and preserve captured decode graphs
--weight-transfer-config '{"backend": "hccl"}' Cross-NPU weight transfer Register the Ascend HCCL transfer engine
--weight-transfer-config '{"backend": "ipc"}' Same-NPU weight transfer Select the Ascend NPU IPC transfer engine
--enable-return-routed-experts MoE router replay Return encoded expert routing decisions
--return-sampling-mask Sampling Mask (Distribution Replay) Return the support set for each generated token; disabled by default
--enable-scale-out Token-in/token-out requests on a normal server Register /inference/v1/generate; --tokens-only also registers this endpoint
--enable-trace-replay trace replay Forces decoding to follow a predetermined token sequence

For the Ascend-specific option definitions, see Additional Configuration and Environment Variables.