pytorch - ✅(Solved) Fix Multiple logic issues in `TORCH_CHECK_VALUE()` in `ScaledBlas.cpp` [1 pull requests, 1 comments, 1 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
pytorch/pytorch#178686Fetched 2026-04-08 01:45:09
View on GitHub
Comments
1
Participants
1
Timeline
83
Reactions
0
Participants
Timeline (top)
mentioned ×32subscribed ×32referenced ×10labeled ×5

Fix Action

Fix / Workaround

This will be fixed by #178685

PR fix notes

PR #178685: [CUDA] Fix multiple logic issues in TORCH_CHECK_VALUE() in ScaledBlas.cpp

Description (problem / solution / changelog)

This fixes #178686

There are three issues (clearly typos) in TORCH_CHECK_VALUE() in ScaledBlas.cpp which are fixed with this PR.

Contributed by Benedikt Johannes

Changed files

  • aten/src/ATen/native/cuda/ScaledBlas.cpp (modified, +3/-3)

Code Example

// scale_a stride
  TORCH_CHECK_VALUE(
    scale_a.stride(0) == 1 &&
    (
      scale_a.stride(1) == M ||
      (scale_a.size(1) == 1 && scale_b.stride(1) == 1)
    ),
    "scale_a strides must be (", 1, ", ", M, "); got: ", scale_a.strides()
  );

---

// scale_a stride
  TORCH_CHECK_VALUE(
    scale_a.stride(0) == 1 &&
    (
      scale_a.stride(1) == M ||
      (scale_a.size(1) == 1 && scale_a.stride(1) == 1)
    ),
    "scale_a strides must be (", 1, ", ", M, "); got: ", scale_a.strides()
  );
RAW_BUFFERClick to expand / collapse

🐛 Describe the bug

This will be fixed by #178685

We got three issues with TORCH_CHECK_VALUE() in ScaledBlas.cpp

// scale_a stride
  TORCH_CHECK_VALUE(
    scale_a.stride(0) == 1 &&
    (
      scale_a.stride(1) == M ||
      (scale_a.size(1) == 1 && scale_b.stride(1) == 1)
    ),
    "scale_a strides must be (", 1, ", ", M, "); got: ", scale_a.strides()
  );

needs to be

// scale_a stride
  TORCH_CHECK_VALUE(
    scale_a.stride(0) == 1 &&
    (
      scale_a.stride(1) == M ||
      (scale_a.size(1) == 1 && scale_a.stride(1) == 1)
    ),
    "scale_a strides must be (", 1, ", ", M, "); got: ", scale_a.strides()
  );

(b and a were mixed up)

in line 851

and 3.

in line 989

there are similar issues

Versions

Latest

cc @jbschlosser @malfet @jianyuh @nikitaved @mruberry @walterddr @xwang233 @Lezcano

extent analysis

Fix Plan

To fix the issues with TORCH_CHECK_VALUE() in ScaledBlas.cpp, we need to correct the stride checks for scale_a and scale_b. The fixes involve swapping scale_b with scale_a in the conditions.

  • For issue 1, update the condition to check scale_a.stride(1) instead of scale_b.stride(1):
TORCH_CHECK_VALUE(
  scale_a.stride(0) == 1 &&
  (
    scale_a.stride(1) == M ||
    (scale_a.size(1) == 1 && scale_a.stride(1) == 1)
  ),
  "scale_a strides must be (", 1, ", ", M, "); got: ", scale_a.strides()
);
  • For issues 2 and 3, apply similar fixes in lines 851 and 989, respectively.

Verification

To verify the fixes, re-run the tests that previously failed due to these issues. Check that the TORCH_CHECK_VALUE() assertions pass without errors.

Extra Tips

  • Double-check the corrected conditions to ensure they match the expected stride patterns for scale_a and scale_b.
  • Consider adding additional tests to cover different scenarios and prevent similar issues in the future.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING