Environment variables reference
Code version: afd-plugin @ 7452d52 · 2026-10-27 · vLLM @ ced6857
In one sentence
The plugin reads some settings from the environment, not from the AFD config. This page lists every one, with its default and read site.
How the plugin uses the environment#
Most AFD settings go through --additional-config (see AFD config reference: the additional_config["afd"] keys). A
smaller set of settings comes from environment variables. The plugin uses them for build-time choices, the
profilers, the Ascend operator loader, the benchmark routing strategy, and a few runtime switches. The AFD
config values do not change these; you set them in the shell.
The table below is generated from the source, so the names, defaults and lines stay correct at the pinned
commit. Run python3 tools/gen_env_vars.py to refresh it. The generator parses the Python with
ast only; it never imports the plugin or vLLM.
Every variable the plugin reads or sets#
The Kind column says what the plugin does with the variable: reads it,
sets it, or prepends a path to it. A default shows only where the read site gives
one. Build-time variables (in setup.py) run at install time, not at serve time.
Generated by tools/gen_env_vars.py from afd_plugin/** and setup.py. Each variable is listed with its default (when the read site gives one), whether the plugin reads, sets or prepends it, and every source line. Do not edit between the markers.
51 environment variables.
| Variable | Default | Kind | Read at |
|---|---|---|---|
AFD_ASYNC_CAM_LAYERED_GMM | '' | reads | afd_plugin/envs.py:19 |
AFD_ASYNC_MOE_LAYOUT_LOG | '' | reads | afd_plugin/model_executor/models/npu/async_cam_layout.py:187 |
AFD_BENCHMARK_FORCE_LB_TOPN_PER_RANK | '0' | reads | afd_plugin/model_executor/routing_simulator.py:127 |
AFD_BUILD_ASCEND_OPS | — | reads | setup.py:44 |
AFD_CAM_OP_IO_LOG | '' | reads | afd_plugin/connectors/npu/async_cam.py:955 |
AFD_CUST_OPAPI_LIB_PATH | — | sets | afd_plugin/compat/npu/ops.py:54 |
AFD_FORCE_BALANCED_TOPK_IDS | '' | reads | afd_plugin/envs.py:15 |
AFD_FORCE_SPAWN_MULTIPROCESSING | — | reads | afd_plugin/__init__.py:60 |
AFD_GPU_ATTENTION_PROFILER_ACTIVE | 10 | reads | afd_plugin/compat/profiler.py:54 |
AFD_GPU_ATTENTION_PROFILER_DIR | './profiler_logs/attn' | reads | afd_plugin/compat/profiler.py:60 |
AFD_GPU_ATTENTION_PROFILER_ENABLE | False | reads | afd_plugin/compat/profiler.py:51 |
AFD_GPU_ATTENTION_PROFILER_REPEAT | 1 | reads | afd_plugin/compat/profiler.py:55 |
AFD_GPU_ATTENTION_PROFILER_SKIP_FIRST | 0 | reads | afd_plugin/compat/profiler.py:56 |
AFD_GPU_ATTENTION_PROFILER_WAIT | 2500 | reads | afd_plugin/compat/profiler.py:52 |
AFD_GPU_ATTENTION_PROFILER_WARMUP | 1 | reads | afd_plugin/compat/profiler.py:53 |
AFD_GPU_FFN_PROFILER_ACTIVE | 10 | reads | afd_plugin/compat/profiler.py:54 |
AFD_GPU_FFN_PROFILER_DIR | './profiler_logs/ffn' | reads | afd_plugin/compat/profiler.py:60 |
AFD_GPU_FFN_PROFILER_ENABLE | False | reads | afd_plugin/compat/profiler.py:51 |
AFD_GPU_FFN_PROFILER_REPEAT | 1 | reads | afd_plugin/compat/profiler.py:55 |
AFD_GPU_FFN_PROFILER_SKIP_FIRST | 0 | reads | afd_plugin/compat/profiler.py:56 |
AFD_GPU_FFN_PROFILER_WAIT | 2500 | reads | afd_plugin/compat/profiler.py:52 |
AFD_GPU_FFN_PROFILER_WARMUP | 1 | reads | afd_plugin/compat/profiler.py:53 |
AFD_NPU_ATTENTION_PROFILER_ACTIVE | 10 | reads | afd_plugin/compat/npu/profiler.py:61 |
AFD_NPU_ATTENTION_PROFILER_DIR | '/tmp/profile/attn' | reads | afd_plugin/compat/npu/profiler.py:67 |
AFD_NPU_ATTENTION_PROFILER_ENABLE | False | reads | afd_plugin/compat/npu/profiler.py:58 |
AFD_NPU_ATTENTION_PROFILER_REPEAT | 1 | reads | afd_plugin/compat/npu/profiler.py:62 |
AFD_NPU_ATTENTION_PROFILER_SKIP_FIRST | 1500 | reads | afd_plugin/compat/npu/profiler.py:63 |
AFD_NPU_ATTENTION_PROFILER_WAIT | 2 | reads | afd_plugin/compat/npu/profiler.py:59 |
AFD_NPU_ATTENTION_PROFILER_WARMUP | 1 | reads | afd_plugin/compat/npu/profiler.py:60 |
AFD_NPU_ATTENTION_PROFILER_WITH_STACK | False | reads | afd_plugin/compat/npu/profiler.py:68 |
AFD_NPU_FFN_PROFILER_ACTIVE | 20 | reads | afd_plugin/compat/npu/profiler.py:61 |
AFD_NPU_FFN_PROFILER_DIR | '/tmp/profile/ffn' | reads | afd_plugin/compat/npu/profiler.py:67 |
AFD_NPU_FFN_PROFILER_ENABLE | False | reads | afd_plugin/compat/npu/profiler.py:58 |
AFD_NPU_FFN_PROFILER_REPEAT | 1 | reads | afd_plugin/compat/npu/profiler.py:62 |
AFD_NPU_FFN_PROFILER_SKIP_FIRST | 1500 | reads | afd_plugin/compat/npu/profiler.py:63 |
AFD_NPU_FFN_PROFILER_WAIT | 2 | reads | afd_plugin/compat/npu/profiler.py:59 |
AFD_NPU_FFN_PROFILER_WARMUP | 1 | reads | afd_plugin/compat/npu/profiler.py:60 |
AFD_NPU_FFN_PROFILER_WITH_STACK | False | reads | afd_plugin/compat/npu/profiler.py:68 |
AFD_SKIP_ACLNN_BUILD | '0' | reads | setup.py:66 |
ASCEND_CUSTOM_OPP_PATH | — | prepends | afd_plugin/compat/npu/ops.py:48 |
ASCEND_HOME_PATH | — | reads | setup.py:38 setup.py:98 setup.py:99 |
ASCEND_OPP_PATH | — | reads | setup.py:38 |
ASCEND_TOOLKIT_HOME | — | reads | setup.py:38 |
BATCH_SIZE_FACTOR | '1' | reads | afd_plugin/compat/npu/feature_validation.py:247 afd_plugin/validation.py:52 |
CMAKE_BUILD_TYPE | 'Release' | reads | setup.py:85 |
LD_LIBRARY_PATH | — | prepends | afd_plugin/compat/npu/ops.py:51 |
MAX_JOBS | — | reads | setup.py:104 |
SOC_VERSION | '910c' | reads | setup.py:67 setup.py:88 |
TORCH_NPU_PATH | — | reads | setup.py:38 setup.py:100 setup.py:101 |
VLLM_ASCEND_ENABLE_FLASHCOMM1 | '0' | reads | afd_plugin/compat/npu/feature_validation.py:190 afd_plugin/connectors/npu/async_cam.py:427 |
VLLM_TORCH_PROFILER_DIR | — | reads | afd_plugin/compat/npu/profiler.py:149 afd_plugin/compat/profiler.py:132 |
What each group does#
The generated table gives the default and the read site. This section gives the effect, with a citation. The variables fall into five groups.
Deep diveMultiprocessing
AFD_FORCE_SPAWN_MULTIPROCESSING— when set to1,register_afdforces thespawnmultiprocessing start method at import and at registration (afd_plugin/__init__.py:55-62). AFD needs separate processes per role, so the start method matters. See The plugin entry point: register_afd.
Deep diveBuild-time (setup.py)
These run at install time, when you build the plugin. They decide whether to build the Ascend operators and how. They have no effect on a running server.
AFD_BUILD_ASCEND_OPS— forces the Ascend operator build on or off. When unset, the build auto-detects an Ascend platform (setup.py:43-54).AFD_SKIP_ACLNN_BUILD— when not1, the build runscsrc/npu/build_aclnn.sh(setup.py:66-71).SOC_VERSION— the Ascend SoC version passed to the operator build; default910c(setup.py:67,setup.py:88).CMAKE_BUILD_TYPE— the CMake build type; defaultRelease(setup.py:85).ASCEND_HOME_PATH,TORCH_NPU_PATH— passed to CMake when set (setup.py:98-101); also two of the four variables that mark an Ascend platform (setup.py:18-23,setup.py:38).ASCEND_OPP_PATH,ASCEND_TOOLKIT_HOME— the other two platform markers (setup.py:18-23,setup.py:38).MAX_JOBS— the parallel build job count; defaults to the CPU count (setup.py:104).
Deep diveProfilers
The plugin owns a torch profiler for each GPU runner role and each NPU runner role. Each family has its own
prefix: AFD_GPU_ATTENTION_PROFILER, AFD_GPU_FFN_PROFILER,
AFD_NPU_ATTENTION_PROFILER, AFD_NPU_FFN_PROFILER. The suffix picks the setting
(_ENABLE, _WAIT, _WARMUP, _ACTIVE, _REPEAT,
_SKIP_FIRST, _DIR; the NPU profiler adds _WITH_STACK). The GPU profiler
reads them in afd_gpu_profiler_config (afd_plugin/compat/profiler.py:46-61); the NPU
profiler in afd_npu_profiler_config (afd_plugin/compat/npu/profiler.py:52-70).
..._ENABLE— turns the profiler on for that role; default off. Only when it is on does the plugin build a torch profiler (afd_plugin/compat/profiler.py:64-96)...._WAIT,..._WARMUP,..._ACTIVE,..._REPEAT,..._SKIP_FIRST— the torch profiler schedule (afd_plugin/compat/profiler.py:83-89)...._DIR— the trace output directory. When unset, the plugin falls back toVLLM_TORCH_PROFILER_DIR, then to the per-role default (afd_plugin/compat/profiler.py:131-132)...._WITH_STACK(NPU only) — records Python stacks in the trace (afd_plugin/compat/npu/profiler.py:69).
Deep diveBenchmark and routing
AFD_BENCHMARK_FORCE_LB_TOPN_PER_RANK— limits the local expert pool per EP rank in the afd_balanced routing routing strategy;0selects all local experts (afd_plugin/model_executor/routing_simulator.py:125-127). It changes model outputs, so it is for benchmark runs only. See Tuning: the knobs the repo exposes.AFD_FORCE_BALANCED_TOPK_IDS— a runtime switch for balanced top-k expert ids (afd_plugin/envs.py:14-15).
Deep diveAscend (NPU) runtime
These matter only on an Ascend NPU. The Ascend NPU overview: the same contract, different transports page covers the NPU path.
BATCH_SIZE_FACTOR— multiplies the CAM receive capacity (262144 × factor, with native float rounding), and marks the async FFN graph capacity (afd_plugin/validation.py:45-54,afd_plugin/compat/npu/feature_validation.py:245-249). Default1.AFD_CUST_OPAPI_LIB_PATH— the loader sets this to the plugin's custom op-API library path when it exists (afd_plugin/compat/npu/ops.py:52-54).ASCEND_CUSTOM_OPP_PATH,LD_LIBRARY_PATH— the loader prepends the plugin's vendor paths to these (afd_plugin/compat/npu/ops.py:43-54).AFD_ASYNC_CAM_LAYERED_GMM— selects the layered GMM path for the async CAM connector (afd_plugin/envs.py:18-19).AFD_CAM_OP_IO_LOG,AFD_ASYNC_MOE_LAYOUT_LOG— diagnostic logging switches (afd_plugin/connectors/npu/async_cam.py:955,afd_plugin/model_executor/models/npu/async_cam_layout.py:187).VLLM_ASCEND_ENABLE_FLASHCOMM1— a vLLM-Ascend switch the plugin reads to gate a feature path (afd_plugin/compat/npu/feature_validation.py:188-191,afd_plugin/connectors/npu/async_cam.py:425-428).
vLLM variables that AFD depends on#
These variables belong to vLLM, not to the plugin, but AFD needs them set correctly. The recipes set the first one.
| Variable | Why AFD needs it | Source (vLLM) |
|---|---|---|
VLLM_USE_V2_MODEL_RUNNER |
AFD runs on Model Runner V2. The validator raises when V2 resolves to off
(afd_plugin/validation.py:90-91). When the variable is unset, vLLM still picks V2 by default;
the recipes set it to 1 to be explicit. |
vllm:vllm/envs.py:2037-2038, vllm:vllm/config/vllm.py:692-694 |
VLLM_PLUGINS |
vLLM's plugin loader filters by this list. AFD loads only when afd is in the list, or
the variable is unset (vllm:vllm/plugins/__init__.py:64). An empty string loads no plugin. |
vllm:vllm/envs.py:1146-1150 |
VLLM_MOE_ROUTING_SIMULATION_STRATEGY |
Selects a routing strategy. Set it to afd_balanced to use the plugin's deterministic
benchmark routing (afd_plugin/model_executor/routing_simulator.py:5-8). |
vllm:vllm/envs.py:1743-1745 |
VLLM_TORCH_PROFILER_DIR |
The plugin profilers fall back to this directory for traces when the per-role
..._DIR is unset (afd_plugin/compat/profiler.py:131-132). |
Not declared in vLLM v0.30.0 (see note). |
Refreshing this page#
Run the generator from the explainer folder:
python3 tools/gen_env_vars.py # rewrite the table
python3 tools/gen_env_vars.py --check # exit 1 if the table is out of date
python3 tools/gen_env_vars.py --report # print the extracted facts