TorchSpec
TorchSpec copied to clipboard
Add TensorRT-LLM support for inference backend
Summary
Integrates TensorRT-LLM (v1.3.0rc18) as an inference backend for hidden-state capture, alongside the existing vLLM and SGLang backends.
Approach
TRT-LLM already ships the EAGLE3 capture machinery natively (SaveHiddenStatesDecodingConfig / SaveHiddenStatesResourceManager), so this integration is thin. It builds on that mode and adds a small patch that redirects captured aux + final hidden states to Mooncake instead of writing .pt files to disk. No reimplementation of the capture path is needed.
Changes
patches/trtllm/v1.3.0rc18/trtllm.patch: env-gated (TORCHSPEC_TRTLLM_MOONCAKE) Mooncake redirect insave_hidden_state.py. Also fixes a per-request token-offset bug so batched prefill works (upstream only handled a single request per forward).torchspec/inference/engine/trtllm_engine.py:TrtllmEngineRay actor wrapping the PyTorch-backend LLM; mapsRequestOutput.request_id-> Mooncake key using the same sanitizer as the patch.factory.py/ config : "trtllm" dispatch, TrtllmConfig, trtllm_ flatten prefix.docker/trtllm/v1.3.0rc18/Dockerfile+justfilebranch + [trtllm] extra : patches the installed package at build time with an assertion guard, and includes the CUDA-13 Mooncake wheel fix.configs/trtllm_qwen3_8b.yaml+ README entry.
Notes
- Single-node tensor parallelism only : nnodes > 1 raises NotImplementedError (TRT-LLM spawns its own MPI workers; multi-node TP needs more orchestration).