Skip to content

Conversation

nvxuanyuc
Copy link
Collaborator

@nvxuanyuc nvxuanyuc commented Oct 3, 2025

… to ignore from the prompt for precense and frequency penalties for trt and torch path.

Summary by CodeRabbit

  • New Features

    • Added prompt_ignore_length to generation, allowing part of the prompt to be excluded from repetition/presence/frequency penalties. Supports scalar or per-batch values.
    • Available via Python SamplingParams, generate() kwargs, dynamic decode setup, and OpenAI-compatible Completion/ChatCompletion requests.
    • New CLI flag --prompt_ignore_length.
  • Examples

    • Updated example scripts to accept and pass prompt_ignore_length through the generation pipeline (including long-context eval, run, and summarize workflows).

Description

Currently, penalties are always applied across both prompt and generated tokens, with no way to restrict them to only generated tokens. This PR adds a new parameter prompt_ignore_length to sampling config, allowing dynamic control over how many prompt tokens are excluded, making the sampling penalty logic more flexible.

Test Coverage

Add additional sampling kernel unit tests, including:

  • Default mode (no prompt tokens ignored)
  • Partial prompt ignored
  • Full prompt ignored

GitHub Bot Help

/bot [-h] ['run', 'kill', 'skip', 'reuse-pipeline'] ...

Provide a user friendly way for developers to interact with a Jenkins server.

Run /bot [-h|--help] to print this help message.

See details below for each supported subcommand.

run [--reuse-test (optional)pipeline-id --disable-fail-fast --skip-test --stage-list "A10-PyTorch-1, xxx" --gpu-type "A30, H100_PCIe" --test-backend "pytorch, cpp" --add-multi-gpu-test --only-multi-gpu-test --disable-multi-gpu-test --post-merge --extra-stage "H100_PCIe-TensorRT-Post-Merge-1, xxx" --detailed-log --debug(experimental)]

Launch build/test pipelines. All previously running jobs will be killed.

--reuse-test (optional)pipeline-id (OPTIONAL) : Allow the new pipeline to reuse build artifacts and skip successful test stages from a specified pipeline or the last pipeline if no pipeline-id is indicated. If the Git commit ID has changed, this option will be always ignored. The DEFAULT behavior of the bot is to reuse build artifacts and successful test results from the last pipeline.

--disable-reuse-test (OPTIONAL) : Explicitly prevent the pipeline from reusing build artifacts and skipping successful test stages from a previous pipeline. Ensure that all builds and tests are run regardless of previous successes.

--disable-fail-fast (OPTIONAL) : Disable fail fast on build/tests/infra failures.

--skip-test (OPTIONAL) : Skip all test stages, but still run build stages, package stages and sanity check stages. Note: Does NOT update GitHub check status.

--stage-list "A10-PyTorch-1, xxx" (OPTIONAL) : Only run the specified test stages. Examples: "A10-PyTorch-1, xxx". Note: Does NOT update GitHub check status.

--gpu-type "A30, H100_PCIe" (OPTIONAL) : Only run the test stages on the specified GPU types. Examples: "A30, H100_PCIe". Note: Does NOT update GitHub check status.

--test-backend "pytorch, cpp" (OPTIONAL) : Skip test stages which don't match the specified backends. Only support [pytorch, cpp, tensorrt, triton]. Examples: "pytorch, cpp" (does not run test stages with tensorrt or triton backend). Note: Does NOT update GitHub pipeline status.

--only-multi-gpu-test (OPTIONAL) : Only run the multi-GPU tests. Note: Does NOT update GitHub check status.

--disable-multi-gpu-test (OPTIONAL) : Disable the multi-GPU tests. Note: Does NOT update GitHub check status.

--add-multi-gpu-test (OPTIONAL) : Force run the multi-GPU tests in addition to running L0 pre-merge pipeline.

--post-merge (OPTIONAL) : Run the L0 post-merge pipeline instead of the ordinary L0 pre-merge pipeline.

--extra-stage "H100_PCIe-TensorRT-Post-Merge-1, xxx" (OPTIONAL) : Run the ordinary L0 pre-merge pipeline and specified test stages. Examples: --extra-stage "H100_PCIe-TensorRT-Post-Merge-1, xxx".

--detailed-log (OPTIONAL) : Enable flushing out all logs to the Jenkins console. This will significantly increase the log volume and may slow down the job.

--debug (OPTIONAL) : Experimental feature. Enable access to the CI container for debugging purpose. Note: Specify exactly one stage in the stage-list parameter to access the appropriate container environment. Note: Does NOT update GitHub check status.

For guidance on mapping tests to stage names, see docs/source/reference/ci-overview.md
and the scripts/test_to_stage_mapping.py helper.

kill

kill

Kill all running builds associated with pull request.

skip

skip --comment COMMENT

Skip testing for latest commit on pull request. --comment "Reason for skipping build/test" is required. IMPORTANT NOTE: This is dangerous since lack of user care and validation can cause top of tree to break.

reuse-pipeline

reuse-pipeline

Reuse a previous pipeline to validate current commit. This action will also kill all currently running builds associated with the pull request. IMPORTANT NOTE: This is dangerous since lack of user care and validation can cause top of tree to break.

@nvxuanyuc nvxuanyuc requested a review from a team as a code owner October 3, 2025 00:12
@jhaotingc
Copy link
Collaborator

/bot run --disable-fail-fast

Copy link
Contributor

coderabbitai bot commented Oct 3, 2025

📝 Walkthrough

Walkthrough

Adds a new optional parameter “promptIgnoreLength” across the stack to control how many initial tokens are ignored by presence/frequency penalties. The change threads this field from public APIs (Python/OpenAI protocol) through bindings, serialization, executor/runtime configs, decoding layers, and into CUDA penalty kernels, with tests and examples updated accordingly.

Changes

Cohort / File(s) Summary
Executor SamplingConfig API
cpp/include/tensorrt_llm/executor/executor.h, cpp/tensorrt_llm/executor/samplingConfig.cpp, cpp/tensorrt_llm/executor/serialization.cpp
Introduces SamplingConfig::promptIgnoreLength (optional SizeType32): ctor parameter, private member, getter/setter, static checker, equality update; serialization/deserialization and size computations updated.
Runtime Sampling Config & Decoder
cpp/include/tensorrt_llm/runtime/samplingConfig.h, cpp/tensorrt_llm/runtime/gptDecoder.cpp
Adds OptVec promptIgnoreLength to runtime::SamplingConfig; propagates to PenaltySetupParams during decoder setup and disable-lookahead path.
Kernels: Penalty
cpp/tensorrt_llm/kernels/penaltyKernels.cu, cpp/tensorrt_llm/kernels/penaltyKernels.h, cpp/tensorrt_llm/kernels/penaltyTypes.h
batchApplyPenalty gains promptIgnoreLengths input; workspace expanded to 2×vocabSize; logic updated to ignore first N tokens per-beam for presence/frequency; new DecodingPenaltyType::PromptIgnoreLength and limits handling; launcher params extended.
Layers: Penalty setup/buffers
cpp/tensorrt_llm/layers/penaltyLayer.cpp, cpp/tensorrt_llm/layers/penaltyLayer.h, cpp/tensorrt_llm/layers/decodingParams.h, cpp/include/tensorrt_llm/layers/defaultDecodingParams.h
Adds PenaltySetupParams::promptIgnoreLength; allocates/handles host/device buffers; doubles penalty workspace when used; forwards promptIgnoreLengths to kernels; DefaultDecodingParams exposes getPromptIgnoreLength() constexpr=0.
Torch Dynamic Decode op
cpp/tensorrt_llm/thop/dynamicDecodeOp.h, cpp/tensorrt_llm/thop/dynamicDecodeOp.cpp
Adds optional prompt_ignore_length tensor parameter to setup signatures (IFtDynamicDecode, FtDynamicDecode, DynamicDecodeOp); threads value into penalty params.
Python runtime
tensorrt_llm/runtime/generation.py, tensorrt_llm/runtime/model_runner_cpp.py
SamplingConfig gains prompt_ignore_length; decoder setup materializes per-batch int32 tensor and passes it to dynamic decoder; generate() kwargs accept prompt_ignore_length.
Bindings (C++ ⇄ Python)
cpp/tensorrt_llm/nanobind/bindings.cpp, cpp/tensorrt_llm/nanobind/executor/request.cpp, cpp/tensorrt_llm/pybind/bindings.cpp, cpp/tensorrt_llm/pybind/executor/request.cpp
Expose SamplingConfig.prompt_ignore_length property; update getstate/setstate tuple size to 20; ctor/binding arg lists and indices adjusted.
Serving API & Params
tensorrt_llm/serve/openai_protocol.py, tensorrt_llm/sampling_params.py
Adds prompt_ignore_length to CompletionRequest/ChatCompletionRequest and passes through to SamplingParams; SamplingParams includes optional prompt_ignore_length.
Examples
examples/utils.py, examples/run.py, examples/eval_long_context.py, examples/summarize.py
CLI adds --prompt_ignore_length; generate() calls forward prompt_ignore_length through runners in examples and eval paths.
Tests
cpp/tests/unit_tests/executor/samplingConfigTest.cpp, cpp/tests/unit_tests/runtime/samplingConfigTest.cpp, cpp/tests/unit_tests/kernels/sampling/samplingPenaltyTest.cpp, cpp/tests/unit_tests/layers/dynamicDecodeLayerTest.h
Update constructors and expectations for new field; extend penalty tests to cover promptIgnoreLengths behavior; expand penalty workspace to 2×vocab; add test params vector for promptIgnoreLengths.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  participant Client
  participant Serve as OpenAI Protocol
  participant Py as Python Runtime
  participant Bind as C++ Bindings
  participant Exec as Executor::SamplingConfig
  participant Run as Runtime::SamplingConfig
  participant Layer as PenaltyLayer
  participant Kern as CUDA Penalty Kernel

  Client->>Serve: Request(prompt_ignore_length=?)
  Serve->>Py: SamplingParams(prompt_ignore_length)
  Py->>Py: Build SamplingConfig(prompt_ignore_length)
  Py->>Bind: set SamplingConfig.prompt_ignore_length
  Bind->>Exec: construct SamplingConfig(..., promptIgnoreLength)
  Exec->>Run: to runtime::SamplingConfig(promptIgnoreLength per-batch)
  Run->>Layer: PenaltySetupParams.promptIgnoreLength
  Layer->>Kern: batchApplyPenalty(..., promptIgnoreLengths, workspace=2×vocab)
  Note over Kern: Ignore first N tokens for presence/frequency
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Pre-merge checks and finishing touches

❌ Failed checks (2 warnings)
Check name Status Explanation Resolution
Description Check ⚠️ Warning The PR description includes a Description and Test Coverage section but still contains unremoved template comments, lacks a filled summary in place of the stub “@coderabbitai summary,” and omits the required PR Checklist section. Remove the commented template instructions, provide a concise summary after the “@coderabbitai summary” marker, and add a PR Checklist section that follows the repository template.
Docstring Coverage ⚠️ Warning Docstring coverage is 6.52% which is insufficient. The required threshold is 80.00%. You can run `@coderabbitai generate docstrings` to improve docstring coverage.
✅ Passed checks (1 passed)
Check name Status Explanation
Title Check ✅ Passed The title follows the required “[ticket][type] Summary” format with a valid “None” ticket and “[feat]” type, and it clearly and concisely describes the primary change of adding support for ignored prompt length in the sampling configuration.
✨ Finishing touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
cpp/tensorrt_llm/nanobind/executor/request.cpp (1)

84-108: Restore backward compatibility for pickled SamplingConfig state

Older pickles still store 19 fields. With this change __setstate__ now throws for those tuples, so any previously serialized executor/request state can no longer be loaded. Please accept both versions and default promptIgnoreLength when the legacy layout is encountered.

Here is one way to keep both formats working:

-        if (state.size() != 20)
+        if (state.size() != 19 && state.size() != 20)
         {
             throw std::runtime_error("Invalid SamplingConfig state!");
         }
-        new (&samplingConfig) tle::SamplingConfig(nb::cast<SizeType32>(state[0]), // BeamWidth
+        if (state.size() == 20)
+        {
+        new (&samplingConfig) tle::SamplingConfig(nb::cast<SizeType32>(state[0]), // BeamWidth-            nb::cast<std::optional<FloatType>>(state[18]),                        // MinP
-            nb::cast<std::optional<std::vector<SizeType32>>>(state[19])           // BeamWidthArray
-        );
+            nb::cast<std::optional<FloatType>>(state[18]),                        // MinP
+            nb::cast<std::optional<std::vector<SizeType32>>>(state[19])           // BeamWidthArray
+        );
+        }
+        else
+        {
+        new (&samplingConfig) tle::SamplingConfig(nb::cast<SizeType32>(state[0]), // BeamWidth
+            nb::cast<std::optional<SizeType32>>(state[1]),                        // TopK
+
+            nb::cast<std::optional<FloatType>>(state[12]),                        // FrequencyPenalty
+            std::nullopt,                                                        // PromptIgnoreLength (legacy)
+            nb::cast<std::optional<FloatType>>(state[13]),                        // LengthPenalty
+            nb::cast<std::optional<SizeType32>>(state[14]),                       // EarlyStopping
+            nb::cast<std::optional<SizeType32>>(state[15]),                       // NoRepeatNgramSize
+            nb::cast<std::optional<SizeType32>>(state[16]),                       // NumReturnSequences
+            nb::cast<std::optional<FloatType>>(state[17]),                        // MinP
+            nb::cast<std::optional<std::vector<SizeType32>>>(state[18]));         // BeamWidthArray
+        }
🧹 Nitpick comments (2)
examples/utils.py (1)

307-307: Document the new CLI flag.

Please add a short help= string so users know this flag controls how many prompt tokens are exempt from repetition penalties. It keeps the CLI self-documenting alongside the rest of the sampling knobs.

tensorrt_llm/serve/openai_protocol.py (1)

227-228: Clamp invalid prompt_ignore_length early.

Right now callers could send a negative value, which would travel through SamplingParams and eventually the CUDA penalties path without any guard. Please add Field(ge=0) (or similar validation) so we reject bad inputs at the API layer before they hit runtime math.

📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between a5b59fd and 4d33465.

📒 Files selected for processing (30)
  • cpp/include/tensorrt_llm/executor/executor.h (5 hunks)
  • cpp/include/tensorrt_llm/layers/defaultDecodingParams.h (1 hunks)
  • cpp/include/tensorrt_llm/runtime/samplingConfig.h (4 hunks)
  • cpp/tensorrt_llm/executor/samplingConfig.cpp (6 hunks)
  • cpp/tensorrt_llm/executor/serialization.cpp (4 hunks)
  • cpp/tensorrt_llm/kernels/penaltyKernels.cu (7 hunks)
  • cpp/tensorrt_llm/kernels/penaltyKernels.h (1 hunks)
  • cpp/tensorrt_llm/kernels/penaltyTypes.h (2 hunks)
  • cpp/tensorrt_llm/layers/decodingParams.h (1 hunks)
  • cpp/tensorrt_llm/layers/penaltyLayer.cpp (7 hunks)
  • cpp/tensorrt_llm/layers/penaltyLayer.h (1 hunks)
  • cpp/tensorrt_llm/nanobind/bindings.cpp (3 hunks)
  • cpp/tensorrt_llm/nanobind/executor/request.cpp (5 hunks)
  • cpp/tensorrt_llm/pybind/bindings.cpp (3 hunks)
  • cpp/tensorrt_llm/pybind/executor/request.cpp (5 hunks)
  • cpp/tensorrt_llm/runtime/gptDecoder.cpp (2 hunks)
  • cpp/tensorrt_llm/thop/dynamicDecodeOp.cpp (5 hunks)
  • cpp/tensorrt_llm/thop/dynamicDecodeOp.h (3 hunks)
  • cpp/tests/unit_tests/executor/samplingConfigTest.cpp (4 hunks)
  • cpp/tests/unit_tests/kernels/sampling/samplingPenaltyTest.cpp (40 hunks)
  • cpp/tests/unit_tests/layers/dynamicDecodeLayerTest.h (1 hunks)
  • cpp/tests/unit_tests/runtime/samplingConfigTest.cpp (5 hunks)
  • examples/eval_long_context.py (1 hunks)
  • examples/run.py (3 hunks)
  • examples/summarize.py (2 hunks)
  • examples/utils.py (1 hunks)
  • tensorrt_llm/runtime/generation.py (3 hunks)
  • tensorrt_llm/runtime/model_runner_cpp.py (1 hunks)
  • tensorrt_llm/sampling_params.py (2 hunks)
  • tensorrt_llm/serve/openai_protocol.py (4 hunks)
🧰 Additional context used
📓 Path-based instructions (8)
**/*.{h,hpp,hh,hxx,cpp,cxx,cc,cu,cuh,py}

📄 CodeRabbit inference engine (CODING_GUIDELINES.md)

Use only spaces, no tabs; indent with 4 spaces.

Files:

  • tensorrt_llm/runtime/model_runner_cpp.py
  • cpp/tensorrt_llm/kernels/penaltyTypes.h
  • examples/run.py
  • cpp/tensorrt_llm/kernels/penaltyKernels.h
  • cpp/tensorrt_llm/layers/decodingParams.h
  • examples/eval_long_context.py
  • cpp/tensorrt_llm/runtime/gptDecoder.cpp
  • cpp/include/tensorrt_llm/runtime/samplingConfig.h
  • cpp/tensorrt_llm/layers/penaltyLayer.h
  • cpp/tensorrt_llm/nanobind/bindings.cpp
  • tensorrt_llm/sampling_params.py
  • cpp/tensorrt_llm/layers/penaltyLayer.cpp
  • cpp/include/tensorrt_llm/layers/defaultDecodingParams.h
  • cpp/tensorrt_llm/pybind/bindings.cpp
  • cpp/tensorrt_llm/pybind/executor/request.cpp
  • examples/summarize.py
  • examples/utils.py
  • cpp/tests/unit_tests/layers/dynamicDecodeLayerTest.h
  • tensorrt_llm/runtime/generation.py
  • tensorrt_llm/serve/openai_protocol.py
  • cpp/tensorrt_llm/thop/dynamicDecodeOp.h
  • cpp/tests/unit_tests/executor/samplingConfigTest.cpp
  • cpp/include/tensorrt_llm/executor/executor.h
  • cpp/tensorrt_llm/nanobind/executor/request.cpp
  • cpp/tests/unit_tests/kernels/sampling/samplingPenaltyTest.cpp
  • cpp/tensorrt_llm/executor/serialization.cpp
  • cpp/tensorrt_llm/executor/samplingConfig.cpp
  • cpp/tensorrt_llm/thop/dynamicDecodeOp.cpp
  • cpp/tests/unit_tests/runtime/samplingConfigTest.cpp
  • cpp/tensorrt_llm/kernels/penaltyKernels.cu
**/*.py

📄 CodeRabbit inference engine (CODING_GUIDELINES.md)

**/*.py: Python code must target Python 3.8+.
Indent Python code with 4 spaces; do not use tabs.
Maintain module namespace when importing; prefer 'from package.subpackage import foo' then 'foo.SomeClass()' instead of importing the class directly.
Python filenames should be snake_case (e.g., some_file.py).
Python classes use PascalCase names.
Functions and methods use snake_case names.
Local variables use snake_case; prefix 'k' for variables that start with a number (e.g., k_99th_percentile).
Global variables use upper SNAKE_CASE prefixed with 'G' (e.g., G_MY_GLOBAL).
Constants use upper SNAKE_CASE (e.g., MY_CONSTANT).
Avoid shadowing variables from an outer scope.
Initialize all externally visible members of a class in the constructor.
Prefer docstrings for interfaces that may be used outside a file; comments for in-function or file-local interfaces.
Use Google-style docstrings for classes and functions (Sphinx-parsable).
Document attributes and variables inline so they render under the class/function docstring.
Avoid reflection when a simpler, explicit approach suffices (e.g., avoid dict(**locals()) patterns).
In try/except, catch the most specific exceptions possible.
For duck-typing try/except, keep the try body minimal and use else for the main logic.

Files:

  • tensorrt_llm/runtime/model_runner_cpp.py
  • examples/run.py
  • examples/eval_long_context.py
  • tensorrt_llm/sampling_params.py
  • examples/summarize.py
  • examples/utils.py
  • tensorrt_llm/runtime/generation.py
  • tensorrt_llm/serve/openai_protocol.py
**/*.{cpp,cxx,cc,h,hpp,hh,hxx,cu,cuh,py}

📄 CodeRabbit inference engine (CODING_GUIDELINES.md)

Prepend the NVIDIA Apache-2.0 copyright header with current year to the top of all source files (e.g., .cpp, .h, .cu, .py).

Files:

  • tensorrt_llm/runtime/model_runner_cpp.py
  • cpp/tensorrt_llm/kernels/penaltyTypes.h
  • examples/run.py
  • cpp/tensorrt_llm/kernels/penaltyKernels.h
  • cpp/tensorrt_llm/layers/decodingParams.h
  • examples/eval_long_context.py
  • cpp/tensorrt_llm/runtime/gptDecoder.cpp
  • cpp/include/tensorrt_llm/runtime/samplingConfig.h
  • cpp/tensorrt_llm/layers/penaltyLayer.h
  • cpp/tensorrt_llm/nanobind/bindings.cpp
  • tensorrt_llm/sampling_params.py
  • cpp/tensorrt_llm/layers/penaltyLayer.cpp
  • cpp/include/tensorrt_llm/layers/defaultDecodingParams.h
  • cpp/tensorrt_llm/pybind/bindings.cpp
  • cpp/tensorrt_llm/pybind/executor/request.cpp
  • examples/summarize.py
  • examples/utils.py
  • cpp/tests/unit_tests/layers/dynamicDecodeLayerTest.h
  • tensorrt_llm/runtime/generation.py
  • tensorrt_llm/serve/openai_protocol.py
  • cpp/tensorrt_llm/thop/dynamicDecodeOp.h
  • cpp/tests/unit_tests/executor/samplingConfigTest.cpp
  • cpp/include/tensorrt_llm/executor/executor.h
  • cpp/tensorrt_llm/nanobind/executor/request.cpp
  • cpp/tests/unit_tests/kernels/sampling/samplingPenaltyTest.cpp
  • cpp/tensorrt_llm/executor/serialization.cpp
  • cpp/tensorrt_llm/executor/samplingConfig.cpp
  • cpp/tensorrt_llm/thop/dynamicDecodeOp.cpp
  • cpp/tests/unit_tests/runtime/samplingConfigTest.cpp
  • cpp/tensorrt_llm/kernels/penaltyKernels.cu
**/*.{h,hpp,hh,hxx,cpp,cxx,cc,cu,cuh}

📄 CodeRabbit inference engine (CODING_GUIDELINES.md)

**/*.{h,hpp,hh,hxx,cpp,cxx,cc,cu,cuh}: Namespace closing braces must include a trailing comment with the namespace name (e.g., '} // namespace foo').
Prefer const or constexpr variables over #define for constants.
Declare variables that are not modified after initialization as const.
Avoid magic literals in code; except for 0, nullptr, true, false. Use named constants for comparisons and logic.
Use Allman brace style for formatting.
Place the semicolon of an empty for/while loop on a new line.
Bodies of switch/while/do-while/for must be compound statements (brace-delimited), and if/else must always be followed by brace-delimited statements.
Type names (e.g., classes) must be CamelCase starting with an uppercase letter (e.g., FooBar).
Local variables, methods, and namespaces use lowerCamelCase (e.g., localFooBar).
Non-magic-number global variables that are non-static and not in an anonymous namespace must be lowerCamelCase prefixed with 'g' (e.g., gDontUseGlobalFoos).
Non-magic-number globals that are static or in an anonymous namespace use lowerCamelCase prefixed with 's' (e.g., sMutableStaticGlobal).
Locally visible static variables use lowerCamelCase with 's' prefix (e.g., static std::once_flag sFlag).
Private/protected member variables use 'm' prefix with CamelCase (e.g., mNbFooValues). Public members may omit, but 'm' is encouraged for clarity.
Constants (enums, global constants, static constants, and function-scope magic/literal constants) use uppercase SNAKE_CASE with 'k' prefix (e.g., kDIGIT_NUM).
Function-scope constants that are not magic numbers or literals are named like non-constant variables (e.g., bool const pass = a && b).
If macros are necessary, name them in UPPER_SNAKE_CASE (e.g., FOO_VERSION) and prefer constants over #define.
Use LLVM clang-format; wrap lines at a maximum of 120 columns; use '// clang-format off/on' sparingly with justification.
Use smart pointers for heap allocations; prefer unique_ptr for sole ownership, shared_ptr for shared...

Files:

  • cpp/tensorrt_llm/kernels/penaltyTypes.h
  • cpp/tensorrt_llm/kernels/penaltyKernels.h
  • cpp/tensorrt_llm/layers/decodingParams.h
  • cpp/tensorrt_llm/runtime/gptDecoder.cpp
  • cpp/include/tensorrt_llm/runtime/samplingConfig.h
  • cpp/tensorrt_llm/layers/penaltyLayer.h
  • cpp/tensorrt_llm/nanobind/bindings.cpp
  • cpp/tensorrt_llm/layers/penaltyLayer.cpp
  • cpp/include/tensorrt_llm/layers/defaultDecodingParams.h
  • cpp/tensorrt_llm/pybind/bindings.cpp
  • cpp/tensorrt_llm/pybind/executor/request.cpp
  • cpp/tests/unit_tests/layers/dynamicDecodeLayerTest.h
  • cpp/tensorrt_llm/thop/dynamicDecodeOp.h
  • cpp/tests/unit_tests/executor/samplingConfigTest.cpp
  • cpp/include/tensorrt_llm/executor/executor.h
  • cpp/tensorrt_llm/nanobind/executor/request.cpp
  • cpp/tests/unit_tests/kernels/sampling/samplingPenaltyTest.cpp
  • cpp/tensorrt_llm/executor/serialization.cpp
  • cpp/tensorrt_llm/executor/samplingConfig.cpp
  • cpp/tensorrt_llm/thop/dynamicDecodeOp.cpp
  • cpp/tests/unit_tests/runtime/samplingConfigTest.cpp
  • cpp/tensorrt_llm/kernels/penaltyKernels.cu
**/*.{cpp,cxx,cc,cu,h,hpp,hh,hxx,cuh}

📄 CodeRabbit inference engine (CODING_GUIDELINES.md)

C++ filenames should be lowerCamelCase (first letter lowercase) and must be case-insensitive unique within a compilation target.

Files:

  • cpp/tensorrt_llm/kernels/penaltyTypes.h
  • cpp/tensorrt_llm/kernels/penaltyKernels.h
  • cpp/tensorrt_llm/layers/decodingParams.h
  • cpp/tensorrt_llm/runtime/gptDecoder.cpp
  • cpp/include/tensorrt_llm/runtime/samplingConfig.h
  • cpp/tensorrt_llm/layers/penaltyLayer.h
  • cpp/tensorrt_llm/nanobind/bindings.cpp
  • cpp/tensorrt_llm/layers/penaltyLayer.cpp
  • cpp/include/tensorrt_llm/layers/defaultDecodingParams.h
  • cpp/tensorrt_llm/pybind/bindings.cpp
  • cpp/tensorrt_llm/pybind/executor/request.cpp
  • cpp/tests/unit_tests/layers/dynamicDecodeLayerTest.h
  • cpp/tensorrt_llm/thop/dynamicDecodeOp.h
  • cpp/tests/unit_tests/executor/samplingConfigTest.cpp
  • cpp/include/tensorrt_llm/executor/executor.h
  • cpp/tensorrt_llm/nanobind/executor/request.cpp
  • cpp/tests/unit_tests/kernels/sampling/samplingPenaltyTest.cpp
  • cpp/tensorrt_llm/executor/serialization.cpp
  • cpp/tensorrt_llm/executor/samplingConfig.cpp
  • cpp/tensorrt_llm/thop/dynamicDecodeOp.cpp
  • cpp/tests/unit_tests/runtime/samplingConfigTest.cpp
  • cpp/tensorrt_llm/kernels/penaltyKernels.cu
**/*.{h,hpp,hh,hxx}

📄 CodeRabbit inference engine (CODING_GUIDELINES.md)

Document new class interfaces and function prototypes with Doxygen; use //! for single-line and //!< for members.

Files:

  • cpp/tensorrt_llm/kernels/penaltyTypes.h
  • cpp/tensorrt_llm/kernels/penaltyKernels.h
  • cpp/tensorrt_llm/layers/decodingParams.h
  • cpp/include/tensorrt_llm/runtime/samplingConfig.h
  • cpp/tensorrt_llm/layers/penaltyLayer.h
  • cpp/include/tensorrt_llm/layers/defaultDecodingParams.h
  • cpp/tests/unit_tests/layers/dynamicDecodeLayerTest.h
  • cpp/tensorrt_llm/thop/dynamicDecodeOp.h
  • cpp/include/tensorrt_llm/executor/executor.h
**/*.{h,hpp,hh,hxx,cpp,cxx,cc}

📄 CodeRabbit inference engine (CODING_GUIDELINES.md)

**/*.{h,hpp,hh,hxx,cpp,cxx,cc}: Prefer anonymous namespaces over 'static' for internal linkage of functions.
All templates (class/function/member/static) must be instantiated at least once; non-POD classes should have private data members.

Files:

  • cpp/tensorrt_llm/kernels/penaltyTypes.h
  • cpp/tensorrt_llm/kernels/penaltyKernels.h
  • cpp/tensorrt_llm/layers/decodingParams.h
  • cpp/tensorrt_llm/runtime/gptDecoder.cpp
  • cpp/include/tensorrt_llm/runtime/samplingConfig.h
  • cpp/tensorrt_llm/layers/penaltyLayer.h
  • cpp/tensorrt_llm/nanobind/bindings.cpp
  • cpp/tensorrt_llm/layers/penaltyLayer.cpp
  • cpp/include/tensorrt_llm/layers/defaultDecodingParams.h
  • cpp/tensorrt_llm/pybind/bindings.cpp
  • cpp/tensorrt_llm/pybind/executor/request.cpp
  • cpp/tests/unit_tests/layers/dynamicDecodeLayerTest.h
  • cpp/tensorrt_llm/thop/dynamicDecodeOp.h
  • cpp/tests/unit_tests/executor/samplingConfigTest.cpp
  • cpp/include/tensorrt_llm/executor/executor.h
  • cpp/tensorrt_llm/nanobind/executor/request.cpp
  • cpp/tests/unit_tests/kernels/sampling/samplingPenaltyTest.cpp
  • cpp/tensorrt_llm/executor/serialization.cpp
  • cpp/tensorrt_llm/executor/samplingConfig.cpp
  • cpp/tensorrt_llm/thop/dynamicDecodeOp.cpp
  • cpp/tests/unit_tests/runtime/samplingConfigTest.cpp
**/*.{h,hpp,hh,hxx,cuh}

📄 CodeRabbit inference engine (CODING_GUIDELINES.md)

Use include guards named 'TRTLLM_<FILE_NAME_IN_CAPS_WITH_UNDERSCORES>_H' (no leading or trailing underscore; directory names excluded).

Files:

  • cpp/tensorrt_llm/kernels/penaltyTypes.h
  • cpp/tensorrt_llm/kernels/penaltyKernels.h
  • cpp/tensorrt_llm/layers/decodingParams.h
  • cpp/include/tensorrt_llm/runtime/samplingConfig.h
  • cpp/tensorrt_llm/layers/penaltyLayer.h
  • cpp/include/tensorrt_llm/layers/defaultDecodingParams.h
  • cpp/tests/unit_tests/layers/dynamicDecodeLayerTest.h
  • cpp/tensorrt_llm/thop/dynamicDecodeOp.h
  • cpp/include/tensorrt_llm/executor/executor.h
🧬 Code graph analysis (12)
cpp/tensorrt_llm/layers/decodingParams.h (1)
cpp/include/tensorrt_llm/layers/defaultDecodingParams.h (5)
  • SizeType32 (54-57)
  • SizeType32 (59-62)
  • SizeType32 (77-80)
  • SizeType32 (112-115)
  • SizeType32 (127-130)
cpp/include/tensorrt_llm/runtime/samplingConfig.h (2)
cpp/include/tensorrt_llm/layers/defaultDecodingParams.h (7)
  • SizeType32 (54-57)
  • SizeType32 (59-62)
  • SizeType32 (77-80)
  • SizeType32 (112-115)
  • SizeType32 (127-130)
  • layers (28-142)
  • DefaultDecodingParams (31-141)
cpp/tensorrt_llm/executor/samplingConfig.cpp (4)
  • getPromptIgnoreLength (148-151)
  • getPromptIgnoreLength (148-148)
  • other (64-75)
  • other (64-64)
cpp/tensorrt_llm/layers/penaltyLayer.cpp (3)
cpp/tensorrt_llm/layers/penaltyLayer.h (1)
  • mUsePromptIgnoreLength (84-95)
cpp/tensorrt_llm/executor/samplingConfig.cpp (2)
  • getPromptIgnoreLength (148-151)
  • getPromptIgnoreLength (148-148)
cpp/include/tensorrt_llm/layers/defaultDecodingParams.h (5)
  • SizeType32 (54-57)
  • SizeType32 (59-62)
  • SizeType32 (77-80)
  • SizeType32 (112-115)
  • SizeType32 (127-130)
cpp/include/tensorrt_llm/layers/defaultDecodingParams.h (1)
cpp/tensorrt_llm/executor/samplingConfig.cpp (2)
  • getPromptIgnoreLength (148-151)
  • getPromptIgnoreLength (148-148)
cpp/tensorrt_llm/pybind/executor/request.cpp (1)
cpp/tensorrt_llm/executor/samplingConfig.cpp (4)
  • getPromptIgnoreLength (148-151)
  • getPromptIgnoreLength (148-148)
  • setPromptIgnoreLength (250-253)
  • setPromptIgnoreLength (250-250)
cpp/tests/unit_tests/layers/dynamicDecodeLayerTest.h (1)
cpp/include/tensorrt_llm/layers/defaultDecodingParams.h (5)
  • SizeType32 (54-57)
  • SizeType32 (59-62)
  • SizeType32 (77-80)
  • SizeType32 (112-115)
  • SizeType32 (127-130)
cpp/tests/unit_tests/executor/samplingConfigTest.cpp (4)
cpp/include/tensorrt_llm/runtime/samplingConfig.h (1)
  • SamplingConfig (112-196)
cpp/tensorrt_llm/executor/samplingConfig.cpp (1)
  • SamplingConfig (33-62)
tensorrt_llm/runtime/generation.py (1)
  • SamplingConfig (658-708)
cpp/tests/unit_tests/runtime/samplingConfigTest.cpp (2)
  • test (34-82)
  • test (34-43)
cpp/include/tensorrt_llm/executor/executor.h (2)
cpp/include/tensorrt_llm/layers/defaultDecodingParams.h (5)
  • SizeType32 (54-57)
  • SizeType32 (59-62)
  • SizeType32 (77-80)
  • SizeType32 (112-115)
  • SizeType32 (127-130)
cpp/tensorrt_llm/executor/samplingConfig.cpp (6)
  • getPromptIgnoreLength (148-151)
  • getPromptIgnoreLength (148-148)
  • setPromptIgnoreLength (250-253)
  • setPromptIgnoreLength (250-250)
  • checkPromptIgnoreLength (377-384)
  • checkPromptIgnoreLength (377-377)
cpp/tensorrt_llm/nanobind/executor/request.cpp (1)
cpp/tensorrt_llm/executor/samplingConfig.cpp (4)
  • getPromptIgnoreLength (148-151)
  • getPromptIgnoreLength (148-148)
  • setPromptIgnoreLength (250-253)
  • setPromptIgnoreLength (250-250)
cpp/tensorrt_llm/executor/samplingConfig.cpp (1)
cpp/include/tensorrt_llm/batch_manager/llmRequest.h (1)
  • mNumReturnSequences (2011-2011)
cpp/tests/unit_tests/runtime/samplingConfigTest.cpp (1)
cpp/tests/unit_tests/executor/samplingConfigTest.cpp (2)
  • test (31-76)
  • test (31-40)
cpp/tensorrt_llm/kernels/penaltyKernels.cu (2)
cpp/tensorrt_llm/kernels/beamSearchKernels.h (1)
  • parentIdsPtr (95-222)
cpp/tensorrt_llm/executor/samplingConfig.cpp (2)
  • getPromptIgnoreLength (148-151)
  • getPromptIgnoreLength (148-148)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Pre-commit Check
🔇 Additional comments (14)
cpp/include/tensorrt_llm/layers/defaultDecodingParams.h (1)

59-62: Default accessor looks good.

Thanks for adding the helper—having a canonical zero default lines up with the new SamplingConfig plumbing.

tensorrt_llm/serve/openai_protocol.py (1)

621-622: Propagation looks correct.

Nice to see the value threaded straight into SamplingParams; matches the completions path.

cpp/tensorrt_llm/kernels/penaltyKernels.h (1)

38-38: LGTM! New field added correctly.

The promptIgnoreLengths field is properly declared as a const pointer, follows naming conventions, and is correctly positioned in the parameter struct.

cpp/tensorrt_llm/kernels/penaltyTypes.h (2)

37-37: LGTM! Enum value added correctly.

The PromptIgnoreLength enumerator is properly added to the DecodingPenaltyType enum with an appropriate descriptive comment.


53-53: LGTM! Switch case handles new penalty type correctly.

The case for PromptIgnoreLength returns appropriate limits matching the MinLength penalty, which makes sense for a length-related parameter.

tensorrt_llm/runtime/model_runner_cpp.py (1)

647-647: LGTM! Parameter properly added to accepted list.

The prompt_ignore_length parameter is correctly added to the accepted_parameters list, enabling it to flow through to SamplingConfig construction.

cpp/tensorrt_llm/layers/decodingParams.h (1)

136-136: LGTM! Field added consistently with existing patterns.

The promptIgnoreLength field is properly declared with the correct type OptVec<runtime::SizeType32>, follows naming conventions, and is positioned logically among other penalty parameters.

examples/run.py (1)

543-543: LGTM! Parameter consistently propagated through all generation paths.

The prompt_ignore_length parameter is correctly added to all three generate() calls (main execution, profiling warmup, and profiling benchmark), ensuring consistent behavior across all code paths.

Also applies to: 643-643, 682-682

cpp/tests/unit_tests/layers/dynamicDecodeLayerTest.h (1)

43-43: LGTM! Test parameter field added correctly.

The promptIgnoreLengths field is properly declared with the appropriate type and naming convention for test parameters.

cpp/tensorrt_llm/layers/penaltyLayer.h (1)

70-70: LGTM! Penalty layer members added consistently.

The three new members (mPromptIgnoreLengthDevice, mPromptIgnoreLength, and mUsePromptIgnoreLength) follow the established pattern for penalty parameters with correct naming conventions and appropriate types.

Also applies to: 77-77, 84-84

examples/eval_long_context.py (1)

284-284: LGTM! Parameter correctly propagated to generation call.

The prompt_ignore_length argument is properly added to the generate() call, consistent with other penalty parameters and matching the pattern used in other example files.

tensorrt_llm/sampling_params.py (1)

169-170: Doc and field addition look consistent.

Docstring update and dataclass wiring stay aligned with executor field mapping.

Also applies to: 237-238

cpp/tensorrt_llm/runtime/gptDecoder.cpp (1)

84-90: Prompt-ignore length flows into penalty params.

Propagation in both disableLookahead and setup keeps penalty configuration consistent.

Also applies to: 137-143

tensorrt_llm/runtime/generation.py (1)

688-689: Runtime support mirrors existing patterns.

The new prompt_ignore_length plumbing matches other scalar/tensor knobs and threads into dynamic_decoder.setup correctly.

Also applies to: 1422-1451, 1513-1534

Comment on lines 381 to 394
config.promptIgnoreLength = t[6].cast<SizeType32>();
config.topK = t[7].cast<OptVec<SizeType32>>();
config.topP = t[8].cast<OptVec<float>>();
config.randomSeed = t[9].cast<OptVec<uint64_t>>();
config.topPDecay = t[10].cast<OptVec<float>>();
config.topPMin = t[11].cast<OptVec<float>>();
config.topPResetIds = t[12].cast<OptVec<TokenIdType>>();
config.beamSearchDiversityRate = t[13].cast<OptVec<float>>();
config.lengthPenalty = t[14].cast<OptVec<float>>();
config.earlyStopping = t[15].cast<OptVec<SizeType32>>();
config.noRepeatNgramSize = t[16].cast<OptVec<SizeType32>>();
config.numReturnSequences = t[17].cast<SizeType32>();
config.minP = t[18].cast<OptVec<float>>();
config.beamWidthArray = t[19].cast<OptVec<std::vector<SizeType32>>>();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical

Fix prompt_ignore_length deserialization type

config.promptIgnoreLength is an OptVec<SizeType32> (optional vector). Casting t[6] to SizeType32 is a type mismatch, so this code fails to compile and would still break pickle round-trips if it did. Cast to the matching optional-vector type instead.

-        config.promptIgnoreLength = t[6].cast<SizeType32>();
+        config.promptIgnoreLength = t[6].cast<OptVec<SizeType32>>();
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
config.promptIgnoreLength = t[6].cast<SizeType32>();
config.topK = t[7].cast<OptVec<SizeType32>>();
config.topP = t[8].cast<OptVec<float>>();
config.randomSeed = t[9].cast<OptVec<uint64_t>>();
config.topPDecay = t[10].cast<OptVec<float>>();
config.topPMin = t[11].cast<OptVec<float>>();
config.topPResetIds = t[12].cast<OptVec<TokenIdType>>();
config.beamSearchDiversityRate = t[13].cast<OptVec<float>>();
config.lengthPenalty = t[14].cast<OptVec<float>>();
config.earlyStopping = t[15].cast<OptVec<SizeType32>>();
config.noRepeatNgramSize = t[16].cast<OptVec<SizeType32>>();
config.numReturnSequences = t[17].cast<SizeType32>();
config.minP = t[18].cast<OptVec<float>>();
config.beamWidthArray = t[19].cast<OptVec<std::vector<SizeType32>>>();
config.promptIgnoreLength = t[6].cast<OptVec<SizeType32>>();
config.topK = t[7].cast<OptVec<SizeType32>>();
config.topP = t[8].cast<OptVec<float>>();
config.randomSeed = t[9].cast<OptVec<uint64_t>>();
config.topPDecay = t[10].cast<OptVec<float>>();
config.topPMin = t[11].cast<OptVec<float>>();
config.topPResetIds = t[12].cast<OptVec<TokenIdType>>();
config.beamSearchDiversityRate = t[13].cast<OptVec<float>>();
config.lengthPenalty = t[14].cast<OptVec<float>>();
config.earlyStopping = t[15].cast<OptVec<SizeType32>>();
config.noRepeatNgramSize = t[16].cast<OptVec<SizeType32>>();
config.numReturnSequences = t[17].cast<SizeType32>();
config.minP = t[18].cast<OptVec<float>>();
config.beamWidthArray = t[19].cast<OptVec<std::vector<SizeType32>>>();
🤖 Prompt for AI Agents
In cpp/tensorrt_llm/pybind/bindings.cpp around lines 381 to 394,
config.promptIgnoreLength is declared as OptVec<SizeType32> but the code casts
t[6] to SizeType32; change the deserialization to cast t[6] to
OptVec<SizeType32> and assign that, so the type matches and pickle round-trips
compile and work correctly.

@tensorrt-cicd
Copy link
Collaborator

PR_Github #20560 [ run ] triggered by Bot

@tensorrt-cicd
Copy link
Collaborator

PR_Github #20560 [ run ] completed with state FAILURE
/LLM/main/L0_MergeRequest_PR pipeline #15517 completed with status: 'FAILURE'

… to ignore from the prompt for precense and frequency penalties for trt and torch path.

Signed-off-by: Xuanyu Chen <[email protected]>
@nvxuanyuc nvxuanyuc force-pushed the prompt_ignore_penalty branch from 4d33465 to 6997c66 Compare October 3, 2025 17:28
@jhaotingc
Copy link
Collaborator

cc @pathorn @Pernekhan

@nvxuanyuc
Copy link
Collaborator Author

/bot run --disable-fail-fast

@tensorrt-cicd
Copy link
Collaborator

PR_Github #20606 [ run ] triggered by Bot

@tensorrt-cicd
Copy link
Collaborator

PR_Github #20606 [ run ] completed with state SUCCESS
/LLM/main/L0_MergeRequest_PR pipeline #15555 completed with status: 'FAILURE'

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.

3 participants