Repository navigation
fix: Pass rtol and atol of Nx.all_close/3 to mx::allclose in their order - #162
Open
georgeguimaraes wants to merge 1 commit into
Open
georgeguimaraes wants to merge 1 commit into
georgeguimaraes wants to merge 1 commit into
Conversation
The eager AllClose block passed atol as rtol and rtol as atol, so it tested |a - b| <= rtol + atol * |b|. For large values it said that close tensors were not close. It now passes rtol and atol in the order of EMLX.allclose/5. mx::allclose takes abs(b) in the type of b, which overflows at the smallest signed integer. The swap hid this case in the doctest of Nx.all_close/3 with s8 values. Two integer tensors now go to the default function, which widens them first, as Nx does.
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.
The eager
Nx.Block.AllCloseblock ofEMLX.BackendpassedatolasrtolandrtolasatoltoEMLX.allclose/5. So it tested|a - b| <= rtol + atol * |b|, and for large valuesNx.all_close/3said that close tensors were not close. For example, 1000.0 and 1000.005 are within the defaultrtolof 1.0e-5, but the block returned 0.This change passes the two values in their order. The swap also hid a second problem:
mx::allclosetakesabs(b)in the type ofb, which overflows at the smallest signed integer. The s8 doctest ofNx.all_close/3fails after the swap fix because of this overflow. Two integer tensors now go to the default function, which widens them beforeabs, as Nx does.The new test checks the eager and the compiled path. It fails without the fix.