Skip to content

Fix misusing incompletely generated artifacts#605

Open
fzyzcjy wants to merge 7 commits intofeat/abs_pathfrom
feat/verify_done
Open

Fix misusing incompletely generated artifacts#605
fzyzcjy wants to merge 7 commits intofeat/abs_pathfrom
feat/verify_done

Conversation

@fzyzcjy
Copy link
Collaborator

@fzyzcjy fzyzcjy commented Feb 15, 2026

No description provided.

Move the "release" tracker file write to be the very last operation,
after the checkpoint directory rename. This ensures the tracker content
reliably indicates that all conversion work (including the directory
rename) is fully complete.
Replace naive directory-existence checks with proper completion
sentinels: convert_checkpoint now verifies
latest_checkpointed_iteration.txt contains "release", and
fp8_cast_bf16 now checks for model.safetensors.index.json.
Both are the last files written by their respective tools,
preventing false-positive skips after mid-conversion crashes.
…eeded

If another rank crashed during save_checkpoint, the barrier will fail
before we write the "release" marker, preventing a false completion signal.
@fzyzcjy fzyzcjy changed the title Reorder tracker write after shutil.move in convert_hf_to_torch_dist Fix misusing incompletely generated artifacts Feb 15, 2026
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @fzyzcjy, 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 potential race conditions and improves the robustness of checkpoint conversion and FP8 casting processes. It reorders the signaling of completion in the convert_hf_to_torch_dist.py script to ensure that a 'release' tracker file is written only after the final directory move and distributed synchronization. Additionally, the PR enhances the skip logic in command_utils.py by introducing more specific checks for completion, relying on the content of a tracker file or the presence of a sentinel file, rather than just directory existence.

Highlights

  • Tracker Write Reordering: The writing of the 'release' status to the checkpoint tracker file in convert_hf_to_torch_dist.py was moved to occur after the shutil.move operation and a dist.barrier(), ensuring proper synchronization and completion signaling.
  • Improved Checkpoint Skip Logic: The convert_checkpoint function now skips conversion only if a latest_checkpointed_iteration.txt file exists and contains 'release', providing a more robust check for already converted checkpoints.
  • Refined FP8 Cast Skip Logic: The fp8_cast_bf16 function now checks for the existence of model.safetensors.index.json as a sentinel to determine if the FP8 casting process has already been completed.
Changelog
  • miles/utils/external_utils/command_utils.py
    • Updated the convert_checkpoint function's skip condition to check for a 'release' status in the latest_checkpointed_iteration.txt file.
    • Modified the fp8_cast_bf16 function's skip condition to verify the presence of model.safetensors.index.json.
  • tools/convert_hf_to_torch_dist.py
    • Reordered the writing of the 'release' status to the checkpoint tracker file, moving it after the shutil.move operation and a dist.barrier().
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 improves the robustness of artifact generation by checking for specific completion markers instead of just directory existence, preventing the misuse of incompletely generated artifacts. However, the changes introduce potential security vulnerabilities related to insecure file handling and path traversal. Specifically, unvalidated CLI arguments used to construct file paths for moving directories and writing tracker files could be exploited to manipulate arbitrary files on the system. Additionally, I've provided suggestions to make the completion checks more robust by handling potential file I/O errors and validating file content.

The fused attention backend (cuDNN) consistently fails on node 4
(10.220.47.4) with CUDNN_STATUS_SUBLIBRARY_LOADING_FAILED during
compute_log_prob in TransformerEngine's context parallel path.
Switching to flash attention resolves this while maintaining correct
training behavior with MLA + CP=4.
@fzyzcjy fzyzcjy force-pushed the feat/verify_done branch 2 times, most recently from a8fdcba to 1a76781 Compare February 15, 2026 14:33
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.

1 participant