Skip to content

HOTFIX: Skip mamba Stochastic Rounding tests on sm_120#2699

Merged
bkryu merged 2 commits intoflashinfer-ai:mainfrom
ishovkun:main
Mar 5, 2026
Merged

HOTFIX: Skip mamba Stochastic Rounding tests on sm_120#2699
bkryu merged 2 commits intoflashinfer-ai:mainfrom
ishovkun:main

Conversation

@ishovkun
Copy link
Contributor

@ishovkun ishovkun commented Mar 5, 2026

📌 Description

I added a checker is_cvt_rs_supported that is used to skip mamba tests that use Triton is a reference.
FlashInfer implementation already has fallback software-emulated SR emulation, whereas the Triton reference does not, which leads to test failures. Previously, we only checked that the main SM version is larger or equal than 100.

🔍 Related Issues

🚀 Pull Request Checklist

Thank you for contributing to FlashInfer! Before we review your pull request, please make sure the following items are complete.

✅ Pre-commit Checks

  • I have installed pre-commit by running pip install pre-commit (or used your preferred method).
  • I have installed the hooks with pre-commit install.
  • I have run the hooks manually with pre-commit run --all-files and fixed any reported issues.

If you are unsure about how to set up pre-commit, see the pre-commit documentation.

🧪 Tests

  • Tests have been added or updated as needed.
  • All tests are passing (unittest, etc.).

Reviewer Notes

Summary by CodeRabbit

  • New Features

    • Added a utility to detect CUDA compute capability and whether a device supports a specific runtime rounding path.
  • Tests

    • Updated tests to use the new runtime capability check, improving when GPU-dependent stochastic rounding and related references are exercised or skipped.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 5, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 76245d60-39fc-42bb-9124-b74667709bca

📥 Commits

Reviewing files that changed from the base of the PR and between da9a290 and 5e7ae55.

📒 Files selected for processing (1)
  • flashinfer/utils.py

📝 Walkthrough

Walkthrough

Added a new public utility function is_cvt_rs_supported(device: torch.device = None) -> bool in flashinfer/utils.py that detects CVT.RS support from device compute capability (returns True for SM10x and SM11x; notes SM120 unsupported). Updated three tests to use this helper instead of hardcoded SM major checks.

Changes

Cohort / File(s) Summary
Core Utility Function
flashinfer/utils.py
Added is_cvt_rs_supported(device: torch.device = None) -> bool which queries device compute capability and returns True for SM10x and SM11x; docstring clarifies SM120 lacks support.
Test Updates
tests/mamba/test_philox_rounding.py, tests/mamba/test_selective_state_update_mtp.py, tests/mamba/test_selective_state_update_stp.py
Replaced direct SM major-version checks with is_cvt_rs_supported() calls to gate test execution and determine stochastic rounding seeding/behavior. Imports updated accordingly.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested labels

v0.6.2, run-ci

Suggested reviewers

  • yzh119
  • bkryu
  • kahyunnam
  • jimmyzho

Poem

🐰 I sniff the SM and give a hop of cheer,
No magic numbers—just capability clear.
I guard the tests where rounding likes to play,
Hopping hardcodes out, I pave the way. ✨

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: adding a checker to skip mamba stochastic rounding tests on SM_120 GPUs due to unsupported features.
Description check ✅ Passed The description covers the main objective (is_cvt_rs_supported checker), motivation (Triton lacks fallback), and checklist items are marked as complete, though Related Issues section is empty.
Docstring Coverage ✅ Passed Docstring coverage is 85.71% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello, 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 introduces a hotfix to prevent test failures related to stochastic rounding on specific GPU architectures, particularly SM120 (Blackwell lite). It achieves this by adding a new utility function to precisely determine hardware support for a critical PTX instruction (cvt.rs.f16x2.f32) and then using this check to conditionally skip relevant Mamba tests. This ensures that tests only run on environments where Triton's reference implementation can correctly execute stochastic rounding, while FlashInfer's implementation, which includes a software fallback, remains unaffected.

Highlights

  • New Utility Function: Introduced a new utility function is_cvt_rs_supported to accurately detect GPU support for the cvt.rs.f16x2.f32 instruction, specifically identifying that SM120 (Blackwell lite) does not support it.
  • Conditional Test Skipping: Modified Mamba stochastic rounding tests to leverage is_cvt_rs_supported, ensuring these tests are skipped on GPUs that lack the necessary hardware support (e.g., SM120).
  • Test Stability: Addressed test failures on SM120 by preventing Triton's reference implementation, which lacks a software fallback for stochastic rounding, from running on unsupported hardware.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Changelog
  • flashinfer/utils.py
    • Added is_cvt_rs_supported function to check for GPU support of the cvt.rs.f16x2.f32 instruction, specifically excluding SM120.
  • tests/mamba/test_philox_rounding.py
    • Imported is_cvt_rs_supported from flashinfer.utils.
    • Modified the stochastic_round_module function to use is_cvt_rs_supported for conditionally skipping tests that require cvt.rs.f16x2.f32.
  • tests/mamba/test_selective_state_update_mtp.py
    • Imported is_cvt_rs_supported from flashinfer.utils.
    • Updated the make_reference_output method to use is_cvt_rs_supported for determining whether to apply stochastic rounding (rand_seed) in the Triton reference implementation.
  • tests/mamba/test_selective_state_update_stp.py
    • Imported is_cvt_rs_supported from flashinfer.utils.
    • Updated the make_reference_output method to use is_cvt_rs_supported for determining whether to apply stochastic rounding (rand_seed) in the Triton reference implementation.
Activity
  • Pre-commit checks were installed and run, with all reported issues fixed.
  • Tests were added or updated as needed, and all tests are passing.
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 introduces a helper function is_cvt_rs_supported to correctly detect hardware support for the cvt.rs.f16x2.f32 PTX instruction, which is not available on all SM >= 100 architectures (e.g., SM120). This function is then used in Mamba tests to conditionally skip or adjust tests that rely on Triton's stochastic rounding, which lacks a software fallback unlike FlashInfer's implementation. The changes correctly address the test failures on unsupported hardware. I have one suggestion to make the new helper function more robust against future architecture changes, given the feature is non-forward-compatible.

Do not assume the forward compatibility of cv.rs

Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
flashinfer/utils.py (1)

589-599: Cache this public utility to follow module-level API caching convention.

Please add @functools.cache to this API helper.

Proposed fix
+@functools.cache
-def is_cvt_rs_supported(device: torch.device = None) -> bool:
+def is_cvt_rs_supported(device: Optional[torch.device] = None) -> bool:

As per coding guidelines: "flashinfer/*.py: Use @functools.cache decorator on Python API functions to implement two-level module caching (Python in-memory and file-level on disk)".

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@flashinfer/utils.py` around lines 589 - 599, The public helper
is_cvt_rs_supported lacks module-level in-memory caching; add the
`@functools.cache` decorator to the is_cvt_rs_supported function to follow the
module caching convention and ensure you import functools at top if not already
present; keep the function semantics unchanged, only prepend `@functools.cache` to
is_cvt_rs_supported so repeated calls reuse the cached result.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@flashinfer/utils.py`:
- Around line 589-599: The current is_cvt_rs_supported function returns True for
any major >= 10 except 12, which may enable unsupported future SMs; restrict the
support check to known supported families only by changing the predicate in
is_cvt_rs_supported (which calls get_compute_capability) to explicitly return
True only for the supported majors (e.g., 10 and 11) and False otherwise,
ensuring the function does not assume forward compatibility for unknown SM
majors.

---

Nitpick comments:
In `@flashinfer/utils.py`:
- Around line 589-599: The public helper is_cvt_rs_supported lacks module-level
in-memory caching; add the `@functools.cache` decorator to the is_cvt_rs_supported
function to follow the module caching convention and ensure you import functools
at top if not already present; keep the function semantics unchanged, only
prepend `@functools.cache` to is_cvt_rs_supported so repeated calls reuse the
cached result.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 4d521cca-be48-43eb-a4c4-78661caa1a91

📥 Commits

Reviewing files that changed from the base of the PR and between 858d8ff and da9a290.

📒 Files selected for processing (4)
  • flashinfer/utils.py
  • tests/mamba/test_philox_rounding.py
  • tests/mamba/test_selective_state_update_mtp.py
  • tests/mamba/test_selective_state_update_stp.py

@bkryu
Copy link
Collaborator

bkryu commented Mar 5, 2026

/bot run

@flashinfer-bot
Copy link
Collaborator

GitLab MR !384 has been created, and the CI pipeline #45457628 is currently running. I'll report back once the pipeline job completes.

@bkryu bkryu merged commit 124a2d3 into flashinfer-ai:main Mar 5, 2026
24 checks passed
ameynaik-hub pushed a commit to ameynaik-hub/flashinfer that referenced this pull request Mar 18, 2026
…#2699)

<!-- .github/pull_request_template.md -->

## 📌 Description

I added a checker `is_cvt_rs_supported` that is used to skip mamba tests
that use Triton is a reference.
FlashInfer implementation already has fallback software-emulated SR
emulation, whereas the Triton reference does not, which leads to test
failures. Previously, we only checked that the main SM version is larger
or equal than 100.

## 🔍 Related Issues

## 🚀 Pull Request Checklist

Thank you for contributing to FlashInfer! Before we review your pull
request, please make sure the following items are complete.

### ✅ Pre-commit Checks

- [x] I have installed `pre-commit` by running `pip install pre-commit`
(or used your preferred method).
- [x] I have installed the hooks with `pre-commit install`.
- [x] I have run the hooks manually with `pre-commit run --all-files`
and fixed any reported issues.

> If you are unsure about how to set up `pre-commit`, see [the
pre-commit documentation](https://pre-commit.com/).

## 🧪 Tests

- [x] Tests have been added or updated as needed.
- [x] All tests are passing (`unittest`, etc.).

## Reviewer Notes

<!-- Optional: anything you'd like reviewers to focus on, concerns, etc.
-->

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

* **New Features**
* Added a utility to detect CUDA compute capability and whether a device
supports a specific runtime rounding path.

* **Tests**
* Updated tests to use the new runtime capability check, improving when
GPU-dependent stochastic rounding and related references are exercised
or skipped.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->

---------

Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Signed-off-by: Amey Naik <212485788+ameynaik-hub@users.noreply.github.com>
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.

3 participants