Checking captured tensor computations #
This entry point checks a typed IR artifact and optionally executes supplied arguments or compares supplied reference outputs. The result states the scope of each check. Passing these checks is not a theorem about all inputs, a proof of the frontend translation, or a validation of external kernels.
The report preserves the artifact's capture_constraints as unchecked metadata. Structure,
type and example-execution checks do not establish these conditions for all inputs.
compare treats two NaN results as equal whatever their sign and payload, which the IR leaves
unspecified; compare_bitwise requires equal words for NaNs too. Any other difference between the
IR's results and the reference fails. For a Jaxpr artifact whose reference XLA's CPU backend
computed, the checker then runs the program a second time as XLA's compiled CPU code computes it,
where this is exactly emulable: reciprocals of broadcast and constant divisors, jax.jit's
division and power rewrites when the artifact records a jax.jit reference, and the flushing of
subnormal values. A value that XLA's own rsqrt or power function computes counts as reproduced
within the window of Internal.window, measured in the format the function computes in. If the
second run reproduces every differing element, the failed finding lists the behaviours in
consistent_with. That field is advice, not an explanation: an importer error with the same
effect on these arguments cannot be ruled out, and some importer errors coincide with XLA's own
rewrites. Under jax.jit it also requires the artifact's primitive-by-primitive reference, when
there is one, to agree with the IR or to be reproduced without jax.jit's rewrites. The checker
trusts the artifact's record of how the reference was computed, so a forged record can at most
add this advice to a failure.
Unknown requests are reported as unsupported. They must not disappear from a successful report. Existing certificate checkers and mathematical proof APIs remain separate tools with their own contracts.
Read a supported tensor from complete element words, with no host-float conversion.
Instances For
FloatLib's classification of one binary word: whether it is a NaN and whether it is subnormal, under the format's exceptional-value encoding.
Instances For
Compare one result with its reference. Two NaNs agree unless bitwise is set.
Instances For
XLA's documented CPU behaviour #
The behaviours, how the artifact says XLA compiled the reference, and the emulated program that
compare runs for a differing Jaxpr result.
A documented way in which XLA's compiled CPU code computes differently from the IR, with the
code that a failed comparison lists in consistent_with and the description of
NN/IR/README.md.
Instances For
Instances For
A division by a broadcast divisor, or under jax.jit by a constant.
Instances For
The simplifier's division rewrites under jax.jit.
Instances For
Constant exponents computed as products under jax.jit.
Instances For
Subnormal values flushed to zero.
Instances For
XLA's own reciprocal square root.
Instances For
The window, in units in the last place of dtype, within which a value that XLA's own rsqrt or
power function computes in dtype counts as reproduced: the largest distance measured between
XLA's function and the IR's in that format, 2 for rsqrt and 1 for the power, in binary32 and
binary64. XLA's power is within 1 ulp of the IR's for integral exponents and where |y log x| < 1;
elsewhere FloatLib's power is farther from it, and such a result is not reproduced. XLA computes
binary16 and bfloat16 rsqrt and powers in binary32 and rounds once, so the window applies to the
binary32 value, before that rounding; a node of a reduced format has none.
Instances For
How XLA compiled a Jaxpr reference, as the artifact records it.
- jit : Bool
The reference came from
jax.jit, which compiles the whole program as one computation. Otherwise, for each node, the computation XLA compiled it in: the JAX importer's index of the primitive, or of the nested
jax.jitcall, that produced it.The computations that are nested
jax.jitcalls.
Instances For
Read reference_execution, jit_computations and each node's computation; or, with
perPrimitive, describe the primitive-by-primitive reference, where each primitive, inside nested
jax.jit calls too, is a computation of its own, identified by the node's primitive_index. A raw
node that the lowering expands owns every node up to its result, as in the type assignment of
Import.IR.Internal.parse.
Instances For
Whether jax.jit compiles any part of the program.
Instances For
The program as XLA's CPU code computes it, built node by node from the IR program.
- jit : Bool
The reference came from
jax.jit. Nodes of the emulated program.
Element type of each node.
- primitives : Array (Option IR.Primitive)
Casts and registered operations, aligned with
nodes. - constants : Array (Option IR.Interpreter.reference.Value)
Values of the copied constants and of the ones that the rewrites add.
The IR node each copied node comes from, for its payload entries.
The computation each node belongs to, as in
Compilation.- site : Array (Option (XlaBehaviour × ℕ))
The documented behaviour that produced each node, with the IR node it rewrites.
Instances For
Whether node id belongs to computation. Under jax.jit every node does.
Instances For
Whether a divisor is a broadcast computed in computation, past reshapes and permutations.
Instances For
The IR node being emulated, its computation, and the documented behaviour that the new nodes emulate, if any.
- node : ℕ
The IR node.
Its computation.
- jitted : Bool
Whether
jax.jitcompiles it. - difference : Option XlaBehaviour
The behaviour the new nodes emulate.
Instances For
Construction of the emulated program.
Instances For
Add a node for site, returning its id.
Instances For
The word of the integer n rounded once to format.
Instances For
A constant of ones.
Instances For
Formats in which jax.jit rewrites quotients of quotients and quotients by quotients, each
step rounded to the format. XLA computes bfloat16 in binary32, where the conversions between
operations block the rewrites.
Instances For
Formats in which the emulation rewrites divisions by square roots, reciprocal square roots
and powers. The IR computes binary16 rsqrt and pow in binary32, so these patterns are not
binary16 operations there.
Instances For
A division as XLA's CPU code computes it. A broadcast divisor, or under jax.jit a constant one,
becomes multiplication by its reciprocal rounded to the format; bfloat16 computes both in binary32
and rounds the product once. Otherwise, under jax.jit, the simplifier's rewrites
(x / y) / z = x / (y * z) and x / (y / z) = (x * z) / y apply in rewritesIn formats, then
x / sqrt y = x * rsqrt y, x / rsqrt y = x * sqrt y and x / y ^ c = x * y ^ -c in
rootRewritesIn formats, in that order, and the division a rewrite produces is computed by the
same rules.
Instances For
The exponent 2, 3 or -1 that jax.jit computes as products or a reciprocal, when every
element of a binary16, binary32 or binary64 exponent is that integer.
Instances For
Build the emulated program from the IR program and its node values, returning the emulated
node of each IR node. Under jax.jit a constant exponent 2, 3 or -1 becomes products or a
reciprocal, each rounded to the format; XLA rounds every product of a binary16 base to binary16,
so the binary32 power that the JAX importer writes for it is computed in binary16 and widened.
Instances For
Whether XLA's CPU code flushes subnormal values of dtype: bfloat16, binary32 and binary64.
It computes binary16 in binary32, where binary16 subnormals are normal.
Instances For
Whether a node flushes its operands and its result. A node that jax.jit folds flushes
neither; a conversion from binary32 or bfloat16 to binary64 flushes its operand, and one from
binary64 to binary32 or bfloat16 its result.
Instances For
Replace the subnormal elements of a bfloat16, binary32 or binary64 value by zero of the same sign, reporting whether any element changed.
Instances For
The IR payload, read through the origins of the emulated nodes.
Instances For
The emulated program and its interface, as a Program, with the payload read through it.
- emulation : Emulation
The documented behaviours applied to each node.
- program : IR.Program
The emulated program.
- payload : IR.Interpreter.reference.Payload
Its payload.
- arguments : Array IR.Interpreter.reference.Value
The arguments.
Instances For
Evaluate one emulated node on values, flushing its operands and its result as flushing
says, and report whether flushing changed a word.
Instances For
A result that XLA's own function computes, and the window within which it counts as reproduced.
- behaviour : XlaBehaviour
XLA's function.
- source : ℕ
The emulated
rsqrtorpownode. The window, in units in the last place of the source node's format, or why there is none.
The nodes from the source to the result, in order, the result last.
Instances For
XLA's own function computing result id: an rsqrt or pow node, reached through layout
operations, negation and conversions between binary formats, with its window when the node is of
binary32 or binary64. A power has a window only when both its operands are arguments
(exactArgument), so that XLA's function and the IR's receive the same values: a power with a
small exponent hides a large error in its base, and one with a large base a small error in its
exponent.
Instances For
Whether a word of format has its sign bit set.
Instances For
Whether a word of format is an infinity.
Instances For
The words ulps steps below and above word in the order of the magnitudes of an IEEE
format, keeping its sign and staying finite: the window never crosses zero or reaches an
infinity. An infinity or a NaN is its own window.
Instances For
The ends of the window around each element of the approximation's source node, carried to the result through its path: rounding is monotone, and negation and layout operations move the ends with the value.
Instances For
Whether the reference word wanted lies between the window's ends low and high at the
result and has the sign and the finiteness of the emulated word: a difference in the sign of zero
or between a finite value and an infinity is outside every window.
Instances For
The window used for a result: XLA's function, its width and format, and the differing elements within it.
- behaviour : XlaBehaviour
XLA's function.
- ulps : ℕ
Units in the last place.
- dtype : IR.DType
The format the function computes in.
- result : IR.DType
The result's format, which the window's ends are rounded to.
- elements : ℕ
Differing elements within the window.
Instances For
What the emulation of XLA's CPU code reproduces of one differing result.
- result : ℕ
Position of the result.
- mismatch : Mismatch
Its differing elements.
- applied : Array (XlaBehaviour × ℕ)
Documented behaviours applied to nodes the result depends on, each with the IR nodes it rewrites, or for flushing the emulated nodes where it changed a word.
- reproduced : ℕ
Differing elements whose words the emulated program returns.
The window of XLA's own function computing the result, if one applies.
- withheld : Option (XlaBehaviour × String)
XLA's own function computing the result when no window applies, and why.
Elements not reproduced, with the IR's, the emulation's and the reference's words.
Instances For
The behaviours the reproduction used: those applied, and XLA's function if its window holds a differing element.
Instances For
The report entry of a differing result.
Instances For
The behaviours applied, in words.
Instances For
The window, in words.
Instances For
One sentence for the report message.
Instances For
What the emulated program reproduces of result index's differing elements.
Instances For
Run the emulation of XLA's CPU code that compilation describes and report what it
reproduces of each differing result.
Instances For
Compare the IR's results with the reference tensors in field, returning the references and
the elements that differ.
Instances For
The behaviours a set of reproductions used, each once, in order.
Instances For
Their codes.
Instances For
What the primitive-by-primitive reference says about a mismatch with a jax.jit reference:
whether the IR agrees with it, or the emulation of XLA's CPU code without jax.jit reproduces it,
with a sentence and report entries.
Instances For
The compare or compare_bitwise finding for computed results and every node value. Any
difference fails. For a Jaxpr artifact with a CPU reference, a failure whose differing elements
the emulation of XLA's CPU code reproduces carries the behaviours in consistent_with, as advice:
an importer error with the same effect cannot be ruled out. With a jax.jit reference, the
artifact's primitive-by-primitive reference, when it has one, must also agree with the IR or be
reproduced without jax.jit.
Instances For
Serialize computed results for inspection without a lossy numerical display conversion.
Instances For
Run requested checks, returning explicit failures and unsupported requests as report entries.
execute, compare and compare_bitwise concern only arguments stored in the artifact. A
comparison uses complete binary words, except that compare lets two NaNs agree whatever their
sign and payload. It can expose legitimate differences in reduction or elementary-function
implementations; a mismatch alone does not identify a bug, and it always fails. For a Jaxpr
artifact, the failure lists in consistent_with the documented behaviours of XLA's CPU code whose
emulation reproduces every differing element (see the module documentation).