Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
7001c5e
docs(recipes): add Kimi-K3 wide-EP on gfx1250 (4-node dp16ep16)
Sep 24, 2026
44ea425
docs(recipes): rename to Kimi-K3-455-wideEP.md, correct the KV-budget…
Sep 24, 2026
e58181a
docs(recipes): state ATOM PR #2380 as a hard prerequisite
Sep 24, 2026
7e63cdd
docs(recipes): add ubench07 fabric validation
Sep 24, 2026
02316bd
docs(recipes): document driver load and UALink training after a reboot
Sep 24, 2026
6ac1b94
docs(recipes): apply PR #2380 as a diff, not by swapping ATOM
Sep 24, 2026
fa3caad
recipe(k3-455-wideep): add throughput numbers, profiling, and AgentX …
Sep 24, 2026
7dde01f
recipe(k3-455-wideep): fix profiling -- CLI flag only, env var does n…
Sep 24, 2026
5ad42dc
recipe(k3-455-wideep): AgentX server launch, and the two knobs that l…
Sep 26, 2026
2bd34fb
recipe(k3-455-wideep): B0-built images need no translation; platform …
zejunchen-zejun Sep 28, 2026
6dc4ffa
recipe(k3-455-wideep): raise max-num-batched-tokens on 432 GiB boards
zejunchen-zejun Sep 28, 2026
70e6404
recipe(k3-455-wideep): AgentX numbers, 16 GPUs
zejunchen-zejun Sep 28, 2026
9c1706c
recipe(k3-455-wideep): --fake-eplb is the agentic method; concurrency…
zejunchen-zejun Sep 28, 2026
c3d2bcd
recipe(k3-455-wideep): VRAM alone does not tell you the rack is free
zejunchen-zejun Sep 28, 2026
e7381c7
recipe(k3-455-wideep): VRAM alone does not tell you the rack is free
zejunchen-zejun Sep 28, 2026
fd9e141
recipe(k3-455-wideep): appendix with the exact validated configuration
zejunchen-zejun Sep 28, 2026
2334162
recipe(k3-455-wideep): lead with the B0-built image and its agentic n…
zejunchen-zejun Sep 28, 2026
c66cd6a
recipe(k3-455-wideep): correct the A0/B0 framing and restructure arou…
zejunchen-zejun Sep 29, 2026
21e42ce
recipe(k3-455-wideep): MEGA_DISPATCH=flydsl is inert on the fp4 wire
zejunchen-zejun Sep 29, 2026
069bd43
perf(kimi-k3): add MI455 B0 optimization harness
XiaobingSuper Oct 2, 2026
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
91 changes: 91 additions & 0 deletions experiments/kimi_k3_b0/generate_bf16_sweep.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
#!/usr/bin/env python3

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ [ruff] <EXE001> reported by reviewdog 🐶
Shebang is present but file is not executable

"""Generate observed Kimi-K3 BF16 GEMM shapes for gfx1250 tuning."""

from __future__ import annotations

import argparse
import csv
from pathlib import Path


M_VALUES = (1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384)
Comment on lines +4 to +11

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ [ruff] <I001> reported by reviewdog 🐶
Import block is un-sorted or un-formatted

Suggested change
from __future__ import annotations
import argparse
import csv
from pathlib import Path
M_VALUES = (1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384)
from __future__ import annotations
import argparse
import csv
from pathlib import Path
M_VALUES = (1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384)


# Recurred in the B0 DP16/EP16 AgentX server logs. The first five families
# dominate the 16k chunked-prefill path; the rest are secondary projections.
HOT_FAMILIES = (
(67584, 7168),
(7168, 33792),
(12288, 7168),
(7168, 12288),
(7168, 6144),
)
SECONDARY_FAMILIES = (
(49376, 7168),
(18432, 1536),
(24576, 512),
(12288, 128),
(10240, 7168),
)

# The LM head is observed at small decode M. Sweeping it to the prefill budget
# would allocate a huge output shape that the serving path does not request.
LM_HEAD_FAMILY = (163840, 7168)
LM_HEAD_M_VALUES = (1, 2, 4, 8, 16)


def main() -> None:
parser = argparse.ArgumentParser()
parser.add_argument("output", type=Path)
parser.add_argument(
"--stage",
choices=("hot", "all"),
default="hot",
help="hot: five dominant families; all: include secondary and LM head",
)
args = parser.parse_args()

families = list(HOT_FAMILIES)
if args.stage == "all":
families.extend(SECONDARY_FAMILIES)

rows = []
for n, k in families:
rows.extend(
{
"M": m,
"N": n,
"K": k,
"bias": False,
"dtype": "torch.bfloat16",
"outdtype": "torch.bfloat16",
"scaleAB": False,
"bpreshuffle": False,
}
for m in M_VALUES
)
if args.stage == "all":
n, k = LM_HEAD_FAMILY
rows.extend(
{
"M": m,
"N": n,
"K": k,
"bias": False,
"dtype": "torch.bfloat16",
"outdtype": "torch.bfloat16",
"scaleAB": False,
"bpreshuffle": False,
}
for m in LM_HEAD_M_VALUES
)

args.output.parent.mkdir(parents=True, exist_ok=True)
with args.output.open("w", newline="") as f:
writer = csv.DictWriter(f, fieldnames=rows[0].keys())
writer.writeheader()
writer.writerows(rows)
print(f"wrote {len(rows)} shapes to {args.output}")


if __name__ == "__main__":
main()
161 changes: 161 additions & 0 deletions experiments/kimi_k3_b0/launch_server.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,161 @@
#!/bin/bash
set -euo pipefail

: "${DPRANK:?set DPRANK to this node first global DP rank}"

MASTER_IP="${MASTER_IP:-10.210.11.14}"
DATA_PARALLEL_SIZE="${DATA_PARALLEL_SIZE:-16}"
DATA_PARALLEL_SIZE_LOCAL="${DATA_PARALLEL_SIZE_LOCAL:-4}"
MAX_NUM_SEQS="${MAX_NUM_SEQS:-8}"
MAX_NUM_BATCHED_TOKENS="${MAX_NUM_BATCHED_TOKENS:-16384}"
GPU_MEMORY_UTILIZATION="${GPU_MEMORY_UTILIZATION:-0.94}"
ENABLE_PREFIX_CACHING="${ENABLE_PREFIX_CACHING:-1}"
FAKE_EPLB="${FAKE_EPLB:-1}"
MORI_FUSED="${MORI_FUSED:-1}"
SESSION_AFFINITY="${SESSION_AFFINITY:-1}"
PREFILL_DECODE_INTERVAL="${PREFILL_DECODE_INTERVAL:-0}"
PREFILL_DELAYER_TARGET_FILL="${PREFILL_DELAYER_TARGET_FILL:-0.9}"
BF16_GEMM_CONFIG="${BF16_GEMM_CONFIG:-}"
ONLINE_QUANT_CONFIG="${ONLINE_QUANT_CONFIG:-}"
DRAFT_MODEL_PATH="${DRAFT_MODEL_PATH:-}"
NUM_SPECULATIVE_TOKENS="${NUM_SPECULATIVE_TOKENS:-0}"
SPEC_DECODE_ACCEPTANCE_LENGTH="${SPEC_DECODE_ACCEPTANCE_LENGTH:-}"
CUDAGRAPH_CAPTURE_SIZES="${CUDAGRAPH_CAPTURE_SIZES:-}"
LONG_PREFILL_TOKEN_THRESHOLD="${LONG_PREFILL_TOKEN_THRESHOLD:-0}"
STATE_CHECKPOINT_INTERVAL_TOKENS="${STATE_CHECKPOINT_INTERVAL_TOKENS:-8192}"
STATE_CHECKPOINT_DEMAND="${STATE_CHECKPOINT_DEMAND:-1}"
ENABLE_REPLAYSSM="${ENABLE_REPLAYSSM:-0}"
MEGA_COMBINE_WIRE="${MEGA_COMBINE_WIRE:-bf16}"
DP_LB_REQ_EQUIV="${DP_LB_REQ_EQUIV:-512}"
ENABLE_PREFILL_DELAYER="${ENABLE_PREFILL_DELAYER:-1}"

export PYTORCH_ROCM_ARCH=gfx1250 AITER_RUNTIME_GPU_ARCH=gfx1250
export GPU_ARCHS=gfx1250 GPU_ARCH_LIST=gfx1250 MORI_GPU_ARCHS=gfx1250
export HSA_OVERRIDE_GFX_VERSION=12.5.0
export ENABLE_CK=0

export ATOM_USE_TRITON_MLA=1
export ATOM_USE_TRITON_MLA_SHUFFLE_KV=0
export ATOM_UNFUSED_GATHER_KV_B_PROJ=1
export ATOM_USE_AITER_TRITON_ATTN=1 ATOM_USE_UNIFIED_ATTN=1

export ATOM_MOE_GU_ITLV=1
export ATOM_USE_TRITON_MOE_DECODE=0
export MEGA_DISPATCH=mori MEGA_DISPATCH_WIRE=fp4
export ATOM_MORI_V2=1 ATOM_MORI_V2_FUSED="${MORI_FUSED}"
export ATOM_MEGA_COMBINE_WIRE="${MEGA_COMBINE_WIRE}"
export AITER_USE_GROUPED_GEMM=1 AITER_USE_OPUS_MOE_SORTING=1

export ATOM_USE_TRITON_GEMM=1 ATOM_WO_A_USE_FLYDSL=1
export ATOM_FP8_BLOCKSCALE_USE_E8M0_SCALE=1
export AITER_ROPE_TRITON_BACKEND=1 AITER_USE_SYSTEM_TRITON=1

export NCCL_MNNVL_ENABLE=1
export NCCL_IB_DISABLE=1 NCCL_P2P_DISABLE=0 NCCL_P2P_LEVEL=SYS
export NCCL_CUMEM_ENABLE=1
export ATOM_DP_LM_HEAD_MODE=allgather
export ATOM_USE_CUSTOM_ALL_GATHER=1 AITER_CUSTOM_AR_USE_SYMM_MEM=1
export MORI_SOCKET_IFNAME=enp1s0f1
export NCCL_SOCKET_IFNAME=enp1s0f1
export GLOO_SOCKET_IFNAME=enp1s0f1

export ATOM_DP_SESSION_AFFINITY="${SESSION_AFFINITY}"
export ATOM_DP_LB_REQ_EQUIV="${DP_LB_REQ_EQUIV}"
export ATOM_ENABLE_PREFILL_DELAYER="${ENABLE_PREFILL_DELAYER}"
export ATOM_PREFILL_DECODE_INTERVAL="${PREFILL_DECODE_INTERVAL}"
export ATOM_PREFILL_DELAYER_TARGET_FILL="${PREFILL_DELAYER_TARGET_FILL}"
export ATOM_STATE_CHECKPOINT_DEMAND="${STATE_CHECKPOINT_DEMAND}"
export ATOM_ENABLE_REPLAYSSM="${ENABLE_REPLAYSSM}"
export HSA_XNACK=1 HSA_USE_SVM=1 HSA_ENABLE_SDMA=1
export ATOM_LOADER_USE_THREADPOOL=1 ATOM_LOADER_NUM_THREADS=4
if [[ -n "${BF16_GEMM_CONFIG}" ]]; then
export AITER_CONFIG_GEMM_BF16="${BF16_GEMM_CONFIG}"
fi

# PR #2380 defines this runtime switch. Stock image ATOM silently ignores the
# environment variable, then crashes on a long chunked prefill. Fail before
# allocating model weights when the required patch was not installed.
python3 -c '
from atom.utils import envs
assert hasattr(envs, "ATOM_UNFUSED_GATHER_KV_B_PROJ"), (
"Kimi-K3 gfx1250 requires ATOM PR #2380; "
"ATOM_UNFUSED_GATHER_KV_B_PROJ is missing"
)
'

if [[ "${MEGA_COMBINE_WIRE}" != "bf16" ]]; then
python3 -c '
import inspect
from atom.model_ops.fused_moe.mori_v2_prepare_finalize import _import_mega

mega = _import_mega()
assert "combine_quant" in inspect.signature(mega.__init__).parameters, (
"ATOM_MEGA_COMBINE_WIRE=fp8/fp4 requires ROCm/AITER #5176 "
"(commit 22ab77eb19d3); the installed AITER predates quantized combine"
)
assert "combine_quant" in inspect.signature(mega.__call__).parameters, (
"installed MegaMoEGfx1250 cannot select a quantized combine wire per step"
)
'
fi

args=(
--model /models/Kimi-K3
--served-model-name moonshotai/Kimi-K3
--trust-remote-code
-tp 1
--data-parallel-size "${DATA_PARALLEL_SIZE}"
--data-parallel-size-local "${DATA_PARALLEL_SIZE_LOCAL}"
--data-parallel-rank "${DPRANK}"
--data-parallel-master-ip "${MASTER_IP}"
--data-parallel-master-port 29500
--data-parallel-base-port 29700
--enable-expert-parallel
--enable-dp-attention
--kv_cache_dtype fp8
--index-cache-dtype fp8
--cudagraph-mode FULL
--max-num-seqs "${MAX_NUM_SEQS}"
--max-num-batched-tokens "${MAX_NUM_BATCHED_TOKENS}"
--long-prefill-token-threshold "${LONG_PREFILL_TOKEN_THRESHOLD}"
--state-checkpoint-interval-tokens "${STATE_CHECKPOINT_INTERVAL_TOKENS}"
--gpu-memory-utilization "${GPU_MEMORY_UTILIZATION}"
--disable_uvicorn_access_log
)

if [[ "${ENABLE_PREFIX_CACHING}" == "1" ]]; then
args+=(--enable_prefix_caching)
else
args+=(--no-enable_prefix_caching)
fi

if [[ "${FAKE_EPLB}" == "1" ]]; then
args+=(--fake-eplb)
fi

if [[ -n "${ONLINE_QUANT_CONFIG}" ]]; then
args+=(--online_quant_config "${ONLINE_QUANT_CONFIG}")
fi

if [[ "${NUM_SPECULATIVE_TOKENS}" != "0" ]]; then
: "${DRAFT_MODEL_PATH:?set DRAFT_MODEL_PATH when speculative decoding is enabled}"
args+=(
--method dspark
--draft-model "${DRAFT_MODEL_PATH}"
--num-speculative-tokens "${NUM_SPECULATIVE_TOKENS}"
)
if [[ -n "${SPEC_DECODE_ACCEPTANCE_LENGTH}" ]]; then
args+=(--spec-decode-acceptance-length "${SPEC_DECODE_ACCEPTANCE_LENGTH}")
fi
fi

if [[ -n "${CUDAGRAPH_CAPTURE_SIZES}" ]]; then
args+=(--cudagraph-capture-sizes "${CUDAGRAPH_CAPTURE_SIZES}")
fi

if [[ -n "${TORCH_PROFILER_DIR:-}" ]]; then
args+=(--torch-profiler-dir "${TORCH_PROFILER_DIR}")
fi

cd /tmp
exec python3 -m atom.entrypoints.openai_server "${args[@]}"
46 changes: 46 additions & 0 deletions experiments/kimi_k3_b0/run_agentx.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
#!/bin/bash
set -euo pipefail

CONCURRENCY="${CONCURRENCY:-32}"
BENCHMARK_DURATION="${BENCHMARK_DURATION:-900}"
WARMUP_REQUESTS_PER_LANE="${WARMUP_REQUESTS_PER_LANE:-3}"
RUN_NAME="${RUN_NAME:-agentx-c${CONCURRENCY}-$(date -u +%Y%m%d_%H%M%S)}"
AIPERF="${AIPERF:-/root/agentx/venv/bin/aiperf}"
ARTIFACT_ROOT="${ARTIFACT_ROOT:-/root/agentx/artifacts-opt}"
SERVER_URL="${SERVER_URL:-http://10.210.11.14:8000}"

unset HTTP_PROXY HTTPS_PROXY http_proxy https_proxy
export AIPERF_DATASET_CONFIGURATION_TIMEOUT=1800
export AIPERF_SERVICE_PROFILE_CONFIGURE_TIMEOUT=1800
export AIPERF_UI_REALTIME_METRICS_ENABLED=true
export AIPERF_HTTP_TCP_USER_TIMEOUT=900000

artifact_dir="${ARTIFACT_ROOT}/${RUN_NAME}"
mkdir -p "${artifact_dir}"

exec "${AIPERF}" profile \
--scenario inferencex-agentx-mvp \
--url "${SERVER_URL}" \
--endpoint /v1/chat/completions \
--endpoint-type chat \
--streaming \
--model moonshotai/Kimi-K3 \
--tokenizer moonshotai/Kimi-K3 \
--tokenizer-trust-remote-code \
--apply-chat-template \
--concurrency "${CONCURRENCY}" \
--benchmark-duration "${BENCHMARK_DURATION}" \
--stats-interval 30 \
--random-seed 42 \
--failed-request-threshold 0.10 \
--trajectory-start-min-ratio 0.25 \
--trajectory-start-max-ratio 0.75 \
--warmup-requests-per-lane "${WARMUP_REQUESTS_PER_LANE}" \
--warmup-grace-period 1800 \
--trace-idle-gap-cap-seconds 300 \
--use-server-token-count \
--no-gpu-telemetry \
--num-dataset-entries 393 \
--slice-duration 1.0 \
--public-dataset semianalysis_cc_traces_weka_062126 \
--output-artifact-dir "${artifact_dir}"
Loading