[Test] Add unit tests for managers/schedule_batch.py#24381
Open
yangyonggit wants to merge 4 commits intosgl-project:mainfrom
Open
[Test] Add unit tests for managers/schedule_batch.py#24381yangyonggit wants to merge 4 commits intosgl-project:mainfrom
yangyonggit wants to merge 4 commits intosgl-project:mainfrom
Conversation
Add 67 CPU-only unit tests covering the Req class in schedule_batch.py,
which had no dedicated unit test coverage.
Tests cover:
- Finish reason to_json() for all 5 reason types
- seqlen, finished(), output_ids_through_stop properties
- check_finished(): already-finished noop, to_finish transfer, length
limit, stop token ID, eos_token_ids, ignore_eos bypass, stop string
in decoded_text, finished_len correctness
- reset_for_retract(): retraction counter, prefix_indices, KV lengths,
flags, output_ids cleared only when input_embeds is set
- set_extend_input_len(): basic set and extend_logprob_start_len
computation for logprob_start_len = 0, positive, -1, and clamped
- update_reasoning_tokens(): think_end_id in middle/first/last/absent,
noop after reasoning over, single-int input
- _check_vocab_boundary_finish(): valid tokens, token above vocab_size,
negative token, stop_token_id/eos replacement, eos wins over stop,
finished_len at correct offset, stops at first bad token
- init_incremental_detokenize(): first-call offset computation, short
input (surr_offset=0), incremental extension, stability with no new tokens
- check_match_stop_str_prefix(): no stop_strs, empty tail, full match,
partial suffix overlap ("EN" vs "END"), single-char overlap, no match,
multiple stop strings
All tests run on CPU (stage-a-test-cpu) with no server or model weights.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
6 tasks
Contributor
There was a problem hiding this comment.
Code Review
This pull request introduces a comprehensive suite of unit tests for the schedule_batch.py manager, specifically focusing on the Req class and various finish reason objects. The tests cover request properties, finish condition logic (including token and string matches), state resets during retraction, reasoning token tracking, and incremental detokenization offsets. I have no feedback to provide.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
Closes #20865
Add 67 CPU-only unit tests for the
Reqclass insrt/managers/schedule_batch.py, which had no dedicated unit test file.FINISH_MATCHED_TOKEN,FINISH_MATCHED_STR,FINISHED_MATCHED_REGEX,FINISH_LENGTH,FINISH_ABORT):to_json()shape andis_errorflagseqlen,finished(),output_ids_through_stopcheck_finished: already-finished noop,to_finishtransfer, length limit, stop token ID,eos_token_ids,ignore_eosbypass, stop string indecoded_text,finished_lencorrectnessreset_for_retract: retraction counter,prefix_indicescleared, KV lengths/flags zeroed,output_idscleared only wheninput_embedsis setset_extend_input_len:extend_logprob_start_lenforlogprob_start_len= 0, positive, −1, and clamped casesupdate_reasoning_tokens:think_end_idin middle/first/last/absent, noop after reasoning over, single-int input_check_vocab_boundary_finish: valid tokens, token abovevocab_size, negative token,stop_token_id/eosreplacement, eos wins when both set,finished_lenat correct offsetinit_incremental_detokenize: first-call offset computation, short input (surr_offset=0), incremental extension, stability with no new tokenscheck_match_stop_str_prefix: no stop strings, empty tail, full match, partial suffix overlap ("EN"vs"END"), single-char overlap, multiple stop stringsTest plan
stage-a-test-cpu(register_cpu_ci)pre-commit run --filespasses (isort, black, ruff, codespell)🤖 Generated with Claude Code