Skip to content

Conversation

@YushunXiang
Copy link
Contributor

PR type

  • Bug Fix
  • New Feature
  • Document Updates
  • More Models or Datasets Support

Bug information

I found that if I pass the resume_from_checkpoint parameter, tqdm function in the swift/trainers/callback.py calculate the progress incorrectly.

PR information

This pull request makes a minor improvement to the training progress bar initialization in the ProgressCallbackNew class. The main change ensures that the progress bar accurately reflects the current training step when resuming from a checkpoint or a non-zero step.

  • Progress bar initialization improvement:
    • The progress bar in ProgressCallbackNew.on_train_begin now starts at the correct step (state.global_step or 0) instead of always starting at zero. This ensures accurate progress reporting when training is resumed from a checkpoint. (swift/trainers/callback.py)

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @YushunXiang, 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 resolves a bug related to the training progress bar's initialization. It ensures that when training is resumed from a checkpoint, the progress bar accurately reflects the current training step from the outset, providing a more precise visual representation of the training's advancement.

Highlights

  • Bug Fix: Corrected an issue where the tqdm training progress bar displayed incorrect progress when resuming training from a checkpoint.
  • Progress Bar Initialization: The ProgressCallbackNew.on_train_begin method now initializes the training progress bar with the current global step, ensuring accurate reporting from the start of a resumed training session.
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 correctly addresses an issue with the training progress bar not reflecting the correct step when resuming from a checkpoint. The changes in swift/trainers/callback.py properly initialize the tqdm progress bar with the current global_step. The logic is sound. I have one minor suggestion to make the code more concise and Pythonic.

@YushunXiang YushunXiang changed the title Enhance ProgressCallback to initialize training bar with current step [Fix Bug] Enhance ProgressCallback to initialize training bar with current step Nov 4, 2025
@YushunXiang YushunXiang changed the title [Fix Bug] Enhance ProgressCallback to initialize training bar with current step [Fix Bug] Enhance ProgressCallbackNew to initialize training bar with current step Nov 4, 2025
@Jintao-Huang
Copy link
Collaborator

Hello, thanks for your PR, Could you please provide a script that can reproduce the issue you mentioned

@YushunXiang
Copy link
Contributor Author

Yeah, here are my scipt:

I use swift sft.

[
    "--train_type",
    "lora",
    "--seed",
    "42",
    "--model",
    "model/Qwen/Qwen2.5-VL-7B-Instruct",
    "--torch_dtype",
    "bfloat16",
    "--model_kwargs",
    "{\"min_pixels\": 3136, \"max_pixels\": 20704}",
    "--dataset",
    "dataset/OCL_data",
    "--dataset_num_proc",
    "40",
    "--custom_register_path",
    "src/ocl_vlm/template/qwen_ocl_template.py",
    "src/ocl_vlm/dataset/preprocessor/ocl/chat/ocl_cot_preprocessor.py",
    "--template",
    "qwen2_5_vl_ocl",
    "--output_dir",
    "output/Qwen2.5-VL-7B-SFT-LoRA-CoT-1029",
    "--per_device_train_batch_size",
    "8",
    "--learning_rate",
    "3e-5",
    "--max_grad_norm",
    "0.5",
    "--num_train_epochs",
    "20",
    "--gradient_accumulation_steps",
    "1",
    "--save_steps",
    "3000",
    "--save_total_limit",
    "10",
    "--logging_steps",
    "1",
    "--warmup_ratio",
    "0.1",
    "--dataloader_num_workers",
    "16",
    "--average_tokens_across_devices",
    "True",
    "--freeze_vit",
    "False",
    "--freeze_llm",
    "False",
    "--freeze_aligner",
    "False",
    "--target_modules",
    "all-linear",
    "--lora_rank",
    "8",
    "--lora_alpha",
    "32",
    "--attn_impl",
    "flash_attn",
    "--report_to",
    "wandb",
    "--resume_from_checkpoint",
    "output/Qwen2.5-VL-7B-SFT-LoRA-CoT-1029/checkpoint-18000",
    "--no_add_version"
]

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