Skip to content

Conversation

@pan-x-c
Copy link
Collaborator

@pan-x-c pan-x-c commented Dec 8, 2025

Description

  1. fix min_tokens mismatch
  2. fix repetition_penalty mismatch
  3. fix logprobs calculation in debug mode

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 @pan-x-c, 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 addresses an issue with log probability calculations in debug mode by refactoring the model initialization and API server management within the vLLM integration. It introduces a standardized asynchronous prepare method for inference models, which encapsulates the necessary setup steps like applying patches and starting the API server. This change streamlines the model lifecycle, improves the reliability of logprobs, and enhances test coverage for these critical functionalities.

Highlights

  • Standardized Model Preparation: Introduced a new prepare asynchronous method across inference models to centralize setup logic, including API server startup and patch application, streamlining the model lifecycle.
  • Logprobs Calculation Fix & Testing: Corrected the enable_log_requests setting for vLLM and added a comprehensive test_logprobs_api to validate log probability calculations under various temperatures, ensuring accuracy in debug mode.
  • Refactored API Server Startup: Decoupled the API server startup from direct calls, integrating it into the new prepare method, and made get_api_server_url synchronous after the model has been prepared.
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 refactors the model initialization logic by introducing a prepare method to ensure models are properly set up before use, which is a good improvement for code structure and reliability. The core change to enable log requests in vLLM and the addition of comprehensive tests for log probability calculations effectively address the goal of fixing debug mode logprobs. I've identified a critical issue in a new test helper function that would lead to runtime errors and offered a suggestion to improve code conciseness. Once these points are addressed, the changes look solid.

@pan-x-c
Copy link
Collaborator Author

pan-x-c commented Dec 8, 2025

/unittest-diff

@pan-x-c pan-x-c changed the title Fix debug mode logprobs calculation Fix the mismatch between vLLM OpenAI API and vLLM generate Dec 8, 2025
@github-actions
Copy link

github-actions bot commented Dec 8, 2025

Summary

Tests 📝 Passed ✅ Failed ❌ Skipped ⏭️ Other ❓ Flaky 🍂 Duration ⏱️
86 78 7 1 0 0 23m 55s

Failed Tests

Failed Tests ❌ Fail Message
❌ tests/common/vllm_test.py::ModelWrapperTest_0::test_generate The test failed in the call phase due to an exception
❌ tests/common/vllm_test.py::ModelWrapperTest_1::test_generate The test failed in the call phase due to an exception
❌ tests/common/vllm_test.py::ModelWrapperTest_2::test_generate The test failed in the call phase due to an exception
❌ tests/explorer/explorer_test.py::TestExplorerCountdownEval::test_explorer The test failed in the call phase due to an assertion error
❌ tests/explorer/explorer_test.py::TestExplorerGSM8KRULERNoEval::test_explorer The test failed in the call phase due to an assertion error
❌ tests/explorer/explorer_test.py::TestExplorerGSM8k::test_explorer The test failed in the call phase due to an exception
❌ tests/explorer/workflow_test.py::TestWorkflowRunner::test_workflow_with_openai The test failed in the call phase

Skipped

Tests Status
tests/explorer/workflow_test.py::TestAgentScopeWorkflowAdapter::test_adapter skipped ⏭️

Tests

Test Name Status Flaky Duration
tests/common/config_test.py::TestConfig::test_all_examples_are_valid 33.9s
tests/common/config_test.py::TestConfig::test_chat_template_path 98ms
tests/common/config_test.py::TestConfig::test_config_flatten 43ms
tests/common/config_test.py::TestConfig::test_continue_from_checkpoint_is_valid 197ms
tests/common/config_test.py::TestConfig::test_default_workflow 94ms
tests/common/config_test.py::TestConfig::test_load_default_config 3.5s
tests/common/config_test.py::TestConfig::test_max_token_len_per_gpu_set_correctly 96ms
tests/common/config_test.py::TestConfig::test_optimizer_config_propagation 95ms
tests/common/config_test.py::TestConfig::test_update_config_from_ray_cluster 1.7s
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 16ms
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 1m 36s
tests/common/vllm_test.py::ModelWrapperTest_1::test_generate 1m 16s
tests/common/vllm_test.py::ModelWrapperTest_2::test_generate 1m 20s
tests/common/vllm_test.py::TestModelLen_0::test_model_len 16.6s
tests/common/vllm_test.py::TestModelLen_1::test_model_len 16.3s
tests/common/vllm_test.py::TestModelLen_2::test_model_len 15.8s
tests/common/vllm_test.py::TestModelLenWithoutPromptTruncation::test_model_len 15.5s
tests/common/vllm_test.py::TestAPIServer::test_api 21.4s
tests/common/vllm_test.py::TestLogprobs::test_logprobs_api 16.4s
tests/common/vllm_test.py::TestAsyncAPIServer::test_api_async 21.0s
tests/common/vllm_test.py::TestTokenizer::test_action_mask 266ms
tests/common/vllm_test.py::TestTokenizer::test_action_mask_with_tools 241ms
tests/common/vllm_test.py::TestAPIServerToolCall_0_deepseek_r1::test_api_tool_calls 18.1s
tests/common/vllm_test.py::TestAPIServerToolCall_1::test_api_tool_calls 16.1s
tests/common/vllm_test.py::TestSuperLongGeneration::test_generate 2m 41s
tests/explorer/explorer_test.py::TestExplorerCountdownEval::test_explorer 1m 43s
tests/explorer/explorer_test.py::TestExplorerGSM8KRULERNoEval::test_explorer 2m 27s
tests/explorer/explorer_test.py::TestExplorerGSM8k::test_explorer 1m 42s
tests/explorer/explorer_test.py::ServeTest::test_serve 1m 22s
tests/explorer/scheduler_test.py::SchedulerTest::test_async_workflow 12.1s
tests/explorer/scheduler_test.py::SchedulerTest::test_concurrent_operations 12.4s
tests/explorer/scheduler_test.py::SchedulerTest::test_dynamic_timeout 20.2s
tests/explorer/scheduler_test.py::SchedulerTest::test_get_results 27.6s
tests/explorer/scheduler_test.py::SchedulerTest::test_metric_calculation_with_non_repeatable_workflow_0 12.6s
tests/explorer/scheduler_test.py::SchedulerTest::test_metric_calculation_with_non_repeatable_workflow_1 12.3s
tests/explorer/scheduler_test.py::SchedulerTest::test_metric_calculation_with_repeatable_workflow_0 12.2s
tests/explorer/scheduler_test.py::SchedulerTest::test_metric_calculation_with_repeatable_workflow_1 12.6s
tests/explorer/scheduler_test.py::SchedulerTest::test_multi_step_execution 12.9s
tests/explorer/scheduler_test.py::SchedulerTest::test_non_repeatable_workflow 12.6s
tests/explorer/scheduler_test.py::SchedulerTest::test_over_rollout_min_wait 16.4s
tests/explorer/scheduler_test.py::SchedulerTest::test_scheduler_all_methods 22.3s
tests/explorer/scheduler_test.py::SchedulerTest::test_scheduler_restart_after_stop 24.0s
tests/explorer/scheduler_test.py::SchedulerTest::test_split_tasks 16.1s
tests/explorer/scheduler_test.py::SchedulerTest::test_stepwise_experience_eid 32.5s
tests/explorer/scheduler_test.py::SchedulerTest::test_wait_all 15.4s
tests/explorer/scheduler_test.py::SchedulerTest::test_wait_all_timeout_with_multi_batch 21.3s
tests/explorer/scheduler_test.py::TestRunnerStateCollection::test_runner_state_collection 17.3s
tests/explorer/step_wise_workflow_test.py::WorkflowTest::test_reward_propagation_workflow_0 2ms
tests/explorer/step_wise_workflow_test.py::WorkflowTest::test_reward_propagation_workflow_1 602ms
tests/explorer/step_wise_workflow_test.py::WorkflowTest::test_step_wise_reward_workflow_0 1ms
tests/explorer/step_wise_workflow_test.py::WorkflowTest::test_step_wise_reward_workflow_1 1.0s
tests/explorer/step_wise_workflow_test.py::WorkflowTest::test_workflows_raise_error 1ms
tests/explorer/step_wise_workflow_test.py::WorkflowTest::test_workflows_stop_at_max_env_steps 1.0s
tests/explorer/workflow_test.py::WorkflowTest::test_gsm8k_workflow 35ms
tests/explorer/workflow_test.py::WorkflowTest::test_math_boxed_workflow 24ms
tests/explorer/workflow_test.py::WorkflowTest::test_math_complex_workflow 175ms
tests/explorer/workflow_test.py::WorkflowTest::test_math_eval_workflow 4ms
tests/explorer/workflow_test.py::WorkflowTest::test_math_fraction_workflow 13ms
tests/explorer/workflow_test.py::WorkflowTest::test_math_workflow 8ms
tests/explorer/workflow_test.py::WorkflowTest::test_rm_gallery_workflow 140ms
tests/explorer/workflow_test.py::WorkflowTest::test_workflow_repeatable_0 1ms
tests/explorer/workflow_test.py::WorkflowTest::test_workflow_repeatable_1 101ms
tests/explorer/workflow_test.py::WorkflowTest::test_workflow_resettable_0 1ms
tests/explorer/workflow_test.py::WorkflowTest::test_workflow_resettable_1 201ms
tests/explorer/workflow_test.py::MultiTurnWorkflowTest_0::test_multi_turn_workflow 14.2s
tests/explorer/workflow_test.py::MultiTurnWorkflowTest_1::test_multi_turn_workflow 14.6s
tests/explorer/workflow_test.py::TestWorkflowStateRecording::test_workflow_state_recording 4.0s
tests/explorer/workflow_test.py::TestAgentScopeWorkflowAdapter::test_adapter ⏭️ 1ms
tests/explorer/workflow_test.py::TestWorkflowRunner::test_workflow_runner 303ms
tests/explorer/workflow_test.py::TestWorkflowRunner::test_workflow_runner_get_state 8.1s
tests/explorer/workflow_test.py::TestWorkflowRunner::test_workflow_with_openai 13.0s

Github Test Reporter by CTRF 💚

@pan-x-c
Copy link
Collaborator Author

pan-x-c commented Dec 8, 2025

/unittest-diff

@github-actions
Copy link

github-actions bot commented Dec 8, 2025

Summary

Tests 📝 Passed ✅ Failed ❌ Skipped ⏭️ Other ❓ Flaky 🍂 Duration ⏱️
86 85 0 1 0 0 22m 48s

Skipped

Tests Status
tests/explorer/workflow_test.py::TestAgentScopeWorkflowAdapter::test_adapter skipped ⏭️

Tests

Test Name Status Flaky Duration
tests/common/config_test.py::TestConfig::test_all_examples_are_valid 34.3s
tests/common/config_test.py::TestConfig::test_chat_template_path 96ms
tests/common/config_test.py::TestConfig::test_config_flatten 42ms
tests/common/config_test.py::TestConfig::test_continue_from_checkpoint_is_valid 194ms
tests/common/config_test.py::TestConfig::test_default_workflow 93ms
tests/common/config_test.py::TestConfig::test_load_default_config 3.7s
tests/common/config_test.py::TestConfig::test_max_token_len_per_gpu_set_correctly 96ms
tests/common/config_test.py::TestConfig::test_optimizer_config_propagation 94ms
tests/common/config_test.py::TestConfig::test_update_config_from_ray_cluster 1.9s
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 16ms
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 59.9s
tests/common/vllm_test.py::ModelWrapperTest_1::test_generate 31.8s
tests/common/vllm_test.py::ModelWrapperTest_2::test_generate 43.3s
tests/common/vllm_test.py::TestModelLen_0::test_model_len 15.9s
tests/common/vllm_test.py::TestModelLen_1::test_model_len 15.5s
tests/common/vllm_test.py::TestModelLen_2::test_model_len 15.3s
tests/common/vllm_test.py::TestModelLenWithoutPromptTruncation::test_model_len 15.2s
tests/common/vllm_test.py::TestAPIServer::test_api 21.1s
tests/common/vllm_test.py::TestLogprobs::test_logprobs_api 16.2s
tests/common/vllm_test.py::TestAsyncAPIServer::test_api_async 22.4s
tests/common/vllm_test.py::TestTokenizer::test_action_mask 242ms
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 18.0s
tests/common/vllm_test.py::TestAPIServerToolCall_1::test_api_tool_calls 16.4s
tests/common/vllm_test.py::TestSuperLongGeneration::test_generate 2m 41s
tests/explorer/explorer_test.py::TestExplorerCountdownEval::test_explorer 1m 18s
tests/explorer/explorer_test.py::TestExplorerGSM8KRULERNoEval::test_explorer 1m 43s
tests/explorer/explorer_test.py::TestExplorerGSM8k::test_explorer 3m 37s
tests/explorer/explorer_test.py::ServeTest::test_serve 1m 21s
tests/explorer/scheduler_test.py::SchedulerTest::test_async_workflow 12.7s
tests/explorer/scheduler_test.py::SchedulerTest::test_concurrent_operations 12.3s
tests/explorer/scheduler_test.py::SchedulerTest::test_dynamic_timeout 20.5s
tests/explorer/scheduler_test.py::SchedulerTest::test_get_results 27.8s
tests/explorer/scheduler_test.py::SchedulerTest::test_metric_calculation_with_non_repeatable_workflow_0 12.3s
tests/explorer/scheduler_test.py::SchedulerTest::test_metric_calculation_with_non_repeatable_workflow_1 12.2s
tests/explorer/scheduler_test.py::SchedulerTest::test_metric_calculation_with_repeatable_workflow_0 12.1s
tests/explorer/scheduler_test.py::SchedulerTest::test_metric_calculation_with_repeatable_workflow_1 12.3s
tests/explorer/scheduler_test.py::SchedulerTest::test_multi_step_execution 12.9s
tests/explorer/scheduler_test.py::SchedulerTest::test_non_repeatable_workflow 12.6s
tests/explorer/scheduler_test.py::SchedulerTest::test_over_rollout_min_wait 16.4s
tests/explorer/scheduler_test.py::SchedulerTest::test_scheduler_all_methods 22.2s
tests/explorer/scheduler_test.py::SchedulerTest::test_scheduler_restart_after_stop 24.2s
tests/explorer/scheduler_test.py::SchedulerTest::test_split_tasks 15.5s
tests/explorer/scheduler_test.py::SchedulerTest::test_stepwise_experience_eid 32.7s
tests/explorer/scheduler_test.py::SchedulerTest::test_wait_all 15.5s
tests/explorer/scheduler_test.py::SchedulerTest::test_wait_all_timeout_with_multi_batch 21.3s
tests/explorer/scheduler_test.py::TestRunnerStateCollection::test_runner_state_collection 17.4s
tests/explorer/step_wise_workflow_test.py::WorkflowTest::test_reward_propagation_workflow_0 2ms
tests/explorer/step_wise_workflow_test.py::WorkflowTest::test_reward_propagation_workflow_1 602ms
tests/explorer/step_wise_workflow_test.py::WorkflowTest::test_step_wise_reward_workflow_0 1ms
tests/explorer/step_wise_workflow_test.py::WorkflowTest::test_step_wise_reward_workflow_1 1.0s
tests/explorer/step_wise_workflow_test.py::WorkflowTest::test_workflows_raise_error 1ms
tests/explorer/step_wise_workflow_test.py::WorkflowTest::test_workflows_stop_at_max_env_steps 1.0s
tests/explorer/workflow_test.py::WorkflowTest::test_gsm8k_workflow 38ms
tests/explorer/workflow_test.py::WorkflowTest::test_math_boxed_workflow 24ms
tests/explorer/workflow_test.py::WorkflowTest::test_math_complex_workflow 684ms
tests/explorer/workflow_test.py::WorkflowTest::test_math_eval_workflow 4ms
tests/explorer/workflow_test.py::WorkflowTest::test_math_fraction_workflow 14ms
tests/explorer/workflow_test.py::WorkflowTest::test_math_workflow 9ms
tests/explorer/workflow_test.py::WorkflowTest::test_rm_gallery_workflow 133ms
tests/explorer/workflow_test.py::WorkflowTest::test_workflow_repeatable_0 1ms
tests/explorer/workflow_test.py::WorkflowTest::test_workflow_repeatable_1 101ms
tests/explorer/workflow_test.py::WorkflowTest::test_workflow_resettable_0 1ms
tests/explorer/workflow_test.py::WorkflowTest::test_workflow_resettable_1 201ms
tests/explorer/workflow_test.py::MultiTurnWorkflowTest_0::test_multi_turn_workflow 14.5s
tests/explorer/workflow_test.py::MultiTurnWorkflowTest_1::test_multi_turn_workflow 14.9s
tests/explorer/workflow_test.py::TestWorkflowStateRecording::test_workflow_state_recording 4.0s
tests/explorer/workflow_test.py::TestAgentScopeWorkflowAdapter::test_adapter ⏭️ 1ms
tests/explorer/workflow_test.py::TestWorkflowRunner::test_workflow_runner 305ms
tests/explorer/workflow_test.py::TestWorkflowRunner::test_workflow_runner_get_state 8.1s
tests/explorer/workflow_test.py::TestWorkflowRunner::test_workflow_with_openai 16.4s

Github Test Reporter by CTRF 💚

@pan-x-c pan-x-c merged commit 154bd71 into modelscope:main Dec 9, 2025
1 check 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