Skip to content

R15

What to build

Only one sampler owns a device-wide peak-reset interval at a time.

Source and evidence

Repository scientific/architectural review, snapshot 86c8517, item R15. Classification: confirmed defect; high severity.

PyTorchPeakSampler.start() checks a shared set, invokes the backend reset, then adds the device to that set. The check and claim are not atomic, and an external backend call separates them. Two callers can both reset and become active owners. Stopping either removes the shared ownership entry while the other remains active, allowing further overlapping resets. This contradicts the documented exclusive device ownership needed to keep device-wide peak evidence scoped to one run.

The retained peak ownership probe uses two threads and an injected reset method with a two-party barrier. Both checks complete before either reset returns. Both starts succeed: simultaneous_owners = 2. Each owner is stopped in cleanup. This proves the concurrency defect in the ownership mechanism, not CUDA qualification or the accuracy of any hardware counters. Existing unit and contract tests exercise only sequential ownership conflicts.

Acceptance criteria

  • [ ] A barrier-synchronized two-thread start admits exactly one owner and performs at most one accepted reset.
  • [ ] Reset failure releases the reservation so a later healthy start succeeds.
  • [ ] Stopping one sampler cannot release another sampler's ownership; stop/start races preserve exclusivity.
  • [ ] Different devices can proceed independently and fake backend tests do not claim CUDA qualification.
  • [ ] Preserve Consumer-owned meaning, payload-free evidence, disabled optional-import isolation, safe diagnostics and the non-relaxable Safety Floor.
  • [ ] Run the narrowest observable contract, then applicable committed Make gates. Record every command and outcome; update specifications/compatibility evidence for changed public or wire contracts. Run native Collector verification for changed Collector assets and build for packaging changes.

Design guidance

Reserve an owner token under a short registry lock before calling the backend. Release/rollback only that token; do not hold a global lock across slow unrelated backend work.

Keep prefactoring narrow and verifiable in this slice. Reuse established owners and structural interfaces; introduce a pattern only when it clarifies a real responsibility or variation point. Do not add consumer vocabulary or private payloads to platform code or evidence. Mocked/local results must not claim hosted, production, accelerator or release qualification.

Blocked by

None (can start immediately). Shared-area coordination is useful, but no other review fix is a genuine prerequisite for this slice.

Verification scope

Convert the described counterexample or investigation oracle into an observable test at the lowest suitable public boundary. Prefer bounded operation-count or deterministic interleaving evidence to flaky timing assertions; timing guarantees need a declared tolerance and independently owned cleanup. This ticket authorizes remediation/research, not publication or deployment.