Skip to content

[ROCm] Enable ROCm support for inductor's dynamic_rblock_scaling - #129663

Closed
jataylo wants to merge 9 commits into
pytorch:mainfrom
jataylo:regs_per_mp
Closed

jataylo wants to merge 9 commits into
pytorch:mainfrom
jataylo:regs_per_mp

Conversation

@jataylo

@jataylo jataylo commented Jun 27, 2024 •

Copy link
Copy Markdown
Collaborator

As of ROCm 6.1 hipDeviceProp_t::regsPerMultiprocessor is now available allowing us to enable this attribute on ROCm.

>>> torch.cuda.get_device_properties(0)
_CudaDeviceProperties(name='AMD Instinct MI250X/MI250', major=9, minor=0, gcnArchName='gfx90a:sramecc+:xnack-', total_memory=65520MB, multi_processor_count=104)
>>> torch.cuda.get_device_properties(0).regs_per_multiprocessor
65536

With https://github.com/triton-lang/triton/pull/3962we can extract n_regs and n_spells from a triton binary with AMD backend allowing us to enable inductor's dynamic_rblock_scaling on ROCm initially implemented in #115094

Leaving this in draft until following PRs have landed:

cc @jeffdaily @sunway513 @jithunnair-amd @pruthvistony @ROCmSupport @dllehr-amd @hongxiayang @voznesenskym @penguinwu @EikanWang @jgong5 @Guobing-Chen @XiaobingSuper @zhuhaozhe @blzheng @wenzhe-nrv @jiayisunx @peterbell10 @ipiszy @yf225 @chenyang78 @kadeng @muchulee8 @ColinPeppler @amjames @desertfire @chauhang

@jataylo
jataylo requested review from htyu, jansel and shunting314 June 27, 2024 15:22
@pytorch-bot

pytorch-bot Bot commented Jun 27, 2024 •

Copy link
Copy Markdown

🔗 Helpful Links

🧪 See artifacts and rendered test results at hud.pytorch.org/pr/129663

Note: Links to docs will display an error until the docs builds have been completed.

✅ You can merge normally! (3 Unrelated Failures)

As of commit 2863ae2 with merge base 356f14e (image):

FLAKY - The following jobs failed but were likely due to flakiness present on trunk:

This comment was automatically generated by Dr. CI and updates every 15 minutes.

@shunting314 shunting314 left a comment

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.

Looks good. Can accept after you rebase and make the CI clean.

and device_prop.type == ["cuda", "hip"]
and device_prop.major
and device_prop.major >= 8
and (device_prop.major >= 8 or torch.version.hip)

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.

Why is it not enough to just check device_prop.major ?

@jataylo jataylo Jun 27, 2024 •

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.

The device_prop.major >=8 is CUDA specific, so this was a just a simple way to conditionalize out this restriction for ROCm. Perhaps if(not torch.version.hip and device_prop.major >=8) reads better though.

I will consult if we should have some similar restriction on ROCm side.

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.

Hey @shunting314, ready for review now, we are green any other comments or are we happy to close this?

Comment thread torch/_inductor/runtime/hints.py Resolved
@jataylo

jataylo commented Jul 9, 2024

Copy link
Copy Markdown
Collaborator Author

Needs a rebase

@jataylo

jataylo commented Jul 9, 2024

Copy link
Copy Markdown
Collaborator Author

@pytorchbot rebase

@jataylo
jataylo marked this pull request as ready for review July 9, 2024 13:14
@jataylo
jataylo requested a review from eqy as a code owner July 9, 2024 13:14
@pytorchmergebot

Copy link
Copy Markdown
Collaborator

@pytorchbot started a rebase job onto refs/remotes/origin/viable/strict. Check the current status here

@pytorchmergebot

Copy link
Copy Markdown
Collaborator

Successfully rebased regs_per_mp onto refs/remotes/origin/viable/strict, please pull locally before adding more changes (for example, via git checkout regs_per_mp && git pull --rebase)

@jataylo

jataylo commented Jul 15, 2024

Copy link
Copy Markdown
Collaborator Author

Hey @shunting314 any more comments or are we good to merge?

We already have some approval so I'll give it a day or so to see if you have any further comments before merging

@jataylo jataylo added the release notes: rocm mandatorylabel label Jul 18, 2024
@jataylo

jataylo commented Jul 18, 2024

Copy link
Copy Markdown
Collaborator Author

@pytorchbot merge

@pytorch-bot pytorch-bot Bot added the ciflow/trunk Trigger trunk jobs on your pull request label Jul 18, 2024
@jataylo
jataylo requested a review from syed-ahmed as a code owner August 23, 2024 13:28
@pruthvistony
pruthvistony marked this pull request as draft August 26, 2024 20:43
@jataylo

jataylo commented Sep 11, 2024

Copy link
Copy Markdown
Collaborator Author

@pytorchbot rebase

@pytorchmergebot

Copy link
Copy Markdown
Collaborator

@pytorchbot started a rebase job onto refs/remotes/origin/viable/strict. Check the current status here

@pytorchmergebot

Copy link
Copy Markdown
Collaborator

Successfully rebased regs_per_mp onto refs/remotes/origin/viable/strict, please pull locally before adding more changes (for example, via git checkout regs_per_mp && git pull --rebase)

@jataylo
jataylo marked this pull request as ready for review September 11, 2024 15:18
@jataylo

jataylo commented Sep 11, 2024

Copy link
Copy Markdown
Collaborator Author

@pytorchbot merge

@pytorchmergebot

Copy link
Copy Markdown
Collaborator

Merge started

Your change will be merged once all checks pass (ETA 0-4 Hours).

Learn more about merging in the wiki.

Questions? Feedback? Please reach out to the PyTorch DevX Team

Advanced Debugging
Check the merge workflow status
here

@pytorchmergebot

Copy link
Copy Markdown
Collaborator

Merge failed

Reason: 1 jobs have failed, first few of them are: Meta Internal-Only Changes Check

Details for Dev Infra team Raised by workflow job

@atalman

atalman commented Sep 13, 2024

Copy link
Copy Markdown
Collaborator

@pytorchbot merge -f "failures are flaky internal diff abandoned"

@pytorchmergebot

Copy link
Copy Markdown
Collaborator

Merge started

Your change will be merged immediately since you used the force (-f) flag, bypassing any CI checks (ETA: 1-5 minutes). Please use -f as last resort and instead consider -i/--ignore-current to continue the merge ignoring current failures. This will allow currently pending tests to finish and report signal before the merge.

Learn more about merging in the wiki.

Questions? Feedback? Please reach out to the PyTorch DevX Team

Advanced Debugging
Check the merge workflow status
here

Chao1Han pushed a commit to Chao1Han/pytorch that referenced this pull request Sep 20, 2024
…orch#129663)

As of ROCm 6.1 [hipDeviceProp_t::regsPerMultiprocessor](https://rocm.docs.amd.com/projects/HIP/en/latest/doxygen/html/structhip_device_prop__t.html#a7390d5b180d63978c81aa971060270b4) is now available allowing us to enable this attribute on ROCm.
```
>>> torch.cuda.get_device_properties(0)
_CudaDeviceProperties(name='AMD Instinct MI250X/MI250', major=9, minor=0, gcnArchName='gfx90a:sramecc+:xnack-', total_memory=65520MB, multi_processor_count=104)
>>> torch.cuda.get_device_properties(0).regs_per_multiprocessor
65536
```

With https://github.com/triton-lang/triton/pull/3962we can extract n_regs and n_spells from a triton binary with AMD backend allowing us to enable inductor's dynamic_rblock_scaling on ROCm initially implemented in pytorch#115094

Leaving this in draft until following PRs have landed:
- pytorch#129361 to bump the triton commit pin
- pytorch#128449 to allow us to grab warp_size from device properties instead of hard coding 64 on ROCm.

Pull Request resolved: pytorch#129663
Approved by: https://github.com/jansel, https://github.com/shunting314
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ciflow/inductor ciflow/trunk Trigger trunk jobs on your pull request Merged module: inductor module: rocm AMD GPU support for Pytorch open source release notes: releng release notes category release notes: rocm mandatorylabel Reverted rocm This tag is for PRs from ROCm team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

9 participants