Skip to content

fixes hardcoded "cuda" device references in unit tests to use a dynamic device selection#12761

Merged
hnyls2002 merged 2 commits intosgl-project:mainfrom
kalyank007:attn_bkn_test
Nov 7, 2025
Merged

fixes hardcoded "cuda" device references in unit tests to use a dynamic device selection#12761
hnyls2002 merged 2 commits intosgl-project:mainfrom
kalyank007:attn_bkn_test

Conversation

@kalyank007
Copy link
Contributor

fixes hardcoded "cuda" device references in unit tests to use a dynamic device selection function instead. This change improves test portability across different hardware backends (e.g., CUDA, XPU, ROCm, CPU).

Key changes:
Replaced all hardcoded "cuda" string literals with get_device() function calls, Applied changes to two test methods: test_build_unified_kv_indices and _test_extend_attention_unified_vs_regular_once

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @kalyank007, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request improves the robustness and portability of unit tests by eliminating hardcoded "cuda" device references. By dynamically selecting the appropriate device, the tests can now run seamlessly on diverse hardware backends, ensuring broader compatibility and reducing maintenance overhead for different computing environments.

Highlights

  • Dynamic Device Selection: Replaced hardcoded "cuda" device references in unit tests with a dynamic get_device() function call.
  • Improved Test Portability: Enhances the portability of unit tests across various hardware backends like CUDA, XPU, ROCm, and CPU.
  • Affected Test Methods: Changes were applied to test_build_unified_kv_indices and _test_extend_attention_unified_vs_regular_once methods.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request is a good step towards making the unit tests device-agnostic by replacing hardcoded "cuda" strings with dynamic device selection.

However, the implementation is incomplete. The changes are only applied to _test_extend_attention_unified_vs_regular_once and test_build_unified_kv_indices, but many other test methods in test/srt/test_triton_attention_kernels.py still have hardcoded "cuda" device references. To fully achieve the goal of this PR, I recommend updating the following methods as well:

  • _test_extend_attention_once
  • _test_extend_attention_sliding_window_once
  • _test_context_attention_once
  • _test_decode_attention_once
  • _test_grouped_decode_attention_once

Most importantly, the current changes introduce a NameError because the get_device function is used without being imported. I've added a specific comment pointing out where this needs to be fixed.

@kalyank007 kalyank007 force-pushed the attn_bkn_test branch 2 times, most recently from aae7ece to c8beb74 Compare November 6, 2025 08:19
device selection function instead. This change improves test portability
across different hardware backends (e.g., CUDA, XPU, ROCm, CPU).

Key changes:

Replaced all hardcoded "cuda" string literals with get_device() function
calls, Applied changes to two test methods: test_build_unified_kv_indices and
_test_extend_attention_unified_vs_regular_once
@kalyank007
Copy link
Contributor Author

Code Review

This pull request is a good step towards making the unit tests device-agnostic by replacing hardcoded "cuda" strings with dynamic device selection.

However, the implementation is incomplete. The changes are only applied to _test_extend_attention_unified_vs_regular_once and test_build_unified_kv_indices, but many other test methods in test/srt/test_triton_attention_kernels.py still have hardcoded "cuda" device references. To fully achieve the goal of this PR, I recommend updating the following methods as well:

  • _test_extend_attention_once
  • _test_extend_attention_sliding_window_once
  • _test_context_attention_once
  • _test_decode_attention_once
  • _test_grouped_decode_attention_once

Most importantly, the current changes introduce a NameError because the get_device function is used without being imported. I've added a specific comment pointing out where this needs to be fixed.

resolved

@kalyank007 kalyank007 closed this Nov 6, 2025
@kalyank007 kalyank007 reopened this Nov 6, 2025
@hnyls2002 hnyls2002 merged commit 3b1cc46 into sgl-project:main Nov 7, 2025
45 of 50 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

Comments