Repository navigation
[Feature] Beam search support - #31626
Conversation
… to completions streaming interface.
1. handle_beam_search_output, beam search only support BatchTokenIDOutput and BatchStrOutput 2. _create_initial_beam_sequences, add beam score for complete beam 3. _tail_str unit test error
Fix missing beam_search_output in _handle_output_by_index. Refactor related logic to improve code readability.
# Conflicts: # python/sglang/srt/managers/scheduler.py
# Conflicts: # python/sglang/srt/managers/io_struct.py # python/sglang/srt/managers/multi_tokenizer_mixin.py # python/sglang/srt/managers/schedule_batch.py # python/sglang/srt/managers/scheduler_components/output_streamer.py # python/sglang/srt/mem_cache/memory_pool.py
# Conflicts: # python/sglang/srt/managers/scheduler.py
|
Thank you!! @hnyls2002 |
|
Introducing FlashRec: a wide-beam inference engine for generative recommendation Hi all, Today we’re excited to introduce FlashRec, an open-source inference engine for generative recommendation. https://github.com/sohu-mptc/FlashRec General-purpose LLM engines (vLLM, SGLang, TensorRT-LLM) are optimized for long, single-path decoding. Generative recommendation is a different shape: a few decode steps, a very wide beam, and every continuation must land in a valid semantic-ID catalog. A wide-beam request occupies the engine; throughput barely scales with concurrency; open-vocabulary decoding leaves ~17–27% of beams illegal. FlashRec is built for that workload:
On public OneRec-1.7B (OpenOneRec RecIF-Bench, RTX 5090), FlashRec consistently delivers higher throughput than existing engines, achieving up to 2.0× vs SGLang, 2.2× vs TensorRT-LLM, and 7.2× vs vLLM. On production SoHuRec traffic, up to ~3× vs SGLang. The illegal-SID rate is 0. FlashRec is fully open-source (Apache-2.0), with a layout following mini-sglang. You can serve a public checkpoint with: We welcome the community to try it, file issues, and contribute. Please feel free to forward. Thanks, |
Signed-off-by: Sage Ahrac <sagiahrak@gmail.com> Co-authored-by: Liangsheng Yin <hnyls2002@gmail.com>
Beam search as a per-request feature:
sampling_params.beam_width = kruns ak-wide beam and returns the top-
nsequences,ndefaulting to 1 as in HF andthe OpenAI API (
n <= k;n > 1returns that many candidates instead ofparallel samples). No server flag; beam and ordinary requests share the same
batches and memory pools.
Results
Qwen/Qwen3-0.6B-Base, 1x H200,beam_width = 5000. End-to-end latency (ms),mean / p50 / p90:
sglang:fwd_occupancymedian under saturated load is 43.7-50.1%, at 67-87%whole-device utilization.
Repro
python -m sglang.launch_server \ --model-path Qwen/Qwen3-0.6B-Base --port 30000 \ --dtype bfloat16 --attention-backend flashinfer \ --mem-fraction-static 0.4 --max-running-requests 20004 \ --context-length 4096 --random-seed 0 \ --disable-radix-cache --disable-chunked-prefix-cache # add --disable-overlap-schedule for the sync columnDrive concurrent
/generatecalls with{"beam_width": 5000, "n": 5000},sweeping
max_new_tokens. Per row,(max_new_tokens, num_requests, qps, concurrency):(3, 23, 0.8, 4),(16, 10, 0.3, 2),(32, 8, 0.25, 2),(64, 6, 0.2, 2),(128, 4, 0.15, 2).For the occupancy row, add
SGLANG_ENABLE_METRICS_DEVICE_TIMER=1,--enable-metrics --decode-log-interval 2, and take the median ofsglang:fwd_occupancy.--decode-log-interval 1reportsNaN: the windowresets every batch and never reaches the branch that computes the ratio.
Verification
beam_search, managers, mem_cache): 2062 passed.test/manual/beam_search/test_beam_parity.py): sequence-setoverlap 8/10 at
k = 10.test/manual/beam_search/test_beam_search_load.py): mixed widths 2-100,100 requests at 10 QPS, p50/p90/p99 = 53/58/175 ms; 3200-wide fan-out passes.
SGLANG_ENABLE_STRICT_MEM_CHECK_DURING_BUSY=1silent throughout.few_shot_gsm8k200q greedy 0.470 unchanged.Not supported yet
Rejected at admission with an explicit error: speculative decoding, PD
disaggregation, dp attention, pipeline parallelism,
page_size > 1,hierarchical cache, SWA/mamba hybrid caches, hisparse, encoder-decoder,
diffusion LLM, LoRA, sessions, constrained decoding, stop strings/regex,
min_new_tokens,return_logprob,return_hidden_states, andsampling-mask/routed-experts returns. Beam requests are also excluded from
mixed-chunk prefill batches.
Retraction. A beam group cannot be retracted: its member rows alias the
leader's prompt KV, so rolling back part of the group corrupts it. Under KV
pressure ordinary requests are retracted first, and if that is not enough the
whole group is aborted with HTTP 500 instead of being requeued. Admission
reserves the group's
req_to_tokenrows but still budgets decode KV at onetoken per step, so a large
beam_widthcan reach this path under load.CI States
Latest PR Test (Base): ✅ Run #33016852973
Latest PR Test (Extra): ✅ Run #33026857281
Latest PR Test (AMD ROCm 7.2): 🚫 Run #33016853050