Skip to content

Fixed torch profiler API changes in python benchmarks#2139

Merged
xwang233 merged 3 commits intomainfrom
benchmark-profiler-api-changes
Apr 24, 2024
Merged

Fixed torch profiler API changes in python benchmarks#2139
xwang233 merged 3 commits intomainfrom
benchmark-profiler-api-changes

Conversation

@xwang233
Copy link
Copy Markdown
Collaborator

Re: pytorch/pytorch#123247

This PR changed self_cuda_time_total to self_device_time_total in API calls.

@xwang233
Copy link
Copy Markdown
Collaborator Author

!build --pybench

Priya2698
Priya2698 previously approved these changes Apr 24, 2024
Copy link
Copy Markdown
Collaborator

@Priya2698 Priya2698 left a comment

Choose a reason for hiding this comment

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

Thanks for updating!
Do we need to have different API based on torch version? In this PR: pytorch/pytorch#123247, I don't see any version update though, so this should be sufficient.

Comment thread benchmarks/python/core.py Outdated
sum(
[
event.self_cuda_time_total
event.self_device_time_total
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I think you'll need to guard this with NVF_TORCH_VERSION_GREATER. Otherwise we won't be able to build with stable torch release

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

wait... this is python. wasn't paying attention to that.

But how did it work through CI? we did test against stable torch version right. Is benchmark not part of CI on older torch version?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

For torch stable build & test in CI, we run python tests but not python benchmarks.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Should we add the check for torch version then?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I think we should. Otherwise we won't be able to run benchmark against old torch version.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

torch==2.3 is still using self_cuda_time_total. Will add a version guard for torch 2.4.

@xwang233
Copy link
Copy Markdown
Collaborator Author

!build --pybench

@Priya2698 Priya2698 dismissed their stale review April 24, 2024 22:30

Not applicable

@Priya2698
Copy link
Copy Markdown
Collaborator

!build --pybench

Is this running benchmarking? Otherwise this run won't really check this API usage

@xwang233
Copy link
Copy Markdown
Collaborator Author

!build --pybench

Is this running benchmarking? Otherwise this run won't really check this API usage

It runs pytest with --disable-benchmarking

@xwang233
Copy link
Copy Markdown
Collaborator Author

!build

@Priya2698
Copy link
Copy Markdown
Collaborator

!build --pybench

Is this running benchmarking? Otherwise this run won't really check this API usage

It runs pytest with --disable-benchmarking

This API change will be exercised only if we enable benchmarking and not during validation which is the case on the CI. Generally, we don't need to benchmark on the CI but PRs like these cannot be tested since the torch.profiler will not be used.

Copy link
Copy Markdown
Collaborator

@Priya2698 Priya2698 left a comment

Choose a reason for hiding this comment

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

This should avoid API failures for now, although seems like this PR was closed: pytorch/pytorch#123247. We can revisit and add torch version guards instead of attribute checks once the torch API is final.

@xwang233 xwang233 merged commit dad05c3 into main Apr 24, 2024
@xwang233 xwang233 deleted the benchmark-profiler-api-changes branch April 24, 2024 23:44
@jjsjann123
Copy link
Copy Markdown
Collaborator

This should avoid API failures for now, although seems like this PR was closed: pytorch/pytorch#123247. We can revisit and add torch version guards instead of attribute checks once the torch API is final.

Just to clarify that we shouldn't need to revisit this unless upstream renames the API to something else.

That upstream PR is merged and Xiao's patch looks pretty solid to me. There's no need to version guard anything, since attribute query should work just fine.

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