Skip to content

return_log_probs slow down generation #2367

Closed as not planned
Closed as not planned

Description

@Desmond819

System Info

Hi team,

when I try to add return_log_probs true and output_log_probs = true to return logprob, the generation speed degraded significantly. Below is my testing.

time curl -X POST localhost:8080/v2/models/ensemble/generate_stream -d '{"text_input": "Explain in detail 5 important events of WW2.", "parameters": {"max_tokens": 2000,"bad_words":[""],"stop_words":[""],"stream": true,"temperature": 0.0}}' | grep 'data: ' | wc -l

Result: 0m6.186s

time curl -X POST localhost:8080/v2/models/ensemble/generate_stream -d '{"text_input": "Explain in detail 5 important events of WW2.", "parameters": {"max_tokens": 2000,"bad_words":[""],"stop_words":[""],"stream": true,"temperature": 0.0, "return_log_probs": true}}' | grep 'data: ' | wc -l

Result: 1m9.191s

I am running Meta-Llama-3.1-8B-Instruct on a 8xH100 with TP8.

Who can help?

No response

Information

  • The official example scripts
  • My own modified scripts

Tasks

  • An officially supported task in the examples folder (such as GLUE/SQuAD, ...)
  • My own task or dataset (give details below)

Reproduction

See above

Expected behavior

NA

actual behavior

NA

additional notes

NA

Activity

  1. Superjomn commented on Oct 24, 2024

    @Superjomn
    Contributor

    Thanks for sharing the issue.
    I wonder what API you are using. The triton-backend, the openai_server.py or anything else? @Desmond819

  2. added
    PerformanceTRTLLM model inference speed, throughput, efficiency. Latency, benchmarks, regressions, opts.
    on Oct 24, 2024
  3. Desmond819 commented on Oct 24, 2024

    @Desmond819
    Author

    I am using triton-backend

  4. Desmond819 commented on Oct 29, 2024

    @Desmond819
    Author

    @Superjomn, any update on this?

  5. CortexEdgeUser commented on Nov 27, 2024

    @CortexEdgeUser

    Same problem, on versions 0.12.0; 0.14.0; 0.16.0. return_log_probs slows down text generation

  6. added
    triagedIssue has been triaged by maintainers
    PerformanceTRTLLM model inference speed, throughput, efficiency. Latency, benchmarks, regressions, opts.
    and removed
    PerformanceTRTLLM model inference speed, throughput, efficiency. Latency, benchmarks, regressions, opts.
    on May 21, 2025
  7. marcomancini1994 commented on Jul 24, 2025

    @marcomancini1994

    @kaiyux any idea on when this would be picked up?
    I think I've understood why this happens.

    The problem is during the decoding sampling strategy ( https://github.com/NVIDIA/TensorRT-LLM/blob/main/cpp/tensorrt_llm/kernels/samplingTopKKernels.cu ) and what happens is the following:

    When output log probs is enabled: Raw logits → probabilities → sampling → log conversion

    When disabled: Raw logits → sampling (direct comparison possible)

    Was wondering if something like this could be an optimisation to take into account:
    Populate the output probabilities using a mix of the two approaches where you first select the topK logits value and then calculate the outputlogprobs based on those selections? Avoiding to calculate the exponential before and just computing what's needed for the topK selected?

    PS: I am a newbie on CUDA code, might have missed something or gave a wrong optimisation for the problematic path, sorry in advance in that's the case

  8. added
    Decoding/Sampling<NV>Token sampling algorithms in TRTLLM for text gen (top-k, top-p, beam).
    General perf<NV>Broad performance issues not specific to a particular component
    on Sep 9, 2025
  9. karljang commented on Sep 29, 2025

    @karljang
    Collaborator

    @Desmond819 ,
    Apologies for the delayed response. Given the several updates made to the sampling feature, could you please try the latest version to see if the issue still persists?

  10. github-actions commented on Oct 14, 2025

    @github-actions

    Issue has not received an update in over 14 days. Adding stale label.

  11. github-actions commented on Oct 28, 2025

    @github-actions

    This issue was closed because it has been 14 days without activity since it has been marked as stale.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Decoding/Sampling<NV>Token sampling algorithms in TRTLLM for text gen (top-k, top-p, beam).General perf<NV>Broad performance issues not specific to a particular componentInvestigatingPerformanceTRTLLM model inference speed, throughput, efficiency. Latency, benchmarks, regressions, opts.bugSomething isn't workingstaletriagedIssue has been triaged by maintainerswaiting for feedback

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions