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

Function is_valid_sequence

tensorrt_llm/serve/scripts/benchmark_dataset.py:319–343  ·  view source on GitHub ↗

Validate a sequence based on prompt and output lengths. Default pruning criteria are copied from the original `sample_hf_requests` and `sample_sharegpt_requests` functions in benchmark_serving.py, as well as from `sample_requests` in benchmark_throughput.py.

(
    prompt_len: int,
    output_len: int,
    min_len: int = 4,
    max_prompt_len: int = 1024,
    max_total_len: int = 2048,
    skip_min_output_len_check: bool = False,
)

Source from the content-addressed store, hash-verified

317
318
319def is_valid_sequence(
320 prompt_len: int,
321 output_len: int,
322 min_len: int = 4,
323 max_prompt_len: int = 1024,
324 max_total_len: int = 2048,
325 skip_min_output_len_check: bool = False,
326) -> bool:
327 """
328 Validate a sequence based on prompt and output lengths.
329
330 Default pruning criteria are copied from the original `sample_hf_requests`
331 and `sample_sharegpt_requests` functions in benchmark_serving.py, as well as
332 from `sample_requests` in benchmark_throughput.py.
333 """
334 # Check for invalid conditions
335 prompt_too_short = prompt_len < min_len
336 output_too_short = (not skip_min_output_len_check) and (output_len
337 < min_len)
338 prompt_too_long = prompt_len > max_prompt_len
339 combined_too_long = (prompt_len + output_len) > max_total_len
340
341 # Return True if none of the invalid conditions are met
342 return not (prompt_too_short or output_too_short or prompt_too_long
343 or combined_too_long)
344
345
346def process_image(image: Any) -> Mapping[str, Any]:

Callers 3

sampleMethod · 0.85
sampleMethod · 0.85
sampleMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected