Skip to content

fix: simplify qkv_format checks using a membership tuple - #3365

Open
andrewwhitecdw wants to merge 1 commit into
NVIDIA:mainfrom
andrewwhitecdw:codequality/run-attention-with-cp-simplify-qkv-format-checks-using-a
Open

fix: simplify qkv_format checks using a membership tuple#3365
andrewwhitecdw wants to merge 1 commit into
NVIDIA:mainfrom
andrewwhitecdw:codequality/run-attention-with-cp-simplify-qkv-format-checks-using-a

Conversation

@andrewwhitecdw

Copy link
Copy Markdown
Contributor

This PR addresses the following issue in tests/pytorch/attention/run_attention_with_cp.py: simplify qkv_format checks using a membership tuple.

Changes

  • tests/pytorch/attention/run_attention_with_cp.py: simplify qkv_format checks using a membership tuple.

Details

--- a/tests/pytorch/attention/run_attention_with_cp.py
+++ b/tests/pytorch/attention/run_attention_with_cp.py
@@ -1,2 +1,2 @@
-    if qkv_format == "bshd" or qkv_format == "sbhd":
-        seq_dim = qkv_format.index("s")
+    if qkv_format in ("bshd", "sbhd"):
+        seq_dim = qkv_format.index("s")

Tests

Let me know if you want tests added for this fix or not.

Squashed to single commit for review.

Original PR: #13
@github-actions github-actions Bot added the community-contribution PRs from external contributor outside the core maintainers, representing community-driven work. label Aug 13, 2026
@greptile-apps

greptile-apps Bot commented Aug 13, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR simplifies two equivalent qkv_format checks without changing their accepted values or branch behavior.

  • Replaces repeated equality expressions with tuple membership checks.
  • Applies the same refactor in context-parallel tensor preparation and result comparison.

Confidence Score: 5/5

The PR appears safe to merge.

No blocking failure remains.

Important Files Changed

Filename Overview
tests/pytorch/attention/run_attention_with_cp.py Both modified conditions remain behaviorally equivalent, accepting only bshd and sbhd.

Reviews (2): Last reviewed commit: "fix: simplify qkv_format checks using a ..." | Re-trigger Greptile

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

Labels

community-contribution PRs from external contributor outside the core maintainers, representing community-driven work.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants