Repository navigation
[CuTeDSL] Preserve Float32 results for integer Vector division - #3923
Open
taking-lying-flat wants to merge 4 commits into
Open
taking-lying-flat wants to merge 4 commits into
taking-lying-flat wants to merge 4 commits into
Conversation
fengxie
requested changes
Dec 1, 2026
fengxie
left a comment
Collaborator
There was a problem hiding this comment.
Thanks for fixing. Can you add regression test egression test under test/python/CuTeDSL?
It can cover Int32/Int8/Uint8/Int64/Boolean Vector true division (forward & reverse, Python int/float, runtime Float32 scalar, and Vector operands) plus Float16/Float64 controls, matching test_tensor_ssa_truediv.py in #3872
fengxie
approved these changes
Dec 1, 2026
fengxie
left a comment
Collaborator
There was a problem hiding this comment.
Thanks a lot. LGTM. Approved with a small nit.
| if not self._dtype.is_float: | ||
| rhs = self.to(Float32, loc=loc, ip=ip) | ||
| if isinstance(other, Vector): | ||
| other = other.to(Float32, loc=loc, ip=ip) |
Collaborator
There was a problem hiding this comment.
This may convert Float64 to Float32 losing precision. How about using this?
if isinstance(other, Vector) and not other._dtype.is_float:
...This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Related to #3871; complements #3872, which fixes the TensorSSA path.
Integer
Vectortrue division produces floating-point values, but wrapping them with the input integer dtype truncates element extraction:[1, 3, 5, 7] / 2yields[0, 1, 2, 3]instead of[0.5, 1.5, 2.5, 3.5].In
__truediv__and__rtruediv__, promote integer/Boolean vectors and Vector operands to Float32 before scalar coercion or broadcasting, and preserve that result dtype. This also prevents Python float operands from raisingstd::bad_castand runtime Float32 scalars such as2.5from being narrowed to integers. Floating-point vectors retain their dtype.Extend the existing
test/python/CuTeDSL/test_vector_reduction_fastmath.pywith one parameterized division regression test. It covers Int32/Int8/Uint8/Int64/Boolean plus Float16/Float64 controls, forward/reverse division, and Python int/float, runtime Float32 scalar and Vector operands. Each of the 56 combinations checks runtime-input IR, result/extracted-element types and constant-folded values using the same module. No new test file or CUDA GPU is required.Validation with this checkout and
nvidia-cutlass-dsl==4.9.0.dev1MLIR components:python -m pytest -q test/python/CuTeDSL/test_vector_reduction_fastmath.py -k TestVectorTrueDiv: 1 test and 56 subtests passed.git diff --checkpass.The pre-existing reduction test has an unrelated exact-string mismatch with these MLIR components (
fastmath<reassoc,nsz>versusfastmath<reassoc>), reproduced before and after the division changes. Its assertion is unchanged.