Skip to content

Conversation

@neelay893
Copy link
Contributor

Type inference bugs cause analysis results to Bottom in certain cases. Add a check for bottom to not implement vmath binop desugaring if either argument is type Bottom.

@codecov
Copy link

codecov bot commented Nov 21, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@github-actions
Copy link
Contributor

☂️ Python Coverage

current status: ✅

Overall Coverage

Lines Covered Coverage Threshold Status
11714 10451 89% 0% 🟢

New Files

No new covered files...

Modified Files

File Coverage Status
src/kirin/dialects/vmath/rewrites/desugar.py 79% 🟢
TOTAL 79% 🟢

updated for commit: 87d7c07 by action🐍

@github-actions
Copy link
Contributor

github-actions bot commented Nov 21, 2025

PR Preview Action v1.6.3
Preview removed because the pull request was closed.
2025-11-21 19:42 UTC

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR addresses type inference bugs that cause analysis results to reach Bottom type in certain cases. The fix prevents vmath binary operation desugaring when either operand has Bottom type, avoiding incorrect transformations.

Key changes:

  • Added early return in DesugarBinOp.rewrite_Statement() to skip desugaring when operands are Bottom type
  • Added test cases documenting known type inference failures with @pytest.mark.xfail() markers
  • Fixed test data type from integer to float list in test_typed_kernel_add() to match type annotations

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 5 comments.

File Description
src/kirin/dialects/vmath/rewrites/desugar.py Added check to prevent desugaring when either operand is Bottom type, returning empty RewriteResult() instead
test/dialects/vmath/test_desugar.py Added pytest import, marked 5 tests as expected failures with @pytest.mark.xfail(), added new multiplication test case, and fixed test data types

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

assert np.allclose(np.asarray(res), np.array([6, 7, 8]))


@pytest.mark.xfail()
Copy link

Copilot AI Nov 21, 2025

Choose a reason for hiding this comment

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

The @pytest.mark.xfail() decorator should include a reason parameter to explain why this test is expected to fail. Other tests in the codebase consistently use @mark.xfail(reason="...") to document the known issue.

For example, based on the PR description, consider: @pytest.mark.xfail(reason="type inference results in Bottom type for these cases")

Copilot uses AI. Check for mistakes.
return x - y


@pytest.mark.xfail()
Copy link

Copilot AI Nov 21, 2025

Choose a reason for hiding this comment

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

The @pytest.mark.xfail() decorator should include a reason parameter to explain why this test is expected to fail. Other tests in the codebase consistently use @mark.xfail(reason="...") to document the known issue.

For example, based on the PR description, consider: @pytest.mark.xfail(reason="type inference results in Bottom type for these cases")

Copilot uses AI. Check for mistakes.
return mult_kernel(x=3.0, y=[3.0, 4.0, 5.0])


@pytest.mark.xfail()
Copy link

Copilot AI Nov 21, 2025

Choose a reason for hiding this comment

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

The @pytest.mark.xfail() decorator should include a reason parameter to explain why this test is expected to fail. Other tests in the codebase consistently use @mark.xfail(reason="...") to document the known issue.

For example, based on the PR description, consider: @pytest.mark.xfail(reason="type inference results in Bottom type for these cases")

Copilot uses AI. Check for mistakes.
assert np.allclose(np.asarray(res), np.asarray([0, 3, 6]))


@pytest.mark.xfail()
Copy link

Copilot AI Nov 21, 2025

Choose a reason for hiding this comment

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

The @pytest.mark.xfail() decorator should include a reason parameter to explain why this test is expected to fail. Other tests in the codebase consistently use @mark.xfail(reason="...") to document the known issue.

For example, based on the PR description, consider: @pytest.mark.xfail(reason="type inference results in Bottom type for these cases")

Copilot uses AI. Check for mistakes.
return add_kernel(x=3.0, y=[3.0, 4, 5])


@pytest.mark.xfail()
Copy link

Copilot AI Nov 21, 2025

Choose a reason for hiding this comment

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

The @pytest.mark.xfail() decorators should include a reason parameter to explain why these tests are expected to fail. Other tests in the codebase consistently use @mark.xfail(reason="...") to document the known issue.

For example, based on the PR description, consider: @pytest.mark.xfail(reason="type inference results in Bottom type for these cases")

Copilot uses AI. Check for mistakes.
Copy link
Collaborator

@kaihsin kaihsin left a comment

Choose a reason for hiding this comment

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

LGTM, for context @Roger-luo this is causing some issue with downstream behavior. We should address this typeinfer issue properly in another PR

@neelay893 neelay893 merged commit 6ae43a8 into main Nov 21, 2025
19 checks passed
@neelay893 neelay893 deleted the neelay/fix-vmath branch November 21, 2025 19:41
@cduck
Copy link
Contributor

cduck commented Nov 21, 2025

Yay! This fixed a tricky bug in my pipeline. Any chance of backporting it to 0.21 @neelay893?

@kaihsin
Copy link
Collaborator

kaihsin commented Nov 21, 2025

Yes this should be able to backport to 0.21 too.

kaihsin pushed a commit that referenced this pull request Nov 21, 2025
Type inference bugs cause analysis results to `Bottom` in certain cases.
Add a check for bottom to not implement vmath binop desugaring if either
argument is type `Bottom`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants