Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Chakra callback #12514

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open

Add Chakra callback #12514

wants to merge 2 commits into from

Conversation

TaekyungHeo
Copy link
Member

@TaekyungHeo TaekyungHeo commented Mar 6, 2025

Important

The Update branch button must only be pressed in very rare occasions.
An outdated branch is never blocking the merge of a PR.
Please reach out to the automation team before pressing that button.

What does this PR do?

This PR introduces the ChakraCallback, a new PyTorch Lightning callback that collects Chakra host and device traces during training.

Collection: nemo.lightning.pytorch.callbacks

Changelog

  • Added ChakraCallback to nemo.lightning.pytorch.callbacks.
  • Implemented profiling support for capturing PyTorch execution traces (host) and Kineto traces (device).
  • Updated __init__.py to include ChakraCallback.

Usage

Example of how to use the ChakraCallback:

from nemo.lightning.pytorch.callbacks.chakra import ChakraCallback

chakra_callback = ChakraCallback(
    start_step=5,
    end_step=10,
    warmup_steps=1,
    active_steps=1,
    trace_dir="/workspace/"
)

trainer = Trainer(callbacks=[chakra_callback])

GitHub Actions CI

The Jenkins CI system has been replaced by GitHub Actions self-hosted runners.

The GitHub Actions CI will run automatically when the "Run CICD" label is added to the PR.
To re-run CI remove and add the label again.
To run CI on an untrusted fork, a NeMo user with write access must first click "Approve and run".

Before your PR is "Ready for review"

Pre checks:

  • Make sure you read and followed Contributor guidelines
  • Did you write any new necessary tests?
  • Did you add or update any necessary documentation?
  • Does the PR affect components that are optional to install? (Ex: Numba, Pynini, Apex etc)
    • Reviewer: Does the PR have correct import guards for all optional libraries?

PR Type:

  • New Feature
  • Bugfix
  • Documentation

If you haven't finished some of the above items you can still open "Draft" PR.

Additional Information

@TaekyungHeo TaekyungHeo force-pushed the chakra-cb-pr branch 3 times, most recently from 898fae5 to 47cbede Compare March 6, 2025 15:15
Signed-off-by: Taekyung Heo <[email protected]>
@TaekyungHeo TaekyungHeo marked this pull request as ready for review March 6, 2025 15:21
Copy link
Collaborator

@titu1994 titu1994 left a comment

Choose a reason for hiding this comment

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

Looks reasonable

from nemo.utils.get_rank import get_rank


class ChakraCallback(Callback):
Copy link
Collaborator

Choose a reason for hiding this comment

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

Rename to PytorchProfilerCallback rather than some code name.


self.trace_observer = torch.profiler.ExecutionTraceObserver()

def trace_handler(prof):
Copy link
Collaborator

Choose a reason for hiding this comment

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

Inner function cannot be serialized, is it necessary? Maybe move it out.

if end_step < start_step:
raise ValueError("end_step must be greater than or equal to start_step.")

if not trace_dir or not os.path.isdir(trace_dir):
Copy link
Collaborator

Choose a reason for hiding this comment

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

If trace_dir is required, should it have no default?

@maanug-nv
Copy link
Collaborator

Adding a short test would be good as well, to ensure all files that are expected to be created do exist. Fine with a separate PR for that

Copy link
Contributor

This PR is stale because it has been open for 14 days with no activity. Remove stale label or comment or update or this will be closed in 7 days.

@github-actions github-actions bot added the stale label Mar 22, 2025
@github-actions github-actions bot removed the stale label Mar 23, 2025
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.

3 participants