Skip to content

harden free-threaded lock ownership - #3009

Merged
Qubitium merged 3 commits into
mainfrom
agent/harden-free-threaded-lock-ownership
Aug 7, 2026
Merged

harden free-threaded lock ownership#3009
Qubitium merged 3 commits into
mainfrom
agent/harden-free-threaded-lock-ownership

Conversation

@Qubitium

@Qubitium Qubitium commented Aug 7, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • require constructor-owned locks for Looper cache state, module wrappers, thread-pool telemetry, and patched autotuners
  • pre-create locks for the known extension registry and create workspace locks once per previously unseen device, with an allocation-free established-key path
  • drain every submitted worker future before propagating any BaseException
  • use built-in dictionary equality while retaining synchronized mutation and iteration snapshots
  • retain best-effort device-handle shutdown while logging ignored close failures at DEBUG level

Why

Several fallback paths dynamically created locks during ordinary API calls or allocated a temporary lock on every workspace lease. That adds overhead and makes free-threaded ownership harder to reason about. Worker collection also used an exception allow-list, allowing a custom BaseException subclass to bypass the drain guarantee while other workers could still be using shared subset state.

The locks remain access-scoped or key-scoped. Worker tasks are still submitted before result collection, so module processing remains parallel.

Validation

  • focused free-threaded lock and concurrency suite — 29 passed
  • coverage-instrumented targeted suite — 41 passed, 1 skipped
  • CUDA workspace contention test — 1 passed
  • changed executable code — 36/36 lines and 8/8 branches covered (100%)
  • Ruff checks on the modified sources and tests — passed
  • repository source audit — 0 lazy lock-attribute checks, 0 setdefault(..., Lock()) factories

github-code-quality[bot]

This comment was marked as resolved.

@Qubitium
Qubitium marked this pull request as ready for review August 7, 2026 03:36

@devin-ai-integration devin-ai-integration Bot 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.

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no bugs or issues to report.

Open in Devin Review

@devin-ai-integration devin-ai-integration Bot 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.

Devin Review found 1 new potential issue.

Open in Devin Review

Comment thread tests/test_triton_patch_api.py Outdated
@Qubitium
Qubitium merged commit 9f4e5ba into main Aug 7, 2026
6 checks passed
@Qubitium
Qubitium deleted the agent/harden-free-threaded-lock-ownership branch August 7, 2026 04:17
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