Repository navigation
A masking write under a data-dependent condition is a rolled walk, and it unrolls now (#184) - #191
Merged
Merged
Conversation
Owner
Author
|
The |
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.
Closes #184.
RegTile::maskwas the rolled walk #180 did not reach, and it carries #166'spattern now —
__unroll_config::<0>()plus an inline-constbound on bothlevels. That is the whole of the code change; the rest of this is the
measurement that says it should ship, because the naive form of it is what #184
recorded and did not push.
Why a mask and not a map
A conditional write is a different shape from the maps beside it.
self.set(slot, value, fill)under a data-dependentkeepkeeps the slot arrayaddressable across the branch, so the rolled walk homed the whole tile to a
.localframe — and homed it on every iteration of whatever loop the mask satin, not only on the ones that masked anything. That is why one
right_fillonone chunk in 786 cost oxide-train's tile classifier a 400 B frame with the
stores inside the vocabulary loop. Nothing else in
reg.rshas that shape: amap writes every value unconditionally and a reduction writes none, which is why
this is the only walk in the file that unrolls and the map walks stay #166's
open remainder.
regcount(sm_100a), main5e4d3ff-> this branchTwo entry functions move. Every other row of all three tables is identical —
194 harness kernels, 8
examples/, 83experiments/, same registers, samespills, same stack, same smem. Occupancy gate green, timed twins green.
.localdeclst.localld.localexamples/flash_forwarddevice-tests/mask_probe_128_causalThe two rows moving in opposite directions is the finding, not an anomaly. The
probe's load walk is open-coded on purpose — it is what a kernel writes without
the movers — so its band stays in the frame and an unrolled mask reads it out
and writes it back.
flash_forward's walks around the mask are movers andalready unroll, so its band leaves the frame instead. The probe's frame does not
grow: its
st.localis a static instruction count, and unrolling trades onerolled store for 128 predicated ones at constant offsets without changing what
runs. The census comment now says which of its columns are bytes and which are
instructions, because that distinction is the whole of this table's diff.
mask_probe's doc carried #7's claim thatmake_causal_atand the loop itreplaces price alike. That is now true at 32 columns and false at 128, and the
doc says so and says why.
The 255, measured rather than argued
flash_forwardis the constraint #184 stopped on. It is not a spill and it isnot an occupancy step:
ptxasreports 0 spill stores and 0 spill loads at 255.The driver reports 1 block/SM before and after. This kernel's own
147 532 B shared plan admits exactly one CTA against the SM's 227 KiB, so the
register term — three CTAs' worth to two — has no second CTA to take away.
device-tests' occupancy ladder makes the same point from the other side.It gets faster.
scripts/modal-run exampleson a B200, checked beforetimed, five warm-ups and the minimum of thirty launches:
+90 registers, -15% wall clock: the register column ordering time backwards for
the sixth time here (#47, #63, #67, #76, #94), because the frame it replaced was
written and read in the innermost loop.
docs/kernels/flash_forward.mdcarriesthe table and the caveat — a kernel with room to spare in shared memory, where
the third CTA is real, would read this differently.
The downstream witness
A scratch clone of oxide-train at
feat/issue-70-tile-probes,gpu/opspinnedto this branch's
445f88e, nothing else touched.fused_classifier_forward_tile_bf16is a warp-per-band softmax over aRegTile<16, 64>whose only use ofmaskis oneright_fill:st.localld.local__local_depot13[400]__local_depot13[272]128 B, exactly one
ClassChunk(RegTile<16, 64>is 2 slots x 16 values offp32). The mask's tile came out of the frame and nothing else did; the 272 B
that remain are the
row_max/sub_row/exp/row_sumwalks around it,which are #166's map-walk remainder and not this issue. So the depot does not go
to zero, and the reason it does not is attributable to the byte.
On a clock, same container, shipped block-per-row kernel as the control:
1.358x, and past the 0.563x #184 measured for deleting the
right_fillentirely — the walk was costing more than the mask it computed. Every other
family in that bench is unmoved within 1.5% (
rms_normforward/backward, fourswiglurungs), which is the control that says this is the mask and not thecontainer.
This is a witness, not a perf claim. That kernel loses either way, it is out
of the training path, and oxide-train#78 leaves it flat. No training step gets
faster from this.
What is deliberately not done
Both alternatives to the unroll were built and measured, and both are worse:
self.set(slot, value, if keep {old} else {fill}), sothere is no branch to keep the array addressable. Without the markers the walk
stays rolled and the frame stays:
flash_forward165 -> 167 registers, 1824 Beither way, depot 774/455. With the markers it produces a byte-identical
regcounttable to the branch form. The extragetbuys nothing, so thebranch stays.
BaseLdtm::column's[0, 1, 8, 9][value % 4], which RegTile::mask is a rolled walk #180 did not reach: a 400 B frame and 27% of a kernel, from one right_fill #184's PTX showsbeing re-stored to
.localand read back by a runtime index every iteration.It is equal to
8 * (value / 2) + value % 2— no array, pure arithmetic, andthe existing host tests pass on it unchanged. It is also a tree-wide codegen
perturbation: half the ladder and probe rows move, in both directions
(
ladder_probe_32x192_all_in_place251 -> 32,ladder_probe_32x256_fusedpicks up 456 more spill stores, several rungs lose their 144-272 B frames
outright), and four of
regcount's twenty timed rungs come off their laddertwins, which fails the run. It is a real finding and it wants its own issue
and its own before/after; it is not this change, and RegTile::mask is a rolled walk #180 did not reach: a 400 B frame and 27% of a kernel, from one right_fill #184 does not need it —
once the mask unrolls,
valueis a constant and that table folds.Gates
scripts/fmt --check,cargo test(111 + 81 doctests) clean.scripts/modal-run regcountfrom this branch: green end to end, tables above.scripts/modal-run device_testson a B200: 51 of 51.scripts/modal-run exampleson a B200: every check passes,flash_forward2x256x128 rows attended, worst relative error 1.66e-3— the same figure asbefore the change.