Guidance for AI agents working with InferenceX.
- Start every task with
docs/index.md. Choose the one focused guide that matches the task. Do not load every documentation page. - Repository source, schemas, workflows, launchers, and collectors are authoritative. If documentation disagrees with implementation, follow the implementation and update the nearest English guide plus its Chinese counterpart.
- Read
CONTRIBUTING.mdbefore opening or reviewing a PR or changing review, sweep, or merge policy. - Read
KLAUD_DEBUG.mdbefore debugging a Klaud-Cold orclaude/*image-bump PR.
- Pareto logic changes must update both InferenceX and InferenceX-app with matching regression tests and cross-linked PRs.
- Every PR description must include an AI model disclosure section naming the exact model/version used to prepare the PR. List each contributing model and its role, including delegated agents. Tool names such as Claude Code, Cursor, or Perplexity Computer are not model identities. Copy the model identifier exposed by the runtime; do not guess an unavailable identifier. If the runtime does not expose the exact model, explicitly state that it could not be verified. Human-only PRs must state
No AI used. Keep the disclosure current when later edits use another model. - Repository skills are canonical under
.agents/skills/. Add or update skills there..claude/skills/contains compatibility symlinks for Claude discovery. - PR and issue titles, descriptions, and human-authored PR comments must include English and natural Simplified Chinese. Titles use
<English title> / <中文标题>. In bodies and comments, keep English visible and put Chinese in one collapsed<details><summary>中文</summary>section. Keep code, commands, logs, stack traces, model names, hardware SKUs, framework names, flags, and identifiers unchanged. The exact CODEOWNER sign-off template is English-only. Seedocs/documentation-procedures.mdand.github/AGENT_OPERATIONS.md. - One reviewer checklist per PR: Only one eligible CODEOWNER reviewer needs to post the completed PR Review Checklist. Check for an existing checklist before posting; other reviewers do not need to duplicate it. The original reviewer must edit their existing checklist comment when correcting items or adding evidence, rather than post a new checklist. Create a replacement only if the original was deleted. See
CONTRIBUTING.md. - Klaud Cold reports: Follow the compact body/comment templates in
docs/klaud-reporting.md, including cleanup and completion reports. - Commit subjects use conventional English style, while commit bodies include the Chinese translation. Contributor-facing docs use English as the source version and ship with a synchronized
_zh.mdpage and language switcher. - Python under
infx/uses all stable Ruff rules with reviewed exclusions ininfx/ruff.toml, line length 100, and the Ruff formatter. The Lint job in.github/workflows/ci.ymlruns whenever Python files change and fails on any finding. Before pushing Python changes, run the commands in the testing guide. Fix findings where practical; justified exceptions use inline# noqa: CODErather than file-wide ignores. - Follow the nearest existing pattern. Python uses typed signatures and strict Pydantic schemas. YAML uses kebab-case fields. Shared benchmark Bash behavior belongs in
benchmark_lib.sh, with parameters passed through environment variables.
These rules apply to active Bash scripts and shell commands embedded in workflows and recipes. Follow them when adding, changing, or reviewing Bash code. Leave deprecated code alone unless explicitly asked to update it.
- Configuration flows from the caller. Workflows, master configs, runtime profiles, and launchers explicitly supply configuration to the scripts they invoke. Receiving scripts consume and validate those inputs; they must not silently choose defaults.
- No fallback defaults for caller-supplied configuration. Avoid
${VAR:-default},${VAR:=default}, their colon-free equivalents, and equivalent "if unset, assign a default" logic. A missing input is a caller error and must fail clearly. Pass values such asfalseand0explicitly too. - Validate every required environment input with
check_env_varsbefore use. Use the shared helper inbenchmarks/benchmark_lib.sh. Group required inputs near the beginning, after sourcing the helper; validate inputs used only by a particular execution path when entering that path. The helper rejects both missing and empty values. Do not duplicate it or remove its safe handling of unset variables. Callers needing validation without benchmark initialization can source the library with--validation-only. - Do not enable nounset. No
set -u,set -o nounset, combined flags such asset -euo pipefail, orbash -uinvocation flags. Use explicit validation; preserve other intended shell options, for exampleset -eo pipefail. - Preserve configuration precedence and forwarding. Apply caller-owned settings before recipe-specific overrides, and explicitly forward required inputs across container or job boundaries. Do not replace a supported override with an unconditional assignment in the receiving script.
- Preserve deliberate optional-input handling, runtime-derived values, and unset-safe internal-state probes. These are not permission to invent fallback configuration or replace a documented automatic selection with an arbitrary constant.
For example, remove this from the receiving script:
export IS_MULTINODE="${IS_MULTINODE:-true}"Set it in the responsible caller:
export IS_MULTINODE=trueThen validate it in the receiving script after sourcing the shared helper:
check_env_vars IS_MULTINODE MODEL_NAME PRECISION- Move deprecated entries out of the active master config into
configs/deprecated/amd-master.yamlorconfigs/deprecated/nvidia-master.yaml, matching the vendor. These are the only deprecated master-config files; do not create separate files per model, scenario, or deprecation. - For a partial deprecation, archive only the retired scenarios and retain the supported scenarios in the active entry. Preserve archived settings and explanatory comments; do not update historical image pins or runners during archival.
- Keep every archive key unique. If a key already exists with different settings, preserve both versions with a descriptive suffix on the historical key and a comment recording its original config key. Existing colliding 1k1k versions use
-deprecated-1k1k. Never overwrite an archived version or add duplicate YAML keys. - Check retirement statements in
MODELS.mdagainst active configs and script routing in the same PR, and updateMODELS.mdplusMODELS_zh.mdtogether. Preserve explicitly documented exceptions and conditional retirement policies; do not treat planned retirement as completed. - Remove unused retired-model branches from launchers and runtime settings, and update workflow/agent guidance that still recommends retired coverage. Audit callers before removing shared helpers; retained SPEED-Bench collectors and historical result readers may still need model-specific support.
- Keep these archives out of active sweep inputs. Follow the existing benchmark-script archival convention, moving retired scripts into the sibling
deprecated/directory only when no active config still uses them.
- The reusable workflows run
bash ./runners/launch_${RUNNER_NAME%%_*}.sh. The runner-name prefix before the first underscore is the only routing key, so each self-hosted pool maps to exactly onerunners/launch_<pool>.sh, and everyrunners/launch_*.shmust be the launcher of a pool listed inconfigs/runners.yaml. For example, runnerb200-nscale-slurm_03runsrunners/launch_b200-nscale-slurm.sh. See Stage 4 indocs/architecture.md. - Do not add a second launcher for a pool and
execinto it for some jobs. Different execution paths for one pool (single-nodesalloc, srt-slurm recipes, cluster-maintained lanes) branch inside that pool's one file. Select the path once near the top and name it, so the routing for a pool reads in one place. - Do not add launcher-name aliases to
runners/runtime_settings.shor elsewhere for scripts that no runner resolves to. A launcher without a pool is dead code; a pool without a launcher fails at job start. - When a pool is retired, delete its launcher in the same PR rather than keeping it as a fallback for another pool.
- Do not hard-code synthetic acceptance lengths in SRT recipes, master configs, or launchers. InferenceX automatically selects the measured value from
golden_al_distribution/for speculative AgentX throughput runs. Do not add manualSYNTHETIC_ACCEPTANCE_LENGTH, vLLMsynthetic_acceptance_length, SGLangSGLANG_SIMULATE_ACC_LEN, or TRT-LLMTLLM_SPEC_DECODE_FORCE_NUM_ACCEPTED_TOKENSsettings. - Submit recipes through
apply_srt_recipe. Itsinfx/srt_slurmconnector applies native SRT--set/--unsetoverrides; calling upstreamsrtctldirectly does not perform InferenceX's automatic selection. - Keep the actual speculative method, draft model, draft-token count, and relevant sampling settings explicit in the recipe. The connector combines the generation role's settings (decode, otherwise aggregated), after caller overrides, with
MODEL_PREFIXandTHINKING_MODEto select the golden curve. For Kimi DSpark, explicitly setdraft_sample_methodtogreedyorprobabilistic. - Eval-only and non-AgentX runs use real verification; the connector removes stale synthetic settings. Non-speculative roles do not receive simulation settings.
RUN_EVALdoes not disable simulation for the throughput portion. - Missing golden curves or unmeasured draft lengths fail before submission. Add the corresponding measured golden data when supporting a new combination; do not work around the error with a guessed or hard-coded acceptance length.
The one rule: a test must exercise the real implementation with concrete inputs and assert on what it computes, returns, writes, or raises. A test that inspects the code, the repo, or a config file instead of running behavior is not a test and must be deleted. These rules are mandatory for every test added, modified, or reviewed in this repository. When in doubt, delete the test.
Never write, and always delete on sight, a test that does any of the following:
- Reads source text and asserts on it. Opening a
.sh,.py,.yml,.yaml,.cjs, or.mdfile and asserting that a string, flag, regex, command, or line is present or absent, counting occurrences, or checking line order. This includes launchers, workflow files, skill files, and docs. Grepping is not testing. - Parses source structure. Using
ast.parse,inspect.getsource,inspect.signature,hasattr,callable,__doc__, or import-succeeds checks to assert that a function, class, constant, argument, or flag exists or has a given shape. - Git-greps the repo. Asserting which files contain a literal, how many files match, or that a pin appears in exactly N places.
- Pins checked-in config or data. Asserting the contents of a recipe, master config,
runners.yaml,platform_config.json, a registry dict, an enum, an image tag, a SHA, a port number, or the current count of recipes, SKUs, backends, or models. Validate config through the real validation code with controlled inputs instead. - Is tautological. Asserting a constant equals its own literal; asserting a dict or fixture equals what the test just built; asserting only that a mock was called with the arguments the test itself passed; or computing the expected value with the same helper, formula, or algorithm the test is supposed to check.
- Reimplements the code under test. Any parser, filter, jq/YAML expression, argparse tree, formula, or state machine copied into the test file so the test can run against the copy. This also covers "mirror" parsers and "reference specs" cross-checked against a second in-test implementation.
- Tests the test infrastructure. Tests of fixtures, conftest helpers, in-test expression evaluators, or "this test has teeth" self-checks.
- Is smoke-only. Module imports,
--helpexits 0, or "does not raise" with no assertion on output. - Duplicates a covered path. Several tests that reach the same branch with trivially different inputs. Keep one, or use
pytest.mark.parametrize/subTest. A second test is justified only by a distinct branch, error path, or boundary.
- Feeds small, controlled inputs into the real function, CLI, or script and asserts on the computed output, written artifact, exit code, or raised error.
- Uses expected values worked out independently by hand, never derived by calling the implementation or its helpers.
- Covers a specific branch, boundary, malformed input, or failure path that no other test already covers.
- Mocks only external collaborators (network, GitHub, Slurm, clocks, GPUs), never the behavior under test. Shell scripts are tested by running them with stubbed binaries on
PATHand checking what they produced, not by reading their text. - Would fail on a plausible regression in observable behavior, and would not fail on a harmless refactor, a rename, or the addition of a valid recipe or SKU.
- Which line of the real implementation does this run, and what bug in it would make the assertion fail?
- Would this test still pass if the code were rewritten with identical behavior? If not, it is testing structure and must go.
- Would this test fail because someone added a recipe, bumped an image tag, or reworded a comment? If yes, it is pinning config or source and must go.
- Does an existing test already reach this branch? If yes, extend it or drop the new one.
Deleting a test that fails these questions needs no replacement. Do not preserve test counts. See the testing guide for the reasoning and Randy Coulman's Tautological Tests for the distinction between independent expectations and assertions that repeat the implementation.
- Every priority-scheduled benchmark job on a self-hosted cluster must request exactly one
nodes:Nlabel, whereNis the positive integer number of physical Slurm nodes required. Single-node jobs usenodes:1; generated multi-node jobs must forward their computednode-count. A queued job missing this label is ineligible for priority scheduling, and labels cannot be added retroactively, so fix the source branch and dispatch a new run. - Every change that can affect benchmark performance and every recipe addition or modification requires a new
perf-changelog.yamlentry. The file is append-only and byte-sensitive. Preserve all existing bytes and separator whitespace, and append only at the tail. - Multi-node srt-slurm changes update the recipe YAML and matching master config together. For image bumps,
model.containermust equalimage. - Every
*_mtp.shpasses--use-chat-templatetorun_benchmark_serving. - Benchmarks create no new directories under
/workspace. Root containers must not leave root-owned files in shared AMD runner workspaces. - Generated configuration is not runtime proof. Run the narrowest local check, then the applicable smoke, sweep, or eval procedure from
docs/procedures.md.
All repository maps, task routes, commands, schemas, sweep semantics, artifact contracts, recovery steps, and detailed conventions live behind docs/index.md.