Skip to content

Test harness: let a variant's tolerance vary across a dtype sweep #192

Description

@fabianlim

atol and rtol are scalars on a variant entry, read as entry.get("atol", 0) in
test_ktir_examples.py and test_device_launch.py. All 25 uses in the tree are scalars.

That means a dtype sweep cannot carry a tolerance, because tolerance is a property of the
dtype — fp16 ulp at a given magnitude is 8192x fp32's. So a fixture wanting both dtypes must
split into two entries, duplicating summary, tags, kernel_fn, factory, constexpr,
params and the whole tolerance rationale, in order to vary one number.

Concrete instance, from #190: the statistic chain needs 2.5e-1 at fp16 and 3e-5 at fp32.
Both are "16 ulp of the statistic" under one rule — the sqrt(64) reordering prediction
doubled — and expressing that one rule required two entries and two copies of the derivation.

This gets worse as fp32 variants are added across fixtures: every dtype sweep hits it.

Proposed

atol/rtol accept either a scalar (unchanged — the 25 existing uses keep working) or a dict
keyed by dtype, resolved against the variant's own DTYPE from its already-resolved params.

Two properties worth insisting on:

  • One resolution site. Both consumers call one helper in conftest.py. Two copies of a
    tolerance rule will drift, and the drift is invisible.
  • A dict missing the variant's dtype is an error naming the variant and the dtype, never a
    silent default. A silently-zero tolerance makes a test pass or fail for a reason nothing
    states.

Spike

Branch fixture-per-dtype-tolerance — one commit on top of #189's branch. Contains the helper,
both call sites, the fixtures/README.md field-table row (which had no rtol/atol row at
all), and one converted consumer in elementwise/meta.py.

It does not include collapsing the statistic-chain entries into one, which depends on
fixtures not present on that base. That part is small and was done once already; it can be
redone when this lands.

Note the spike is verified green as part of a larger branch, but has not been run on #189's base
in isolation — worth doing before merging.

Also fixed by this

Four in-tree comments assert that rtol/atol are fields rather than params (reduce's Level C
and Level D banners, 2d_compute, and elementwise's 2d_spyre_stick_fp32). Those stop being
true.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions