Skip to content

Commit 4e0fddd

Browse files
authored
[TRTLLM-17679][feat] KernelBuilder build mode and autotuner tune mode on per-rank worker processes; JIT builds shared within a node by default (#22374)
Signed-off-by: chenfeiz0326 <203214996+chenfeiz0326@users.noreply.github.com> Co-authored-by: chenfeiz0326 <203214996+chenfeiz0326@users.noreply.github.com>
1 parent bacc8ef commit 4e0fddd

30 files changed

Lines changed: 5428 additions & 199 deletions

‎docs/source/llm-api/index.md‎

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ configured environment variable takes precedence.
245245
| `FLASHINFER_WORKSPACE_BASE` | `$HOME/.cache/tensorrt_llm/flashinfer/rank-N` in MPI workers (see below), `$HOME/.cache/flashinfer` otherwise | `flashinfer/rank-N` in MPI workers, `flashinfer` otherwise |
246246
| `CUTE_DSL_CACHE_DIR` | `/tmp/$USER/cutlass_python_cache` | `cute_dsl` |
247247
| `DG_JIT_CACHE_DIR` | `$HOME/.deep_gemm` | `deep_gemm` |
248-
| `TLLM_JIT_SHARE_DIR` | Disabled | Not set (one directory per launch, see below) |
248+
| `TLLM_JIT_SHARE_DIR` | Not set: `/tmp/tllm-jit-<uid>/<launch>` for a launch of several processes per node (see below) | Not set (one directory per launch, see below) |
249249
| `TRTLLM_DG_CACHE_DIR` | Disabled | `trtllm_deep_gemm` |
250250
| `CUDA_CACHE_PATH` | `$HOME/.nv/ComputeCache` | `cuda` |
251251

@@ -296,6 +296,25 @@ at most `TLLM_JIT_SHARE_WAIT_S` seconds (default 60) and then builds the kernel
296296
itself, as it does whenever the directory cannot be used.
297297
`TLLM_JIT_SHARE_LOG=1` records each kernel in `<TLLM_JIT_SHARE_DIR>/log`.
298298

299+
Without `TLLM_JIT_SHARE_DIR`, the processes of a launch that run on one node share their
300+
builds this way by default, through `/tmp/tllm-jit-<uid>/<launch>` on the node's local disk.
301+
This applies to a launch of several processes per node that its launcher names: a PMIx
302+
namespace, a Slurm job step, a torchrun run (`--rdzv_id` or `--standalone`), or a DWDP
303+
rendezvous. That directory leaves DeepGEMM's disk cache where it is, and launch directories
304+
whose processes have all exited are removed after six hours.
305+
`TLLM_JIT_SHARE_DEFAULT=0` turns the default directory off. Where it cannot be used (another
306+
user can write to `/tmp/tllm-jit-<uid>`, or no launcher names the launch), each process builds
307+
its kernels itself and logs why once.
308+
309+
During the memory-profiling warmup, ops that opt in build their JIT kernels ahead, in
310+
parallel, on worker processes of each rank (KernelBuilder). The workers start only while the
311+
rank's GPU keeps 8 GiB free, and stop when the warmup ends.
312+
`TLLM_KERNEL_BUILDER_WORKERS` caps the workers of a rank (default: its share of the CPUs, up
313+
to 8). A worker that does not reply to a build within `TLLM_KERNEL_BUILDER_BUILD_TIMEOUT_S`
314+
seconds (default 900; `0` waits without a limit) is stopped, and that kernel builds where it is
315+
first used. `TLLM_KERNEL_BUILDER=0` starts no worker and turns the default sharing directory off:
316+
every kernel then builds where it is first used.
317+
299318
Note that, when `TRTLLM_CACHE_DIR` is set, the FlashInfer workspace isolation
300319
mechanism described below still applies. This will prevent race conditions
301320
during cache read/writes, at the cost of limiting cache sharing. To disable

‎docs/source/release-notes.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ All published functionality in the Release Notes has been fully tested and verif
2323

2424
- Eligible text-only Kimi-K3 chat requests use the renderer’s native token IDs; `/v1/messages/count_tokens` excludes the same prompt tokens as response usage (three fewer for the default Kimi-K3 template). Requests containing media, server or tokenizer templates, forced tool-call prefixes, added special tokens, or prompt truncation retain the text path.
2525
- Single-GPU LLM instances whose model runs in a spawned MPI worker (the default) and single-rank `trtllm-llmapi-launch` runs now isolate FlashInfer JIT workspaces like multi-GPU ones. By default each process claims a persistent slot under `~/.cache/tensorrt_llm/flashinfer/rank-N` instead of using `~/.cache/flashinfer`, whose existing contents are not reused, so the first launch downloads and compiles FlashInfer artifacts again. Set `TRTLLM_FLASHINFER_WORKSPACE_PER_PROCESS=0` to keep the shared cache. See [FlashInfer JIT workspaces](llm-api/index.md#flashinfer-jit-workspaces-for-mpi-workers) for the temporary-workspace fallback, the precedence of an explicit `FLASHINFER_WORKSPACE_BASE`, and offline hosts.
26+
- **The processes of a launch on one node now build each DeepGEMM and CuTe DSL kernel once.** Without `TLLM_JIT_SHARE_DIR`, a launch of several processes per node that its launcher names (PMIx, Slurm job step, torchrun `--rdzv_id` or `--standalone`, DWDP) shares its JIT builds through `/tmp/tllm-jit-<uid>/<launch>` on the node's local disk: the first process to claim a kernel builds it, and the others wait up to `TLLM_JIT_SHARE_WAIT_S` seconds and load it. During the memory-profiling warmup, the ops that opt in also build their kernels ahead on worker processes of each rank, capped by `TLLM_KERNEL_BUILDER_WORKERS`. `TLLM_JIT_SHARE_DEFAULT=0` turns the shared directory off; `TLLM_KERNEL_BUILDER=0` also starts no worker. See [Unified Cache for Compiled Artifacts](llm-api/index.md#unified-cache-for-compiled-artifacts).
2627
- `/v1/responses`: a response cut short by `max_output_tokens` now reports `incomplete_details.reason` `max_output_tokens`, and when streamed it ends with `response.incomplete` instead of `response.completed`, as in the OpenAI API.
2728
- <span style="color: red">**[BREAKING CHANGE] Removed obsolete C++ executor orchestration helpers.**</span> The internal `RequestWithId` type, its `serializeReqWithIds` / `deserializeReqWithIds` functions, all production `insertRequestInOrder` overloads, and the unused `requestUtils.h` and `orchestratorUtils.h` helpers have been removed. These helpers belonged to the retired C++ executor orchestration path; downstream code linking their exported symbols must stop using them and rebuild. The current `Request` / `Response` interfaces and serialization remain available. Executor factory and worker constructors no longer accept the unused `engine` and `batched_logits_processor` arguments; callers should omit them and continue passing model configuration through `llm_args` and `hf_model_dir`. Unused decoder, request-cancellation, executor, legacy-model, orchestration, and speculative-decoding MPI tag names have also been removed; values 1–23, 127–129, and 1023–1025 are retired. The default, KV-cache event, and context-transfer tags retain their existing values. Internal `LogprobParams` and `LogProbsResult` tuples now contain only prompt-logprob fields; generation logprobs remain supplied by the sampler. The unused `TLLM_EXECUTOR_PERIODICAL_RESP_IN_AWAIT` environment variable has been removed.
2829
- <span style="color: red">**[BREAKING CHANGE] Media loaders now decode images as RGB PIL images and video as RGB uint8 NumPy arrays.**</span>

0 commit comments

Comments
 (0)