You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
2.17Issues related to 2.17 releasecomp:opsOPs related issuesstaleThis label marks the issue/pr stale - to be closed automatically if no activitystat:awaiting responseStatus - Awaiting response from authortype:bugBug
@pekaalto The GPU implementation of bucketize might not handle the rounding or boundary conditions in the same way as the CPU implementation. This could lead to differences in how values are categorized into buckets.
@pekaalto The GPU implementation of bucketize might not handle the rounding or boundary conditions in the same way as the CPU implementation. This could lead to differences in how values are categorized into buckets.
Thank you!
Hi, you can see in the example that bucket boundaries are well away from the values to bucketize so it's not immediate boundary condition.
However, I suspect that there is some implicit data type conversion happening to boundaries on GPU which makes it boundary condition and then it fails.
The bucketize function in TensorFlow appears to produce inconsistent results between CPU and GPU execution. When using TensorFlow versions 2.9.3, 2.15.0, and 2.18.0-dev20240624, the function yields different outcomes on these devices.
Here's a reproducible example demonstrating the issue:
The CPU output is [0 1 2 2], whereas the GPU output is [1 2 2 2], indicating a discrepancy. The GPU result seems incorrect based on the defined boundaries.
note changing x = [0,1,2,3] to x = [0.,1.,2.,3.] fixes the problem. I think this is because the cpu version is casting to the boundaries' type and the gpu version casts into the type of the input. which is the more correct version? I personally lean towards the cpu's version, because it gives the correct output for the boundaries' type (if you already give it a float, you would assume it uses it without rounding down)
it's also easier to fix the gpu's version (I already have the fix locally)
Hi @pekaalto ,
Thank you so much for filing this issue. We truly appreciate your support. At the moment, this request is not prioritized and mark it for community contributions. If you would like to contribute on a fix, please feel free to fork the repository and submit a pull request in accordance with the TensorFlow CONTRIBUTION GUIDELINES and link this issue in your PR to ensure the maintainers can easily review and collaborate.
To avoid duplicate work, please leave a comment here if you decide to take it on!
Thank you again for your interest and we look forward to seeing your contributions!
Hi @pekaalto ,
Thank you for raising your concern here.
A fix for this issue has been proposed in this #128013. Once it is merged, this issue will be resolved.
Hi @bodapatisaikrishna ,
Thank you for raising the PR to address this issue. We truly appreciate your initiative and the effort in contributing the fix.
The fix for this issue was merged into master via commit e2c7dee, from PR #128013. I verified the provided code using the latest tf-nightly build, and I am no longer able to reproduce the reported behavior. Now the code produces the consistent results on both CPU and GPU.
Could you please test this with the latest tf-nightly build on your side and confirm whether the issue has been resolved?
I have also attached gist file for your reference.
2.17Issues related to 2.17 releasecomp:opsOPs related issuesstaleThis label marks the issue/pr stale - to be closed automatically if no activitystat:awaiting responseStatus - Awaiting response from authortype:bugBug
Activity
sushreebarsa commentedon Jun 27, 2024
@pekaalto The GPU implementation of bucketize might not handle the rounding or boundary conditions in the same way as the CPU implementation. This could lead to differences in how values are categorized into buckets.
Thank you!
pekaalto commentedon Jun 29, 2024
Hi, you can see in the example that bucket boundaries are well away from the values to bucketize so it's not immediate boundary condition.
However, I suspect that there is some implicit data type conversion happening to boundaries on GPU which makes it boundary condition and then it fails.
Feeding int tensor doesn't work:
but with float it works
sushreebarsa commentedon Jul 1, 2024
@tilakrayal I was able to replicate the issue reported here.
Thank you!
ashok2216-A commentedon Jul 1, 2024
The
bucketizefunction in TensorFlow appears to produce inconsistent results between CPU and GPU execution. When using TensorFlow versions 2.9.3, 2.15.0, and 2.18.0-dev20240624, the function yields different outcomes on these devices.Here's a reproducible example demonstrating the issue:
Output:
The CPU output is
[0 1 2 2], whereas the GPU output is[1 2 2 2], indicating a discrepancy. The GPU result seems incorrect based on the defined boundaries.ghostway0 commentedon Jul 26, 2024
note changing
x = [0,1,2,3]tox = [0.,1.,2.,3.]fixes the problem. I think this is because the cpu version is casting to the boundaries' type and the gpu version casts into the type of the input. which is the more correct version? I personally lean towards the cpu's version, because it gives the correct output for the boundaries' type (if you already give it a float, you would assume it uses it without rounding down)it's also easier to fix the gpu's version (I already have the fix locally)
6 remaining items
Venkat6871 commentedon Jun 3, 2026
Hi @pekaalto ,
Thank you so much for filing this issue. We truly appreciate your support. At the moment, this request is not prioritized and mark it for community contributions. If you would like to contribute on a fix, please feel free to fork the repository and submit a pull request in accordance with the TensorFlow CONTRIBUTION GUIDELINES and link this issue in your PR to ensure the maintainers can easily review and collaborate.
To avoid duplicate work, please leave a comment here if you decide to take it on!
Thank you again for your interest and we look forward to seeing your contributions!
Venkat6871 commentedon Sep 28, 2026
Hi @pekaalto ,
Thank you for raising your concern here.
A fix for this issue has been proposed in this #128013. Once it is merged, this issue will be resolved.
Hi @bodapatisaikrishna ,
Thank you for raising the PR to address this issue. We truly appreciate your initiative and the effort in contributing the fix.
Kayyuri commentedon Oct 1, 2026
Hi @pekaalto, Thank you for your patience!
The fix for this issue was merged into
mastervia commit e2c7dee, from PR #128013. I verified the provided code using the latesttf-nightlybuild, and I am no longer able to reproduce the reported behavior. Now the code produces the consistent results on both CPU and GPU.Could you please test this with the latest
tf-nightlybuild on your side and confirm whether the issue has been resolved?I have also attached gist file for your reference.
Thank you!
github-actions commentedon Oct 15, 2026
This issue is stale because it has been open for 7 days with no activity. It will be closed if no further activity occurs. Thank you.
github-actions commentedon Oct 22, 2026
This issue was closed because it has been inactive for 7 days since being marked as stale. Please reopen if you'd like to work on this further.
google-ml-butler commentedon Oct 22, 2026
Are you satisfied with the resolution of your issue?
Yes
No