这是indexloc提供的服务,不要输入任何密码
Skip to content

Test Suite has errors on MacOS #499

@fyellin

Description

@fyellin

The Test Suite is showing errors when run on MacOS running Apple M1 Pro.

It seems that on the M1 Pro's GPU, exp2(x) is returning a slightly incorrect number $x < 0$.

I have texted it on the following values:

exp2(-1) =  0.4999999403953552
exp2(-2) = 0.2499999701976776
exp2(-3) = 0.1249999850988388

This causes any shader that uses PACK_BYTES_INTO_FLOAT_CODE or PACK_FLOAT_INTO_BYTES_CODE to work incorrectly. These are used by the test suite, but are not used by Quirk itself on the Mac, since it can use the more direct float options. I looked at the shaders used by all the example circuits, and the only use of exp2 was a guaranteed non-negative exponent.

Replacing exp2(exponent) with exp2(max(exponent, 0)) / exp2(max(-exponent, 0)) does work correctly. When I replaced the two code snippets above to use this alternate version, all tests passed (except for the Painter print_line aligned, which claims it is very machine and browser specific.)

I'm not quite sure what the best way to deal with this is. Ignore it? I at least wanted there to be some documentation.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions