Jax float64 precision issues do not play ball with hypothesis
还没有人认领这个 Issue。
评估
调研方向
首先,使用 JAX 和报告中所示的 Hypothesis 数组策略重现失败的 test_diff 示例。检查生成的 float64 值与 JAX 的 float32 表示之间的差异,并确定 Array API 的预期行为;当相关测试不再产生这种精度不匹配时,该 issue 即完成。
由索引模型根据 Issue 内容生成。
描述
A typical example is (test_diff):
self = <hypothesis.extra.array_api.ArrayStrategy object at 0x7e6a6cf6c990>, val = 2.112233982580733, val_0d = Array(2.1122339, dtype=float32)
strategy = FloatStrategy(min_value=2.0, max_value=64.0, allow_nan=False, smallest_nonzero_magnitude=2.2250738585072014e-308)
def check_set_value(self, val, val_0d, strategy):
if val == val and self.builtin(val_0d) != val:
if self.builtin is float:
assert self.finfo is not None # for mypy
try:
is_subnormal = 0 < abs(val) < self.finfo.smallest_normal
except Exception:
# val may be a non-float that does not support the
# operations __lt__ and __abs__
is_subnormal = False
if is_subnormal:
raise InvalidArgument(
f"Generated subnormal float {val} from strategy "
f"{strategy} resulted in {val_0d!r}, probably "
f"as a result of array module {self.xp.__name__} "
"being built with flush-to-zero compiler options. "
"Consider passing allow_subnormal=False."
)
> raise InvalidArgument(
f"Generated array element {val!r} from strategy {strategy} "
f"cannot be represented with dtype {self.dtype}. "
f"Array module {self.xp.__name__} instead "
f"represents the element as {val_0d}. "
"Consider using a more precise elements strategy, "
"for example passing the width argument to floats()."
)
E hypothesis.errors.InvalidArgument: Generated array element 2.112233982580733 from strategy FloatStrategy(min_value=2.0, max_value=64.0, allow_nan=False, smallest_nonzero_magnitude=2.2250738585072014e-308) cannot be represented with dtype <class 'jax.numpy.float64'>. Array module jax.numpy instead represents the element as 2.112233877182007. Consider using a more precise elements strategy, for example passing the width argument to floats().
E while generating 'x' from sampled_from((<class 'jax.numpy.uint8'>, <class 'jax.numpy.int8'>, <class 'jax.numpy.int16'>, <class 'jax.numpy.int32'>, <class 'jax.numpy.float32'>, <class 'jax.numpy.float64'>, <class 'jax.numpy.complex64'>, <class 'jax.numpy.complex128'>)).flatmap(lambda d: arrays(d, *args, elements=elements, **kwargs))
E Explanation:
E These lines were always and only run by failing examples:
E /home/ev-br/.conda/envs/array-api/lib/python3.11/site-packages/jax/_src/array.py:328
E /home/ev-br/.conda/envs/array-api/lib/python3.11/site-packages/jax/_src/array.py:651
E /home/ev-br/.conda/envs/array-api/lib/python3.11/site-packages/numpy/_core/getlimits.py:609
- 主要语言
- Python
- 星标
- 74
- 派生
- 54
- 平均合并
- 4 天 15 小时
- 30 天内合并 PR
- 6
贡献指南
这个仓库没有索引到贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
data-apis/array-api-tests 的其他 Issue
-
难度 2/5 1-3 小时 新手友好度 87/100
data-apis/array-api-tests#465 · 1 条评论 ·
-
难度 3/5 1-2 天 新手友好度 68/100
data-apis/array-api-tests#460 · 1 条评论 ·
-
难度 3/5 1-2 天 新手友好度 68/100
data-apis/array-api-tests#455 · 2 条评论 ·
-
tracking
难度 5/5 一周以上 新手友好度 25/100
data-apis/array-api-tests#381 · 9 条评论 ·
-
难度 5/5 一周以上 新手友好度 38/100
data-apis/array-api-tests#379 · 10 条评论 ·
查看 data-apis/array-api-tests 的全部 Issue
相似的 Issue
-
triage/confirmed
难度 2/5 1-3 小时 新手友好度 88/100
agentscope-ai/agentscope#2775 ·
-
comp/desktop P3 type/bug
难度 1/5 1 小时以内 新手友好度 92/100
NousResearch/hermes-agent#118866 ·
-
bug
难度 1/5 1 小时以内 新手友好度 90/100
apache/cloudstack#14222 ·
-
难度 2/5 1-3 小时 新手友好度 76/100
-
bug
难度 2/5 1-3 小时 新手友好度 82/100