Repository navigation
Commit 77ade40
Fix two environment-sensitive test failures (qwen_image golden tolerance, Gemma4 cache skip) (#553)
Two unrelated, long-standing failures on `main`. Both turned out to be
defects in the *tests*, not in the product. Suite goes from **8 failed /
4613 passed** to **6 failed / 4621 passed**; the remaining 6 are the
onnx-genai schema-drift failures being fixed in a separate PR.
## Failure 1 —
`qwen_image_test.py::test_deterministic_l4_l5_image_edit_golden`
**Root cause: float32 noise floor, not a numerical regression.**
The failing assertion compares a *pure* PyTorch/diffusers chain against
golden values recorded in #465 on a different BLAS backend — no ONNX
involved — at `rtol=atol=1e-6`.
Evidence gathered before changing anything:
- The divergence is **stable and deterministic**: identical value under
`OMP_NUM_THREADS=1` and `=4`, and byte-identical across runs. Not flaky.
- It is a **single isolated element** moving in the last decimal place
(1.5196e-6), not a broad shift — a logic bug would move many values or
move one a lot.
- Magnitude analysis: these tensors peak near `|x| ≈ 3.3`, where one
float32 ULP is ≈ 2.4e-7. So `atol=1e-6` was only ~4 ULP of headroom for
a chain of one transformer layer + three scheduler steps + a VAE decode.
The observed drift is ~6 ULP.
- The *sibling* golden comparisons in the same test already sit at
6.3e-7 and 5.8e-7 against the same 1e-6 bound — i.e. the whole test was
riding the float32 noise floor and would have tipped over on the next
platform change regardless.
**Fix:** a principled, commented bound of `rtol=1e-5 / atol=5e-6` (~20
ULP at the peak magnitude, ~3x the observed drift) applied to the three
golden comparisons via a shared named constant. That is still two orders
of magnitude tighter than the `1e-4` this same test uses for
ONNX-vs-torch parity, so a genuine logic regression still fails. The
ONNX-vs-reference assertions are untouched.
**On the `Weight '...' not found in the model. Skipped applying.`
warnings** — these are **expected, not a second bug**. The test applies
the *full* VAE state dict to both halves of the split encoder/decoder
package (`apply_weights(vae_package["encoder"], vae_weights)` and again
for `"decoder"`), so each half warns about the other's weights. Verified
by counting: 90 skip warnings, and **no weight name is skipped twice** —
every weight lands in exactly one of the two models, including
`quant_conv` (encoder side) and `post_quant_conv` (decoder side). Noisy,
but correct. No follow-up needed.
## Failure 2 —
`inference_metadata_test.py::TestNativeVlmPackageMetadata::test_cached_gemma_processor_matches_emitted_patch_budget`
**Root cause: a hard assert on optional local Hugging Face cache
state.**
The test reads two artifacts *straight out of the local HF cache*
(deliberately offline-style, like its siblings), but handled absence
badly in both places:
1. `assert cached_config is not None` on
`google/gemma-4-E2B-it-assistant/config.json` — hard failure when
uncached. This value is never used again; it is only a sanity
cross-check that the assistant variant reports `model_type ==
"gemma4_assistant"`.
2. `max(processor_cache.glob("*/processor_config.json"), ...)` on
`google/gemma-4-E2B-it` — would raise `ValueError: max() arg is an empty
sequence` if uncached. This is the artifact the test actually needs.
Neither repo is fetched by the test or vendored; they just happened to
be in the author's cache at #416. Both exist on the Hub, so this is
genuinely environmental/optional, matching how
`_onnx_genai_schema_path()`, the Qwen test and the Phi test in this same
file already `pytest.skip`.
**Fix (surgical, confined to the cache lookup to minimise conflict with
the schema PR):**
- The assistant `config.json` cross-check becomes conditional — **still
asserted when the repo is cached**, skipped as a check when it is not.
- Missing processor config now `pytest.skip`s with an explicit reason
instead of crashing.
**Verified it does not degrade into a silent skip:** I fetched both
artifacts into the cache and re-ran — the test **runs and passes**,
exercising all original assertions including the `model_type`
cross-check and the `(1, 2520, 768)` / `252` patch-budget parity.
Without them it skips cleanly.
## Verification
```
python -m pytest tests/build_graph_test.py tests/cli_test.py src/ -q \
-k "not phi4mm and not apply_weights_unknown" -n auto
```
| | before | after |
|---|---|---|
| failed | 8 | 6 |
| passed | 4613 | 4621 |
Remaining 6 are exactly the out-of-scope
`jsonschema.exceptions.ValidationError` failures in `comfyui_test.py` /
`inference_metadata_test.py`. No new failures.
`lintrunner f --output oneline --all-files` then `lintrunner` → `ok No
lint issues.` Commit is signed off.
---------
Signed-off-by: Justin Chu <[email protected]>
Co-authored-by: Copilot App <[email protected]>
Co-authored-by: Copilot Autofix powered by AI <[email protected]>1 parent 4f7e5c8 commit 77ade40
2 files changed
Lines changed: 30 additions & 11 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1277 | 1277 | | |
1278 | 1278 | | |
1279 | 1279 | | |
| 1280 | + | |
| 1281 | + | |
1280 | 1282 | | |
1281 | 1283 | | |
1282 | 1284 | | |
| |||
1288 | 1290 | | |
1289 | 1291 | | |
1290 | 1292 | | |
1291 | | - | |
1292 | | - | |
1293 | | - | |
1294 | | - | |
| 1293 | + | |
| 1294 | + | |
| 1295 | + | |
| 1296 | + | |
| 1297 | + | |
| 1298 | + | |
1295 | 1299 | | |
1296 | 1300 | | |
1297 | 1301 | | |
1298 | 1302 | | |
1299 | 1303 | | |
1300 | | - | |
| 1304 | + | |
1301 | 1305 | | |
1302 | 1306 | | |
1303 | 1307 | | |
| 1308 | + | |
| 1309 | + | |
| 1310 | + | |
| 1311 | + | |
| 1312 | + | |
| 1313 | + | |
1304 | 1314 | | |
1305 | 1315 | | |
1306 | 1316 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
659 | 659 | | |
660 | 660 | | |
661 | 661 | | |
| 662 | + | |
| 663 | + | |
| 664 | + | |
| 665 | + | |
| 666 | + | |
| 667 | + | |
| 668 | + | |
| 669 | + | |
| 670 | + | |
662 | 671 | | |
663 | 672 | | |
664 | 673 | | |
665 | | - | |
666 | | - | |
| 674 | + | |
| 675 | + | |
667 | 676 | | |
668 | 677 | | |
669 | 678 | | |
670 | 679 | | |
671 | | - | |
672 | | - | |
| 680 | + | |
| 681 | + | |
673 | 682 | | |
674 | 683 | | |
675 | 684 | | |
676 | 685 | | |
677 | | - | |
678 | | - | |
| 686 | + | |
| 687 | + | |
679 | 688 | | |
680 | 689 | | |
681 | 690 | | |
| |||
0 commit comments