Add LLImpl pack/unpack over LLPacket geometry (#3554) - #3554
Closed
function47 wants to merge 1 commit into
Closed
Conversation
Contributor
|
@function47 has exported this pull request. If you are a Meta employee, you can view the originating Diff in D110940544. |
function47
added a commit
to function47/torchcomms-1
that referenced
this pull request
Aug 10, 2026
Summary: Second llx building block: `LLImpl<P>`, the ThreadGroup-driven encode/decode of a byte range into/out of an `LLPacket`-formatted staging region. - `pack(group, staging, src, nbytes, flagVal)`: encode the payload into consecutive packets, stamping each packet's trailing flag with `flagVal`. - `unpack(group, dst, staging, nbytes, flagVal)`: spin until each owned packet's flag == `flagVal`, then decode the payload out. - Flag I/O (`store_flag` / `load_flag` / `is_flag_set`): the flag sits entirely inside `P::kFlagLane`'s 16 B slot, so it is read/written as ONE wide volatile transfer instead of a per-word scalar loop. `flagVal` is replicated across the full flag width, so a torn transfer that carries the new value in only part of the flag fails `is_flag_set` — `unpack` never accepts half-arrived data. Parallelism (v1): one thread owns one whole packet, grid-strided across the group. `pack` writes each packet's trailing flag last; on the wire the whole staging region is fenced and RDMA-put as one unit, so the flag is never observed before its data. `unpack` spins only on the packets a thread owns (no group-wide readiness barrier), then decodes. Additive only: new header `comms/prims/core/LLImpl.cuh` behind a new `//comms/prims:ll_impl` target, plus `//comms/prims/tests:ll_impl_test` and its `:ll_impl_test_kernels` companion. No existing code path is modified. Reviewed By: snarayankh Differential Revision: D110940544
function47
force-pushed
the
export-D110940544
branch
from
August 10, 2026 19:07
8ac131c to
7ae7f90
Compare
function47
added a commit
to function47/torchcomms-1
that referenced
this pull request
Aug 10, 2026
Summary: Second llx building block: `LLImpl<P>`, the ThreadGroup-driven encode/decode of a byte range into/out of an `LLPacket`-formatted staging region. - `pack(group, staging, src, nbytes, flagVal)`: encode the payload into consecutive packets, stamping each packet's trailing flag with `flagVal`. - `unpack(group, dst, staging, nbytes, flagVal)`: spin until each owned packet's flag == `flagVal`, then decode the payload out. - Flag I/O (`store_flag` / `load_flag` / `is_flag_set`): the flag sits entirely inside `P::kFlagLane`'s 16 B slot, so it is read/written as ONE wide volatile transfer instead of a per-word scalar loop. `flagVal` is replicated across the full flag width, so a torn transfer that carries the new value in only part of the flag fails `is_flag_set` — `unpack` never accepts half-arrived data. Parallelism (v1): one thread owns one whole packet, grid-strided across the group. `pack` writes each packet's trailing flag last; on the wire the whole staging region is fenced and RDMA-put as one unit, so the flag is never observed before its data. `unpack` spins only on the packets a thread owns (no group-wide readiness barrier), then decodes. Additive only: new header `comms/prims/core/LLImpl.cuh` behind a new `//comms/prims:ll_impl` target, plus `//comms/prims/tests:ll_impl_test` and its `:ll_impl_test_kernels` companion. No existing code path is modified. Reviewed By: snarayankh Differential Revision: D110940544
Summary: Second llx building block: `LLImpl<P>`, the ThreadGroup-driven encode/decode of a byte range into/out of an `LLPacket`-formatted staging region. - `pack(group, staging, src, nbytes, flagVal)`: encode the payload into consecutive packets, stamping each packet's trailing flag with `flagVal`. - `unpack(group, dst, staging, nbytes, flagVal)`: spin until each owned packet's flag == `flagVal`, then decode the payload out. - Flag I/O (`store_flag` / `load_flag` / `is_flag_set`): the flag sits entirely inside `P::kFlagLane`'s 16 B slot, so it is read/written as ONE wide volatile transfer instead of a per-word scalar loop. `flagVal` is replicated across the full flag width, so a torn transfer that carries the new value in only part of the flag fails `is_flag_set` — `unpack` never accepts half-arrived data. Parallelism (v1): one thread owns one whole packet, grid-strided across the group. `pack` writes each packet's trailing flag last; on the wire the whole staging region is fenced and RDMA-put as one unit, so the flag is never observed before its data. `unpack` spins only on the packets a thread owns (no group-wide readiness barrier), then decodes. Additive only: new header `comms/prims/core/LLImpl.cuh` behind a new `//comms/prims:ll_impl` target, plus `//comms/prims/tests:ll_impl_test` and its `:ll_impl_test_kernels` companion. No existing code path is modified. Reviewed By: snarayankh Differential Revision: D110940544
function47
force-pushed
the
export-D110940544
branch
from
August 10, 2026 19:34
7ae7f90 to
71e390b
Compare
Contributor
|
This pull request has been merged in a66c6f6. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary:
Second llx building block:
LLImpl<P>, the ThreadGroup-driven encode/decode ofa byte range into/out of an
LLPacket-formatted staging region.pack(group, staging, src, nbytes, flagVal): encode the payload intoconsecutive packets, stamping each packet's trailing flag with
flagVal.unpack(group, dst, staging, nbytes, flagVal): spin until each ownedpacket's flag ==
flagVal, then decode the payload out.store_flag/load_flag/is_flag_set): the flag sits entirelyinside
P::kFlagLane's 16 B slot, so it is read/written as ONE wide volatiletransfer instead of a per-word scalar loop.
flagValis replicated across thefull flag width, so a torn transfer that carries the new value in only part of
the flag fails
is_flag_set—unpacknever accepts half-arrived data.Parallelism (v1): one thread owns one whole packet, grid-strided across the
group.
packwrites each packet's trailing flag last; on the wire the wholestaging region is fenced and RDMA-put as one unit, so the flag is never observed
before its data.
unpackspins only on the packets a thread owns (nogroup-wide readiness barrier), then decodes.
Additive only: new header
comms/prims/core/LLImpl.cuhbehind a new//comms/prims:ll_impltarget, plus//comms/prims/tests:ll_impl_testand its:ll_impl_test_kernelscompanion. No existing code path is modified.Reviewed By: snarayankh
Differential Revision: D110940544