Companion to selene.proto, which is normative for fields. This
file defines who may do what, in which order, and what each party must prove before memory
is reused. The manager implements the manager side of each flow (section 12 lists what it serves);
the instance side (crate flare-selene, module flare_selene::pool in selene/src/pool/)
implements the other.
The rules the protocol rests on. The numbered sections give their mechanics and cite them by number.
- One stream per instance.
Hellois a stateless unary call; everything else rides one bidirectionalSessionstream per instance process and scope; only the peer ranks of a multi-process instance addRankstreams (section 13). The stream's order is the only ordering the protocol needs. - Incarnations.
manager_incarnationis a random nonzero 64-bit value picked at manager start.session_incarnationis assigned by the manager atSessionOpenedfrom a counter, so a client cannot forge or reuse one.instance_idis stable across restarts: BLAKE2b-128 over the pool name, model identity, layout fingerprint and the sorted UUIDs of the instance's GPUs. Instances on one host use disjoint GPUs, so it is unique per host. A process is told apart by a randomprocess_nonce(fresh per process, unchanged across a reconnect) and by the session incarnation. A new session for a knowninstance_idsupersedes the old one: the newer incarnation wins, the older is fenced, and the old session's index entries are removed at once; the new session's snapshot announces its holdings chunk by chunk (section 3). - Encryption is declared, not negotiated. The client selects its connection
mode before connecting; see address forms and trust.
For TCP clients,
Hello.encryptionmust equal what the client connected with, else instance startup fails with an encryption-mode error. Unix-socket clients trust filesystem permissions and accept either network mode. RDMA is not listed indata_transportswhen the manager is TLS. - Same host is proven by the socket; levels.
shared_memoryis returned only on a Unix-domain socket whose peer uid and gid match the manager's and whose exit can be watched: a nonzero peer pid, or a pidfd fromSO_PEERPIDFD(Linux 6.5+). A pid-zero peer without that descriptor receives no shared memory; on older kernels, share a PID namespace or configure--listenand connect over TCP for the data channel. A session without shared memory usesDATA_CHANNELonly. It may be an export source when the manager serves a data channel: its windows are relayed through the manager (section 7.5). Instance-sourced candidates (neighbour GPU = level 2, neighbour DRAM = 3, neighbour NVMe = 4) are offered to every session, whether the copy goes through shared windows or through the manager's relay. Manager-store candidates are offered to every session: a same-host manager chain is level 3 when every record the claim reads is in DRAM, and level 4 when any requires NVMe. A remote manager's records (DRAM or NVMe) are level 5. The candidate'stieris the endpoint's tier; its level reflects the slowest tier read from the requester's perspective. - Content keys. A source pins ready content by its scoped prefix key and validates the chain shape. Index entries are hints: late evictions can remove a fresh hint and cause a miss, but cannot grant ownership or change bytes.
- COPIED is the requester's word, and only after exact coverage (section 5).
Everything else terminal is
FAILED. - Window ownership and reclaim. A window passes manager, source, requester,
manager. Each acknowledgment clears only the sending party's obligations
(
ExportEnd,FenceAck,WindowReleased,Goodbye{quiesced}are all per-party). Memory is reclaimed only after every party that could have touched it has drained (section 7). - Claim and put ids are requester-chosen and strictly increasing per
(instance_id, process_nonce). The manager keeps a high-water mark per
(instance, process) and refuses any id at or below it (
INVALID_CLAIM, orPutRefused{INVALID}), which is what makes a replayedClaimharmless after its record has expired (section 5). - Fence-class messages cross sessions.
FenceAck,ExportEnd,WindowReleasedandClaimReleaseare resolved by (instance_id, process_nonce, id) and are accepted from any current session of the same process, because the accesses they speak for outlive the stream that started them. A session of a different process (a restarted or competing one) never attests for another process's accesses; those windows and pins wait for the old process's exit (section 7.4). - Readiness follows recovery. The manager serves lookups, claims and puts once its own NVMe scan completes. Sources reconnect and announce independently; a missing or partial source index can cause a miss, never grant a pin.
- Transfer cost uses the requester's rolling bandwidth for each copy level, seeded until a restore completes. The manager does not report per-source estimates.
- Logical split versus physical page offset.
Claim.begin_tokensis the resident prefix end and need not be page-aligned. The source supplies pages fromfloor(begin_tokens / page_tokens)tofloor(key.consumed_tokens / page_tokens)plus the row, the same flooring Flare'sMatchuses. Zero pages with the row is a legal row-only tail. A candidate'sbegin_tokensis likewise exact; itsskip_pagesis the physical offset into the first record. - Claims run after admission, inside
fetch(PooledStore::fetchinselene/src/pool/store.rs). Lookup is asynchronous while a request queues; claims start when the scheduler has reserved the ticket. A failed claim drains before reporting failure; the request recomputes, or uses a local copy of the same endpoint when available. - GPU exports need retained staging first. A
GPU-tier export is accepted only after staging for the whole export is
reserved: the manager reserves it from the index's size before sending the
ExportRequest(reserved_bytes), and the source compares the chain it pinned against it before answering: a larger chain is unpinned and refused, never acknowledgedPINNED. Otherwise the claim failsNO_WINDOWSat once. The GPU pin is therefore bounded by the D2H, never by the requester's pace. Host-tier sources (DRAM, NVMe) may stream withwindow_credits. - Export slots are per instance. An export touches every rank, so the per-GPU count (default 2) is also the per-instance count. The same default bounds claims in flight per requester. A quarantined export keeps its slot.
- Headroom is counterfactual. The source's check applies Flare's own
eviction rules (leaf eviction needs
pins == 0; compaction needs no direct pin and exactly one remaining child; snapshot aliasing) to the cache with the export pinned, subtracts the resources the pin protects once, and uses the reservation arithmetic that admission uses, never a copy of it. - Put is part of the protocol. The eviction cascade ends in a write into the manager's store. A DRAM retirement transfers its path root-first. Each predecessor must be confirmed before its child starts. Failed puts release the selection and retain the source path. Claims pin their source through the last transfer window. The model worker continues serving.
- Entries die with their session; its successor announces its own. When a
session ends, with or without a successor, the manager removes every entry it
announced. When a new session opens for the same
instance_id, the old session's entries stop being offered at once (its source session is stale: a claim naming it isSTALE_SOURCE), and the new session's snapshot chunks are applied as they arrive (section 3), so a lookup can see a partial snapshot. A restarted instance re-announces what its local tiers recovered under the same id. - Lookup input is bucket-keyed. The request carries the history's aligned
boundary keys (capped); the manager returns candidates from the matching
buckets and the client re-verifies each node with
history.key_at. - Data-channel framing is outside this contract. Only the invariants in
DataChannelRefand section 7 are fixed here. - Persisted checksums. A DRAM or NVMe export serves the checksums committed with the record, never hashes of the bytes just read; the manager validates every page and row. A restore never reads a whole record from NVMe into DRAM: a window read from NVMe into staging is served as it was read, with the persisted checksums, and the requester's check is the only one. The manager validates Put metadata against the accepted geometry, scope identity, parent, length and its own verification of the received payload before indexing. Only a GPU source, having no stored checksum, hashes what it wrote.
- Ticket handling. The pool lookup ticket (
LookupTicket,selene/src/pool/lookup.rs) belongs to one request; the Helios worker clears it explicitly at admission, not by dropping theIncoming(which moves intoActive). A ticket whose answer is still pending at admission stays with the admitted request. The worker drops it when the request has submitted prefill or carries conditioned inputs, or when the answer arrives without a longer prefix; an answer with a longer prefix is used for one readmission. Candidates are validated against the request's complete held plan, not GPU residency alone.
An instance is a SOURCE (announces entries, serves exports), a REQUESTER (looks up, claims, copies) and a WRITER (puts) on one session. The manager is the index, the broker of claims and windows, the owner of the shared-memory regions and of its own DRAM/NVMe store.
Scope is (pool_name, model_identity, layout_fingerprint, geometry). The manager
supplies its configured name in Hello; OpenSession supplies the model and
geometry. The manager keeps one index and one set of claims per scope_id;
no message can name another. A claim whose source belongs to another scope is
UNKNOWN_SOURCE, which is what an unknown name answers too. Rank geometry is part
of the scope, so TP widths never share records.
Every message after open carries Header{manager_incarnation, session_incarnation}. Receivers drop messages with a wrong manager incarnation.
The manager closes the stream (SessionClosing{CLOSING_STALE_SESSION}) on a wrong session
incarnation, except for the fence-class messages of decision 9.
client manager
| Hello{protocol} ------------->|
|<---- HelloReply{status, incarnation M, encryption, readiness, limits, shm?}
| check: status ok, encryption == connected_with
| Session stream open |
| OpenSession{M, instance_id, scope, slots} --->|
|<---- SessionOpened{S, scope_id, slots}
| check: scope_id equal
| ResyncBegin / Chunk* / End (may be empty) -->| applies hints live
|<---- ResyncAck
| NoticeBatch ... ----------------------------->|
| Lookup / Claim / Put at any time after open (when READY)
STALE_MANAGER: the manager restarted between Hello and open. Redo Hello.- A second
Sessionfor the sameinstance_idsupersedes the first: the newer incarnation wins. The manager sendsSessionClosing{CLOSING_SUPERSEDED}on the old stream and treats it as lost (section 8.5). Two cases, told apart byprocess_nonce: the same nonce is a reconnect after a blip (the old stream's fence-class messages stay valid on the new session); a different nonce is another process (a restart, or two processes started with the same GPUs): the older process is fenced, nothing it attested is trusted from the new process, its windows stay quarantined until its exit is confirmed, and its pins are its own to release when it exits. Goodbye{quiesced=true}is the only close that lets the manager stop waiting for THIS process's acknowledgments: it clears only this party's obligations. A window or pin that the opposite party of a claim may still touch is reclaimed only after that party has drained too (section 7.2). Any other end of the stream is a disconnect. A source sendsExportEndfor every export before a quiescedGoodbye; a quarantined export keeps its pin and makesquiescedfalse.- Reconnect uses exponential backoff with a cap (100 ms doubling to 1 s); no more
than one Hello in flight. While disconnected the client is in
Localstate (PoolStatus::Local,selene/src/pool/shared.rs).
Each session announces its GPU, DRAM and NVMe holdings. Notices upsert, spill or evict hints on the ordered control stream. Every claim validates and pins the actual source before copying; the index grants no ownership.
A snapshot consists of Begin, bounded chunks and End. Begin clears this source's hints; each chunk is applied live. End is acknowledged. Lookups may see a partial snapshot and miss during this short interval. A second Begin clears a partial predecessor too. Session supersession and disconnection remove that session's hints.
The client takes holdings and clears its unsent queue under one lock. Changes after that cut follow the last snapshot chunk. Queue overflow or lost GPU eviction notices request another snapshot without blocking the worker. Entry, chunk and batch bounds are enforced. The stream's order is the only ordering: the protocol has no notice sequence numbers, delta buffers, watermarks or snapshot timeout.
Request: the history's aligned boundaries, before_tokens, resident_tokens.
The manager answers from its index only; it never contacts a source.
Manager algorithm for each candidate source entry (endpoint E with a row):
- Skip the requester's own instance and sources the requester cannot reach (decision 4), including sources with no export slots. Busy sources are eligible.
- Compute the initial level from the endpoint's tier and the relation to the requester.
begin=resident_tokens(exact, not page-aligned); the physical start isfloor(begin / page_tokens). Walk parents fromEto the node containing that page and require a contiguous chain. A hole gives no candidate. Manager chains may mix DRAM and NVMe; instance chains must stay in one tier. For a same-host manager, use level 4 if any record the claim reads requires NVMe; otherwise use level 3. The candidate'stierremains the endpoint's tier.- Drop it if it supplies no page and no row beyond
begin(zero pages with the row is kept: a row-only tail). - Order by longest match, then fixed copy level and stable source identity; return at most
max_candidates, each with at mostmax_chain_nodesnodes.
Answers: LOOKUP_OK, LOOKUP_NOT_READY (with retry_after_ms),
LOOKUP_OVERLOADED (the session already has max_concurrent_lookups lookups
waiting; answered at once, never queued), LOOKUP_INVALID.
The requester treats every non-OK answer, a timeout, and a lost session as "no
pool candidates for this attempt" and can admit with its local match. A queued
request whose ticket has no answer retries the lookup when selected for
admission. Each request owns its lookup ticket.
A candidate is a hint. After the reply the client verifies each node against its
history; any mismatch drops the candidate. Lookup reserves no export slot: another
claim can fill the source between lookup and claim, causing SOURCE_LIMIT. The
client retries that refusal within the restore's size-scaled deadline;
a temporarily busy source does not cause a recompute. A quarantined export keeps
its slot until drained or its process exits. Pending host writes are not announced
as ready holdings; a GPU holding can be offered while its separate host copy is
in flight.
The manager holds one record per claim, keyed (instance_id, process_nonce, claim_id), mutated only by the manager's single claim task (so "one authoritative transition" is a compare-and-set on that task, not a lock). Ownership and replay tracking are separate:
- Fence records live until every party that could have touched the claim's memory has drained or its process has exited, however long quarantine lasts.
- Replay tracking uses a per-(instance, process) high-water mark. Reusing a
claim id is refused
INVALID_CLAIM, without starting another lifecycle. Fence acknowledgments resolve through the fence records kept for their memory. A process entry is dropped after exit and after its final fence record is gone.
Claim
(none) ---------------------------> REQUESTED
| refused at once: NOT_READY, REGIONS_HELD, RANKS_DETACHED, CLAIM_LIMIT,
| SOURCE_LIMIT, UNKNOWN_SOURCE, STALE_SOURCE, INVALID_CLAIM, CHAIN_GAP,
| NO_WINDOWS ==> FAILED (ClaimTerminal, fence_required=false)
REQUESTED --pin held, grant sent--> GRANTED
GRANTED --exact CopyResult COPY_OK--> COPIED
any non-terminal --> FAILED refusal, loss, cancellation, copy error,
deadline or no-progress timeout (reason preserved)
Terminal means COPIED or FAILED. The first transition into a
terminal state wins and is final; later events for the claim only cause
idempotent replies and fence bookkeeping. On entering a terminal state the
manager, in this order:
- records the state and reason;
- sends
ClaimTerminalto the requester once; - sends
ExportCancelto the source if its export has not ended; - stops the data-channel transfer if any;
- starts fence tracking (section 7).
Only the requester's CopyResult{COPY_OK} makes COPIED. The manager accepts
it only on exact coverage of the granted records: the windows issued, filled
and released together cover every page of every record in records and the
endpoint row if granted, once each, with no hole and no duplicate (for streamed
host-tier claims, after the last window has been issued, not merely after all
windows issued so far were released); on the data channel, the transfer ended
with exactly total_pages pages and the row. Anything else becomes
FAILED{COPY_ERROR}. The requester performs the same coverage check on its side
before sending COPY_OK.
Manager-store sources have no export: the manager takes its own reference
on the record inside Claim handling before granting it, so
refusals (record evicted) are immediate and identical on the wire.
requester manager source (model worker via poll)
Claim ---------->| checks; reserve retained staging for the whole export
| (none available: FAILED NO_WINDOWS at once); REQUESTED
| ExportRequest{reserved_bytes}->| poll -> worker:
| | revalidate chain, headroom, pin_checkpoint; then size <= reserved
|<------------------ PinAck PINNED{records}
| pin held; allocate windows
<--ClaimGranted--| GRANTED (the hold is in force)
| ExportFill{windows} --------->| D2H into windows (lowest-priority stream)
|<------------ WindowFilled{i, xxh3} (after the D2H drained)
<--WindowReady---| GRANTED
H2D from window i
WindowReleased-->| (after H2D drained)
|<------------ ExportEnd{EXPORT_COMPLETE, DRAINED} (pin released after last fill)
CopyResult OK -->| COPIED
<-ClaimTerminal--| fence_required
FenceAck DRAINED>| windows freed once source also ended
The requester gives up (deadline of its own) while the export is in flight.
requester manager source
Claim ------>| REQUESTED, ExportRequest ->| queued in poll
ClaimRelease>| FAILED{CANCELLED}
<ClaimTerminal| ExportCancel ------------>|
| | case A: request not started -> drop,
| | PinAck REFUSED{CANCELLED}, no ExportEnd
|<--- PinAck PINNED (crossed) | case B: pin done, ack sent before the cancel
| late pin: terminal claim | was processed -> manager re-sends
| ExportCancel (idempotent) ->| ExportCancel; source unpins after in-flight
| | copies drain, ExportEnd{EXPORT_RELEASED}
|<------------ ExportEnd ----|
| export slot freed | case C: cancel processed between pin and ack
| | -> unpin, PinAck REFUSED{CANCELLED}
Source rule: exactly one PinAck per ExportRequest; if it is PINNED, exactly
one ExportEnd later. The manager frees the source's export slot on PinAck REFUSED, on ExportEnd, or on session loss while the export is still
Requested, never on its own terminal transition (the source may still hold
the pin). Session loss ends an unanswered export and releases its slot: no copy
windows were issued, and pin_ack accepts an acknowledgment only while the
export is Requested. The source may still hold a pin it acknowledged on the
lost session for as long as it remains stalled; it releases the pin after it
resumes and drains. That pin has no windows, so fencing is unaffected. A PINNED
ack for a terminal claim never produces a grant.
ClaimGranted arrives at a requester that has already released the claim, or
that does not know it (restarted, or the claim was cancelled and forgotten).
- The requester never touches the windows of a claim it does not hold. It
ignores
ClaimGrantedandWindowReadyfor such a claim. - It answers the following
ClaimTerminal, when that setsfence_required, withFenceAck{DRAINED}at once (it has no accesses to drain). For a claim id it has never heard of it does the same. If it already started a copy before releasing, it drains first. - A requester that restarted is another process under the same
instance_id(decision 2); the manager fails the old process's claims withREQUESTER_LOSTwhen its stream ends or is superseded (section 8.3).
| Message | Duplicate or late arrival |
|---|---|
Claim with a reused id |
refused INVALID_CLAIM |
ClaimRelease |
no effect once terminal; unknown id answered ClaimTerminal{FAILED, UNKNOWN_CLAIM} |
WindowReleased |
each (claim, index) returns its credit once |
CopyResult |
first one counts; others ignored |
FenceAck, ExportEnd |
first per (claim, party) counts |
PinAck |
counts only while the export is Requested; PINNED for a terminal claim triggers ExportCancel; ignored after session loss ends the unanswered export |
ExportCancel |
idempotent; unknown export answered ExportEnd{EXPORT_RELEASED, DRAINED} |
NoticeBatch |
applied in stream order |
PutCancel |
idempotent |
Nothing promises exactly-once delivery across a process death; every state above is recoverable by timeout.
An ExportRequest reaches the instance's pool client. Its I/O thread refuses a
request bound to another session (STALE_SOURCE) and one it cannot serve: no
memory to fill for it, the instance's own export slot count reached, or the
client closing (SOURCE_BUSY; the manager's own pre-check answers
SOURCE_LIMIT). It hands any other request to its owner:
- GPU tier: delivered through
pollto the model worker asStoreEvent::ExportRequested. On the worker, atomically (one scheduler step,serve_exportinhelios/src/server/runtime.rs):- resolve the ready checkpoint by its scoped key; otherwise refuse
NOT_FOUND; - verify the chain from the physical start (
floor(begin_tokens / page_tokens)) is contiguous and has the row if wanted (CHAIN_GAP); - run the headroom check (
RequestScheduler::export_fits); refuseNO_HEADROOM; pin_checkpoint(id). The refusal is returned at once. It never waits for pages to appear. The pool client then compares the pinned chain's size withreserved_bytes: a larger chain is unpinned and answeredREFUSED{NO_WINDOWS}before any window is filled.
- resolve the ready checkpoint by its scoped key; otherwise refuse
- Host tiers (DRAM, NVMe):
PooledStore::poll, which the model worker calls, takes a reference on the record chain from the local tier (TierStore::pin_export) and answers. NoStoreEventreaches the scheduler and no headroom check runs; the windows are filled on a host copy thread.
After PINNED the source waits for ExportFill. A GPU export receives all its
windows in one ExportFill (retained staging was reserved before the pin), so the
pin lasts only for the D2H. It copies each window (GPU: D2H on the lowest-priority
copy stream, behind the instance's own restores and offloads; host: memcpy of the
record bytes, with the persisted checksums, decision 21), and sends WindowFilled
only after the copy has drained. It releases the pin after its last fill, on
ExportCancel, on session loss, or on a failed fill, and reports
ExportEnd{fence = DRAINED} once the pin is released. A DMA already submitted is
never revoked: cancellation lets it drain first.
If the source cannot prove a copy drained it sends ExportEnd{fence = QUARANTINED}
and keeps the pin (a GPU checkpoint stays pinned until the process exits;
unpinning memory a DMA may still read is never allowed). QUARANTINED does not
release the export slot.
If the source sees its session lost it releases pins itself after draining and
reports ExportEnd on the next session.
A source without shared memory (a TCP session) is asked the same way, and the request also
carries channel: a data-channel reference for this export. After PINNED the source connects to
it and writes the windows there, in the direction of a put (section 7.5). The manager sends it no
ExportFill and expects no WindowFilled: each window is granted on the channel, the source copies
it (GPU: D2H into a slot of its own registered staging; host: the persisted bytes) and writes it
with the checksums it states, and ExportEnd follows as for any source. The pin is released once
every copy has drained, exactly as for a source with shared memory; the manager's windows are
written only by its own handler, so they are not the source's to fence.
- Logical invalidation stops new work and rejects stale messages: a new
session_incarnation, a terminal claim state, a cancelled export. It says nothing about copies already running. - Physical fencing is the only thing that allows memory to be reused. Memory (windows, staging, GPU pins, registered regions) returns to service only after every access to it has provably stopped.
Fence parties for a claim: the requester (its reads of windows or its receive
buffers), the source (its writes into windows, its GPU pin), and the manager (its
data handler and registered regions). The manager reuses memory only when every party
that could have touched it is DRAINED; each acknowledgment (ExportEnd,
FenceAck, WindowReleased, Goodbye{quiesced}) clears only the sending party's
obligations, never another party's. A source finishing does not free a window the
requester is still reading, and a requester finishing does not free one the source
is still writing.
FREE --ExportFill--> SOURCE_WRITE --WindowFilled(OK)--> REQUESTER_READ --WindowReleased--> FREE
(manager) (source) (source drained) (requester) (requester drained)
- A window is
SOURCE_WRITEuntil the source says it drained its write. It isREQUESTER_READuntil the requester says it drained its read. WindowFilledmeans the D2H/memcpy completion was observed, so the requester may read;WindowReleasedmeans the H2D/memcpy completion was observed.- A manager-store DRAM source serves ARENA windows aliasing immutable bytes: no
SOURCE_WRITEphase. NVMe sources are read into STAGING by the manager first. - At terminal, a window in
SOURCE_WRITEneeds the source's fence (ExportEndwithDRAINED); one inREQUESTER_READneeds the requester'sFenceAck; aFREEwindow needs nothing. Windows are reclaimed individually. - A window is reclaimed when the last party that held it has drained. The cases:
| State when the claim ends | Reclaimed after |
|---|---|
SOURCE_WRITE |
source ExportEnd{DRAINED} (requester never read it) |
REQUESTER_READ |
requester FenceAck{DRAINED} (source drained earlier, by WindowFilled) |
SOURCE_WRITE, source QUARANTINED |
source process exit, or manager exit |
REQUESTER_READ, requester QUARANTINED |
requester process exit, or manager exit |
either, with Goodbye{quiesced} from one party |
the opposite party's acknowledgment (a Goodbye clears only its sender) |
| Medium | Party | Drained when | Not drained means |
|---|---|---|---|
| CUDA (D2H into a window, H2D out of it, GPU pin) | requester or source | the copy stream or event covering every submitted copy has completed on every rank, including a submission that failed part-way (Flare's PageCopier contract: one aggregated completion after all ranks drain) |
quarantine |
| Disk (NVMe read into staging, writes in a put) | manager | every submitted I/O completion has been reaped | quarantine |
| TCP data channel | both ends | the data handler task has exited and the socket is shut down | quarantine |
| RDMA data channel | both ends | the queue pair is moved to the error state and destroyed successfully (shared::rdma::Qp::close) |
quarantine |
| Local process that exited | requester or source | the manager confirms the process is gone (pidfd) | quarantine until exit |
If drain cannot be established (a peer is unresponsive, or completion state is
unknown), the party reports QUARANTINED (or the manager infers it). The memory
is not reused until the owning process is confirmed exited, or for the lifetime
of the manager process if exit cannot be observed (remote sessions). A
disconnected local process that is still alive keeps its windows quarantined
(Core::holders in selene-manager/src/pool/claims.rs; exit is observed through
the pidfd helpers in selene-manager/src/local.rs). Visible peer pids from
SO_PEERCRED are watched with pidfd_open. When the peer pid is zero because it
is outside the manager's PID namespace, the accepted Unix socket supplies the
pidfd through SO_PEERPIDFD. Socket closure alone is never exit proof; the pidfd
becomes readable after the process has fully exited.
- The manager counts quarantined bytes in
selene_pool_quarantined_bytesand logs each quarantine event once (designed, not implemented: it logs only a failed RDMA queue-pair teardown). Claims that cannot get windows failNO_WINDOWSimmediately. Nothing waits for quarantined memory. - On the client, a registration handle whose drain failed keeps its region alive
and mapped (
HostRegistrarcontract); a GPU pin whose copy cannot be drained is never unpinned (noExportEndedevent is produced for it); the worker stops rather than reuse it (the failure contract ofHostStore::pollinselene/src/store.rs).
ClaimGranted.channel replaces windows. The requester connects, presents the
single-use token, and receives the records in order with per-page and row xxh3
checksums. It verifies every checksum before using the bytes. The manager ends the
transfer on any terminal state. Fencing: the manager's handler exits and its socket
shuts down (RDMA: queue pair quiesced, work requests flushed, regions
deregistered after that); the requester closes its end the same way and only then
sends FenceAck. An unresponsive peer means the manager's registered regions for
that transfer stay quarantined until it exits.
Framing (this implementation). One connection per transfer, after TLS when the manager
has a certificate. The instance sends the 32-byte token, then HELLO naming the carrier
(stream, or RDMA with its queue-pair description). Frames, little-endian, are defined in
flare_selene::shared::frame (the header of selene/src/shared/frame.rs): WINDOW (index, record,
first page, page count, row flag, length, row checksum, slot, one checksum per page) followed on the
stream carrier by length payload bytes, then END; for a put GRANT from the manager and
FILLED (with the instance's checksums) from the instance, payload following on the stream
carrier. On the RDMA carrier the payload never travels on the connection: the manager writes a
claim's window into a private slot the instance lent (CREDIT) and then names it in WINDOW;
the manager answers an RDMA HELLO with ACCEPT, its own queue-pair description. ABORT (with
text) is the manager ending a transfer early. PACKED_WINDOW (tag 8) carries the window shape,
the RDMA destination slot (NO_SLOT on stream), a u32 manifest length, the serialized
PackedWindow, and on the stream carrier the stored bytes; on the RDMA carrier the manager writes
the compressed bytes into the credited slot before naming it in PACKED_WINDOW. Writers with
active compression may attach PutBegin.packed (PackedOffer) so the manager allocates the
compressed v4 extent directly in its arena (PutAccept.packed = true), grants packed put windows,
verifies unit checksums on ingest, and flushes the record verbatim to NVMe. Puts and rank legs use
the stream carrier. Windows arrive in index
order and are checked by the receiver's coverage exactly as shared windows are, so a transfer that
ends short or over is a COPY_ERROR; COPY_OK waits for END.
The manager's windows are read or written only by its own handler, so its exit is the manager's
fence for them (the requester's FenceAck is accepted and idempotent, but no window waits for it).
A stopped handler retains its windows until its exit is observed. These outstanding windows are
counted in selene_pool_quarantined_bytes, including handlers still draining normally.
Relay. A claim whose source has no shared memory, or whose requester asks for
DATA_CHANNEL, goes through the manager's staging in both cases; the two legs are independent
transfers on the data channel (or shared windows for a local end):
- Source leg. The manager opens a transfer for the export and names it in
ExportRequest.channel. The source connects afterPINNED; the managerGRANTs each window it issues (retained staging for a GPU source, reserved before the pin, as for any export; credits otherwise) and the source answers withFILLEDand the payload. Checksums are the source's: persisted ones for a host record, computed over the bytes it wrote for a GPU checkpoint. The manager passes a window on only after itsFILLEDand payload arrived whole, and never trusts a count: a window that does not match the pinned chain's plan fails the claim. - Requester leg. A filled window goes to the requester as
WindowReady(shared windows) or on its own channel asWINDOW(ClaimGranted.channel). On the channel the window is free once written; otherwise when the requester releases it. The manager, not the source, ends the requester's transfer (END) once every window has gone. - Coverage and verdict. Exact coverage is checked by the requester as for any claim and by the
manager at
COPY_OK. A source that ends its connection before every window arrived fails the claim (SOURCE_LOST); a requester that does fails it (COPY_ERROR) and the source is sentExportCancel. - Fencing. A window being filled is the source leg handler's to write, so the handler's exit is
the fence for it, not the source's
ExportEnd; a window being read by a remote requester is that leg's handler's. Each leg is stopped when the claim ends. From that stop until the handler's exit is seen, the windows it may touch stay out of service and are counted inselene_pool_quarantined_bytes; no timer releases them. A source whose session ends is fenced by that: its claims fail, its export is released, and nothing waits for anExportEndit cannot send. - Levels. A relayed copy keeps the source's tier level (neighbour GPU, host DRAM, host NVMe); the requester observes completed restores for its cost estimate.
Flare sees Fetched only after every destination write has drained: selene
aggregates its H2D submissions (one per part) and reports a single result when
all have completed, including on failure. Destination pages are discarded by the
scheduler's failed-ticket path only after that.
Detected by stream error, EOF, a SessionClosing, or a different
manager_incarnation in a later Hello. The instance:
- enters
Localstate: no new claims, exports, puts or lookups are issued; lookups already in flight complete as "no candidates"; - fails every claim it has outstanding locally (all-or-nothing plans fail);
- drains its own CUDA and transport accesses (it cannot ask the manager; the
PageCopiercompletions tell it); - then releases its export pins (
unpin_checkpoint) and drops host-tier references, quarantining whatever it could not drain. It keeps the shared regions mapped and registered: they are mapped and registered once, at startup, and for the life of the process (section 8.6); - continues on its local tiers. Records selected for a put to the manager stay in their local tier, whose own LRU eviction is the end of the chain while the manager is unreachable (section 11);
- reconnects with backoff (Hello, open, resync). The regions are the same
files at the same offsets when the restarted manager reports the same
SharedMemory.regions_generation; a different generation disables the pool until the process restarts (section 8.6). Opening the new session is the instance's statement that step 3 is done.
All sessions, claims, exports, windows and in-flight puts are gone. The new
process picks a new incarnation and becomes READY after scanning its NVMe
records.
- A
ClaimRelease,FenceAckorExportEndthat mentions a vanished claim or export is answered (UNKNOWN_CLAIM) or ignored. When the manager reuses region files, it holds them for recorded processes after a crash or a clean stop with unfenced windows. Section 8.6 describes release of the hold, including the 60-second bound for pid-zero holders. - Records the dead manager held only in DRAM are lost; NVMe records are
recovered if their entire parent chain is on disk. A writer may drop its copy
at
Stored, before arena write-back. Losing an acknowledged row or a required ancestor can make a returning request fetch from a peer or recompute the suffix. - Readiness does not wait for previous instances; source hints return as they resync.
The restarted process has the same instance_id (decision 2) and a new
process_nonce. If the old stream is still open when the new session opens, the
newer wins and the older is fenced (section 2); otherwise the manager first sees
the old stream end. Either way:
- fails each claim of that instance
REQUESTER_LOST, sendsExportCancelto the sources; - windows in
REQUESTER_READstate, and the instance's put windows, stay quarantined until its process exit is confirmed (SIGKILL: immediate; a hung process stays quarantined); - stops offering the old session's entries immediately; they are replaced by the new session's live snapshot chunks, or remain absent if no successor appears.
The new process has no pool state: it opens a session under the same id, resyncs what it recovered, and its first lookup asks the manager directly. Its claim and put counters start afresh (new nonce), and it attests nothing for the old process. The client keeps no copy of the manager's index, so it has nothing to rebuild. A request that arrived before the session was open is admitted without pool candidates.
On stream end or process exit the manager:
- removes the source's entries immediately (decision 18) so no new lookup offers them;
- fails each nonterminal claim served by it
SOURCE_LOSTand ends every unanswered (Requested) export, including those of terminal claims, releasing their export slots; these exports have no issued windows; - quarantines the windows in
SOURCE_WRITEuntil the source process is confirmed exited. Windows inREQUESTER_READhold valid bytes the source does not touch and follow the requester's fence; - never trusts partially filled windows: the requester's all-or-nothing rule discards the restore.
If the stream dropped but the process lives (a blip), the process reconnects;
its ExportEnd{fence} for old exports arrives on the new session
(decision 9) and releases the quarantined windows. No hold survives the source
dying: a hold protects against eviction only (ClaimGranted in selene.proto).
Source session loss ends every unanswered (Requested) export and releases its
slot, whether its claim is still active or already terminal. No windows were
issued for these exports. A shared-memory source's pinned exports retain their
drain and quarantine requirements; a channel source's export ends with its
session, because it reaches its windows only through the manager's handler,
whose exit fences them. An already terminal claim keeps its original reason.
| Event | Claims as requester | Claims as source | Entries | Windows |
|---|---|---|---|---|
| stream ends, process gone | REQUESTER_LOST |
SOURCE_LOST |
removed | reclaimed (exit confirmed) |
| stream ends, process alive | REQUESTER_LOST |
SOURCE_LOST |
removed | quarantined until fence acks arrive on a new session or the process exits |
| superseded by a reconnect (same process) | REQUESTER_LOST |
SOURCE_LOST |
removed; the new session's snapshot announces its own | as above; the old stream's fence acks are accepted on the new session |
superseded by another process (same instance_id) |
REQUESTER_LOST |
SOURCE_LOST |
removed; the new session's snapshot announces its own | quarantined until the old process's exit is confirmed; the new process attests nothing for it |
| manager restart | all dead | all dead | gone | the same region files, held for previous-run processes under 8.6, with a 60 s bound for pid-zero holders |
An instance may register host memory with CUDA only at startup (registration
consumes device memory, and serving allocates none). So the manager's arena and
staging are not per-incarnation: they are fixed-size files, arena and
staging, in a directory named by the pool name and a hash of the absolute Unix
socket path. A per-name lock beside the region directories permits only one
manager per pool name on a host; its holder records its pid and socket. Changing
the listener path selects separate regions after the previous manager stops. An
instance maps and registers them once, when it first connects, for the life of
its process.
Reuse. At start the manager takes the instance lock, then reuses the existing
files when both are regular files of its user with exactly the configured sizes,
and a readable generation. Their paths, inodes and offsets are then unchanged,
and SharedMemory.regions_generation (Hello) is unchanged. Windows name a region
(ARENA or STAGING) and an offset, both stable across the restart. Otherwise
(first start, --memory or --staging changed, a file truncated or replaced) it
recreates both files, chooses a new random nonzero generation and logs that
running instances must restart to use the pool. Only these definite mismatches
recreate the files; an unexpected I/O error during the check (an interrupted
fallocate is retried) fails the start and deletes nothing. The lock decides
ownership, so a live manager's files are never reclaimed and another instance's
directory is never read. Startup refuses region files owned by another user or
symbolic links, and removes its unfinished generation.tmp, holders.tmp
and last-shutdown.tmp metadata writes.
Other files are left alone. Shutdown retains the regions for reconnecting clients.
Client. A client uses the pool only with the regions it registered:
- same generation, paths and sizes after a reconnect: it continues with its existing mappings and registrations;
- a different generation, path or size: its mappings are of files that no longer back the pool. It disables the pool for the process (local tiers only, one warning) and never registers late. Restarting the instance picks up the new regions;
- manager unreachable at the first connect: it waits up to 30 seconds, then
fails startup. Registration failure, session-opening timeout and rejected memory
approval also fail startup; the operator must correct the cause or remove
--prefix-cache-poolto run local-only.
Why reuse is safe. Reusing the files gives up what files created per incarnation would guarantee: that no access under the dead manager can alias a window of the new one. Physical fencing (7.1) is kept by the following rule. The manager records the pids and start times of visible-pid sessions and shared-memory ranks, and the process nonces of pid-zero shared-memory sessions and ranks, in a file that survives a crash. At a clean stop it keeps the registration of each process with a pending or quarantined shared window. This includes a requester whose claim ended before it fenced its window. When the manager reuses the regions, each recorded visible process that is still the same live process, and every recorded pid-zero process, is a previous-run holder. The manager takes the whole of both regions out of service (no window, put extent or record can be allocated in them) until every holder is released:
- A visible-pid holder is released when its pidfd reports exit, or when it opens a new session. A visible process that cannot be watched keeps its hold until it reconnects; there is no time limit for visible-pid holders.
- A pid-zero holder is released when its nonce opens a new session or rank
attachment, or 60 seconds after manager startup (
PID_ZERO_HOLD), whichever comes first. Its pidfd does not survive a restart, so the manager cannot observe its exit. At expiry the manager logs the released nonce prefixes in one line.
A reconnect follows step 3 of 8.1: the client has failed its claims and every copy
it submitted under the dead incarnation has completed on every rank. Stale
messages are rejected by manager_incarnation, so no further copy is submitted
under that incarnation. A live client drains its copies when its session ends,
even if it never reconnects; this bounds its writes from the previous run. The
60-second pid-zero hold allows that drain and prevents a dead client, whose
replacement has a different nonce, from holding the regions indefinitely. This
bound assumes the live client's session-loss detection and copy drain finish
within 60 seconds of manager startup; it is not proof of process exit.
While the hold lasts a claim is refused at once with REGIONS_HELD, not
NO_WINDOWS. It ends as soon as the last holder is released. A requester that
gets it claims again after a short wait (250 ms), within the restore's own
deadline, and recomputes only when that passes.
A process that was not recorded cannot have a window of the dead incarnation, so it needs no wait. Recreated files need no hold: they are different files that no existing mapping can reach. When the hold ends the allocators are fresh, so every window of the previous run is free by construction.
The client chooses the longest matching prefix, then the closest copy level, then a stable source identifier. One source supplies every missing page and the endpoint row. Its chain must cover the resident prefix through the endpoint; local and pool prefixes are never stitched together.
The page count is floor(endpoint/page_tokens) - floor(resident/page_tokens).
A zero-page tail with a row is legal. Destination pages start at zero. Every key
in the chain must match the request history and scope.
After admission, the client obtains one claim and validates page and row checksums
before completing the restore. A failure drains all submitted copies and reports
one failed Fetched. A local copy of the same endpoint can be tried after the
pool copy drains; other pool sources are not replanned. Nothing partial is
published. Waiting restores use the bounded claim-slot queue.
| Limit | Value | Enforced by | On exceeding |
|---|---|---|---|
| Exports at once per instance (per-GPU count) | 2 (export_slots) |
manager (pre-check) and source (re-check) | SOURCE_LIMIT / SOURCE_BUSY, immediate |
| Claims in flight per requester | 2 | manager | CLAIM_LIMIT, immediate |
| Headroom at the source | per check, section 6 | source's model worker | NO_HEADROOM, immediate, never waits |
| Retained staging for a GPU export | whole export reserved before the pin | manager reserves, source checks | NO_WINDOWS, immediate |
| Pin answer time | pin_deadline_ms 250 |
manager timer | SOURCE_TIMEOUT, late pin released |
| Window credits (streamed claims and puts) | 2 | manager | no more windows until a release |
| Claim deadline | setup clamped to 30 s + bytes at 8 MiB/s | manager | FAILED{DEADLINE} |
| No progress | 3 s | manager | FAILED{NO_PROGRESS} |
| Concurrent lookups per session | 8 | manager | LOOKUP_OVERLOADED |
| Candidates, nodes, boundaries | 8, 4096, 8192 | both | trimmed (client) or LOOKUP_INVALID (manager) |
| Ancestor keys per put | 4096 | manager | keys after the first 4096 are not considered |
| Records in a chain before a put starts a new root | 2048 | manager | a put with a row is stored as a root with its complete chain; a page-only put is refused INVALID with the detail "page-only put has no held ancestor it can link to" |
- Exports run on the lowest-priority copy stream.
- A refusal is a normal outcome. The requester claims again 250 ms after a
SOURCE_LIMITorREGIONS_HELDrefusal, within the restore's deadline; after any other refusal it uses a local copy of the same endpoint when it has one, else recomputes (section 9). A source that refusedNO_HEADROOMis not chosen again for 1 s. - None of these scale with max-concurrency.
- The limits are carried in
Hello(Limits). The manager servesflare_selene::shared::Limits::default(); it has no command-line option for them, and only a build with thetest-supportfeature can set other values.
writer manager
PutBegin{put_id, key, ...} --->| validate, budget
<------ PutAccept{first_page, parent, record_bytes, channel?}
<------ PutGrant{window i} | at most window_credits unfilled
write window, drain
PutFilled{i, xxh3} ----------->| verified by the manager
...
PutCommit{metadata} ---------->|
<------ Stored{bytes} | indexed and available to serve. The writer may drop its copy
or <-- PutRefused{reason} | PRESENT is success; other reasons follow pressure policy
PutCancelis legal only beforePutCommit. Unfilled windows stay leased to the writer untilFenceAck{put_id}or process exit.- For a record not already indexed,
PutBegin.ancestor_keyswalks the local chain, listing each record's nearer offered ancestors before its local parent and ending with the root's offered ancestors. An offered ancestor is a GPU checkpoint on the record's parent chain that the producer has already published to its host tiers, whether or not any tier stored it. The writer sends a strictly descending list of at mostMAX_CHAIN_NODES(4,096) keys; the manager considers at most the first 4096 keys and chooses the first ready ancestor whose pages it holds, including a page-only ancestor.PutAcceptnames that parent and its chain-relative end page asfirst_page. The writer sends the remaining pages and the accepted endpoint row, if any. If no ancestor is held, the manager selects no parent andfirst_page = 0, and the writer sends the complete chain as a root. If the chosen ancestor's chain has at least 2048 records, the manager also selects a root, so no stored chain exceeds half of the lookup and claim limit of 4096 records. Admission can also select a root under arena pressure. An absent or empty list usespublished_parentalone and requires that parent to be ready; it never links to an uncommitted parent. Managers that do not implement field 10 ignore the list and usepublished_parentalone. - The writer supplies the scheduler's capture role in
PutBegin.capture_role(field 11). Message and Anchor captures keep their exact recurrent rows. Roots and forks retain available rows regardless of capture role. A newly discovered fork can regain a missing row while a writer still holds it. The writer supplies its local child count inchild_paths(12) and the next child on the retiring path innext_child(13). The manager also counts committed children, counting a known next child only once. The writer setsdescendant_row(14) when a ready descendant on the unbranched path can offer a row after the same-page rule. Absent means false. These topology hints apply to this put. Only the capture role is persisted. - The manager can omit a single-child interior Endpoint row when the writer
sets
descendant_row. Otherwise the same-page rule applies. A covered child alone cannot justify dropping the ancestor that covers it.PutAccept.record_bytesis the exact length of the chosen record, including its header. The writer checks that length against the page-only and row-bearing layouts before opening rank transfers. When a child commits, an arena-only Endpoint ancestor can release its former tip row once active claims drain and a committed descendant row covers the unbranched path. - An Endpoint tip keeps its row unless a row-bearing ancestor on its path has the same completed-page count. Flare checks when offering the row and the manager checks its chosen parent chain at put time. Two protected boundaries in one page each retain their own row for exact rewinds.
- An explicit
row=falseput requires a held parent. A missing parent isINVALID. Arena pressure that requires a root instead isBUDGET. A parent whose chain has at least 2048 records does not count, because the put would then start a new root and a root needs a row: a page-only put there isINVALIDwith the detail "page-only put has no held ancestor it can link to", while a put with a row is stored as a root. A put with zero new pages and no retained row returnsPRESENTbecause its parent already covers it. - A rowless re-put of a held record returns
PRESENT. A writer with a newly protected row can upgrade a held page-only record at that exact key. If every holder has released the row, a later capture can supply it. Restore starts at the deepest retained row and prefills the remaining suffix. - Under disk pressure, the manager can reclaim a durable interior Endpoint row if its only child has a durable row. Roots, forks and protected roles keep available rows.
- The manager echoes the accepted capture role in
PutAccept.capture_role(field 8). The writer puts that value in header flag bits 8 and 9. Zero identifies records from peers without role support and preserves their available rows until a role-aware writer rewrites the record. A legacy writer still commits zero role bits. If the manager already knows the role, it preserves it in the stored header after validating the commit. Record layout, rank geometry and replication flags keep their wire meanings. Older readers can open the same files. PutGrantwindow page numbers count from the accepted record's first page (PutAccept.first_pageis chain-relative), for every writer and rank agent.Storedmeans the manager can serve the indexed record from its arena or from disk. Arena puts can be acknowledged before write-back.PRESENTcan also mean an empty put is already covered by its parent.- A put that conflicts with another put of the same key, or needs to replace a
pinned or disk-busy record, waits for admission. Each continuous conflict
starts one wait in
selene_put_inflight_waits_total. Once the conflict clears, a later conflict starts a fresh five-second wait. Time queued for write-back to free arena space is excluded. selene_put_inflight_wait_max_secondsis the longest individual conflict wait since manager startup among puts admitted (including upgrades) or answeredPRESENT. A put still blocked at its deadline receivesINFLIGHTand incrementsselene_put_inflight_expired_total. A writer whose own store connection pins the key receivesINFLIGHTimmediately. Both refusals count inselene_puts_total{outcome="inflight"}. With one writer process per manager, the own-pin rule limits waiting to write-back, compaction and same-key puts.- Pressure policy. A DRAM handoff sends predecessors root-first. An
ancestor refused with
INVALIDorOVERSIZEtriggers a leaf-only put.BUDGETandINFLIGHTretry once before the same fallback. If the leaf exhausts its retry or the leaf-only put is refused for one of these reasons, the writer drops the leaf. A shared fork stays available to its other children. A manager with a disk root reclaims clean arena duplicates first. Evicting a dirty record writes its undurable predecessors first. A record larger than the arena streams through staging. Full or pinned storage can refuse admission withBUDGET. - Validation. Before indexing, the manager checks the
PutCommitmetadata against the accepted geometry, the scope identity, the accepted parent and first page, the record length, and the checksums it verified over the payload it received; a mismatch isPutRefused{INVALID}and nothing is indexed. On later reads the stored checksums are served unchanged.
The manager embeds store::Store as a library through its command interface.
The store owns record admission, storage, durability and recovery; the pool actor
owns sessions, hints, claims and fences. The pool protocol is the manager's only
wire service; the store has none of its own.
- Transports. See network operations for listeners, address forms, TLS, RDMA and startup warnings.
- The data channel. A session without shared memory can open, resynchronise, look up, see
level-5 candidates (the manager's own records), claim them and put into the manager's store,
with the bytes on the data channel (
--listen-data; section 7.5). An instance may be the source too: a session without shared memory serves exports (export_slotsas asked, up to the limit) and the manager relays its windows; two instances on other hosts, or one on each side, copy through the manager's staging. On a manager with no network listenerDATA_CHANNELis refused (INVALID_CLAIM;PutRefused{INVALID}saying so). A remote instance has no pid, so its connection to the store is opened with pid 0 (StoreCommand::Hello); it is told apart by its session, not watched, and no window is ever leased to it. - Lookup timing. A lookup is queued, not answered inline. The pool actor answers queued
lookups, at most 64 per pass, whenever its event queue is empty and on its 10 ms clock, so a
burst on one session beyond
max_concurrent_lookupsis refusedLOOKUP_OVERLOADEDat once. - Manager-store entries. The manager's own store appears in each scope's index as the
manager's entries (tier DRAM or NVMe; records recovered after a restart start on NVMe).
Manager chains may mix both tiers; instance chains may not. A candidate's
tiernames its endpoint's tier, while its level reflects the slowest tier the claim reads. - Windows. An instance-to-instance claim reserves one staging block for the whole export
(its size rounds up to the allocator's size class), cut into windows by the pinned records.
A host-tier source whose export does not fit streams with
window_credits. Windows for the manager's own records are the store's: arena leases or staging reads, at mostwindow_creditsunreleased at a time. A store-sourced claim whose requester reports an exactCOPY_OKbefore the store reports its own reads drained completes when the store does. - Put. Records go through the store's put path (parent-first chain durability, budget,
deduplication). The manager checks the commit metadata against the accepted put before the
store sees it. A refused or cancelled put leaves its unfilled windows leased to the writer
until its
FenceAck{put_id},Goodbye{quiesced}or exit. - Processes. A process is identified by its Unix-socket credentials (pidfd). A stream that ends while the process lives keeps the windows quarantined until the same process reports on a new session; a process confirmed gone releases everything only it could touch.
- Persisted state. Committed NVMe records and shared-region files, generation and holders survive a restart. The store rebuilds its index from records; instances resynchronise their hints. Live claims and window grants are not recovered.
An instance whose tensor-parallel ranks are separate processes is one instance of the pool.
Rank 0 alone opens the Session (OpenSession.rank_secret set, scope.geometry.ranks one
entry per rank, at least two); it announces, looks up, claims, puts and answers exports.
Every other rank runs an agent that attaches with the Rank stream and moves only its own
slice of each window. Records at rest are the ordinary composite records (one checksum per
page, one for the row; the scope and its identity are those of a single-process instance of
the same shape, so the two share records). Slices exist only in flight.
Slices. A window holds whole page records then optionally the row record; within a record
the ranks follow each other, each rank's planes padded to a block. Rank r's slice of page i of a
window is contiguous at i * page_record_bytes + (the sum of the padded sizes of ranks before r); its row slice likewise in the row record. flare_selene::shared::SliceLayout is the one
implementation of that arithmetic.
Modes. The manager decides each agent's mode when it attaches (RankAttached.mode):
RANK_SHARED (the agent reads and writes the manager's shared windows in place; only when it
is on the manager's host and rank 0 is in shared memory too, because window coordinates reach
an agent only through rank 0) or RANK_CHANNEL (it has its own data channel per transfer, named
in a rank_channels entry of ClaimGranted, ExportRequest or PutAccept; rank 0's own is the
message's channel). A channel carries only that rank's slice: Shape.length is the slice's
length, the frames are those of section 7.5, and the channel is the stream carrier.
Rank 0 and each peer use one persistent RankLink for control, copy jobs and
completions. Losing that link turns the pool off for the whole instance (rank 0
reports it disabled, and quarantines when a transfer was open on that rank);
completion still waits for every submitted copy to drain. The manager's Rank
stream supplies attachment and fencing, and channel-mode copies use the
per-transfer data connection above.
13.1 Attachment. RankAttach{manager_incarnation, instance_id, rank0_nonce, rank, agent_nonce, rank_secret}. The manager checks the incarnation (RANK_STALE_MANAGER),
a live session of that instance run by that process (RANK_NO_SESSION: retry), the secret in
constant time (RANK_BAD_SECRET), the rank (RANK_BAD_RANK), and that a channel-mode agent has a
data listener to reach (RANK_NO_DATA_LISTENER). It assigns a generation from the session counter.
Claims, exports and puts of the instance, and claims naming it as a source, are refused
RANKS_DETACHED (put PUT_NOT_READY) unless every rank 1..W-1 is attached and not drain-only. A
new attachment of a rank supersedes the live one, which stays a drain-only party; the same
process reconnecting its session keeps its agents, another process taking the instance over does
not.
13.2 Identity and fencing. What an agent may still be touching is its own obligation under
(instance_id, agent_nonce), never "rank r": a replacement inherits nothing and clears
nothing. Only the agent's own RankFence{kind, id, DRAINED} for the transfer, its own
RankGoodbye{quiesced} or its process's exit discharges it. Stream loss, replacement, timeout
and cancel are logical invalidation only. A channel leg is fenced by the manager's handler's
exit, which proves the manager's memory quiet, never that a remote rank's GPU copies drained: that
is the rank's own Done to rank 0, and rank 0 releases nothing and reports nothing before every
rank's.
13.3 Drain-only attachments. When rank 0's session ends its agents are not closed: they can be granted nothing, but their open streams can attest and say goodbye. A new attachment requires a live rank-0 session. Stream loss retains shared-window obligations until the process exits. A restarted manager has no record of these obligations: it keeps them in memory only. Section 8.6 states how region files it reuses are held for the previous run's session processes and shared-memory ranks.
13.4 Windows and checksums. A multi-process source states, per rank, slice transfer
checksums (RankSums): rank 0's WindowFilled.rank_sums/PutFilled.rank_sums for itself and
its shared peers, each leg's frame for its rank. A window is whole only when every accessor
has reported once (a bit per accessor, repeats are no vote). The manager then runs the
assembly pass on the window (off the actor, over several threads): it verifies the stated
slice checksums and computes the stored whole-page and row checksums for a single-process
requester or a put's commit, or verifies the stored (or stated whole) checksums and computes
each rank's slice transfer checksums for a multi-process requester (WindowReady.rank_sums,
the leg frames). A window is released to the store or the requester's pool only after the
pass is over, a window is free only when every reader has reported (the requester's session
for rank 0 and its shared peers, one leg per channel rank), an exact CopyResult{COPY_OK} that
arrives before a leg has finished reading is latched, and a put's PutCommit carries the
record the manager rewrites with the checksums it computed.
13.5 RDMA. Experimental RDMA carries only unsliced claim windows as signalled WRITEs.
Rank legs and puts use TCP. Each transfer owns its queue pair, whose destruction fences all
outstanding work before its handler reports Closed. The manager never advertises its region
keys or addresses; only the instance's private transfer staging is remotely writable.
OpenSession.codec (9) and SessionOpened.codec (7) negotiate an envelope revision and a set
of 32-byte receive-profile digests. An absent acknowledgement permits raw transfers only. A
rank offers its capabilities in RankAttach.codec (7) and receives the acknowledgement in
RankAttached.codec (4). Every process of an instance must offer identical capabilities. A
mismatched attach is refused before it can supersede the live rank. Packed windows use shared
memory, a TCP stream, or credited RDMA slots (PACKED_WINDOW with a non-NO_SLOT slot).
Instance holdings may be raw or packed, and PutBegin.packed (15) may supply pre-encoded
packed units (PutAccept.packed confirms acceptance). For manager-owned records, lookup
requires the receiver to support every packed profile in the chain. A claim repeats this check
on the pinned records. Record.packed (6) describes each selected suffix in the grant. Units
are ordered by absolute page index and stored rank, followed by the endpoint row's ranks. Each
unit names its replica destinations. A literal carries the original bytes and their XXH3. A
packet carries its profile and CRC-32/IEEE checksums of the stored and original bytes.
WindowSpec.packed (9) identifies the units in a shared window. TCP tag 8 carries the
little-endian window shape, a little-endian u32 manifest length, a protobuf PackedWindow and
the selected bytes. Each rank receives the units it owns or replicates. A window contains whole
pages or an indivisible row and retains its source until release and fencing. The reader checks
the manifest against the pinned selection, checks stored bytes before decode, and checks the
original CRC before publishing the restore.
The first 4,096-byte disk block uses the raw common fields through creation time at offset 165. Version is 4, and the raw row checksum field is zero. At offsets 173, 181, 185 and 189 are the directory offset (u64, 4096), directory length (u32), directory CRC-32/IEEE (u32), and untruncated physical record length (u64). The directory is a protobuf message with repeated RankPlanes at 1 and PackedOffer at 2. It is bounded to 2 MiB, 16,384 units and 64 ranks. The payload follows immediately. Physical offsets are checked prefix sums. Actual EOF at or beyond the end of the pages but short of the complete row means page-only. EOF within the pages or directory is invalid. Compaction truncates at the row offset. A refill publishes a replacement record. The directory is immutable, including after a truncate. Disk write-back and shutdown publish the physical file length from the chosen header.
A packet encodes one rank's block-padded share of one page or continuation
row. Layout revision 1 names the packet profile ZKV1/v1/64-pivots.
All header and directory words are little-endian u32. The 16-byte header
contains the four bytes ZKV1, version 1, the frame count and the original
byte length. Each 4-byte directory entry stores the frame's payload length in
bits 0–30 and sets bit 31 when the frame is stored literally without
compression. Frame payloads follow the directory in order with no gaps or
trailing bytes. Decoders derive frame boundaries from the declared layout and
validate every header field and frame length before decoding.
Matrix fields (encoding = 1) are grouped up to four 128 × 128 binary32
matrices per frame. Each matrix runs a bit-exact 64-pivot low-rank predictor,
splits residual widths (0..=32) into four little-endian u16 lane word
counts, each followed by that many u32 low-bit words, and compresses the
concatenated group widths as a standard Zstandard frame.
Non-matrix fields are chunked up to 64 KiB per frame, apply byte-lane shuffle
or compound page value/scale split-shuffle, and compress each frame as a
standard Zstandard frame. Any frame whose encoded payload is not smaller than
its raw bytes is stored literally with bit 31 set.
The GPU codec profile GKV1/v2/64-pivots-rans32 uses the same field
transforms and bit-exact 64-pivot matrix predictor, coalesces transformed
streams into 64 KiB chunks, and compresses each chunk with a 32-way
warp-interleaved 12-bit static rANS coder (RLE, sparse table, dense table, or
literal fallback). A GKV1 packet begins with a 24-byte header of six
little-endian u32 words (GKV1, version 2, original_bytes, num_chunks,
num_mats, and low_bytes), followed at byte 24 by the num_chunks-word
u32 chunk directory (bits 0–30 carry payload length; bit 31 marks a literal
chunk), then num_mats * 4 little-endian u16 matrix low-bit lane word
counts, then chunk payloads, and finally low_bytes of 4-lane low-bit
payloads. Both cpu and gpu modes decode GKV1 and ZKV1 packets and
verify stored and original CRC-32/IEEE checksums before publishing restored
bytes.
| Field encoding | Storage in one block |
|---|---|
| 0 | One uninterpreted byte |
| 1 | One 128 × 128 binary32 matrix, 65,536 bytes, aligned to four bytes. The predictor uses 64 pivots. |
| 2 | One bfloat16 element, two bytes |
| 20, 32 | One convolution history entry of ten or sixteen bfloat16 elements (20 or 32 bytes), transposed by byte lane |
| 40 | 256 rows of 512 FP8 values and four binary32 scales per row, 135,168 bytes |
| 41 | 64 rows of 128 FP8 values followed by 64 binary32 scales, 8,448 bytes |
| 42 | 64 rows of 512 FP8 values, 32,768 bytes |
| 45 | 64 rows of 512 packed FP4 data bytes and 16 scale bytes, 33,792 bytes |
| 47 | 64 rows of 256 packed FP4 data bytes and 32 scale bytes, 18,432 bytes |
| 48 | 128 rows of 512 FP8 latent values and 64 FP8 key values per row, 73,728 bytes |