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 refactors two equivalent qkv_format conditionals in the context-parallel attention test helper to use tuple membership.

  • Replaces repeated equality checks for bshd and sbhd without changing accepted formats or control flow.

Confidence Score: 5/5

The PR appears safe to merge because the refactor preserves the existing condition semantics and downstream behavior.

Both changed expressions accept exactly the same two string values as before and leave the associated sequence-dimension and comparison logic unchanged.

Important Files Changed

Filename Overview
tests/pytorch/attention/run_attention_with_cp.py Both changed conditions are behaviorally equivalent membership checks with no correctness, security, or test-coverage regression identified.

Reviews (1): 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