Add comprehensive unit tests for limit_thinking_content_length operators #4510
+877
−0
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Overview
This PR adds comprehensive unit tests for the
limit_thinking_content_lengthandspeculate_limit_thinking_content_lengthoperators that control thinking phase length in model generation.Background
The operators
limit_thinking_content_length_v1,limit_thinking_content_length_v2,speculate_limit_thinking_content_length_v1, andspeculate_limit_thinking_content_length_v2are GPU custom operators designed to limit the length of "thinking" content during model inference. These operators work by:</think>token when max_think_len is exceeded\n</think>\n\nsequence when max_think_len is exceededPreviously, these operators lacked unit tests, making it difficult to verify their correctness and catch regressions.
Changes
Added two new test files with 33 comprehensive test methods (925 lines total):
1.
tests/operators/test_limit_thinking_content_length.pyTests the standard (non-speculative) variants with 16 test methods covering:
2.
tests/operators/test_speculate_limit_thinking_content_length.pyTests the speculative decoding variants with 17 test methods covering:
\n,</think>,\n,\n)Test Coverage
The tests verify:
Example Test Case
Verification
tests/operators/Note: Tests require a GPU environment with PaddlePaddle and dependencies installed to run.
Related Issue
Closes the issue requesting unit tests for
limit_thinking_content_lengthandspeculate_limit_thinking_content_lengthfunctions infastdeploy/model_executor/pre_and_post_process.py.Original prompt
Fixes #4509
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.