Skip to content

[mstx] fix: skip mstx_preprocessing if necessary#31

Closed
tardis-key wants to merge 1 commit into
verl-project:devfrom
tardis-key:dev
Closed

[mstx] fix: skip mstx_preprocessing if necessary#31
tardis-key wants to merge 1 commit into
verl-project:devfrom
tardis-key:dev

Conversation

@tardis-key
Copy link
Copy Markdown
Collaborator

What does this PR do?

skip mstx_preprocessing if necessary
issue -> #20

Add concise overview of what this PR aims to achieve or accomplish. Reference related GitHub issues and PRs that help with the review.

Checklist Before Starting

  • Search for similar PRs. Paste at least one query link here: ...
  • Format the PR title as [{modules}] {type}: {description} (This will be checked by the CI)
    • {modules} include mstx, mvtx, torch_profile, deployment, perf, algo, env, doc, data, cfg, ci, misc,
    • If this PR involves multiple modules, separate them with , like [mstx, ci]
    • {type} is in feat, fix, refactor, chore, test
    • If this PR breaks any API (CLI arguments, config, function signature, etc.), add [BREAKING] to the beginning of the title.
    • Example: [BREAKING][mstx, torch_profile] feat: support timeline parsing

Test

For changes that can not be tested by CI (e.g., algorithm implementation, new model support), validate by experiment(s) and show results like training curve plots, evaluation results, etc.

API and Usage Example

Demonstrate how the API changes if any, and provide usage example(s) if possible.

# Add code snippet or script demonstrating how to use this

Design & Code Changes

Demonstrate the high-level design if this PR is complex, and list the specific changes.

Checklist Before Submitting

Important

Please check all the following items before requesting a review, otherwise the reviewer might deprioritize this PR for review.

@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

Hello, 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 where the MSTX preprocessing step would run unnecessarily even if the output had already been generated. It introduces a check for existing parsed output, allowing the process to be skipped, thereby improving efficiency. Additionally, it refines the example execution script for better clarity and consistency in variable usage.

Highlights

  • Preprocessing Optimization: Implemented logic to skip mstx_preprocessing if the parsed output directory already exists, preventing redundant analysis.
  • Lazy Loading: Refactored torch_npu and its profiler components to be lazily imported within the mstx_preprocessing function, reducing initial load times and dependencies.
  • Script Variable Consistency: Updated the mstx_exec.sh example script to consistently use MSXT_PROFILER_DATA_PATH instead of TORCH_PROFILER_DATA_PATH.
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.

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
Copy Markdown
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 updates the mstx_exec.sh script to use MSTX_PROFILER_DATA_PATH instead of TORCH_PROFILER_DATA_PATH for input paths and renames the profiler analysis title. In mstx_preprocessing.py, it refactors logging to use loguru, removes top-level torch_npu imports, and adds logic to skip re-analysis if parsed output already exists, with torch_npu components now lazily imported. Feedback includes correcting a critical typo (MSXT_PROFILER_DATA_PATH to MSTX_PROFILER_DATA_PATH) in the shell script and ensuring the variable is properly defined. Additionally, an improvement was suggested to simplify the conditional check for lazy imports in mstx_preprocessing.py.

Comment thread examples/mstx_exec.sh
echo "MSTX Profiler Cluster Analysis"
echo "=========================================="
echo "Input Path: ${TORCH_PROFILER_DATA_PATH}"
echo "Input Path: ${MSXT_PROFILER_DATA_PATH}"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

critical

There appears to be a typo in the variable name. It should be MSTX_PROFILER_DATA_PATH instead of MSXT_PROFILER_DATA_PATH. This typo is also present on lines 25 and 30.

Additionally, this new variable is used but not defined within the script. The original variable TORCH_PROFILER_DATA_PATH was initialized on line 5. You might want to replace that initialization with one for MSTX_PROFILER_DATA_PATH to avoid potential errors if the environment variable is not set.

Suggested change
echo "Input Path: ${MSXT_PROFILER_DATA_PATH}"
echo "Input Path: ${MSTX_PROFILER_DATA_PATH}"

Comment thread examples/mstx_exec.sh
echo ">>> Start mstx data preprocessing..."

python -m rl_insight.utils.mstx_preprocessing "${TORCH_PROFILER_DATA_PATH}"
python -m rl_insight.utils.mstx_preprocessing "${MSXT_PROFILER_DATA_PATH}"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

critical

Correcting the typo in the variable name: MSXT_PROFILER_DATA_PATH -> MSTX_PROFILER_DATA_PATH.

Suggested change
python -m rl_insight.utils.mstx_preprocessing "${MSXT_PROFILER_DATA_PATH}"
python -m rl_insight.utils.mstx_preprocessing "${MSTX_PROFILER_DATA_PATH}"

Comment thread examples/mstx_exec.sh

python -m rl_insight.main \
--input-path "${TORCH_PROFILER_DATA_PATH}" \
--input-path "${MSXT_PROFILER_DATA_PATH}" \
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

critical

Correcting the typo in the variable name: MSXT_PROFILER_DATA_PATH -> MSTX_PROFILER_DATA_PATH.

Suggested change
--input-path "${MSXT_PROFILER_DATA_PATH}" \
--input-path "${MSTX_PROFILER_DATA_PATH}" \

continue

try:
if analyse is None or export_type is None:
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

Since analyse and export_type are always initialized together inside this block, you only need to check for one of them to decide whether to perform the lazy import. Checking for analyse is None is sufficient.

Suggested change
if analyse is None or export_type is None:
if analyse is None:

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