Skip to content

Fix: worker-chip region cleanup replay - #1835

Merged
ChaoWao merged 3 commits into
hw-native-sys:mainfrom
ccyywwen:w3-5-followup-review-clean
Aug 14, 2026
Merged

Fix: worker-chip region cleanup replay#1835
ChaoWao merged 3 commits into
hw-native-sys:mainfrom
ccyywwen:w3-5-followup-review-clean

Conversation

@ccyywwen

@ccyywwen ccyywwen commented Aug 14, 2026

Copy link
Copy Markdown
Contributor

Summary

This PR handles the #1770 follow-up items.

Done here:

  • Tighten worker-chip region cleanup shape:
    • replace defensive getattr(region, "expired", ...) with direct region.expired
    • replace defensive getattr(region, "free", None) / callable check with direct region.free()
    • update test fake regions to expose the same cleanup surface as WorkerChipOrchRegion
  • Fix replay double-release:
    • add cleanup-owned chip release tracking separate from user-facing _released
    • mark chip release committed only after control_worker_chip_region_release(...) succeeds
    • allow close replay to retry native host mapping close without releasing the same chip region twice
    • add a whole-tree close regression test for mapping-close failure plus successful chip release

Already handled in #1822:

  • W4 region sync/access refactor onto neutral region-native primitives
  • WorkerChipOrchRegion compatibility facade over W4 region access pieces
  • neutral native mapped-region backend and _region_* binding surface
  • redundant provider root check cleanup in validate_single_owner_region_shape

Not done here:

  • post-W4 comm_region.py hygiene
  • public create_region(...)
  • W5 delegated transactions
  • queue/ring/mailbox/freelist templates
  • Symmetric/OpenSHMEM topology

- Use the WorkerChipOrchRegion contract directly during cleanup
- Require test fake regions to expose the same expired/free surface
Track cleanup-owned chip release separately from user-facing region release. A replayed close now retries the native host mapping close without returning the same chip region twice.
@coderabbitai

coderabbitai Bot commented Aug 14, 2026

Copy link
Copy Markdown

Review Change Stack

Important

Review skipped

Auto incremental reviews are disabled on this repository.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: f5c465db-31d6-4546-893f-3db7bb18ee04

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 000c45d5-8f99-4e30-a2af-8c371336c187

📥 Commits

Reviewing files that changed from the base of the PR and between 87d9d0e and d812b00.

📒 Files selected for processing (4)
  • python/simpler/worker.py
  • python/simpler/worker_chip_orch_comm.py
  • tests/ut/py/test_worker/test_comm_region.py
  • tests/ut/py/test_worker/test_worker_chip_orch_comm.py

📝 Walkthrough

Walkthrough

Worker-chip cleanup now uses public expiration state and explicit release tracking. Failed host mapping closure remains retryable, while committed chip release and region freeing occur only once. Tests cover repeated Worker.close() behavior after an initial mapping-close failure.

Changes

Worker-chip cleanup

Layer / File(s) Summary
Cleanup state and release flow
python/simpler/worker.py, python/simpler/worker_chip_orch_comm.py, tests/ut/py/test_worker/test_comm_region.py
WorkerChipOrchRegion tracks committed chip release. _close_worker_chip_region uses expired, releases chip ownership once, and frees the region after commitment. WorkerHostRegionMapping.close remains open when native closure fails.
Cleanup retry validation
tests/ut/py/test_worker/test_worker_chip_orch_comm.py
The regression test verifies that repeated Worker.close() retries mapping cleanup and does not repeat L2 release.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Merge Risk: ⚪ Minimal · up to d812b

The PR adjusts worker-chip cleanup replay and preserves retryable host-mapping closure behavior; no actionable merge-blocking risk remains beyond normal checks and review.

Possibly related PRs

Poem

A rabbit checks the closing flow,
One release marks the work complete.
Failed mappings wait and try once more,
While freed chip regions sleep neat.
Hop, hop—cleanup stays discrete!

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
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.
Title check ✅ Passed The title clearly and concisely describes the worker-chip region cleanup replay fix.
Description check ✅ Passed The description directly explains the cleanup contract changes, replay behavior, release tracking, and regression test.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@ccyywwen
ccyywwen force-pushed the w3-5-followup-review-clean branch from 80d255b to 17e71fc Compare August 14, 2026 07:03
@ccyywwen
ccyywwen force-pushed the w3-5-followup-review-clean branch from 17e71fc to b9ccf01 Compare August 14, 2026 07:23
@ChaoWao
ChaoWao merged commit 95b2812 into hw-native-sys:main Aug 14, 2026
19 checks passed
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