Skip to content

Conversation

@hiyuchang
Copy link
Collaborator

Description

As the title says.

Checklist

Please check the following items before code is ready to be reviewed.

  • Code has passed all tests
  • Docstrings have been added/updated in Google Style
  • Documentation has been updated
  • Code is ready for review

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @hiyuchang, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request refactors how truncation events are tracked and communicated within the system. By introducing a specific truncate_status field to the Experience object, it provides a clearer and more standardized way to identify whether prompts or responses have been truncated. This change enhances the robustness of truncation handling, particularly within VLLM models, and ensures that related documentation and reward calculation logic are aligned with this new explicit status.

Highlights

  • New truncate_status field: Introduced a dedicated truncate_status field in the Experience class to explicitly indicate if a prompt or response was truncated.
  • Improved Truncation Handling: The VLLM model's generate and convert_messages_to_experience methods now set this truncate_status (e.g., "prompt_truncated", "response_truncated") based on truncation events.
  • Documentation Updates: Clarified in both English and Chinese documentation that enable_prompt_truncation is not effective with OpenAI API mode.
  • Test Enhancements: Added a new test case and updated existing test assertions to validate the truncate_status and token length calculations more thoroughly.
  • Workflow Integration: Updated the workflow logic to use the new truncate_status for determining if a reward should be set to 0.0 due to response truncation.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces a truncate_status field to the Experience object to track whether prompt or response truncation has occurred. The changes are implemented across documentation, configuration, data structures, model logic, and tests. While the feature is valuable, there's a critical issue in the prompt truncation logic that causes it to return a dummy response instead of proceeding with generation. Additionally, there are several areas for improvement regarding code clarity, maintainability, and correctness in comments and tests.

@hiyuchang
Copy link
Collaborator Author

/unittest-module-common

@github-actions
Copy link

Summary

Tests 📝 Passed ✅ Failed ❌ Skipped ⏭️ Other ❓ Flaky 🍂 Duration ⏱️
39 38 1 0 0 0 9m 4s

Failed Tests

Failed Tests ❌ Fail Message
❌ tests/common/experience_test.py::TestExperience::test_assertions The test failed in the call phase due to an assertion error

Tests

Test Name Status Flaky Duration
tests/common/config_test.py::TestConfig::test_all_examples_are_valid 43.3s
tests/common/config_test.py::TestConfig::test_chat_template_path 94ms
tests/common/config_test.py::TestConfig::test_config_flatten 41ms
tests/common/config_test.py::TestConfig::test_continue_from_checkpoint_is_valid 192ms
tests/common/config_test.py::TestConfig::test_default_workflow 91ms
tests/common/config_test.py::TestConfig::test_load_default_config 45.5s
tests/common/config_test.py::TestConfig::test_max_token_len_per_gpu_set_correctly 92ms
tests/common/config_test.py::TestConfig::test_optimizer_config_propagation 95ms
tests/common/config_test.py::TestConfig::test_update_config_from_ray_cluster 1.8s
tests/common/experience_test.py::TestEID::test_eid_properties 1ms
tests/common/experience_test.py::TestExperience::test_action_mask_and_logprobs_type 1ms
tests/common/experience_test.py::TestExperience::test_assertions 1ms
tests/common/experience_test.py::TestExperience::test_dpo_experience 1ms
tests/common/experience_test.py::TestExperience::test_gather 1ms
tests/common/experience_test.py::TestExperience::test_hf_datasets_conversion 15ms
tests/common/experience_test.py::TestExperience::test_multi_turn_experience 1ms
tests/common/experience_test.py::TestExperience::test_serialize_deserialize 2ms
tests/common/experience_test.py::TestExperience::test_single_turn_experience 1ms
tests/common/experience_test.py::TestExperience::test_to_dict 1ms
tests/common/experience_test.py::TestExperienceConversion::test_batch_conversion 1ms
tests/common/experience_test.py::TestExperienceConversion::test_dpo_experience_batch_conversion 1ms
tests/common/experience_test.py::TestExperienceConversion::test_experience_model_experience_conversion 1ms
tests/common/experience_test.py::TestExperienceConversion::test_gather_experiences_with_custom_fields 1ms
tests/common/experience_test.py::TestExperienceConversion::test_multiturn_experience_batch_converstion 1ms
tests/common/vllm_test.py::ModelWrapperTest_0::test_generate 52.4s
tests/common/vllm_test.py::ModelWrapperTest_1::test_generate 31.7s
tests/common/vllm_test.py::ModelWrapperTest_2::test_generate 42.5s
tests/common/vllm_test.py::TestModelLen_0::test_model_len 17.7s
tests/common/vllm_test.py::TestModelLen_1::test_model_len 17.2s
tests/common/vllm_test.py::TestModelLen_2::test_model_len 17.4s
tests/common/vllm_test.py::TestModelLenWithoutPromptTruncation::test_model_len 17.1s
tests/common/vllm_test.py::TestAPIServer::test_api 22.2s
tests/common/vllm_test.py::TestLogprobs::test_logprobs 18.9s
tests/common/vllm_test.py::TestAsyncAPIServer::test_api_async 23.8s
tests/common/vllm_test.py::TestTokenizer::test_action_mask 236ms
tests/common/vllm_test.py::TestTokenizer::test_action_mask_with_tools 231ms
tests/common/vllm_test.py::TestAPIServerToolCall_0_deepseek_r1::test_api_tool_calls 19.9s
tests/common/vllm_test.py::TestAPIServerToolCall_1::test_api_tool_calls 17.5s
tests/common/vllm_test.py::TestSuperLongGeneration::test_generate 2m 25s

Github Test Reporter by CTRF 💚

@hiyuchang
Copy link
Collaborator Author

/unittest-module-trainer

@github-actions
Copy link

Summary

Tests 📝 Passed ✅ Failed ❌ Skipped ⏭️ Other ❓ Flaky 🍂 Duration ⏱️
22 20 0 2 0 0 40m 34s

Skipped

Tests Status
tests/trainer/trainer_test.py::TestMultiModalGRPO::test_trainer skipped ⏭️
tests/trainer/trainer_test.py::TestMultiModalSFT::test_trainer skipped ⏭️

Tests

Test Name Status Flaky Duration
tests/trainer/trainer_test.py::TestTrainerCountdown_0_fsdp::test_trainer 3m 19s
tests/trainer/trainer_test.py::TestTrainerCountdown_1_megatron::test_trainer 3m 54s
tests/trainer/trainer_test.py::TestStepAheadAsyncRL::test_trainer 1m 26s
tests/trainer/trainer_test.py::TestTrainerGSM8K_0_fsdp::test_trainer 1m 24s
tests/trainer/trainer_test.py::TestTrainerGSM8K_1_fsdp2::test_trainer 1m 23s
tests/trainer/trainer_test.py::TestTrainerGSM8K_2_fsdp::test_trainer 1m 27s
tests/trainer/trainer_test.py::TestTrainerGSM8K_3_fsdp2::test_trainer 1m 44s
tests/trainer/trainer_test.py::TestTrainerSFTWarmupGSM8K::test_trainer 2m 34s
tests/trainer/trainer_test.py::TestTrainerDPO::test_trainer 1m 5s
tests/trainer/trainer_test.py::TestTrainerSFT::test_trainer 1m 2s
tests/trainer/trainer_test.py::TestTrainerToolsSFT::test_trainer_tools 1m 2s
tests/trainer/trainer_test.py::TestFullyAsyncMode_0_fsdp::test_fully_async_mode 1m 57s
tests/trainer/trainer_test.py::TestFullyAsyncMode_1_fsdp::test_fully_async_mode 1m 54s
tests/trainer/trainer_test.py::TestFullyAsyncMode_2_megatron::test_fully_async_mode 2m 23s
tests/trainer/trainer_test.py::TestTrainerCheckpointSave_0_fsdp::test_trainer 2m 17s
tests/trainer/trainer_test.py::TestTrainerCheckpointSave_1_megatron::test_trainer 4m
tests/trainer/trainer_test.py::TestTrainerMIX::test_trainer 1m 30s
tests/trainer/trainer_test.py::TestMultiModalGRPO::test_trainer ⏭️ 810ms
tests/trainer/trainer_test.py::TestMultiModalSFT::test_trainer ⏭️ 807ms
tests/trainer/trainer_test.py::TestTrainerLoRA::test_trainer 3m 15s
tests/trainer/trainer_test.py::TestOverRollout::test_trainer 1m 16s
tests/trainer/trainer_test.py::TestTrainerPromptTruncation::test_trainer 1m 13s

Github Test Reporter by CTRF 💚

@hiyuchang
Copy link
Collaborator Author

/unittest-module-common

@github-actions
Copy link

Summary

Tests 📝 Passed ✅ Failed ❌ Skipped ⏭️ Other ❓ Flaky 🍂 Duration ⏱️
40 40 0 0 0 0 10m 33s

Tests

Test Name Status Flaky Duration
tests/common/config_test.py::TestConfig::test_all_examples_are_valid 43.3s
tests/common/config_test.py::TestConfig::test_chat_template_path 94ms
tests/common/config_test.py::TestConfig::test_config_flatten 40ms
tests/common/config_test.py::TestConfig::test_continue_from_checkpoint_is_valid 192ms
tests/common/config_test.py::TestConfig::test_default_workflow 91ms
tests/common/config_test.py::TestConfig::test_load_default_config 4.8s
tests/common/config_test.py::TestConfig::test_max_token_len_per_gpu_set_correctly 93ms
tests/common/config_test.py::TestConfig::test_optimizer_config_propagation 92ms
tests/common/config_test.py::TestConfig::test_update_config_from_ray_cluster 1.8s
tests/common/experience_test.py::TestEID::test_eid_properties 1ms
tests/common/experience_test.py::TestExperience::test_action_mask_and_logprobs_type 1ms
tests/common/experience_test.py::TestExperience::test_assertions 1ms
tests/common/experience_test.py::TestExperience::test_dpo_experience 1ms
tests/common/experience_test.py::TestExperience::test_gather 1ms
tests/common/experience_test.py::TestExperience::test_gather_with_token_level_reward 1ms
tests/common/experience_test.py::TestExperience::test_hf_datasets_conversion 17ms
tests/common/experience_test.py::TestExperience::test_multi_turn_experience 1ms
tests/common/experience_test.py::TestExperience::test_serialize_deserialize 2ms
tests/common/experience_test.py::TestExperience::test_single_turn_experience 1ms
tests/common/experience_test.py::TestExperience::test_to_dict 1ms
tests/common/experience_test.py::TestExperienceConversion::test_batch_conversion 1ms
tests/common/experience_test.py::TestExperienceConversion::test_dpo_experience_batch_conversion 1ms
tests/common/experience_test.py::TestExperienceConversion::test_experience_model_experience_conversion 1ms
tests/common/experience_test.py::TestExperienceConversion::test_gather_experiences_with_custom_fields 1ms
tests/common/experience_test.py::TestExperienceConversion::test_multiturn_experience_batch_converstion 1ms
tests/common/vllm_test.py::ModelWrapperTest_0::test_generate 58.9s
tests/common/vllm_test.py::ModelWrapperTest_1::test_generate 32.7s
tests/common/vllm_test.py::ModelWrapperTest_2::test_generate 43.5s
tests/common/vllm_test.py::TestModelLen_0::test_model_len 17.0s
tests/common/vllm_test.py::TestModelLen_1::test_model_len 17.3s
tests/common/vllm_test.py::TestModelLen_2::test_model_len 17.7s
tests/common/vllm_test.py::TestModelLenWithoutPromptTruncation::test_model_len 17.3s
tests/common/vllm_test.py::TestAPIServer::test_api 22.6s
tests/common/vllm_test.py::TestLogprobs::test_logprobs 18.8s
tests/common/vllm_test.py::TestAsyncAPIServer::test_api_async 22.7s
tests/common/vllm_test.py::TestTokenizer::test_action_mask 236ms
tests/common/vllm_test.py::TestTokenizer::test_action_mask_with_tools 237ms
tests/common/vllm_test.py::TestAPIServerToolCall_0_deepseek_r1::test_api_tool_calls 19.9s
tests/common/vllm_test.py::TestAPIServerToolCall_1::test_api_tool_calls 17.9s
tests/common/vllm_test.py::TestSuperLongGeneration::test_generate 4m 27s

Github Test Reporter by CTRF 💚

@pan-x-c pan-x-c merged commit c615ee7 into modelscope:main Nov 26, 2025
2 checks passed
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.

2 participants