TensorRT-LLM icon indicating copy to clipboard operation
TensorRT-LLM copied to clipboard

[Bug]: min_tokens not work

Open Alireza3242 opened this issue 1 year ago • 4 comments

System Info

GPU A100 docker: 1.1.0 rc4

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

In my requests, I used min_tokens, but the number of output tokens was less than min_tokens.

trtllm-serve /app/data/gemma-3-4b-it/model --max_batch_size 128 --host 0.0.0.0 \
--kv_cache_free_gpu_memory_fraction 0.3
        data["model"] = self.model
        data["stream"] = False
        data["max_tokens"] = 250
        data["min_tokens"] = 250
        
        headers = {"Content-Type": "application/json"}
        url = self.model_url + "/v1/chat/completions"
        a = session.post(url, headers=headers, data=json.dumps(data), timeout=100)

Expected behavior

.

actual behavior

.

additional notes

.

Before submitting a new issue...

  • [x] Make sure you already searched for relevant issues, and checked the documentation and examples for answers to frequently asked questions.

Alireza3242 avatar Sep 13 '25 03:09 Alireza3242

We don't actually support min_tokens yet. @dcampora could you take a look at this?

tongyuantongyu avatar Sep 15 '25 08:09 tongyuantongyu

@evezhier could you please look into this? Thanks a lot!

dcampora avatar Sep 24 '25 08:09 dcampora

Fixed by #7808. However, this specific model has two EOS tokens, TRT-LLM doesn't support it just yet, so the output might still contain one of these tokens and appear shorter in the detokenized form in certain cases. The number of generated tokens will nevertheless be correct.

evezhier avatar Sep 25 '25 19:09 evezhier

Closing the bug, as the actual issue is resolved

evezhier avatar Oct 02 '25 08:10 evezhier