Skip to content

What To Do If Integration Tests Fail

Anooja Jayaraj edited this page Jun 8, 2026 · 2 revisions

Overview

When an integration test fails, do not assume immediately that the example is broken.

In PAOFLOW, integration failures usually fall into one of these categories:

  1. a real behavioral regression
  2. missing or wrong test assets
  3. small numerical differences between the machine that generated the reference data and the machine running the test now

The goal is to determine which of those happened before changing code, references, or thresholds.


First: Look at the Failure Artifacts

For the current QE integration workflow, failed tests generate comparison plots.

Those plots are useful because they show:

  • the reference data
  • the newly produced output
  • the absolute difference between them

This is the fastest way to tell whether a failure is a true regression or just a small numerical drift.

In GitHub Actions

If the QE integration job fails, the CI workflow uploads the plots as an artifact.

Look for the artifact named:

  • qe-comparison-plots

Download it and inspect the PNG files.

In local runs

When run locally, the QE and transport integration tests write plots under a sandbox directory named:

  • _compare_plots

The test failure message prints the sandbox path, so developers can go directly to the generated plots.


How To Read the Plots

Use the plots to answer a simple question:

Are the results qualitatively different, or are they nearly identical with only small numeric shifts?

Signs of a real regression

These usually mean the code or inputs changed in a meaningful way:

  • output and reference curves have clearly different shapes
  • peaks move significantly
  • an output file is missing
  • extra output files appear unexpectedly
  • the output and reference arrays have different sizes
  • the difference plot is large over broad regions, not just tiny noise

Signs of machine-dependent numerical drift

These are often acceptable, especially when the references were generated on a different machine or with a different software stack:

  • the output and reference curves visually overlap almost everywhere
  • the difference plot is small and smooth
  • the failure is limited to tiny deviations near steep features, crossings, or near-zero values
  • the same code passes on one machine but fails on another with very small relative differences

If the curves are visually the same and the mismatch is minor, the issue may be numerical tolerance rather than a real regression.


Check Whether the Failure Is Due to Different Hardware or Software

Before changing anything, compare the environments.

Relevant differences include:

  • CPU architecture
  • BLAS/LAPACK implementation
  • MPI library
  • Python version
  • NumPy / SciPy version
  • compiler and math-library differences
  • QE / VASP / other external-code versions used to generate the reference data

If the reference assets were generated on one machine and CI runs on another, small numeric differences are expected sometimes.

That does not automatically mean the threshold should be relaxed. It means the developer should first confirm that the discrepancy is only numerical.


What The Current Comparison Does

The integration comparison logic checks *.dat files and compares the numeric columns against the reference data.

A few important details:

  • the output and reference file lists must match exactly
  • the data shapes must match
  • the first column is treated as the x-axis and is not used directly in the error check
  • the remaining columns are compared numerically using a tolerance
  • QE and transport failures also generate per-file plots to help visual inspection

So if the failure is only a slight numeric drift, the plot and the reported error values will usually make that obvious.


If The Difference Is Only Numerical

If you inspect the plots and conclude that the output is still scientifically equivalent to the reference, you have two reasonable options.

Option 1: Regenerate the reference assets

This is the better choice if:

  • the new output is still correct
  • the change is expected and stable
  • the old references are no longer representative
  • you intentionally changed the algorithm or dependencies

In that case, regenerate the test assets and publish updated references.

Option 2: Adjust the comparison threshold

This is appropriate only if:

  • the output is visually and scientifically the same
  • the mismatch is due to machine-to-machine numerical variation
  • the current threshold is slightly too strict
  • relaxing it will not hide real regressions

Do not increase tolerances blindly. Keep the change as small as possible and document why it was needed.


Where To Change The Threshold

The threshold used by the CI workflow is currently defined in the integration test entrypoints.

At the moment, the tolerance is hardcoded as:

  • tolerance=0.01

That value is passed into the comparison helper from the suite-specific test file.

Current locations

  • QE integration tests: set in the QE test entrypoint
  • transport integration tests: set in the transport test entrypoint
  • TBmodel integration tests: set in the TBmodel test entrypoint

If CI is failing because of a confirmed machine-dependent numeric drift, update the tolerance in the relevant suite and rerun the tests.

The workflow itself is not reading this threshold from an environment variable right now; it gets the threshold from the test code that CI executes.


Recommended Threshold-Change Workflow

If you think the tolerance needs to be adjusted, use this process:

  1. inspect the plots first
  2. confirm that the difference is only numerical
  3. make the smallest threshold increase that resolves the failure
  4. rerun the failing suite locally
  5. rerun the CI workflow
  6. mention in the pull request that the threshold was adjusted due to machine-dependent numerical drift

A threshold change should always be evidence-based.


When Not To Relax The Threshold

Do not change the threshold if any of the following are true:

  • the plots show visibly different physics
  • output files are missing or added unexpectedly
  • shapes of the arrays differ
  • the failure started after a logic change that could have affected the result
  • the mismatch is large enough that you would not trust the result scientifically

In those cases, debug the code or regenerate references only after understanding the cause.


Practical Debugging Checklist

When an integration test fails:

  1. download the comparison plots from CI or open the local _compare_plots directory
  2. read the failure message carefully
  3. confirm whether files are missing, extra, or shape-mismatched
  4. inspect whether the curves are qualitatively different
  5. decide whether the issue is:
    • a real regression
    • stale reference assets
    • machine-dependent numerical drift
  6. only then choose between:
    • fixing the code
    • regenerating references
    • slightly adjusting the tolerance

Clone this wiki locally