Skip to content

Add unit test for checking any leak of temporary augmented onnx files, on exception during ONNX INT4 AWQ quantization#1383

Open
vishalpandya1990 wants to merge 1 commit intomainfrom
vipandya/int4_temp_file_fix_test
Open

Add unit test for checking any leak of temporary augmented onnx files, on exception during ONNX INT4 AWQ quantization#1383
vishalpandya1990 wants to merge 1 commit intomainfrom
vipandya/int4_temp_file_fix_test

Conversation

@vishalpandya1990
Copy link
Copy Markdown
Contributor

@vishalpandya1990 vishalpandya1990 commented May 3, 2026

What does this PR do?

Type of change: New unit test

  • Adding a unit test for checking whether ONNX INT4 AWQ quantization, on exception, leaks temporary augmented ONNX files it created during quantization process.

  • Monkey patches create-inference-session to raise / simulate exception. Monkey patches temp-filep-creation utility to track temp files created during quantization process.

  • It is a follow up to fix made in to Ensure removal of temp files on error in ONNX INT4 quantization #1359 - here.

Testing

  • Local test run.

Before your PR is "Ready for review"

Make sure you read and follow Contributor guidelines and your commits are signed (git commit -s -S).

Make sure you read and follow the Security Best Practices (e.g. avoiding hardcoded trust_remote_code=True, torch.load(..., weights_only=False), pickle, etc.).

  • Is this change backward compatible?: ✅ / ❌ / N/A
  • If you copied code from any other sources or added a new PIP dependency, did you follow guidance in CONTRIBUTING.md: ✅ / ❌ / N/A
  • Did you write any new necessary tests?: ✅ / ❌ / N/A
  • Did you update Changelog?: ✅ / ❌ / N/A

Additional Information

Summary by CodeRabbit

  • Tests
    • Added regression test to verify temporary files are properly cleaned up during ONNX quantization operations.

… during onnx int4 awq quantization

Signed-off-by: vipandya <vipandya@nvidia.com>
@vishalpandya1990 vishalpandya1990 requested a review from ajrasane May 3, 2026 15:17
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 3, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 5869b0a3-4dcb-4165-bb07-71af273bba20

📥 Commits

Reviewing files that changed from the base of the PR and between 9d2e608 and 8ed7250.

📒 Files selected for processing (1)
  • tests/unit/onnx/quantization/test_quantize_zint4.py

📝 Walkthrough

Walkthrough

The PR adds a parametrized test that verifies temporary files are cleaned up properly when the int4 quantization flow encounters an injected RuntimeError during ONNX Runtime session creation. The test monkeypatches file system and quantization module calls to track temp paths and validate their deletion.

Changes

Int4 Quantization Temp File Cleanup Test

Layer / File(s) Summary
Imports
tests/unit/onnx/quantization/test_quantize_zint4.py
Adds tempfile (as _tempfile) and pytest imports to enable monkeypatching and test setup.
Test Implementation
tests/unit/onnx/quantization/test_quantize_zint4.py
New parametrized test test_awq_no_temp_file_leak with calibration_method=["awq_lite","awq_clip"] and use_external_data_format=[True,False] monkeypatches mkstemp to record created temp paths and create_inference_session to raise RuntimeError, then asserts all tracked files and associated _data files are removed from disk after the exception.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~15 minutes

🚥 Pre-merge checks | ✅ 5 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 25.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and specifically describes the main change: adding a unit test to verify no temporary file leaks occur during ONNX INT4 AWQ quantization when exceptions occur.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Security Anti-Patterns ✅ Passed PR adds a single unit test for temporary file cleanup in INT4 AWQ quantization without introducing security anti-patterns like unsafe deserialization, code execution, or unvalidated dependencies.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch vipandya/int4_temp_file_fix_test

Tip

💬 Introducing Slack Agent: The best way for teams to turn conversations into code.

Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.

  • Generate code and open pull requests
  • Plan features and break down work
  • Investigate incidents and troubleshoot customer tickets together
  • Automate recurring tasks and respond to alerts with triggers
  • Summarize progress and report instantly

Built for teams:

  • Shared memory across your entire org—no repeating context
  • Per-thread sandboxes to safely plan and execute work
  • Governance built-in—scoped access, auditability, and budget controls

One agent for your entire SDLC. Right inside Slack.

👉 Get started


Review rate limit: 9/10 reviews remaining, refill in 6 minutes.

Comment @coderabbitai help to get the list of available commands and usage tips.

@vishalpandya1990 vishalpandya1990 changed the title Add unit test for checking any leak of temporary augmented onnx files, on exception, during ONNX INT4 AWQ quantization Add unit test for checking any leak of temporary augmented onnx files, on exception during ONNX INT4 AWQ quantization May 3, 2026
@codecov
Copy link
Copy Markdown

codecov Bot commented May 3, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 76.98%. Comparing base (9d2e608) to head (8ed7250).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1383      +/-   ##
==========================================
+ Coverage   76.97%   76.98%   +0.01%     
==========================================
  Files         471      471              
  Lines       50510    50510              
==========================================
+ Hits        38881    38887       +6     
+ Misses      11629    11623       -6     
Flag Coverage Δ
unit 52.84% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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.

1 participant