Skip to content

fix(exl3): make slot assignment atomic across processes - #3714

Merged
Qubitium merged 1 commit into
mainfrom
fix/exl3-atomic-slot-assignment
Nov 9, 2026
Merged

Qubitium merged 1 commit into
mainfrom
fix/exl3-atomic-slot-assignment

Conversation

@Qubitium

@Qubitium Qubitium commented Nov 9, 2026

Copy link
Copy Markdown
Collaborator

TL;DR

Make EXL3 assignment publication atomic and add cross-process slot ownership. Concurrent coordinators can no longer overwrite one assignment record or simultaneously lease the same physical coordinator slot.

1. The problem

The old flow checked path.exists() and then used os.replace(). Two coordinators could both pass the check and overwrite each other. Even after assignment publication, slot busy counts were process-local.

Old mechanism Consequence
os.replace(temporary_name, path) in _persist_assignment last writer won
self._busy_slots only two processes could each believe a capacity-one GPU slot was free
losing writer selected from local state both could report new_assignment=True
flowchart TD
    A["coordinator A sees no assignment"] --> C["os.replace"]
    B["coordinator B sees no assignment"] --> C
    C --> D["one file overwrites the other"]
    D --> E["both use process-local busy counts"]
    E --> X["same physical slot leased twice"]
    style X fill:#fee,stroke:#b22
Loading

2. The new flow

flowchart TD
    A["acquire_slot"] --> B{"assignment in local state"}
    B -->|"yes"| H{"local capacity available"}
    B -->|"no"| C["select available slot"]
    C --> D["_persist_assignment"]
    D -->|"os.link succeeds"| E["record new_assignment"]
    D -->|"FileExistsError"| G["_read_assignment"]
    G -->|"missing or invalid"| X["fail closed"]
    E --> H
    G --> H
    H -->|"no"| I["condition wait"]
    H -->|"yes"| J["_acquire_cross_process_slot"]
    J -->|"lock unavailable"| K["timed condition wait"]
    K --> H
    J -->|"lock acquired"| L["return ExecutionSlotLease"]
    L --> M["release local count and FileLock"]
    style X fill:#fee,stroke:#b22
Loading

The same flow and before/after table are committed in docs/exl3-remote-workers.md.

3. Failure contract

Situation Result
Another process publishes first FileExistsError, then authoritative reread and validation
Record disappears after publication conflict RuntimeError
Invalid topology, path, digest, slot, or execution contract ValueError
Cross-process slot lock unavailable timed wait; no lease returned
Lease cleanup local count and FileLock both released

4. Tests

  • test_assignment_publication_is_exclusive_and_resumes_authoritative_slot
  • test_coordinator_slot_lock_is_exclusive_across_processes
  • Existing scheduler, durable resume, transport, envelope, and failure diagnostics tests

Validation

TMPDIR=/dev/shm PYTHONDONTWRITEBYTECODE=1 /root/venv/bin/python -m pytest tests/test_exl3_remote.py -q -p no:cacheprovider -k 'not worker_quantization_resumes_from_its_packed_checkpoint'
16 passed, 1 deselected

ruff check gptqmodel/utils/exl3_remote.py tests/test_exl3_remote.py
All checks passed

The deselected test requires a CUDA JIT build; this host has no CUDA_HOME, so the failure is an environment limitation unrelated to this change.

@Qubitium
Qubitium merged commit 5a861e5 into main Nov 9, 2026
5 checks passed
@Qubitium
Qubitium deleted the fix/exl3-atomic-slot-assignment branch November 9, 2026 12:28

Copy link
Copy Markdown
Collaborator Author

Reviewed: successful assignment publication left a hidden hard link. Reproduced it and opened #3784; the fix removes the temporary name and passes the remote-client tests.

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