For the complete documentation index, see llms.txt. Markdown versions of all pages are available by appending .md to any URL (e.g. /max/get-started.md).
Mojo module
lamport
Shared primitives for the barrier-free Lamport communication protocol.
A Lamport-style exchange replaces an explicit cross-GPU readiness flag with a
reserved value embedded inside the data pack: negative zero. Because IEEE-754
defines -0.0 == +0.0 and x + (-0.0) == x, a producer can sanitize its real
data so that no lane ever holds the -0.0 bit pattern, and a consumer can then
treat "this pack still contains a -0.0 lane" as "the producer has not written
here yet." The 16-byte single-copy-atomic store couples "data present" with
"sentinel gone", so no separate flag word and no hot-path atomic are required.
The three functions here are the dtype- and width-parameterized building blocks of that protocol, with no allreduce-specific logic so broadcast and other comm kernels can reuse them:
remove_neg_zero: producer-side sanitize (map-0.0lanes to+0.0).has_neg_zero: consumer-side readiness poll (any lane still the sentinel).set_neg_zero: produce the all-sentinel "not ready" pack.
LamportGeneration owns the three-buffer generation rotation (flag % 3) that
defends against the classic Lamport write-after-read hazard, so the kernel body
and any future consumer share identical generation semantics.
See the internal Lamport allreduce design doc, section "Design > 1. Shared sentinel primitive", for the protocol context.
comptime valuesβ
LAMPORT_SENTINEL_U32β
comptime LAMPORT_SENTINEL_U32 = UInt32(2147483648)
The universal Lamport "not ready" sentinel, as a uint32 (fp32 -0.0).
Structsβ
- β
Lamport: Sizing and state-block layout for the barrier-free Lamport comm region. - β
LamportGeneration: Owns the three-buffer generation rotation for a Lamport exchange.
Functionsβ
- β
has_neg_zero: Returns True if any lane ofvholds the-0.0sentinel bit pattern. - β
remove_neg_zero: Maps every-0.0lane to+0.0, leaving all other lanes bit-identical. - β
set_neg_zero: Returns the universal "not ready" sentinel pack.
Was this page helpful?
Thank you! We'll create more content like this.
Thank you for helping us improve!