Skip to content

fix(tests): release/ignore Windows ONNX temp-file lock in llada & unet parity tests - #417

Merged
justinchuby merged 1 commit into
mainfrom
fix/windows-tempfile-onnx-lock
Jul 22, 2026
Merged

justinchuby merged 1 commit into
mainfrom
fix/windows-tempfile-onnx-lock

Conversation

@justinchuby

Copy link
Copy Markdown
Member

Summary

  • use TemporaryDirectory(ignore_cleanup_errors=True) for every temporary ONNX model in the LLaDA and UNet parity tests
  • document that ONNX Runtime keeps model files memory-mapped on Windows
  • preserve all inference and parity assertions unchanged

Root cause

ONNX Runtime can retain a memory-mapped handle to the .onnx model on Windows. Temporary-directory teardown then raises PermissionError because Windows does not allow deleting an open file, unlike POSIX.

Verification

  • python3 -m pytest src/mobius/models/unet_parity_test.py src/mobius/models/llada_test.py -q — 3 passed, 4 skipped
  • ruff format --check src/mobius/models/llada_test.py src/mobius/models/unet_parity_test.py
  • ruff check src/mobius/models/llada_test.py src/mobius/models/unet_parity_test.py

lintrunner was also attempted with only these paths; the installed adapter invokes an older Ruff that cannot parse the repository configuration rule RUF067.

ONNX Runtime keeps model files mapped on Windows, causing temporary model cleanup to raise PermissionError. Use cleanup-error-tolerant temporary directories across the LLaDA and UNet parity tests.

Co-authored-by: Copilot <[email protected]>
@github-actions

Copy link
Copy Markdown

🏗️ Architecture Diff

Comparing cce80a4 → 66f5b3c

Model Sub-model Changes Status

No architecture changes detected. ✅


Legend: ⚪ No change · 🔵 Minor (attrs/inits) · 🟡 Moderate (nodes added/removed) · 🔴 Major (interface changed)

@github-actions

Copy link
Copy Markdown

Performance Comparison

Comparing cce80a4 → 66f5b3c

Model Metric Baseline Current Delta
bert (feature-extraction) model_size_bytes 359 KB 359 KB +0.0% ⚪
bert (feature-extraction) num_nodes 60 60 +0.0% ⚪
falcon model_size_bytes 364 KB 364 KB +0.0% ⚪
falcon num_nodes 68 68 +0.0% ⚪
gemma2 model_size_bytes 428 KB 428 KB +0.0% ⚪
gemma2 num_nodes 107 107 +0.0% ⚪
gpt2 model_size_bytes 388 KB 388 KB +0.0% ⚪
gpt2 num_nodes 54 54 +0.0% ⚪
llama model_size_bytes 425 KB 425 KB +0.0% ⚪
llama num_nodes 62 62 +0.0% ⚪
llama (static-cache) model_size_bytes 425 KB 425 KB +0.0% ⚪
llama (static-cache) num_nodes 58 58 +0.0% ⚪
mamba (ssm-text-generation) model_size_bytes 296 KB 296 KB +0.0% ⚪
mamba (ssm-text-generation) num_nodes 98 98 +0.0% ⚪
phi3 model_size_bytes 421 KB 421 KB +0.0% ⚪
phi3 num_nodes 60 60 +0.0% ⚪
phi3 (static-cache) model_size_bytes 421 KB 421 KB +0.0% ⚪
phi3 (static-cache) num_nodes 56 56 +0.0% ⚪
qwen2 model_size_bytes 425 KB 425 KB +0.0% ⚪
qwen2 num_nodes 62 62 +0.0% ⚪
qwen2 (static-cache) model_size_bytes 425 KB 425 KB +0.0% ⚪
qwen2 (static-cache) num_nodes 58 58 +0.0% ⚪
qwen3_5_moe (hybrid-text-generation) model_size_bytes 506 KB 506 KB +0.0% ⚪
qwen3_5_moe (hybrid-text-generation) num_nodes 275 275 +0.0% ⚪
qwen3_5_text (hybrid-text-generation) model_size_bytes 458 KB 458 KB +0.0% ⚪
qwen3_5_text (hybrid-text-generation) num_nodes 129 129 +0.0% ⚪
qwen3_5_vl (hybrid-qwen-vl) model_size_bytes 977 KB 977 KB +0.0% ⚪
qwen3_5_vl (hybrid-qwen-vl) num_nodes 413 413 +0.0% ⚪
t5 (seq2seq) model_size_bytes 836 KB 836 KB +0.0% ⚪
t5 (seq2seq) num_nodes 166 166 +0.0% ⚪
whisper (speech-to-text) model_size_bytes 1008 KB 1008 KB +0.0% ⚪
whisper (speech-to-text) num_nodes 128 128 +0.0% ⚪

No performance regressions.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR makes the LLaDA and UNet numerical parity tests resilient on Windows by avoiding NamedTemporaryFile teardown failures when ONNX Runtime keeps .onnx model files memory-mapped. The parity/inference assertions remain unchanged.

Changes:

  • Replace NamedTemporaryFile usage with TemporaryDirectory(ignore_cleanup_errors=True) and a stable model.onnx path in both test files.
  • Add brief inline documentation explaining the Windows file-lock behavior during ORT session construction.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
src/mobius/models/unet_parity_test.py Writes the temporary UNet ONNX model into a temp dir and ignores cleanup errors to prevent Windows teardown failures.
src/mobius/models/llada_test.py Applies the same temp-dir approach to LLaDA ONNX session creation for Windows compatibility.

with tempfile.NamedTemporaryFile(suffix=".onnx") as handle:
onnx_ir.save(model, handle.name)
session = ort.InferenceSession(handle.name)
# Windows keeps the ORT model file mapped; ignore cleanup errors so the dir can be removed.
# onnxruntime reads the model fully at construction, so the temp file
# can be removed as soon as the session exists.
return ort.InferenceSession(handle.name)
# Windows keeps the ORT model file mapped; ignore cleanup errors so the dir can be removed.
@justinchuby
justinchuby merged commit f56db25 into main Jul 22, 2026
36 of 38 checks passed
@justinchuby
justinchuby deleted the fix/windows-tempfile-onnx-lock branch July 22, 2026 09:22
@codecov

codecov Bot commented Jul 22, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 81.81818% with 4 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/mobius/models/unet_parity_test.py 76.47% 4 Missing ⚠️

📢 Thoughts on this report? Let us know!

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants