[TRTLLM-10030][chore] refactor finish reasons tests#11445
[TRTLLM-10030][chore] refactor finish reasons tests#11445ixlmar merged 2 commits intoNVIDIA:mainfrom
Conversation
|
/bot run --disable-fail-fast |
📝 WalkthroughWalkthroughRestructured test scaffolding in Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes 🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
Tip Issue Planner is now in beta. Read the docs and try it out! Share your feedback on Discord. 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.
Actionable comments posted: 2
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
tests/unittest/_torch/sampler/test_torch_sampler.py (1)
1-1:⚠️ Potential issue | 🟡 MinorUpdate copyright year to 2026.
The copyright header says 2025, but this file has meaningful modifications in 2026. As per coding guidelines, "All source files must contain an NVIDIA copyright header with the year of latest meaningful modification."
Proposed fix
-# Copyright (c) 2025, NVIDIA CORPORATION. All rights reserved. +# Copyright (c) 2025-2026, NVIDIA CORPORATION. All rights reserved.
🤖 Fix all issues with AI agents
In `@tests/unittest/_torch/sampler/test_torch_sampler.py`:
- Around line 686-698: The build(...) classmethod declares check_no_cuda_sync
but never uses it, so the no-CUDA-sync assertion is never triggered; modify
build to propagate this flag into the returned provider or return a tuple so the
caller can call _run_test_with_warmup(uut_provider, max_sync_s=...) when
check_no_cuda_sync is True. Specifically, update build (and its inner
_uut_provider if needed) so that the caller at the test invocation site receives
the check_no_cuda_sync value (or a computed max_sync_s) and then pass that into
_run_test_with_warmup(uut_provider, max_sync_s=...) instead of omitting
max_sync_s; ensure function names referenced: build, _uut_provider, and
_run_test_with_warmup are updated consistently.
- Around line 859-890: Remove the `@classmethod` decorator from
test_are_stop_words_isnt_called_when_no_stop_words and change its signature to
an instance method that accepts the pytest monkeypatch fixture (def
test_are_stop_words_isnt_called_when_no_stop_words(self, monkeypatch:
pytest.MonkeyPatch):). Update any uses of cls inside the method (e.g.,
cls.RequestCase, cls.NOT_FINISHED) to reference the test class via
self.__class__ or type(self) so the code still locates RequestCase and
NOT_FINISHED, and keep the monkeypatch usage to patch
TorchSampler._are_stop_words.
🧹 Nitpick comments (2)
tests/unittest/_torch/sampler/test_torch_sampler.py (2)
644-681: Shared mutable class-level state inseq_slotsmay cause fragile tests.
seq_slotsis a class-level list mutated by.pop()on everyRequestCaseinstantiation. This creates implicit coupling between test cases: slots consumed in one test are unavailable to subsequent tests, test ordering matters, andtorch.randpermwithout a seed makes slot assignments non-reproducible across runs.Consider creating the slot pool per
build()invocation (or per test) instead:Proposed fix — move slot generation into `build()` or `__init__`
class RequestCase: MAX_NEW_TOKENS = 10 MAX_NUM_SEQUENCES = 128 - seq_slots = torch.randperm(MAX_NUM_SEQUENCES).tolist() BEAM = 0 def __init__( self, *, prompt: list[int], new_tokens: list[int], finish_reasons: list[FinishReason], max_new_tokens: int = MAX_NEW_TOKENS, end_id: Optional[int] = None, num_draft_tokens: int | None = None, stop_words_list: Optional[list[list[int]]] = None, + seq_slot: int, ): - seq_slot = self.seq_slots.pop() # random seq slot in MAX_NUM_SEQUENCES self.prompt = promptThen in
build(), generate and distribute slots:seq_slot_pool = torch.randperm(cls.MAX_NUM_SEQUENCES, generator=torch.Generator().manual_seed(42)).tolist() for i, req in enumerate(requests_args): req['seq_slot'] = seq_slot_pool[i]
696-698: Misleading variable namemax_tokens.
max_tokensholds asetof new-token counts (used to assert uniformity), but reads as if it stores a maximum value. Consider a clearer name liketoken_count_setornew_token_lengths.Proposed rename
- max_tokens = set(len(req.new_tokens) for req in requests) - assert len(max_tokens) == 1 - max_draft_len = max_tokens.pop() - 1 + new_token_lengths = set(len(req.new_tokens) for req in requests) + assert len(new_token_lengths) == 1 + max_draft_len = new_token_lengths.pop() - 1
|
PR_Github #35611 [ run ] triggered by Bot. Commit: |
|
/bot run --disable-fail-fast |
|
PR_Github #35618 [ run ] triggered by Bot. Commit: |
Signed-off-by: ixlmar <206748156+ixlmar@users.noreply.github.com>
Signed-off-by: ixlmar <206748156+ixlmar@users.noreply.github.com>
0336248 to
7d15ee8
Compare
|
/bot run --disable-fail-fast |
|
PR_Github #35628 [ run ] triggered by Bot. Commit: |
|
PR_Github #35628 [ run ] completed with state |
Signed-off-by: ixlmar <206748156+ixlmar@users.noreply.github.com>
Description
Code changes group finish reasons related test code in
TestFinishReasonsand add check thatTorchSampler._write_finish_reasonsdoes not stream sync.Test Coverage
PR extends existing tests.
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
Update tava architecture diagram if there is a significant design change in PR.
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.
Details
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-listparameter 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.mdand the
scripts/test_to_stage_mapping.pyhelper.kill
killKill all running builds associated with pull request.
skip
skip --comment COMMENTSkip 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-pipelineReuse 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.
Summary by CodeRabbit