MCPcopy Create free account
hub / github.com/NVIDIA/TensorRT-LLM / _get_output_config

Method _get_output_config

tensorrt_llm/sampling_params.py:486–521  ·  view source on GitHub ↗
(self, is_pytorch_backend: bool = False)

Source from the content-addressed store, hash-verified

484 return tllme.SamplingConfig(**llmapi_to_rt_param_map)
485
486 def _get_output_config(self, is_pytorch_backend: bool = False) -> tllme.OutputConfig:
487 sampling_param_fields = set(dir(SamplingParams))
488 fields = [
489 f
490 for f in dir(tllme.OutputConfig)
491 if not f.startswith("__") and f in sampling_param_fields
492 ]
493
494 config_kwargs = {f: getattr(self, f) for f in fields}
495
496 if is_pytorch_backend:
497 config_kwargs["return_log_probs"] = bool(self.logprobs)
498 if self.prompt_logprobs and not self.return_context_logits:
499 logger.info(
500 "Since prompt_logprobs is requested but return_context_logits is False, "
501 "internally enabling context logits for prompt logprobs computation. "
502 "context logits will be dropped after computation as the user didn't explicitly request them."
503 )
504 # TODO: Find a more elegant way to do this.
505 # NOTE: This is an internal hack, so we can entirely avoid introducing
506 # `prompt_logprobs` into the executor bindings and further into
507 # model engine / sampler.
508 # This is because, prompt_logprobs is a derived quantity from
509 # context logits, and the capability to post-compute it
510 # already exists in the worker. (see _get_logprobs in worker.py)
511 config_kwargs["return_context_logits"] = True
512 else:
513 config_kwargs["return_log_probs"] = self._return_log_probs
514
515 if config_kwargs.get("additional_model_outputs") is not None:
516 config_kwargs["additional_model_outputs"] = [
517 tllme.AdditionalModelOutput(name=output_name, gather_context=False)
518 for output_name in config_kwargs["additional_model_outputs"]
519 ]
520
521 return tllme.OutputConfig(**config_kwargs)
522
523 def _get_guided_decoding_params(self) -> tllme.GuidedDecodingParams:
524 if self.guided_decoding is None:

Callers 1

_enqueue_requestMethod · 0.80

Calls 2

infoMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected