You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
refactor: prototype on-GPU hook path with dual ring buffers #29
Activity
Samfisheryu commentedon Mar 2, 2026
Proposal 1: Dual-Ring Design with One Large Payload Ring Buffer
This is our current Solution 1 for issue #29.
Goal
CUDA Graph replayfast and stable (production-oriented path).Core Architecture
Ring Table: control plane (identity/order/state)Payload Ring Buffer: data plane (raw bytes)S_compute: in-graph model pathS_d2d: out-of-graph persistent copy worker (DtoD consumer)S_d2h: out-of-graph host drain stream (DtoH to CPU)Pre-Barrier Op(in graph): stream-ordered wait gate before computePost-Trigger Kernel(in graph): publish descriptors after computePersistent Copy Kernel(out of graph, launched once): consume descriptors and run DtoD copiesPre-Barrier
Pre-Barrier Opis implemented as stream-ordered waits onS_compute(prefercuStreamWaitValue64).It enforces two conditions before each hook-site compute runs:
Barrier A(source/computation-buffer safety): wait forcopied_seqboundary (DtoD completion)Barrier B(payload-ring space safety): wait forbyte_free/drained_seqboundary (DtoH completion)So this is not a Python-side hook barrier and not a host sync point; it is a stream-level gate in the graph path.
Identity and Mapping
global_seq_no + hook_id.seq, not onlyseq % N).Shared Counters (64-bit atomics)
seq_next: next sequence to allocateproduced_seq: highest sequence published byPost-Triggercopied_seq: highest sequence DtoD-completed by persistent workerdrained_seq: highest sequence DtoH-completed by host drainbyte_resv: payload bytes reserved by producerbyte_free: payload bytes released after DtoH completionSynchronization Contract
S_compute):Pre-Barrier Opwaits (A/B) -> compute kernel ->Post-Triggerwrites descriptor -> release fence -> updateproduced_seqS_d2d):produced_seq-> reads descriptor -> DtoD -> release fence -> updatescopied_seqS_d2h+ host):byte_freeanddrained_seqrelease, consume withacquireIn-Graph vs Out-of-Graph
Pre-Barrier Op(stream wait)Post-Triggerdescriptor publishS_d2dS_d2hSamfisheryu commentedon Mar 2, 2026
Proposal v2 (per-hook ring, no global mapping table)
We propose switching to a per-hook fixed memory region with a local ring (head/tail/commit) instead of a global ring + mapping
table.
Initial sizing plan:
@zhaoyboo will first merges our newest codebase into his branch. And implement this method by reusing some of his codebase