[Bug]: Beam Search encounters SWA error when using Pytorch backend and beam_width >= 32
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 14.7k
- Forks
- 2.8k
- Avg merge
- 2d 23h
- Merged PRs (30d)
- 489
Description
System Info
Environment:
TensorRT-LLM version: 1.3.0rc8
Backend: PyTorch
max_beam_width: 128
max_seq_len: 768
max_batch_size: 2
Single GPU
Who can help?
No response
Information
- The official example scripts
- My own modified scripts
Tasks
- An officially supported task in the
examplesfolder (such as GLUE/SQuAD, ...) - My own task or dataset (give details below)
Reproduction
trtllm-serve serve
--max_beam_width 128
--max_batch_size 8
--max_seq_len 1024
--host 0.0.0.0
--port 8000
--free_gpu_memory_fraction 0.9
Expected behavior
not hangs.
actual behavior
With beam_width=16: works normally.
With beam_width=32, it hangs even with sequential requests, and I see the following error/stack trace in the server logs:
0x7fdceb7d8208 tensorrt_llm::batch_manager::kv_cache_manager::WindowBlockManager::adjustBlocksIfNeeded(tensorrt_llm::batch_manager::kv_cache_manager::GenerationRequest&) + 184
3 0x7fdceb7d8309 tensorrt_llm::batch_manager::kv_cache_manager::BlockManager::adjustBlocksIfNeeded(tensorrt_llm::batch_manager::kv_cache_manager::GenerationRequest&) + 137
4 0x7fdd0e77dca3 /usr/local/lib/python3.12/dist-packages/tensorrt_llm/bindings.cpython-312-x86_64-linux-gnu.so(+0x15eca3) [0x7fdd0e77dca3]
5 0x7fdd0e96e09c /usr/local/lib/python3.12/dist-packages/tensorrt_llm/bindings.cpython-312-x86_64-linux-gnu.so(+0x34f09c) [0x7fdd0e96e09c]
6 0x549825 PyObject_Vectorcall + 53
7 0x5d71d9 _PyEval_EvalFrameDefault + 2697
8 0x54c9d2 /usr/bin/python() [0x54c9d2]
9 0x5db2ca _PyEval_EvalFrameDefault + 19322
10 0x54c9d2 /usr/bin/python() [0x54c9d2]
11 0x6f7cfc /usr/bin/python() [0x6f7cfc]
12 0x6b87dc /usr/bin/python() [0x6b87dc]
13 0x7fe01b5b8aa4 /usr/lib/x86_64-linux-gnu/libc.so.6(+0x9caa4) [0x7fe01b5b8aa4]
14 0x7fe01b645c6c /usr/lib/x86_64-linux-gnu/libc.so.6(+0x129c6c) [0x7fe01b645c6c]
[03/21/2026-18:21:08] [TRT-LLM] [E] Traceback (most recent call last):
File "/usr/local/lib/python3.12/dist-packages/tensorrt_llm/_torch/pyexecutor/py_executor.py", line 579, in _event_loop_wrapper
self.event_loop()
File "/usr/local/lib/python3.12/dist-packages/tensorrt_llm/_torch/pyexecutor/py_executor.py", line 2113, in _executor_loop_overlap
self.resource_manager.prepare_resources(scheduled_batch)
File "/usr/local/lib/python3.12/dist-packages/tensorrt_llm/_torch/pyexecutor/resource_manager.py", line 2565, in prepare_resources
resource_manager.prepare_resources(scheduled_batch)
File "/usr/local/lib/python3.12/dist-packages/tensorrt_llm/_torch/pyexecutor/resource_manager.py", line 632, in prepare_resources
self.impl.add_token(req.py_request_id)
RuntimeError: [TensorRT-LLM][ERROR] Assertion failed: A block only go out-of-window in SWA
With beam_width=64: it hangs, but no useful error is printed.
additional notes
from https://github.com/NVIDIA/TensorRT-LLM/issues/12071
Before submitting a new issue...
- Make sure you already searched for relevant issues, and checked the documentation and examples for answers to frequently asked questions.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the issue with trtllm-serve using the listed max_beam_width and max_seq_len settings, comparing beam widths 16, 32, and 64. Start in _torch/pyexecutor/resource_manager.py at prepare_resources and add_token, then inspect _torch/pyexecutor/py_executor.py and the SWA block-manager stack trace. Done means beam widths >=32 no longer hang or trigger the SWA assertion.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python, pytorch
- Domain
- ai, backend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100