Enhance offload cleanup handling for exception cases - #2317
Open
lvliang-intel wants to merge 4 commits into
Open
Enhance offload cleanup handling for exception cases#2317lvliang-intel wants to merge 4 commits into
lvliang-intel wants to merge 4 commits into
Conversation
Signed-off-by: lvliang-intel <liang1.lv@intel.com>
for more information, see https://pre-commit.ci
Collaborator
|
/azp run Unit-Test-CUDA-AutoRound |
|
Azure Pipelines successfully started running 1 pipeline(s). |
Collaborator
|
/azp run Unit-Test-CUDA-AutoRound |
|
Azure Pipelines successfully started running 1 pipeline(s). |
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
The new sweep logic can fail under races (base dir removed mid-sweep) and doesn’t handle out-of-range PIDs safely, and the new test helper’s path lowercasing can leak temp dirs on case-sensitive filesystems.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
This PR fixes disk waste from killed/crashed quantization runs by making OffloadManager proactively remove stale, PID-tagged offload temp directories during startup, while preserving resume and legacy directories.
Changes:
- PID-tags newly created offload temp dirs and sweeps dead-PID dirs before creating a new one.
- Adds
_pid_alive()and_sweep_stale_dirs()helpers to safely detect and remove stale directories. - Introduces unit tests covering stale-dir removal, live/resume preservation, and “no sweep in resume mode”.
File summaries
| File | Description |
|---|---|
| auto_round/utils/offload.py | Adds stale offload dir sweeping + PID-tagged tempdir naming. |
| test/unit/common/utils/test_offload_helpers.py | Adds unit tests validating sweep behavior across stale/live/resume/legacy cases. |
Review details
- Files reviewed: 2/2 changed files
- Comments generated: 3
- Review effort level: Lite
💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Comment on lines
+913
to
+918
| try: | ||
| os.kill(pid, 0) | ||
| except ProcessLookupError: | ||
| return False # no such process | ||
| except OSError: | ||
| return True # e.g. PermissionError -> exists, owned by another user |
Comment on lines
+923
to
+927
| if not os.path.isdir(base_dir): | ||
| return | ||
| tag = f"{self._prefix}_" | ||
| for entry in sorted(os.listdir(base_dir)): | ||
| full = os.path.join(base_dir, entry) |
Comment on lines
+272
to
+278
| def _offload_base(self, tmp_path, monkeypatch) -> str: | ||
| workspace = str(tmp_path).lower() # envs.AR_WORK_SPACE is lowercased | ||
| monkeypatch.setenv("AR_WORK_SPACE", workspace) | ||
| monkeypatch.delenv("AR_RESUME_DIR", raising=False) | ||
| base = os.path.join(workspace, "offload") | ||
| os.makedirs(base, exist_ok=True) | ||
| return base |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
fix: clean up stale offload temp dirs left by killed/crashed runs.
A quantization run that is killed or crashes mid-tuning (SIGKILL, OOM-killer, host reboot) never reaches OffloadManager.cleanup(), leaving its offload temp dir under {AR_WORK_SPACE}/offload/ on disk forever. These dirs are never read by later runs, so they accumulate as pure disk waste.
This PR makes new runs automatically remove leftovers from dead processes, without ever touching data owned by live processes.
Type of Change
Bug fix
Related Issues
None
Checklist Before Submitting
/azp run Unit-Test-CUDA-AutoRound.