Files
kangguangli a728169447 feat(peer): Unify peer prefix sharing and fence late DMA writes after cancellation (#4056)
<!-- Headings and layout are optional. Include change context and
validation
(checks performed or planned, or why testing was not run or is not
applicable)
anywhere in the description. -->

## Summary

<!-- What changed and why? -->
Unify peer prefix sharing for single-member DP replicas and sharded
TP/KVP replicas. Both use registered layouts and the same discovery,
offer, grant, and release protocol. Remove the legacy same-layout driver
and its Lookup/`Pin`/`Release` handlers. Disk pushes now require an
active offer matching the holder incarnation and offer ID.
Decouple request cancellation from transfer retirement. A cancelled
request can return immediately. A late PeerFetchDone is matched to its
original lease and cannot publish the cancelled prefix or terminate the
engine. Once the reader irrevocably discards the result, the holder may
reuse source KV pages within the registered arena. The reader keeps
destination pages reserved until the transfer retires.
When the backend cannot confirm retirement, use
TOKENSPEED_PEER_READ_RETIREMENT_BOUND_MS (default 300000), followed by
the destination quarantine. This assumes that every physical memory
access completes within the bound after the last possible submission,
including queued work, retries, and remote writes. The hardware worst
case was not measured.

## 300-second retirement bound
TOKENSPEED_PEER_READ_RETIREMENT_BOUND_MS defaults to 300000. The
deployment must guarantee that the time from the final permitted batch
claim to the last possible memory access is within this bound. That
interval includes host scheduling pauses, native and device queues,
retries, reconnects, and accepted remote Disk pushes. Packet TTL alone
does not establish it. The smoke tests exercised the protocol and
measured transferred bytes. They did not establish a hardware worst-case
latency.

For an uncertain transfer, each reader member measures the bound on its
own monotonic clock, starting at the earlier of the attempt being sealed
and its 30-second submission window closing. Once all members report
retirement, the reader observes the existing 5-second target quarantine
before reuse. Confirmed clean completions retain their fast path.
Reusing a registered source slot after abort still requires its backing
memory and registration to remain valid.

## Test Plan

<!-- How was this validated? -->
[x] Passed all 372 control-library tests, plus 4 dual-engine tests, 4
DFLASH Disk tests, 9 general Disk integration tests, and the host
configuration test. Re-ran the 9 Disk integration tests on an MLP
worker.
[x] Model-checked source reuse after abort, missing callbacks, late
completions, and staging-slot reassignment. The model reproduced a late
write into a reused target when the configured bound was shorter than
the DMA tail.
[x] Ran four end-to-end smoke cases on Ascend 910B job psxf6xrtsp7nea
with two TP8/KVP8 Prefill replicas and one two-node DP32 Decode
deployment. All four requests generated 8 tokens.

---------

Signed-off-by: lvyongkang <kangguangli@hotmail.com>
2026-12-02 13:36:32 +08:00
..