Skip to content

fix: preserve custom logits processors when applying logit bias - #2454

Open
charan-rathore wants to merge 4 commits into
abetlen:mainfrom
charan-rathore:fix-completion-logit-bias-composition
Open

charan-rathore wants to merge 4 commits into
abetlen:mainfrom
charan-rathore:fix-completion-logit-bias-composition

Conversation

@charan-rathore

Copy link
Copy Markdown

What changed

create_completion() passed None to generation when both logits_processor and logit_bias were supplied. list.extend() mutates the list and returns None, so the custom processors and the bias callback were discarded from that request. The caller's list was also left with an extra bias callback after the call.

Build a new LogitsProcessorList instead. Custom processors keep their order and run before the bias callback. Reusing the caller's list no longer carries an earlier request's bias into a later request. The processor-only and bias-only paths are unchanged.

Tests

Added model-free tests at the public completion-to-generation boundary for streaming and non-streaming requests, empty processor lists, reused lists, and processor-only, bias-only and neither-option controls. The generation boundary is replaced with a recorder, so these test composition and forwarding, not native model sampling.

Local validation used normal package imports from the checked-out wrapper and the standard upstream 0.3.38 CPU wheel's shared library, without building or changing vendor code:

  • Base: five regression failures and three controls passed.
  • Patched regression tests: all eight passed.
  • New regression tests plus existing grammar, chat-format and speculative tests: 14 passed.
  • Ruff check/format and whitespace checks passed.

The full upstream suite was not run. No model was downloaded or loaded, and these results do not establish native inference or sampling behavior.

AI assistance was used for implementation, tests and review. No native/vendor code changed. No model-sampling or performance claim.

This branch has not been deployed

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant