Skip to content

Prefer cublas when TORCH_BLAS_PREFER_CUBLASLT is false - #174377

Closed
fjankovi wants to merge 8 commits into
pytorch:mainfrom
fjankovi:add-prefer-rocblas-option
Closed

fjankovi wants to merge 8 commits into
pytorch:mainfrom
fjankovi:add-prefer-rocblas-option

Conversation

@fjankovi

@fjankovi fjankovi commented Feb 5, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Set blas_preferred_backend = at::BlasBackend::Cublas when TORCH_BLAS_PREFER_CUBLASLT / TORCH_BLAS_PREFER_HIPBLASLT is explicitly set to false.

For ROCm, if a gfx arch is in the list returned by getHipblasltPreferredArchs() hipBLASLt will be set as blas_preferred_backend by default regardless of TORCH_BLAS_PREFER_HIPBLASLT setting. This PR enables users to explicitly select cublas/rocblas and makes this env. variable behave like a binary toggle.

Changes

  • Modified checks for TORCH_BLAS_PREFER_CUBLASLT/TORCH_BLAS_PREFER_HIPBLASLT env. variables
  • Updated test_preferred_blas_library_settings

@pytorch-bot

pytorch-bot Bot commented Feb 5, 2026 •

Copy link
Copy Markdown

🔗 Helpful Links

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

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

✅ No Failures

As of commit f88d846 with merge base 007b6a4 (image):
💚 Looks good so far! There are no failures yet. 💚

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

@pytorch-bot

pytorch-bot Bot commented Feb 5, 2026

Copy link
Copy Markdown

This PR needs a release notes: label

If your changes are user facing and intended to be a part of release notes, please use a label starting with release notes:.

If not, please add the topic: not user facing label.

To add a label, you can comment to pytorchbot, for example
@pytorchbot label "topic: not user facing"

For more information, see
https://github.com/pytorch/pytorch/wiki/PyTorch-AutoLabel-Bot#why-categorize-for-release-notes-and-how-does-it-work.

@linux-foundation-easycla

linux-foundation-easycla Bot commented Feb 5, 2026 •

Copy link
Copy Markdown

CLA Signed

The committers listed above are authorized under a signed CLA.

@fjankovi

fjankovi commented Feb 5, 2026

Copy link
Copy Markdown
Contributor Author

@jeffdaily Can you please review?

@fjankovi

fjankovi commented Feb 5, 2026

Copy link
Copy Markdown
Contributor Author

@pytorchbot label "topic: not user facing"

@pytorch-bot pytorch-bot Bot added the topic: not user facing topic category label Feb 5, 2026
@zou3519 zou3519 added the triaged This issue has been looked at a team member, and triaged and prioritized into an appropriate module label Feb 6, 2026

@jeffdaily jeffdaily left a comment

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 don't understand why this is needed. The env var TORCH_BLAS_PREFER_CUBLASLT and its alias TORCH_BLAS_PREFER_HIPBLASLT toggle between cu/hipblaslt and cu/rocblas. It's a binary choice. The exception had been that the addmm fused gemm_and_bias path used to be cu/hipblaslt only and its behavior was controlled by a different env var DISABLE_ADDMM_CUDA_LT, but this was fixed by #174350.

@fjankovi

Copy link
Copy Markdown
Contributor Author

I don't understand why this is needed. The env var TORCH_BLAS_PREFER_CUBLASLT and its alias TORCH_BLAS_PREFER_HIPBLASLT toggle between cu/hipblaslt and cu/rocblas. It's a binary choice. The exception had been that the addmm fused gemm_and_bias path used to be cu/hipblaslt only and its behavior was controlled by a different env var DISABLE_ADDMM_CUDA_LT, but this was fixed by #174350.

@jeffdaily For ROCm, if a gfx arch is in the list returned by getHipblasltPreferredArchs() hipBLASLt will be set as blas_preferred_backend by default regardless of TORCH_BLAS_PREFER_HIPBLASLT setting:

blas_preferred_backend = at::BlasBackend::Cublaslt;

If we want TORCH_BLAS_PREFER_CUBLASLT to be a binary toggle, perhaps it is better to set blas_preferred_backend = at::BlasBackend::Cublas when TORCH_BLAS_PREFER_CUBLASLT is explicitly 0:

image

@jeffdaily

Copy link
Copy Markdown
Collaborator

I would accept your change that if the env var is set to false that it would pick cu/rocblas instead. It should have been that way.

@fjankovi fjankovi changed the title Add prefer cublas/rocblas option Prefer cublas when TORCH_BLAS_PREFER_CUBLASLT is false Feb 23, 2026
@fjankovi
fjankovi requested a review from jeffdaily February 23, 2026 15:39
@jeffdaily

Copy link
Copy Markdown
Collaborator

@pytorchbot merge

@pytorch-bot pytorch-bot Bot added the ciflow/trunk Trigger trunk jobs on your pull request label Feb 24, 2026
@eqy
eqy requested a review from nikitaved February 24, 2026 22:59
@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 mandatory check(s) failed. The first few are:

Dig deeper by viewing the failures on hud

Details for Dev Infra team Raised by workflow job

Failing merge rule: Core Maintainers

Comment thread test/test_cuda.py Resolved
@nikitaved nikitaved added the ciflow/rocm-mi300 Trigger "default" config CI on ROCm MI300 label Feb 25, 2026
@pytorch-bot pytorch-bot Bot removed ciflow/trunk Trigger trunk jobs on your pull request ciflow/rocm-mi300 Trigger "default" config CI on ROCm MI300 labels Feb 25, 2026
@nikitaved nikitaved added ciflow/trunk Trigger trunk jobs on your pull request ciflow/rocm-mi300 Trigger "default" config CI on ROCm MI300 labels Feb 25, 2026
@pytorchmergebot

Copy link
Copy Markdown
Collaborator

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

@pytorchmergebot
pytorchmergebot force-pushed the add-prefer-rocblas-option branch from d62b686 to f88d846 Compare March 10, 2026 11:20
@pytorch-bot pytorch-bot Bot removed the ciflow/trunk Trigger trunk jobs on your pull request label Mar 10, 2026
@k-artem

k-artem commented Mar 10, 2026

Copy link
Copy Markdown
Contributor

@pytorchbot merge

@pytorch-bot

pytorch-bot Bot commented Mar 10, 2026

Copy link
Copy Markdown

Pull workflow has not been scheduled for the PR yet. It could be because author doesn't have permissions to run those or skip-checks keywords were added to PR/commits, aborting merge. Please get/give approval for the workflows and/or remove skip ci decorators before next merge attempt. If you think this is a mistake, please contact PyTorch Dev Infra.

@k-artem

k-artem commented Mar 10, 2026

Copy link
Copy Markdown
Contributor

@pytorchbot label "ciflow/trunk"

@pytorch-bot

pytorch-bot Bot commented Mar 10, 2026

Copy link
Copy Markdown

To add these label(s) (ciflow/trunk) to the PR, please first approve the workflows that are awaiting approval (scroll to the bottom of this page).

This helps ensure we don't trigger CI on this PR until it is actually authorized to do so. Please ping one of the reviewers if you do not have access to approve and run workflows.

@k-artem

k-artem commented Mar 10, 2026

Copy link
Copy Markdown
Contributor

@jeffdaily could you please re-run ciflow, thanks.

@jeffdaily

Copy link
Copy Markdown
Collaborator

@pytorchbot merge

@pytorch-bot pytorch-bot Bot added the ciflow/trunk Trigger trunk jobs on your pull request label Mar 11, 2026
@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: trunk / libtorch-linux-jammy-cuda12.8-py3.10-gcc11-debug / build

Details for Dev Infra team Raised by workflow job

@k-artem

k-artem commented Mar 12, 2026

Copy link
Copy Markdown
Contributor

@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

mstankov-amd added a commit to ROCm/pytorch that referenced this pull request Mar 17, 2026
### Summary

Set blas_preferred_backend = at::BlasBackend::Cublas when TORCH_BLAS_PREFER_CUBLASLT / TORCH_BLAS_PREFER_HIPBLASLT is explicitly set to false.

For ROCm, if a gfx arch is in the list returned by getHipblasltPreferredArchs() hipBLASLt will be set as blas_preferred_backend by default regardless of TORCH_BLAS_PREFER_HIPBLASLT setting. This PR enables users to explicitly select cublas/rocblas and makes this env. variable behave like a binary toggle.

### Changes

- Modified checks for TORCH_BLAS_PREFER_CUBLASLT/TORCH_BLAS_PREFER_HIPBLASLT env. variables
- Updated test_preferred_blas_library_settings
Pull Request resolved: pytorch#174377
Approved by: https://github.com/jeffdaily, https://github.com/nikitaved

Co-authored-by: Milica Stankovic <[email protected]>
mstankov-amd added a commit to ROCm/pytorch that referenced this pull request Mar 17, 2026
…) (#3077)

### Summary

Set blas_preferred_backend = at::BlasBackend::Cublas when
TORCH_BLAS_PREFER_CUBLASLT / TORCH_BLAS_PREFER_HIPBLASLT is explicitly
set to false.

For ROCm, if a gfx arch is in the list returned by
getHipblasltPreferredArchs() hipBLASLt will be set as
blas_preferred_backend by default regardless of
TORCH_BLAS_PREFER_HIPBLASLT setting. This PR enables users to explicitly
select cublas/rocblas and makes this env. variable behave like a binary
toggle.

### Changes

- Modified checks for
TORCH_BLAS_PREFER_CUBLASLT/TORCH_BLAS_PREFER_HIPBLASLT env. variables
- Updated test_preferred_blas_library_settings Pull Request resolved:
pytorch#174377 Approved by:
https://github.com/jeffdaily, https://github.com/nikitaved

Co-authored-by: Filip Jankovic <[email protected]>
rocm-repo-management-api-6 Bot pushed a commit to ROCm/pytorch that referenced this pull request Mar 17, 2026
…) (#3077)

### Summary

Set blas_preferred_backend = at::BlasBackend::Cublas when
TORCH_BLAS_PREFER_CUBLASLT / TORCH_BLAS_PREFER_HIPBLASLT is explicitly
set to false.

For ROCm, if a gfx arch is in the list returned by
getHipblasltPreferredArchs() hipBLASLt will be set as
blas_preferred_backend by default regardless of
TORCH_BLAS_PREFER_HIPBLASLT setting. This PR enables users to explicitly
select cublas/rocblas and makes this env. variable behave like a binary
toggle.

### Changes

- Modified checks for
TORCH_BLAS_PREFER_CUBLASLT/TORCH_BLAS_PREFER_HIPBLASLT env. variables
- Updated test_preferred_blas_library_settings Pull Request resolved:
pytorch#174377 Approved by:
https://github.com/jeffdaily, https://github.com/nikitaved

Co-authored-by: Filip Jankovic <[email protected]>
rocm-repo-management-api-6 Bot added a commit to ROCm/pytorch that referenced this pull request Mar 17, 2026
Cherry-pick of #3077

Co-authored-by: Milica Stankovic <[email protected]>
Co-authored-by: Filip Jankovic <[email protected]>
jithunnair-amd pushed a commit to ROCm/pytorch that referenced this pull request Mar 25, 2026
…) (#3077)

### Summary

Set blas_preferred_backend = at::BlasBackend::Cublas when
TORCH_BLAS_PREFER_CUBLASLT / TORCH_BLAS_PREFER_HIPBLASLT is explicitly
set to false.

For ROCm, if a gfx arch is in the list returned by
getHipblasltPreferredArchs() hipBLASLt will be set as
blas_preferred_backend by default regardless of
TORCH_BLAS_PREFER_HIPBLASLT setting. This PR enables users to explicitly
select cublas/rocblas and makes this env. variable behave like a binary
toggle.

### Changes

- Modified checks for
TORCH_BLAS_PREFER_CUBLASLT/TORCH_BLAS_PREFER_HIPBLASLT env. variables
- Updated test_preferred_blas_library_settings Pull Request resolved:
pytorch#174377 Approved by:
https://github.com/jeffdaily, https://github.com/nikitaved

Co-authored-by: Filip Jankovic <[email protected]>
EmanueleCoradin pushed a commit to EmanueleCoradin/pytorch that referenced this pull request Mar 30, 2026
### Summary

Set blas_preferred_backend = at::BlasBackend::Cublas when TORCH_BLAS_PREFER_CUBLASLT / TORCH_BLAS_PREFER_HIPBLASLT is explicitly set to false.

For ROCm, if a gfx arch is in the list returned by getHipblasltPreferredArchs() hipBLASLt will be set as blas_preferred_backend by default regardless of TORCH_BLAS_PREFER_HIPBLASLT setting. This PR enables users to explicitly select cublas/rocblas and makes this env. variable behave like a binary toggle.

### Changes

- Modified checks for TORCH_BLAS_PREFER_CUBLASLT/TORCH_BLAS_PREFER_HIPBLASLT env. variables
- Updated test_preferred_blas_library_settings
Pull Request resolved: pytorch#174377
Approved by: https://github.com/jeffdaily, https://github.com/nikitaved

Co-authored-by: Milica Stankovic <[email protected]>
gplutop7 pushed a commit to gplutop7/pytorch that referenced this pull request Jul 15, 2026
### Summary

Set blas_preferred_backend = at::BlasBackend::Cublas when TORCH_BLAS_PREFER_CUBLASLT / TORCH_BLAS_PREFER_HIPBLASLT is explicitly set to false.

For ROCm, if a gfx arch is in the list returned by getHipblasltPreferredArchs() hipBLASLt will be set as blas_preferred_backend by default regardless of TORCH_BLAS_PREFER_HIPBLASLT setting. This PR enables users to explicitly select cublas/rocblas and makes this env. variable behave like a binary toggle.

### Changes

- Modified checks for TORCH_BLAS_PREFER_CUBLASLT/TORCH_BLAS_PREFER_HIPBLASLT env. variables
- Updated test_preferred_blas_library_settings
Pull Request resolved: pytorch#174377
Approved by: https://github.com/jeffdaily, https://github.com/nikitaved

Co-authored-by: Milica Stankovic <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ciflow/trunk Trigger trunk jobs on your pull request Merged open source topic: not user facing topic category triaged This issue has been looked at a team member, and triaged and prioritized into an appropriate module

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants