sglang icon indicating copy to clipboard operation
sglang copied to clipboard

[Feature] Extend CustomLogitProcessor to Support input_ids in call Method

Open Aykhan-sh opened this issue 10 months ago • 2 comments

Checklist

  • [ ] 1. If the issue you raised is not a feature but a question, please raise a discussion at https://github.com/sgl-project/sglang/discussions/new/choose Otherwise, it will be closed.
  • [x] 2. Please use English, otherwise it will be closed.

Motivation

Thanks @hongpeng-guo for PR #2396. After reviewing your work, I'd like to propose an enhancement to the CustomLogitProcessor. Specifically, I suggest modifying its __call__ method to accept input_ids as an additional parameter—similar to the implementation in Huggingface (see this doc). This change would allow constraints to be applied conditionally based on the entire history of input tokens, enabling more flexible and context-aware processing.

Thank you for considering this feature request!

Related resources

Huggingface LogitsProcessor.

Aykhan-sh avatar Feb 12 '25 12:02 Aykhan-sh

Thank you for your suggestion! You are welcome to raise a new PR to realize the enhancement as you mentioned.

jhinpan avatar Feb 12 '25 18:02 jhinpan

@Aykhan-sh Thanks for your suggestions. It makes a lot of sense to include input_ids as an extra args. I am thinking about if it's necessary to also include args and kwargs to make this function more flexible. But for now, let's just align with the HuggingFace API.

Feel free to start a PR and assign me as a reviewer if you have time. Otherwise, I can take this issue later this week.

hongpeng-guo avatar Feb 12 '25 18:02 hongpeng-guo

Any progress on this?

lambert0312 avatar Mar 20 '25 07:03 lambert0312

+1 I observe QwQ may sometimes generate multiple tokens. We need this mechanism to mask out once it has been generated.

nxphi47 avatar Apr 25 '25 22:04 nxphi47

This issue has been automatically closed due to inactivity. Please feel free to reopen it if needed.

github-actions[bot] avatar Jun 25 '25 00:06 github-actions[bot]

Why was it closed?

akhoroshev avatar Jul 11 '25 11:07 akhoroshev