Validate model outputs#

2026-10-12

2 min read time

Applies to Linux

Use MIGraphX validation tools to compare GPU or CPU target output against the reference implementation. Validation helps confirm that compilation and quantization changes produce numerically consistent results.

Validate with migraphx-driver#

The verify command compiles your model for the reference and target backends, runs both with random data, and checks that outputs match within configured tolerances. Because verify runs with randomized data, verify alone does not prove that the model is running correctly. See MIGraphX driver for full command documentation.

Basic verification#

Verify an ONNX model against the default target:

migraphx-driver verify model.onnx --onnx

Replace model.onnx with your model path.

Verify on GPU with tolerance settings#

Set absolute tolerance (atol), relative tolerance (rtol), and root-mean-square tolerance (rms-tol) when comparing outputs:

migraphx-driver verify model.onnx --onnx --gpu \
    --atol 1e-5 --rtol 1e-5 --rms-tol 0.001

Replace model.onnx with your model path. Default tolerance values are 0.001 for atol, rtol, and rms-tol.

Verify after quantization#

Check that fp16 quantization preserves accuracy within your tolerances:

migraphx-driver verify model.onnx --onnx --gpu --fp16 \
    --atol 1e-3 --rtol 1e-3

Replace model.onnx with your model path.

Additional verify options#

The driver supports these validation-related options:

Option

Description

--per-instruction or -i

Verifies each instruction individually.

--reduce or -r

Reduces the program and verifies the reduced graph.

--atol

Sets tolerance for elementwise absolute difference (default: 0.001).

--rtol

Sets tolerance for elementwise relative difference (default: 0.001).

--rms-tol

Sets tolerance for root-mean-square error (default: 0.001).

Validation environment variables#

Set these environment variables before running migraphx-driver verify or your application to adjust validation behavior.

Output comparison#

Environment variable

Values

MIGRAPHX_VERIFY_ENABLE_ALLCLOSE

1 verifies range tolerance using allclose. 0 returns to default behavior.

MIGRAPHX_VERIFY_DUMP_DIFF

1 writes test output and reference output when they differ. 0 returns to default behavior.

Example:

export MIGRAPHX_VERIFY_DUMP_DIFF=1
migraphx-driver verify model.onnx --onnx --gpu

Replace model.onnx with your model path.

Testing and debugging#

These variables apply when running MIGraphX verify tests or debugging validation failures during development:

Environment variable

Values

MIGRAPHX_TRACE_TEST

1 prints reference and target programs even when verify tests pass.

MIGRAPHX_DUMP_TEST

1 writes the model under verification to an MXR file.

Example:

export MIGRAPHX_TRACE_TEST=1
migraphx-driver verify model.onnx --onnx --gpu

Replace model.onnx with your model path.

See MIGraphX environment variables for the complete list of validation, testing, and tracing variables.

See also#