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

# Serve Beam with ICP

> Deploy Iris Cyber Probe with Beam using SGLang or vLLM and read token-aligned input and output scores

Choose the engine you use to serve Beam with [Iris Cyber Probe](https://developers.reflection.ai/iris-cyber-probe.md).

> [tab] SGLang
>
> SGLang runs Beam and sends activation features to a separate ICP scorer. Your application sends generation requests to SGLang on port 8000 and reads scores from the scorer on port 8001 using the same request ID.
>
> **1. Prepare the weights and image**
>
> This setup uses Docker on a Linux amd64 host with four NVLink-connected NVIDIA B300 SXM GPUs.
>
> * Follow [Download the weights](https://developers.reflection.ai/serving-weights.md) to check compatibility requirements and download Beam 1.0 NVFP4 and the DFlash2 drafter into `$MODEL_DIR`.
> * Follow [Download Iris Cyber Probe](https://developers.reflection.ai/serving-weights.md#download-iris-cyber-probe) to download the probe into `$IRIS_CYBER_PROBE_DIR`.
>
> Use a SGLang image with Beam, DFlash2, and activation-monitor support.
>
> ```bash Pull and pin the image icon="docker" theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
> export IMAGE='lmsysorg/sglang:beam'
> docker pull "$IMAGE"
> export IMAGE="$(docker image inspect "$IMAGE" \
>   --format '{{index .RepoDigests 0}}')"
> ```
>
> **2. Start the scorer and SGLang**
>
> Start the scorer first. The Docker network lets SGLang send it features at `iris-scorer:5557`.
>
> ```bash Start the scorer icon="docker" theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
> docker network create beam-iris
> docker run --detach --rm --init --name iris-scorer \
>   --network beam-iris --gpus '"device=3"' \
>   -p 127.0.0.1:8001:8001 \
>   --mount "type=bind,src=$IRIS_CYBER_PROBE_DIR,dst=/probes/iris-cyber-probe,readonly" \
>   --entrypoint python3 "$IMAGE" \
>   -m sglang_activation_monitor_sidecar \
>   --monitor cyber=/probes/iris-cyber-probe \
>   --feature-endpoint tcp://0.0.0.0:5557 \
>   --host 0.0.0.0 --port 8001 --device cuda:0
> ```
>
> Launch SGLang with the same probe name (`cyber`) and checkpoint as the scorer. The highlighted flags enable feature export and input scores.
>
> ```bash Start SGLang with ICP icon="docker" highlight={32-34} theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
> docker run --detach --rm --init --name beam \
>   --network beam-iris \
>   --gpus '"device=0,1,2,3"' --shm-size=32g \
>   -p 127.0.0.1:8000:8000 \
>   --mount "type=bind,src=$MODEL_DIR,dst=/weights,readonly" \
>   --mount "type=bind,src=$IRIS_CYBER_PROBE_DIR,dst=/probes/iris-cyber-probe,readonly" \
>   -e HF_HUB_OFFLINE=1 -e TRANSFORMERS_OFFLINE=1 \
>   --entrypoint python3 "$IMAGE" \
>   -m sglang.launch_server \
>   --host 0.0.0.0 --port 8000 \
>   --model-path /weights/nvfp4 --served-model-name Beam-1.0-501B-A23B \
>   --tp-size 4 --dtype bfloat16 \
>   --context-length 262144 --max-running-requests 8 \
>   --mem-fraction-static 0.9 --max-total-tokens 262144 \
>   --attention-backend trtllm_mha --moe-runner-backend flashinfer_trtllm \
>   --kv-cache-dtype fp8_e4m3 \
>   --chunked-prefill-size 8192 --max-prefill-tokens 8192 \
>   --cuda-graph-max-bs-decode 8 --page-size 64 \
>   --swa-full-tokens-ratio 0.25 \
>   --tool-call-parser beam --reasoning-parser beam \
>   --default-chat-template-kwargs '{"allow_missing_thinking": false}' \
>   --speculative-algorithm DFLASH \
>   --speculative-draft-model-path /weights/dflash2 \
>   --speculative-draft-load-format safetensors \
>   --speculative-num-draft-tokens 8 \
>   --speculative-draft-attention-backend trtllm_mha \
>   --speculative-draft-kv-cache-dtype fp8_e4m3 \
>   --speculative-draft-window-size 4096 \
>   --json-model-override-args '{"max_position_embeddings":262144}' \
>   --weight-loader-disable-mmap --weight-loader-drop-cache-after-load \
>   --model-loader-extra-config '{"enable_multithread_load":false}' \
>   --activation-monitor-sidecar-probes '[{"name":"cyber","checkpoint":"/probes/iris-cyber-probe"}]' \
>   --activation-monitor-sidecar-endpoint tcp://iris-scorer:5557 \
>   --activation-monitor-sidecar-input-scores
> ```
>
> **3. Generate and read scores**
>
> Once Beam is ready, start generation in the background with a unique request ID.
>
> ```bash Generate with a request ID icon="terminal" highlight={1,6} theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
> export IRIS_RID="iris-$(python3 -c 'import uuid; print(uuid.uuid4().hex)')"
> curl --fail-with-body http://127.0.0.1:8000/generate \
>   -H 'Content-Type: application/json' \
>   -d @- <<JSON &
> {
>   "rid": "$IRIS_RID",
>   "text": "Explain tensor parallelism briefly.",
>   "sampling_params": {"max_new_tokens": 128}
> }
> JSON
> ```
>
> **Input scores** align with prompt activation positions, including tool calls and results in the prompt.
>
> ```bash Stream input scores icon="terminal" highlight={2} theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
> curl --fail-with-body -N \
>   "http://127.0.0.1:8001/v1/monitor_scores/$IRIS_RID/stream?scope=input&since=0"
> ```
>
> **Output scores** align with generated tokens, including new tool calls. Row zero scores the final prompt position, which predicts the first generated token.
>
> ```bash Stream output scores icon="terminal" highlight={2} theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
> curl --fail-with-body -N \
>   "http://127.0.0.1:8001/v1/monitor_scores/$IRIS_RID/stream?scope=output&since=0"
> ```
>
> If the scorer returns HTTP 404 just after you send the request, retry after a moment. In this example, the `scores` event contains two valid rows.
>
> ```json Score event fields theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
> {
>   "offset": 0,
>   "monitors": {
>     "cyber": {
>       "scores": [[-1.3], [3.1]],
>       "valid": [true, true]
>     }
>   },
>   "status": "completed",
>   "complete": true,
>   "has_more": false
> }
> ```
>
> To resume a stream, pass its last `cursor` as `since`. Keep a separate cursor for each scope. For paginated JSON snapshots, remove `/stream` from the URL and follow the cursor until `complete` is true and `has_more` is false.
>
> Generation can deliver tokens before their scores arrive. If your application requires scores, wait for valid scores up to a client deadline. If scoring ends or the deadline expires with a required score missing, withhold the affected output or tool call. See [ICP thresholds](https://developers.reflection.ai/iris-cyber-probe.md#recommended-thresholds) for interpreting scores and [SGLang's activation-monitor guide](https://docs.sglang.io/docs/advanced_features/activation_monitors) for error handling and retention.
>
> To learn more about Iris support in SGLang, read [SGLang's release blog post](https://www.lmsys.org/blog/2026-11-30-project-iris).
>
> **4. Stop the deployment**
>
> ```bash Stop the Iris deployment icon="docker" theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
> docker stop --time 60 beam iris-scorer
> docker network rm beam-iris
> ```

> [tab] vLLM
>
> vLLM runs Beam on the GPUs and sends Iris features to a CPU scorer. Send generation requests to vLLM on port 8000 and read input and output scores from the scorer on port 8001.
>
> **1. Prepare the weights and image**
>
> This setup uses Docker on a Linux amd64 host with four NVLink-connected NVIDIA B300 SXM GPUs.
>
> * Follow [Download the weights](https://developers.reflection.ai/serving-weights.md) to check compatibility requirements and download Beam 1.0 NVFP4 and the DFlash2 drafter into `$MODEL_DIR`.
> * Follow [Download Iris Cyber Probe](https://developers.reflection.ai/serving-weights.md#download-iris-cyber-probe) to download the probe into `$IRIS_CYBER_PROBE_DIR`.
>
> Set `IMAGE` to a vLLM image with Beam, DFlash2, and the Iris sidecar. Pin it and check that it includes the scorer:
>
> ```bash Pull and check the image icon="docker" theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
> docker pull "${IMAGE:?Set IMAGE to a sidecar-enabled vLLM image}"
> export IMAGE="$(docker image inspect "$IMAGE" \
>   --format '{{index .RepoDigests 0}}')"
> docker run --rm --entrypoint python3 "$IMAGE" -m vllm.activation_monitors.scorer --help
> ```
>
> **2. Start the scorer and vLLM**
>
> Start the scorer first. The two containers share a Docker network and load the same probe. The scorer uses the CPU and needs no GPU allocation.
>
> ```bash Start the scorer icon="docker" theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
> docker network create beam-iris
> docker run --detach --rm --init --name iris-scorer \
>   --network beam-iris -p 127.0.0.1:8001:8001 \
>   --mount "type=bind,src=$IRIS_CYBER_PROBE_DIR,dst=/probes/iris-cyber-probe,readonly" \
>   --entrypoint python3 "$IMAGE" -m vllm.activation_monitors.scorer \
>   --name cyber --probe /probes/iris-cyber-probe \
>   --listen tcp://0.0.0.0:5557 --input-scores
> ```
>
> ```bash Start Beam with Iris Cyber Probe icon="docker" theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
> docker run --detach --rm --init --name beam \
>   --network beam-iris --gpus '"device=0,1,2,3"' --shm-size=32g \
>   -p 127.0.0.1:8000:8000 \
>   --mount "type=bind,src=$MODEL_DIR,dst=/weights,readonly" \
>   --mount "type=bind,src=$IRIS_CYBER_PROBE_DIR,dst=/probes/iris-cyber-probe,readonly" \
>   --entrypoint vllm "$IMAGE" serve /weights/nvfp4 \
>   --served-model-name Beam-1.0-501B-A23B --tensor-parallel-size 4 \
>   --max-model-len 131072 --max-num-seqs 8 --kv-cache-dtype fp8 \
>   --enable-auto-tool-choice --tool-call-parser beam --reasoning-parser beam \
>   --speculative-config '{"method":"dflash","model":"/weights/dflash2","num_speculative_tokens":7}' \
>   --activation-monitor-config '{"name":"cyber","model":"/probes/iris-cyber-probe","sidecar":"tcp://iris-scorer:5557"}'
> ```
>
> The first start can take tens of minutes while vLLM loads Beam and compiles GPU kernels. Follow progress with `docker logs beam`, then check both services:
>
> ```bash Check readiness icon="terminal" theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
> curl --fail-with-body http://127.0.0.1:8000/v1/models
> curl --fail-with-body http://127.0.0.1:8001/health
> ```
>
> **3. Generate and read scores**
>
> Send a normal Chat Completions request and save the response ID. Scoring is automatic.
>
> ```bash Generate and capture the response ID icon="terminal" theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
> IRIS_RESPONSE_ID=$(curl --fail --silent --show-error http://127.0.0.1:8000/v1/chat/completions \
>   -H 'Content-Type: application/json' \
>   -d '{
>     "model": "Beam-1.0-501B-A23B",
>     "messages": [{"role": "user", "content": "Explain tensor parallelism briefly."}],
>     "max_tokens": 128
>   }' | python3 -c 'import json, sys; print(json.load(sys.stdin)["id"])')
> ```
>
> Read prompt scores as JSON and generated-token scores as a stream. Either scope supports both formats. Output row zero uses the last prompt position, which predicts the first generated token.
>
> ```bash Read input and output scores icon="terminal" theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
> curl --fail-with-body "http://127.0.0.1:8001/v1/monitor_scores/$IRIS_RESPONSE_ID?scope=input"
> curl --fail-with-body -N "http://127.0.0.1:8001/v1/monitor_scores/$IRIS_RESPONSE_ID/stream?scope=output"
> ```
>
> Read the logits in `monitors.cyber.scores` and use only rows marked `valid`. For paginated JSON, pass the returned `cursor` as `since` on the same scope until `complete` is true and `has_more` is false.
>
> Generation can finish before scoring. If you gate output or tool calls, request `return_token_ids: true` and wait for a valid score for each returned token you release. See [recommended ICP thresholds](https://developers.reflection.ai/iris-cyber-probe.md#recommended-thresholds).
>
> **4. Stop the deployment**
>
> ```bash Stop the Iris deployment icon="docker" theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
> docker stop --time 60 beam iris-scorer
> docker network rm beam-iris
> ```
