-
Notifications
You must be signed in to change notification settings - Fork 1.8k
[None][feat] Dev DeepConf #8362
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?
Conversation
/bot run --disable-fail-fast |
PR_Github #21350 [ run ] triggered by Bot |
📝 WalkthroughWalkthroughAdds DeepConf-based scaffolding generation: new controllers (offline, online, offline/online majority-vote), confidence utilities, public exports, and an example driver script wiring TRTLLM worker, argument parsing, controller selection, and run execution with timing and per-result logging. Changes
Sequence Diagram(s)sequenceDiagram
autonumber
participant U as User
participant RG as run_generation.py
participant SL as ScaffoldingLlm
participant DC as DeepConf {Offline|Online}Controller
participant GC as GenerationController
participant W as LLM Worker
U->>RG: CLI args (model_dir, run_type, params)
RG->>W: init TRTLLMWorker
RG->>GC: init NativeGenerationController(sampling)
RG->>DC: init DeepConf {Offline|Online}(conf_group_size, conf_threshold)
RG->>SL: init with {proposer: W, controller: DC}
RG->>SL: generate(prompts)
SL->>DC: process(tasks)
DC->>GC: generate (stepwise for Online)
GC->>W: infer(next tokens/logprobs)
W-->>GC: tokens, logprobs
GC-->>DC: results (+logprobs)
DC-->>SL: tasks (+confidence_info)
SL-->>RG: results
RG->>W: shutdown
RG-->>U: print outputs
sequenceDiagram
autonumber
participant U as User
participant RG as run_generation.py
participant SL as ScaffoldingLlm
participant MVC as DeepConf {Offline|Online}MajorityVote
participant GCw as Warmup GenController
participant GCf as Final GenController
participant PP as ParallelProcess
participant W as LLM Worker
U->>RG: run_type={offline|online}_majority_vote
RG->>W: init TRTLLMWorker
RG->>MVC: init(sample_num, warmup_sample_num, vote_policy, thresholds)
RG->>SL: init with {proposer: W, controller: MVC}
RG->>SL: generate(prompts)
SL->>MVC: process(tasks)
rect rgba(200,230,255,0.25)
note right of MVC: Warmup phase
MVC->>PP: parallel_generate(tasks, warmup_sample_num, GCw)
PP-->>MVC: warmup task sets
MVC->>MVC: get_conf_bar(percentile or threshold)
end
rect rgba(200,255,200,0.25)
note right of MVC: Final phase
MVC->>PP: parallel_generate(tasks, sample_num, GCf, conf_bar)
PP-->>MVC: final task sets
MVC->>MVC: majority_vote(policy)
end
MVC-->>SL: tasks with voted results
SL-->>RG: results
RG->>W: shutdown
RG-->>U: print outputs
Estimated code review effort🎯 4 (Complex) | ⏱️ ~75 minutes Pre-merge checks and finishing touches❌ Failed checks (2 warnings, 1 inconclusive)
✨ Finishing touches
🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 10
🧹 Nitpick comments (9)
tensorrt_llm/scaffolding/contrib/DeepConf/__init__.py (1)
6-11
: Sort all for lint consistency (RUF022)Optional style tweak: sort exported names alphabetically.
__all__ = [ - "DeepConfOfflineController", - "DeepConfOnlineController", - "DeepConfOfflineMajorityVoteController", - "DeepConfOnlineMajorityVoteController", + "DeepConfOfflineController", + "DeepConfOfflineMajorityVoteController", + "DeepConfOnlineController", + "DeepConfOnlineMajorityVoteController", ]tensorrt_llm/scaffolding/contrib/DeepConf/deep_conf_utils.py (4)
20-27
: Remove extraneous f-string prefixNo placeholders present.
- print( - f"Warning: no valid conf group yet, maybe you should decrease conf_group_size" - ) + print("Warning: no valid conf group yet, maybe you should decrease conf_group_size")
73-76
: Silence unused kwargs and keep extensibilityRename to _kwargs.
-def basic_majority_vote(tasks: List[Task], answers, **kwargs) -> Task: +def basic_majority_vote(tasks: List[Task], answers, **_kwargs) -> Task:
78-101
: Rename param shadowing built-in and add zip length assert
- Avoid using name 'type'.
- Guard zip with equal lengths (3.8-safe).
-def weighted_majority_vote(tasks: List[Task], - answers, - confidences, - filter_top_percent=1.0, - type="", - **kwargs) -> Task: +def weighted_majority_vote(tasks: List[Task], + answers, + confidences, + filter_top_percent: float = 1.0, + policy_label: str = "", + **_kwargs) -> Task: @@ - print(f"Info: {type=} {filter_top_percent=} has {len(tasks)} valid tasks") + print(f"Info: {policy_label=} {filter_top_percent=} has {len(tasks)} valid tasks") @@ - for answer, confidence in zip(answers, confidences): + assert len(answers) == len(confidences), "answers and confidences must match in length" + for answer, confidence in zip(answers, confidences):Also update call sites in majority_vote to use policy_label=vote_policy.
114-119
: Optional: deterministic fallback when no valid tasksFor reproducibility, consider seeding or choosing the highest-confidence task instead of random.choice.
examples/scaffolding/contrib/DeepConf/run_generation.py (3)
74-75
: Silence unused kwargs in helpersRename to _kwargs to avoid lint warnings.
-def test_single_vote_controller(..., **kwargs): +def test_single_vote_controller(..., **_kwargs): @@ -def test_majority_vote_controller(..., **kwargs): +def test_majority_vote_controller(..., **_kwargs):Also applies to: 104-105
165-166
: Remove extraneous f-stringNo placeholders present.
- print(f"init llm worker done") + print("init llm worker done")
178-179
: Avoid double worker shutdownWorker is already shutdown inside run_scaffolding_llm(shutdown_workers=True). This second call is redundant.
- llm_worker.shutdown() - print('llm worker shutdown done') + print('llm worker shutdown done')tensorrt_llm/scaffolding/contrib/DeepConf/deep_conf_controller.py (1)
181-207
: Minor: remove extraneous f-string prefixes in static messagesNo placeholders present.
- print(f"Info: begin warmup") + print("Info: begin warmup") @@ - print(f"Info: end warmup") + print("Info: end warmup") @@ - print(f"Info: begin final") + print("Info: begin final") @@ - print(f"Info: end final") + print("Info: end final") @@ - print(f"Info: end vote") + print("Info: end vote")
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (4)
examples/scaffolding/contrib/DeepConf/run_generation.py
(1 hunks)tensorrt_llm/scaffolding/contrib/DeepConf/__init__.py
(1 hunks)tensorrt_llm/scaffolding/contrib/DeepConf/deep_conf_controller.py
(1 hunks)tensorrt_llm/scaffolding/contrib/DeepConf/deep_conf_utils.py
(1 hunks)
🧰 Additional context used
📓 Path-based instructions (3)
**/*.{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:
examples/scaffolding/contrib/DeepConf/run_generation.py
tensorrt_llm/scaffolding/contrib/DeepConf/__init__.py
tensorrt_llm/scaffolding/contrib/DeepConf/deep_conf_utils.py
tensorrt_llm/scaffolding/contrib/DeepConf/deep_conf_controller.py
**/*.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:
examples/scaffolding/contrib/DeepConf/run_generation.py
tensorrt_llm/scaffolding/contrib/DeepConf/__init__.py
tensorrt_llm/scaffolding/contrib/DeepConf/deep_conf_utils.py
tensorrt_llm/scaffolding/contrib/DeepConf/deep_conf_controller.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:
examples/scaffolding/contrib/DeepConf/run_generation.py
tensorrt_llm/scaffolding/contrib/DeepConf/__init__.py
tensorrt_llm/scaffolding/contrib/DeepConf/deep_conf_utils.py
tensorrt_llm/scaffolding/contrib/DeepConf/deep_conf_controller.py
🧬 Code graph analysis (4)
examples/scaffolding/contrib/DeepConf/run_generation.py (5)
tensorrt_llm/llmapi/llm_args.py (1)
SchedulerConfig
(983-1001)tensorrt_llm/scaffolding/controller.py (1)
NativeGenerationController
(47-72)tensorrt_llm/scaffolding/scaffolding_llm.py (1)
ScaffoldingLlm
(22-237)tensorrt_llm/scaffolding/worker.py (2)
TRTLLMWorker
(134-247)init_with_new_llm
(146-178)tensorrt_llm/scaffolding/contrib/DeepConf/deep_conf_controller.py (4)
DeepConfOfflineController
(12-40)DeepConfOfflineMajorityVoteController
(43-82)DeepConfOnlineController
(85-139)DeepConfOnlineMajorityVoteController
(142-241)
tensorrt_llm/scaffolding/contrib/DeepConf/__init__.py (1)
tensorrt_llm/scaffolding/contrib/DeepConf/deep_conf_controller.py (4)
DeepConfOfflineController
(12-40)DeepConfOfflineMajorityVoteController
(43-82)DeepConfOnlineController
(85-139)DeepConfOnlineMajorityVoteController
(142-241)
tensorrt_llm/scaffolding/contrib/DeepConf/deep_conf_utils.py (2)
tensorrt_llm/scaffolding/task.py (1)
Task
(12-20)tensorrt_llm/scaffolding/math_utils.py (1)
extract_answer_from_boxed
(14-53)
tensorrt_llm/scaffolding/contrib/DeepConf/deep_conf_controller.py (3)
tensorrt_llm/scaffolding/controller.py (2)
Controller
(15-31)ParallelProcess
(34-43)tensorrt_llm/scaffolding/task.py (3)
Task
(12-20)logprobs
(101-102)output_tokens
(83-84)tensorrt_llm/scaffolding/contrib/DeepConf/deep_conf_utils.py (5)
ConfidenceInfo
(12-70)majority_vote
(103-177)update_confidence_info
(58-70)should_stop
(28-30)get_min_conf_grouped
(20-26)
🪛 Ruff (0.14.0)
examples/scaffolding/contrib/DeepConf/run_generation.py
74-74: Unused function argument: kwargs
(ARG001)
104-104: Unused function argument: kwargs
(ARG001)
165-165: f-string without any placeholders
Remove extraneous f
prefix
(F541)
tensorrt_llm/scaffolding/contrib/DeepConf/__init__.py
6-11: __all__
is not sorted
Apply an isort-style sorting to __all__
(RUF022)
tensorrt_llm/scaffolding/contrib/DeepConf/deep_conf_utils.py
23-23: f-string without any placeholders
Remove extraneous f
prefix
(F541)
58-58: Undefined name Logprob
(F821)
59-59: Unused method argument: token_id
(ARG002)
73-73: Unused function argument: kwargs
(ARG001)
83-83: Unused function argument: kwargs
(ARG001)
96-96: zip()
without an explicit strict=
parameter
Add explicit value for parameter strict=
(B905)
118-118: Standard pseudo-random generators are not suitable for cryptographic purposes
(S311)
tensorrt_llm/scaffolding/contrib/DeepConf/deep_conf_controller.py
15-15: Unused method argument: kwargs
(ARG002)
36-37: zip()
without an explicit strict=
parameter
Add explicit value for parameter strict=
(B905)
51-51: Unused method argument: kwargs
(ARG002)
88-88: Unused method argument: kwargs
(ARG002)
110-110: Avoid equality comparisons to False
; use not online_task.end_flag:
for false checks
Replace with not online_task.end_flag
(E712)
153-153: Unused method argument: kwargs
(ARG002)
185-185: f-string without any placeholders
Remove extraneous f
prefix
(F541)
191-191: f-string without any placeholders
Remove extraneous f
prefix
(F541)
196-196: f-string without any placeholders
Remove extraneous f
prefix
(F541)
203-203: f-string without any placeholders
Remove extraneous f
prefix
(F541)
207-207: f-string without any placeholders
Remove extraneous f
prefix
(F541)
⏰ 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 (3)
tensorrt_llm/scaffolding/contrib/DeepConf/deep_conf_controller.py (2)
67-83
: LGTM on parallelization and voting flowThe cloning, parallel process orchestration, and voting assignment look sound.
233-241
: LGTM on conf_bar computationPercentile-based bar with fallback is reasonable.
tensorrt_llm/scaffolding/contrib/DeepConf/deep_conf_utils.py (1)
8-8
: No changes required: extract_answer_from_boxed import is valid. It's re-exported in tensorrt_llm.scaffolding.
tensorrt_llm/scaffolding/contrib/DeepConf/deep_conf_controller.py
Outdated
Show resolved
Hide resolved
PR_Github #21350 [ run ] completed with state |
/bot run --disable-fail-fast |
PR_Github #21405 [ run ] triggered by Bot |
PR_Github #21405 [ run ] completed with state |
/bot run --disable-fail-fast |
tensorrt_llm/scaffolding/contrib/DeepConf/deep_conf_controller.py
Outdated
Show resolved
Hide resolved
tensorrt_llm/scaffolding/contrib/DeepConf/deep_conf_controller.py
Outdated
Show resolved
Hide resolved
tensorrt_llm/scaffolding/contrib/DeepConf/deep_conf_controller.py
Outdated
Show resolved
Hide resolved
tensorrt_llm/scaffolding/contrib/DeepConf/deep_conf_controller.py
Outdated
Show resolved
Hide resolved
PR_Github #21448 [ run ] triggered by Bot |
Signed-off-by: Dong Cao <[email protected]>
fb72746
to
de1f7c3
Compare
/bot run --disable-fail-fast |
PR_Github #21454 [ run ] triggered by Bot |
PR_Github #21448 [ run ] completed with state |
PR_Github #21454 [ run ] completed with state |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Approve document changes.
Summary by CodeRabbit
Description
Test Coverage
PR Checklist
Please review the following before submitting your PR:
PR description clearly explains what and why. If using CodeRabbit's summary, please make sure it makes sense.
PR Follows TRT-LLM CODING GUIDELINES to the best of your knowledge.
Test cases are provided for new code paths (see test instructions)
Any new dependencies have been scanned for license and vulnerabilities
CODEOWNERS updated if ownership changes
Documentation updated as needed
The reviewers assigned automatically/manually are appropriate for the PR.
Please check this after reviewing the above items as appropriate for this PR.
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 thestage-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.