Skip to content

Add toggleCollectionDynamic for XPUPTI #1088

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

Closed
wants to merge 3 commits into from

Conversation

frost-intel
Copy link
Contributor

This PR adds support for toggleCollectionDynamic for Xpupti.

Since Xpupti enables/disables activities based on the session rather than the profiler instance, I cast the IActivityProfilerSession to an XpuptiActivitySession. This assumes that all sessions are XpuptiActivitySessions. In upstream Pytorch, the design rule for now is that there is no simultaneous support for XPU and any other device (CUDA/Roc), so this assumption should be safe?

@facebook-github-bot
Copy link
Contributor

Hi @frost-intel!

Thank you for your pull request.

We require contributors to sign our Contributor License Agreement, and yours needs attention.

You currently have a record in our system, but the CLA is no longer valid, and will need to be resubmitted.

Process

In order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA.

Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with CLA signed. The tagging process may take up to 1 hour after signing. Please give it that time before contacting us about it.

If you have received this in error or have any questions, please contact us at cla@meta.com. Thanks!

@frost-intel
Copy link
Contributor Author

@zejun-chen Could you provide any feedback?

Copy link
Contributor

@zejun-chen zejun-chen left a comment

Choose a reason for hiding this comment

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

LGTM but could you find if there are related UTs for this feature. We need to enable the associated UTs.

@zejun-chen
Copy link
Contributor

This PR adds support for toggleCollectionDynamic for Xpupti.

Since Xpupti enables/disables activities based on the session rather than the profiler instance, I cast the IActivityProfilerSession to an XpuptiActivitySession. This assumes that all sessions are XpuptiActivitySessions. In upstream Pytorch, the design rule for now is that there is no simultaneous support for XPU and any other device (CUDA/Roc), so this assumption should be safe?

The assumption makes sense because when HAS_XPUPTI=true, only xpu device is active i think, so you can cast the base class to xpu class.

@frost-intel
Copy link
Contributor Author

frost-intel commented Jun 4, 2025

LGTM but could you find if there are related UTs for this feature. We need to enable the associated UTs.

It looks like there isn't any test coverage for this feature in kineto, but I'll edit test_profiler.py in pytorch to cover the XPU case when adding the toggle functionality.

Update: Tests for XPU toggling have been added in pytorch/pytorch#155135

@frost-intel frost-intel marked this pull request as ready for review June 4, 2025 14:54
@frost-intel
Copy link
Contributor Author

@sraikund16 Could you please review this PR?

@@ -1209,6 +1212,12 @@ void CuptiActivityProfiler::toggleCollectionDynamic(const bool enable) {
cupti_.disableActivities(derivedConfig_->profileActivityTypes());
}
#endif
#ifdef HAS_XPUPTI
for (auto& session : sessions_) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you leave a comment here explaining that you are making the assumption that all sessions will be XPUPTI since there are no downstream profilers for it? I think a TODO to determine session type is a good idea

Copy link
Contributor

@sraikund16 sraikund16 left a comment

Choose a reason for hiding this comment

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

Overall, LGTM!

@facebook-github-bot
Copy link
Contributor

@sraikund16 has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

@facebook-github-bot
Copy link
Contributor

@frost-intel has updated the pull request. You must reimport the pull request before landing.

@facebook-github-bot
Copy link
Contributor

@sraikund16 has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

@facebook-github-bot
Copy link
Contributor

@sraikund16 merged this pull request in 7fd7d56.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants