Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 35 additions & 1 deletion e2e_workflow/docs/multi_node.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,15 @@ instead, which is per-rank:
every node runs `vllm serve --nnodes N --node-rank i --master-addr --master-port`,
and ranks other than 0 add `--headless` (no HTTP front end; rank0 serves the client).

ATOM's server takes no `--nnodes` / `--node-rank`, so `adapters/atom.sh` defines no
`adapter_dist_args`: an ATOM engine is one TP world on one node's cards, and a generated
`tp_span` launch is refused. It runs `pd_disagg` only. Generated, `adapter_pd_args` gives each
role `--kv-transfer-config '{"kv_role": kv_producer|kv_consumer, "kv_connector": "mooncake",
"proxy_ip": $GEAK_NODE_IP, "handshake_port": <pd bootstrap port>}'` (`mn.py` exports the node's
cluster IP as `GEAK_NODE_IP`; Mooncake reads its protocol from `EXTRA_ENV`'s `MC_*`, not from
`pd`), and `adapter_pd_lb_launch` starts `atomesh launch --pd-disaggregation --prefill <url>...
--decode <url>... --backend atom` as in ATOM's `pd_disaggregation_guide.md`.

Flags are layered in this order, the same one `launchers/magpie.sh` uses:
GEAK's shared flags (`EXTRA_SERVER_ARGS`) → that engine's own accepted flags
(`GEAK_MN_PD_SWEEP_ARGS_<ROLE>`, pd_disagg only) → the rank/world or
Expand Down Expand Up @@ -295,6 +304,16 @@ and EP ride in the server args and do not change it, so dp2 tp8 ep16 on two
nodes is `tp: 16`. Plain DP replicas across nodes (a router in front of N
independent non-PD engines) is not supported; PD replicas (xPyD) are.

For `backend: atom` the command parser reads `--model`, `-tp` / `--tensor-parallel-size`, the
role from `kv_role` in `--kv-transfer-config` (`kv_producer` is prefill, `kv_consumer` decode; no
bootstrap port) and the HTTP port from `--server-port` (8000 when absent; `--port` is the engine's
internal port, never the one a router dials). `--server-port`, `--port`, `-tp`,
`--kv-transfer-config`, `--host` and the DP / PP width are the command's own, so a swept copy is
dropped. The router is `atomesh launch --pd-disaggregation`, checked like sglang's: its `--port`
is `serve_port` and its `--prefill` / `--decode` URLs are exactly the engines'. Replicas of one role
may differ in `--server-port` only. Teardown finds atomesh by its recorded pid and by `atomesh launch`,
and a defunct `ATOM::` child counts as a dead engine, like a defunct `sglang::` one.

## Running it

### 1. The environment check (automatic, before Setup)
Expand All @@ -318,7 +337,7 @@ nothing in it re-runs the check. The check:
(another container's VRAM, a port held by something else) is refused by the rules below;
- probes each node over ssh (the probe goes by content) and records its identity, its NIC for that IP (generated
mode), its software stack and its GPU (gfx, target, product, CU count); nodes on
different sglang/vllm/torch/triton/aiter versions, or with different GPUs, are refused;
different sglang/vllm/atom/torch/triton/aiter versions, or with different GPUs, are refused;
- provided mode: fingerprints every launch script on its node and refuses a missing one;
- opens every port GEAK hands out that one node dials on another (generated: the
dist-init port, PD's bootstrap port) on its node and dials it from the others, and
Expand Down Expand Up @@ -403,6 +422,7 @@ Everything about the machines is in the handoff's `multinode` block, read once b
| `GEAK_MN_DRY_RUN` | — | `1` = render the per-rank scripts and stop, cluster untouched |
| `MEM_FRACTION` | 0.90 | check: the free share of the fullest card's VRAM a node must have |
| `SERVING_LOCK_WAIT` | 7200 | seconds a serving leg waits for a card a GEAK kernel task has leased |
| `ATOM_PROFILE_WINDOW_MAX_SEC` | 6 | ATOM only: the cap on a profile window (see the trace gate) |

The trace wait is fixed: bytes quiet for 30 s count as exported, an incomplete set is
given up after 180 s quiet, 1800 s at most, and the gate expects `TP` traces (under PD
Expand Down Expand Up @@ -447,6 +467,20 @@ Two things it exists to prevent, both of which look like a successful capture:
`ranks/mn_trace_report.json` and only falls back to `ls -t` on a single box.
No trace is moved.

ATOM differs in where its traces land and how a window closes:

- It fixes its trace directory at launch and `/start_profile` takes no body, so under PD
each role is launched with `<profile>/<role>/` (one shared directory would get both
engines' `rank_0/`). `PROFILE=1` records shapes without Python stacks or memory
(`ATOM_PROFILER_RECORD_SHAPES=1`, `ATOM_PROFILER_WITH_STACK=0`, `ATOM_PROFILER_PROFILE_MEMORY=0`).
- A rank writes `<dir>/rank_<N>/<name>.pt.trace.json.gz` (`dp<D>_tp<N>/` under DP); the
name carries no rank, so the gate reads it from the directory and the wait looks one
level deeper.
- `/stop_profile`, not a step count, closes the window, and ATOM answers it only after its
export, so both engines are stopped at once. Every rank holds its whole window in host
memory until then (a long decode window has run a node out of memory), so the window is
capped at `ATOM_PROFILE_WINDOW_MAX_SEC`, the cap `adapters/atom.sh` applies on one node.

### The ROCm runtime

On the ROCm 7.2.0 image roctracer drops the kernels a CUDA graph replays (6 per
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,14 +54,31 @@ def _write_json(path: str, doc: dict) -> str:
KERNEL_EVENT = rb'"cat": ?"kernel"'

TRACE_RE = re.compile(r"(?:TP-|_tp)(\d+)") # sglang ...-TP-3..., vllm <prefix>_dp0_pp0_tp3_...
# ATOM names no rank in the file: each rank writes into its own directory under the profile
# dir, `rank_<N>/`, or `dp<D>_tp<N>/` under data parallelism.
ATOM_RANK_DIR_RE = re.compile(r"^(?:rank_(?P<rank>\d+)|dp(?P<dp>\d+)_tp(?P<tp>\d+))$")
TRACE_PATTERNS = ("*.trace.json.gz", "*.trace.json", "*.json.gz")


def discover(profile_dir: str) -> list[str]:
files = [f for pattern in ("*.trace.json.gz", "*.trace.json", "*.json.gz")
for f in glob.glob(os.path.join(profile_dir, pattern))]
dirs = [profile_dir] + [d for d in glob.glob(os.path.join(profile_dir, "*"))
if os.path.isdir(d) and ATOM_RANK_DIR_RE.match(os.path.basename(d))]
files = [f for d in dirs for pattern in TRACE_PATTERNS for f in glob.glob(os.path.join(d, pattern))]
return sorted(set(f for f in files if not os.path.basename(f).startswith("merged-")))


def rank_of(path: str) -> int | None:
"""TP rank of one trace, None where the path does not say. sglang puts it in the file name
(`...-TP-3-...`); ATOM in the directory the file sits in (`rank_3`, `dp1_tp3`)."""
tp = TRACE_RE.search(os.path.basename(path))
if tp:
return int(tp.group(1))
atom = ATOM_RANK_DIR_RE.match(os.path.basename(os.path.dirname(path)))
if atom:
return int(atom.group("rank") if atom.group("rank") is not None else atom.group("tp"))
return None


def scan(path: str) -> dict:
"""Stream one trace to EOF: a truncated gzip raises here."""
info = {
Expand Down Expand Up @@ -165,15 +182,14 @@ def cmd_trace_gate(argv: list) -> int:
per_rank, unranked = {}, []
for role, directory, node, _exp in lanes:
for path in discover(directory):
name = os.path.basename(path)
match = TRACE_RE.search(name)
tp_rank = rank_of(path)
scanned = scan(path)
if role:
scanned["role"] = role
if not match:
if tp_rank is None:
unranked.append(scanned)
continue
rank = int(match.group(1))
rank = tp_rank
scanned["tp_rank"] = rank
scanned["node_index"] = (lane_node(spans[role][0], rank, spans[role][1])
if role in spans and len(spans[role][0]) > 1
Expand Down
49 changes: 48 additions & 1 deletion e2e_workflow/scripts/adapters/atom.sh
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,10 @@ adapter_launch() {
if [ -n "${PROFILE_DIR:-}" ]; then
mkdir -p "$PROFILE_DIR"
_prof=(--torch-profiler-dir "$PROFILE_DIR")
_prof_env=(ATOM_PROFILER_MORE="${ATOM_PROFILER_MORE:-1}")
# Shapes yes, Python stacks / memory no -- what sglang.sh and vllm.sh ask for: stacks are most
# of the events and slow the profiled steps. An ATOM without the split flags falls back to MORE.
_prof_env=(ATOM_PROFILER_MORE="${ATOM_PROFILER_MORE:-1}" ATOM_PROFILER_RECORD_SHAPES="${ATOM_PROFILER_RECORD_SHAPES:-1}"
ATOM_PROFILER_WITH_STACK="${ATOM_PROFILER_WITH_STACK:-0}" ATOM_PROFILER_PROFILE_MEMORY="${ATOM_PROFILER_PROFILE_MEMORY:-0}")
fi

_atom_server_argv "${EXTRA_SERVER_ARGS:-}" || return 2
Expand Down Expand Up @@ -161,6 +164,50 @@ adapter_launch() {

adapter_health() { curl -sf "${BASE_URL}/health" >/dev/null 2>&1; }

# ---- multi-node P/D (read by adapters/launchers/multinode.sh, generated mode) ----
# ATOM has no --nnodes, so there is no adapter_dist_args: TP cannot span nodes, only P/D can.
# pd_roles: one complete TP-closed server per role, joined by Mooncake.
adapter_pd_mode() { echo pd_roles; }

# adapter_pd_args ROLE HANDSHAKE_PORT TRANSFER_BACKEND [IB_DEVICE]
# Output is shell-quoted: _atom_server_argv splits it with shell rules and the JSON has quotes.
# proxy_ip is this node's cluster IP (mn.py exports GEAK_NODE_IP in the rank head); the peer
# connects to it. TRANSFER_BACKEND / IB_DEVICE are sglang's knobs: ATOM's Mooncake takes its
# protocol from the environment (MC_* in EXTRA_ENV), so they are accepted and ignored.
adapter_pd_args() {
local role="$1" hs="$2" kvrole
case "$role" in
prefill) kvrole=kv_producer ;;
decode) kvrole=kv_consumer ;;
*) echo "!!! atom adapter: unknown PD role '$role'" >&2; return 2 ;;
esac
[ -n "${GEAK_NODE_IP:-}" ] || { echo "!!! atom adapter: GEAK_NODE_IP unset; Mooncake needs the node IP" >&2; return 2; }
local cfg
cfg=$(printf '{"kv_role":"%s","kv_connector":"mooncake","proxy_ip":"%s","handshake_port":%s}' \
"$kvrole" "$GEAK_NODE_IP" "$hs")
printf -- '--kv-transfer-config %q\n' "$cfg"
}

# adapter_pd_lb_launch HOST PORT PREFILL_URLS BOOTSTRAP_PORT DECODE_URLS
# atomesh takes no bootstrap port; URL lists are space-separated (xPyD: one per replica).
# Flags as in ATOM's pd_disaggregation_guide.md.
adapter_pd_lb_launch() {
local host="$1" port="$2" u
local workers=()
for u in $3; do workers+=(--prefill "$u"); done
for u in $5; do workers+=(--decode "$u"); done
# shellcheck disable=SC2086
${SERVER_LAUNCH_PREFIX:-} env $EXTRA_ENV \
atomesh launch \
--host "$host" --port "$port" \
--pd-disaggregation "${workers[@]}" \
--policy "${PD_LB_POLICY:-random}" --backend atom \
--log-level info --disable-health-check --disable-circuit-breaker \
${LB_EXTRA_ARGS:-} \
> "$LOG" 2>&1 &
SERVER_PID=$!
}

# ATOM can answer /health before request-triggered Triton/aiter JIT work has quiesced. The dispatcher
# calls this after its untimed warmup. Isolated replicas intentionally skip that outer warmup, so give
# ATOM one explicit untimed request round here; the native client's own warmups are not a readiness
Expand Down
59 changes: 42 additions & 17 deletions e2e_workflow/scripts/adapters/launchers/multinode.sh
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,8 @@ _MN_PD_HEALTH_TIMEOUT_S=10
# series, summed); empty when it serves no /metrics (sglang without --enable-metrics).
_mn_load() {
curl -sf -m 5 "$1/metrics" 2>/dev/null \
| awk '/^(vllm:num_requests_running|sglang:num_running_reqs)[{ ]/ {s += $NF; n = 1}
/^(vllm|sglang):prompt_tokens_total[{ ]/ {p += $NF}
| awk '/^(vllm:num_requests_running|sglang:num_running_reqs|atom:requests_running)[{ ]/ {s += $NF; n = 1}
/^(vllm|sglang|atom):prompt_tokens_total[{ ]/ {p += $NF}
END {if (n) printf "%d %.0f\n", s, p}'
}

Expand Down Expand Up @@ -150,6 +150,20 @@ _mn_wait_load() {
done
}

# The profiler window in seconds. ATOM keeps the size guard adapters/atom.sh applies on one
# node (ATOM_PROFILE_WINDOW_MAX_SEC, default 6): with ATOM_PROFILER_MORE every rank buffers its
# whole window in host RAM and exports it at /stop_profile, and a long window on a decode engine
# has run a node out of memory.
_mn_window_s() {
local _w="${PROFILE_WINDOW_SEC:-20}" _max="${ATOM_PROFILE_WINDOW_MAX_SEC:-6}"
if [ "${BACKEND:-}" = "atom" ] && [ "$_w" -gt "$_max" ] 2>/dev/null; then
echo ">>> multinode: clamping the ATOM profile window ${_w}->${_max}s" \
"(set ATOM_PROFILE_WINDOW_MAX_SEC to override)" >&2
_w="$_max"
fi
echo "$_w"
}

# pd_disagg window: both engines are opened first and closed
# together, so their GPU-time totals describe the same interval. Prints role=url
# for every engine that opened one. Payload knobs read the backend adapter's env names.
Expand All @@ -161,9 +175,11 @@ _mn_pd_window() {
while IFS='=' read -r _role _url; do
[ -n "$_url" ] || continue
mkdir -p "$PROFILE_DIR/$_role"
if curl -sf -X POST "${_url}/start_profile" -H 'Content-Type: application/json' \
-d "{\"output_dir\":\"${PROFILE_DIR}/${_role}\",\"num_steps\":${PROFILE_NUM_STEPS},\"record_shapes\":true,\"with_stack\":${_stack},\"activities\":${_acts}}" \
>/dev/null 2>&1; then
# ATOM takes no request body: its output dir is fixed at launch (mn.py gives each role its
# own ATOM_TORCH_PROFILER_DIR) and the window is closed by /stop_profile, not by a step count.
local _body=(-H 'Content-Type: application/json' -d "{\"output_dir\":\"${PROFILE_DIR}/${_role}\",\"num_steps\":${PROFILE_NUM_STEPS},\"record_shapes\":true,\"with_stack\":${_stack},\"activities\":${_acts}}")
[ "${BACKEND:-}" = "atom" ] && _body=()
if curl -sf -X POST "${_url}/start_profile" ${_body[@]+"${_body[@]}"} >/dev/null 2>&1; then
_windowed="${_windowed}${_role}=${_url}"$'\n'
else
echo "!!! multinode: /start_profile failed on the $_role engine ($_url)" >&2
Expand All @@ -173,20 +189,27 @@ _mn_pd_window() {
# Bounded by TIME and closed explicitly: num_steps counts forward steps, and
# decode runs ~10x more of them than prefill, so prefill's window would still
# be open at teardown and write nothing.
sleep "${PROFILE_WINDOW_SEC:-20}"
# Bounded: a wedged scheduler never answers /stop_profile.
sleep "$(_mn_window_s)"
# Bounded: a wedged scheduler never answers /stop_profile. Closed on every engine at once:
# ATOM answers /stop_profile only after its export, so closing one engine after the other
# keeps the later engine's window open for the whole export of the first.
local _stops=() _pid
while IFS='=' read -r _role _url; do
[ -n "$_url" ] || continue
_stop_rc=0
curl -sf -m "$_MN_STOP_PROFILE_TIMEOUT_S" -X POST "${_url}/stop_profile" \
>/dev/null 2>&1 || _stop_rc=$?
if [ "$_stop_rc" -eq 28 ]; then
echo "!!! multinode: the $_role engine did not answer /stop_profile within" \
"${_MN_STOP_PROFILE_TIMEOUT_S}s; its traces will be missing" >&2
elif [ "$_stop_rc" -ne 0 ]; then
echo ">>> multinode: the $_role engine had already closed its window" >&2
fi
(
_stop_rc=0
curl -sf -m "$_MN_STOP_PROFILE_TIMEOUT_S" -X POST "${_url}/stop_profile" \
>/dev/null 2>&1 || _stop_rc=$?
if [ "$_stop_rc" -eq 28 ]; then
echo "!!! multinode: the $_role engine did not answer /stop_profile within" \
"${_MN_STOP_PROFILE_TIMEOUT_S}s; its traces will be missing" >&2
elif [ "$_stop_rc" -ne 0 ]; then
echo ">>> multinode: the $_role engine had already closed its window" >&2
fi
) &
_stops+=("$!")
done <<< "$_windowed"
for _pid in "${_stops[@]}"; do wait "$_pid"; done
printf '%s' "$_windowed"
}

Expand Down Expand Up @@ -244,6 +267,8 @@ adapter_profile_window() {
local _expect="$TP"
local _before _after _deadline _depth=1 _windowed=""
[ "$_MN_TOPOLOGY" = "pd_disagg" ] && _depth=2
# ATOM: <profile>/<role>/rank_<N>/<trace>, one directory deeper than sglang's.
[ "${BACKEND:-}" = "atom" ] && _depth=$(( _depth + 1 ))
_mn_traces() { find "$PROFILE_DIR" -maxdepth "$_depth" -name '*.trace.json*' "$@" 2>/dev/null; }
_before=$(_mn_traces | wc -l)

Expand Down Expand Up @@ -301,7 +326,7 @@ adapter_profile_window() {
python3 "$_MN_TRACES" trace-gate \
--profile-dir "$PROFILE_DIR" --expect-ranks "$_expect" \
--nodes "$_MN_NNODES" \
${_launch_json:+--launch-json "$_launch_json" --window-s "${PROFILE_WINDOW_SEC:-20}"}
${_launch_json:+--launch-json "$_launch_json" --window-s "$(_mn_window_s 2>/dev/null)"}
local _rc=$?
# Non-fatal: a partial set still ranks; the verdict is on disk.
if [ "$_rc" -ne 0 ]; then
Expand Down
Loading
Loading