-
Notifications
You must be signed in to change notification settings - Fork 2.7k
[https://nvbugs/6284101][fix] Fix guided decoding for Harmony parser #15741
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -45,6 +45,9 @@ | |
| from .llm_utils import (CachedModelLoader, KvCacheRetentionConfig, | ||
| LlmBuildStats, ModelLoader) | ||
| from .mpi_session import MpiPoolSession, external_mpi_comm_available | ||
| from .reasoning_parser import ( | ||
| adapt_guided_decoding_params_for_reasoning_parser, | ||
| resolve_raw_guided_decoding_reasoning_parser) | ||
| from .thinking_budget import add_thinking_budget_logits_processor | ||
| from .tokenizer import TokenizerBase | ||
| # TODO[chunweiy]: move the following symbols back to utils scope, and remove the following import | ||
|
|
@@ -1390,6 +1393,24 @@ def _prepare_sampling_params( | |
| self._generation_config) | ||
| self._configure_bart_decoder_prefix(sampling_params) | ||
| self._add_whisper_suppress_tokens_logits_processor(sampling_params) | ||
| if sampling_params.guided_decoding is not None: | ||
| reasoning_format_for_guided_decoding = ( | ||
| resolve_raw_guided_decoding_reasoning_parser( | ||
| self.args.reasoning_parser, | ||
| getattr(self._hf_model_config, "model_type", None), | ||
| self.args.guided_decoding_backend, | ||
| )) | ||
| if reasoning_format_for_guided_decoding is not None: | ||
| # SamplingParams carries a caller-provided content | ||
| # constraint, but not how this model frames reasoning and | ||
| # final output. Add that model-aware framing here so | ||
| # xgrammar applies the guide only to Harmony's final | ||
| # channel. Other formats preserve the original guide. | ||
| sampling_params.guided_decoding = ( | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This reassigns |
||
| adapt_guided_decoding_params_for_reasoning_parser( | ||
| sampling_params.guided_decoding, | ||
| reasoning_format_for_guided_decoding, | ||
| )) | ||
| add_thinking_budget_logits_processor( | ||
| sampling_params, | ||
| reasoning_parser=self.args.reasoning_parser, | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.