[TESTS] Allow user defined output_dtype and acc_dtype in matmul tests#2769
Merged
ThomasRaoux merged 2 commits intotriton-lang:mainfrom Dec 12, 2023
Merged
Conversation
ThomasRaoux
reviewed
Dec 6, 2023
Comment on lines
+158
to
+163
| # Use small range of values to prevent numerical issues. | ||
| exponents = torch.randint(-4, 0, size=(m, n)) | ||
| ret = (2.**exponents).to(getattr(torch, dtype)).to("cuda") |
Collaborator
There was a problem hiding this comment.
can we use a smaller range only for the formats that need it.
In this PR we are allowing to manually set acc_dtype and output_dtype in matmul test. They are: - `acc_dtype`: So users of the test class can specify the type used internally in the dot, and not the one set by default given the two types. There are several restrictions for these types anyway. - `output_dtype`: The return type of the matmul. I included a few tests in the case of making a dot with two float16. - I had to modify test_matmul to use a small range of values to prevent numerical issues. In the case of testing with two `float16` and `acc_dtype` `float16`, since I can't force torch to use `float16` internally (it uses `float32`), I was having precision issues when comparing the results with triton. The discussion of why we are doing this for all tests and not only for that particular ones is simplicity, since we should not be testing precision here: The discussion can be seen in openxla#6 (comment) and openxla#6 (comment) but I do not have a strong opinion, so I am ok with just testing with small integers when the acc_dtype is float16.
c1563aa to
c457c49
Compare
ThomasRaoux
approved these changes
Dec 12, 2023
This was referenced Dec 13, 2023
binarman
pushed a commit
to binarman/triton
that referenced
this pull request
Apr 2, 2024
…triton-lang#2769) In this PR we are allowing to manually set acc_dtype and output_dtype in matmul test. They are: - `acc_dtype`: So users of the test class can specify the type used internally in the dot, and not the one set by default given the two types. There are several restrictions for these types anyway. - `output_dtype`: The return type of the matmul. I included a few tests in the case of making a dot with two float16. I also had to modify test_matmul to use a small range of values to prevent numerical issues. In the case of testing with two `float16` and `acc_dtype` `float16`, since I can't force torch to use `float16` internally (it uses `float32`), I was having precision issues when comparing the results with triton.
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.
In this PR we are allowing to manually set acc_dtype and output_dtype in matmul test.
They are:
acc_dtype: So users of the test class can specify the type used internally in the dot, and not the one set by default given the two types. There are several restrictions for these types anyway.output_dtype: The return type of the matmul. I included a few tests in the case of making a dot with two float16.I also had to modify test_matmul to use a small range of values to prevent numerical issues. In the case of testing with two
float16andacc_dtypefloat16, since I can't force torch to usefloat16internally (it usesfloat32), I was having precision issues when comparing the results with triton.