Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ Each release's page on GitHub has its notes and measurements. See [the 1.0.0 rel

## Unreleased

- Flash Next on CUDA: `TF_FLASHNEXT_GATHER_EARLY=1` (default `0`) gathers a shared decode pass's n-gram rows for every lane in one pooled call instead of one call a stream, for passes of at most 64 lanes (wider passes keep the per-stream call); which rows are read and how a row is dequantized do not change, so replies stay main's, and the measured mean decode gain on one GB10 rises to +2.10% at eight streams (#4009). Thanks to @BadAd84.

## 1.3.3

- Kernel contract: the HIP relu² stream tile is checked at 5, 6 and 8 bits in groups of 64 as well as 4, with gates 1 to 4, a planted control for each wider width, and gate-5 records on the four RDNA chips (#3163, part of #3061). Thanks to @gilby.
Expand Down
3 changes: 2 additions & 1 deletion docs/environment.md
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ Direct family readers also refuse malformed values when called without the serve

## Flash Next

Flash Next checks these 35 settings when its engine loads, before any device or checkpoint work: a malformed value
Flash Next checks these 36 settings when its engine loads, before any device or checkpoint work: a malformed value
stops the start with the variable, the supplied text and the accepted forms.

| Variable | Accepted explicit value |
Expand All @@ -159,6 +159,7 @@ stops the start with the variable, the supplied text and the accepted forms.
| `TF_FLASHNEXT_ATTN_LANES` | Exactly `0` or `1`; default off |
| `TF_FLASHNEXT_WARM_AHEAD` | Exactly `0` or `1`; default off |
| `TF_FLASHNEXT_TABLE_WARM` | Exactly `0` or `1`; default off |
| `TF_FLASHNEXT_GATHER_EARLY` | Exactly `0` or `1`; default off. `1` gathers a shared pass's n-gram rows for every stream in one pool call, so the pass shares one distinct-row read and one set of parked readers; the rows, their order and every reply are the per-stream call's |
| `TF_FLASHNEXT_PROFILE` | Exactly `0` or `1`; default off |
| `TF_FLASHNEXT_VERIFY_HOST_LOGITS` | Exactly `0` or `1`; default off |
| `TF_FLASHNEXT_DRAFTS` | Whole draft count; default 6, then clamped to 1 through 15 |
Expand Down
178 changes: 178 additions & 0 deletions docs/receipts/flashnext-gather-early/README.md

Large diffs are not rendered by default.

73 changes: 73 additions & 0 deletions docs/receipts/flashnext-gather-early/cells.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
arm,invocation,prompt,temperature,streams,aggregate_tps,per_stream_tps,tokens_per_round,accepted_per_round,server_accepted,server_drafted,server_acceptance,alone_equal,alone_unequal,serial_equal,serial_unequal,failed,unmeasured
M1,conc_t0,chat,0.0,1,46.5,46.5,2.813,1.813,22760,33060,0.6884,3,0,1,0,0,0
M1,conc_t0,chat,0.0,2,86.6,43.5,2.51,1.51,22760,33060,0.6884,6,0,1,0,0,0
M1,conc_t0,chat,0.0,4,156.6,39.7,2.51,1.51,22760,33060,0.6884,12,0,1,0,0,0
M1,conc_t0,chat,0.0,6,210.7,35.9,2.51,1.51,22760,33060,0.6884,18,0,1,0,0,0
M1,conc_t0,chat,0.0,8,257.9,33.1,2.51,1.51,22760,33060,0.6884,24,0,1,0,0,0
M1,conc_t0,code,0.0,1,73.5,73.5,5.224,4.224,22760,33060,0.6884,3,0,1,0,0,0
M1,conc_t0,code,0.0,2,139.2,70.2,4.83,3.83,22760,33060,0.6884,6,0,1,0,0,0
M1,conc_t0,code,0.0,4,243.7,62.5,4.83,3.83,22760,33060,0.6884,12,0,1,0,0,0
M1,conc_t0,code,0.0,6,307.5,52.9,4.491,3.491,22760,33060,0.6884,18,0,1,0,0,0
M1,conc_t0,code,0.0,8,373.9,49.1,4.491,3.491,22760,33060,0.6884,24,0,1,0,0,0
M1,openai_t0,fibonacci-raw,0.0,1,73.9407779779337,73.9407779779337,5.224,4.224,1488,2384,0.6242,,,,,0,0
M1,openai_t0,gpu-chat-no-think,0.0,1,47.29243959209471,47.29243959209471,2.813,1.813,1488,2384,0.6242,,,,,0,0
B0a,conc_t0,chat,0.0,1,45.9,45.9,2.813,1.813,22760,33060,0.6884,3,0,1,0,0,0
B0a,conc_t0,chat,0.0,2,85.7,43.1,2.51,1.51,22760,33060,0.6884,6,0,1,0,0,0
B0a,conc_t0,chat,0.0,4,154.7,39.3,2.51,1.51,22760,33060,0.6884,12,0,1,0,0,0
B0a,conc_t0,chat,0.0,6,208.6,35.6,2.51,1.51,22760,33060,0.6884,18,0,1,0,0,0
B0a,conc_t0,chat,0.0,8,255.3,32.9,2.51,1.51,22760,33060,0.6884,24,0,1,0,0,0
B0a,conc_t0,code,0.0,1,71.9,71.9,5.224,4.224,22760,33060,0.6884,3,0,1,0,0,0
B0a,conc_t0,code,0.0,2,137.2,69.1,4.83,3.83,22760,33060,0.6884,6,0,1,0,0,0
B0a,conc_t0,code,0.0,4,239.8,61.8,4.83,3.83,22760,33060,0.6884,12,0,1,0,0,0
B0a,conc_t0,code,0.0,6,304.4,52.7,4.491,3.491,22760,33060,0.6884,18,0,1,0,0,0
B0a,conc_t0,code,0.0,8,369.1,48.5,4.491,3.491,22760,33060,0.6884,24,0,1,0,0,0
B0a,openai_t0,fibonacci-raw,0.0,1,71.81520376837803,71.81520376837803,5.224,4.224,1488,2384,0.6242,,,,,0,0
B0a,openai_t0,gpu-chat-no-think,0.0,1,46.038164951481015,46.038164951481015,2.813,1.813,1488,2384,0.6242,,,,,0,0
B1a,conc_t0,chat,0.0,1,46.7,46.7,2.813,1.813,22760,33060,0.6884,3,0,1,0,0,0
B1a,conc_t0,chat,0.0,2,87.0,43.8,2.51,1.51,22760,33060,0.6884,6,0,1,0,0,0
B1a,conc_t0,chat,0.0,4,158.0,40.0,2.51,1.51,22760,33060,0.6884,12,0,1,0,0,0
B1a,conc_t0,chat,0.0,6,213.7,36.5,2.51,1.51,22760,33060,0.6884,18,0,1,0,0,0
B1a,conc_t0,chat,0.0,8,262.0,33.8,2.51,1.51,22760,33060,0.6884,24,0,1,0,0,0
B1a,conc_t0,code,0.0,1,72.9,72.9,5.224,4.224,22760,33060,0.6884,3,0,1,0,0,0
B1a,conc_t0,code,0.0,2,139.0,70.0,4.83,3.83,22760,33060,0.6884,6,0,1,0,0,0
B1a,conc_t0,code,0.0,4,245.5,63.0,4.83,3.83,22760,33060,0.6884,12,0,1,0,0,0
B1a,conc_t0,code,0.0,6,312.1,54.1,4.491,3.491,22760,33060,0.6884,18,0,1,0,0,0
B1a,conc_t0,code,0.0,8,379.3,49.9,4.491,3.491,22760,33060,0.6884,24,0,1,0,0,0
B1a,openai_t0,fibonacci-raw,0.0,1,72.0827562664294,72.0827562664294,5.224,4.224,1488,2384,0.6242,,,,,0,0
B1a,openai_t0,gpu-chat-no-think,0.0,1,46.10521318194038,46.10521318194038,2.813,1.813,1488,2384,0.6242,,,,,0,0
B1b,conc_t0,chat,0.0,1,46.7,46.7,2.813,1.813,22760,33060,0.6884,3,0,1,0,0,0
B1b,conc_t0,chat,0.0,2,87.1,43.8,2.51,1.51,22760,33060,0.6884,6,0,1,0,0,0
B1b,conc_t0,chat,0.0,4,158.2,40.1,2.51,1.51,22760,33060,0.6884,12,0,1,0,0,0
B1b,conc_t0,chat,0.0,6,213.6,36.5,2.51,1.51,22760,33060,0.6884,18,0,1,0,0,0
B1b,conc_t0,chat,0.0,8,262.2,33.9,2.51,1.51,22760,33060,0.6884,24,0,1,0,0,0
B1b,conc_t0,code,0.0,1,72.7,72.7,5.224,4.224,22760,33060,0.6884,3,0,1,0,0,0
B1b,conc_t0,code,0.0,2,138.8,69.9,4.83,3.83,22760,33060,0.6884,6,0,1,0,0,0
B1b,conc_t0,code,0.0,4,245.2,63.0,4.83,3.83,22760,33060,0.6884,12,0,1,0,0,0
B1b,conc_t0,code,0.0,6,312.0,54.1,4.491,3.491,22760,33060,0.6884,18,0,1,0,0,0
B1b,conc_t0,code,0.0,8,379.8,50.0,4.491,3.491,22760,33060,0.6884,24,0,1,0,0,0
B1b,openai_t0,fibonacci-raw,0.0,1,72.96582501540956,72.96582501540956,5.224,4.224,1488,2384,0.6242,,,,,0,0
B1b,openai_t0,gpu-chat-no-think,0.0,1,46.71976289621671,46.71976289621671,2.813,1.813,1488,2384,0.6242,,,,,0,0
B0b,conc_t0,chat,0.0,1,46.6,46.6,2.813,1.813,22760,33060,0.6884,3,0,1,0,0,0
B0b,conc_t0,chat,0.0,2,86.3,43.4,2.51,1.51,22760,33060,0.6884,6,0,1,0,0,0
B0b,conc_t0,chat,0.0,4,156.4,39.6,2.51,1.51,22760,33060,0.6884,12,0,1,0,0,0
B0b,conc_t0,chat,0.0,6,210.9,35.8,2.51,1.51,22760,33060,0.6884,18,0,1,0,0,0
B0b,conc_t0,chat,0.0,8,255.1,32.9,2.51,1.51,22760,33060,0.6884,24,0,1,0,0,0
B0b,conc_t0,code,0.0,1,72.6,72.6,5.224,4.224,22760,33060,0.6884,3,0,1,0,0,0
B0b,conc_t0,code,0.0,2,137.9,69.7,4.83,3.83,22760,33060,0.6884,6,0,1,0,0,0
B0b,conc_t0,code,0.0,4,242.1,62.2,4.83,3.83,22760,33060,0.6884,12,0,1,0,0,0
B0b,conc_t0,code,0.0,6,307.8,53.3,4.491,3.491,22760,33060,0.6884,18,0,1,0,0,0
B0b,conc_t0,code,0.0,8,371.9,49.0,4.491,3.491,22760,33060,0.6884,24,0,1,0,0,0
B0b,openai_t0,fibonacci-raw,0.0,1,72.73186303148962,72.73186303148962,5.224,4.224,1488,2384,0.6242,,,,,0,0
B0b,openai_t0,gpu-chat-no-think,0.0,1,46.631364348835525,46.631364348835525,2.813,1.813,1488,2384,0.6242,,,,,0,0
M2,conc_t0,chat,0.0,1,46.2,46.2,2.813,1.813,22760,33060,0.6884,3,0,1,0,0,0
M2,conc_t0,chat,0.0,2,86.1,43.2,2.51,1.51,22760,33060,0.6884,6,0,1,0,0,0
M2,conc_t0,chat,0.0,4,155.4,39.5,2.51,1.51,22760,33060,0.6884,12,0,1,0,0,0
M2,conc_t0,chat,0.0,6,209.3,35.8,2.51,1.51,22760,33060,0.6884,18,0,1,0,0,0
M2,conc_t0,chat,0.0,8,255.9,33.0,2.51,1.51,22760,33060,0.6884,24,0,1,0,0,0
M2,conc_t0,code,0.0,1,72.2,72.2,5.224,4.224,22760,33060,0.6884,3,0,1,0,0,0
M2,conc_t0,code,0.0,2,137.1,69.2,4.83,3.83,22760,33060,0.6884,6,0,1,0,0,0
M2,conc_t0,code,0.0,4,240.7,61.9,4.83,3.83,22760,33060,0.6884,12,0,1,0,0,0
M2,conc_t0,code,0.0,6,305.5,52.8,4.491,3.491,22760,33060,0.6884,18,0,1,0,0,0
M2,conc_t0,code,0.0,8,369.0,48.6,4.491,3.491,22760,33060,0.6884,24,0,1,0,0,0
M2,openai_t0,fibonacci-raw,0.0,1,72.1171739425607,72.1171739425607,5.224,4.224,1488,2384,0.6242,,,,,0,0
M2,openai_t0,gpu-chat-no-think,0.0,1,46.069790889775746,46.069790889775746,2.813,1.813,1488,2384,0.6242,,,,,0,0
30 changes: 30 additions & 0 deletions docs/receipts/flashnext-gather-early/exactness.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
| contract | M | B0 | B1 |
|---|---|---|---|
| concurrent equals solo (pass A, 1 to 8 streams, greedy) | 252/252 equal | 252/252 equal | 252/252 equal |
| drafted equals `"draft": false` (pass A, 1 to 8 streams, greedy) | 20/20 equal | 20/20 equal | 20/20 equal |
| resumed equals fresh (pass C, 7 chats, cache on against cache off) | 7/7 equal | 7/7 equal | 7/7 equal |
| cancel and reset leave the next request valid (pass C, the cancel route) | 3/3 contracts | 3/3 contracts | 3/3 contracts |
| every greedy reply equals main's (token_sha over pass A's cells), B0 | 528/528 equal | | |
| every greedy reply equals main's (token_sha over pass A's cells), B1 | 528/528 equal | | |

- B0 cache on golden (6 prompts, 1 and 4 streams): concurrent equals solo 5/0; drafted equals `"draft": false` 8/0
- B0 cache on drafts: 8 of 8 equal to `"draft": false` (basis token_ids)
- B0 cache on turns: 7 chats, resumed from cached prompt tokens [13, 16, 16, 13, 24, 18, 3406]
- B0 cache on cancel: 3 of 3 contracts, reply after the cancel True equal to the reference (token_sha256)
- B0 cache off drafts: 8 of 8 equal to `"draft": false` (basis token_ids)
- B0 cache off fresh: 7 of 7 resumed replies equal the fresh ones
- B1 cache on golden (6 prompts, 1 and 4 streams): concurrent equals solo 5/0; drafted equals `"draft": false` 8/0
- B1 cache on drafts: 8 of 8 equal to `"draft": false` (basis token_ids)
- B1 cache on turns: 7 chats, resumed from cached prompt tokens [13, 16, 16, 13, 24, 18, 3406]
- B1 cache on cancel: 3 of 3 contracts, reply after the cancel True equal to the reference (token_sha256)
- B1 cache off drafts: 8 of 8 equal to `"draft": false` (basis token_ids)
- B1 cache off fresh: 7 of 7 resumed replies equal the fresh ones
- M cache on golden (6 prompts, 1 and 4 streams): concurrent equals solo 5/0; drafted equals `"draft": false` 8/0
- M cache on drafts: 8 of 8 equal to `"draft": false` (basis token_ids)
- M cache on turns: 7 chats, resumed from cached prompt tokens [13, 16, 16, 13, 24, 18, 3406]
- M cache on cancel: 3 of 3 contracts, reply after the cancel True equal to the reference (token_sha256)
- M cache off drafts: 8 of 8 equal to `"draft": false` (basis token_ids)
- M cache off fresh: 7 of 7 resumed replies equal the fresh ones
- B0: replies equal over pass A's greedy cells (token_sha): 528 equal, 0 unequal
- B1: replies equal over pass A's greedy cells (token_sha): 528 equal, 0 unequal
- B1 against B0: replies equal over pass A's greedy cells (token_sha): 528 equal, 0 unequal
28 changes: 28 additions & 0 deletions docs/receipts/flashnext-gather-early/noise-rule.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
| invocation | prompt | streams | M1 | B0a | B1a | B1b | B0b | M2 | B0 vs M | B1 vs M | B1 vs B0 | tokens a round M / B0 / B1 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| openai_t0 | fibonacci-raw | 1 | 73.9 | 71.8 | 72.1 | 73.0 | 72.7 | 72.1 | -1.0% level | -0.7% level | +0.3% level | 5.224 / 5.224 / 5.224 |
| openai_t0 | gpu-chat-no-think | 1 | 47.3 | 46.0 | 46.1 | 46.7 | 46.6 | 46.1 | -0.7% level | -0.6% level | +0.2% level | 2.813 / 2.813 / 2.813 |
| conc_t0 | chat | 1 | 46.5 | 45.9 | 46.7 | 46.7 | 46.6 | 46.2 | -0.2% level | +0.8% level | +1.0% level | 2.813 / 2.813 / 2.813 |
| conc_t0 | chat | 2 | 86.6 | 85.7 | 87.0 | 87.1 | 86.3 | 86.1 | -0.4% level | +0.8% level | +1.2% faster | 2.510 / 2.510 / 2.510 |
| conc_t0 | chat | 4 | 156.6 | 154.7 | 158.0 | 158.2 | 156.4 | 155.4 | -0.3% level | +1.3% faster | +1.6% faster | 2.510 / 2.510 / 2.510 |
| conc_t0 | chat | 6 | 210.7 | 208.6 | 213.7 | 213.6 | 210.9 | 209.3 | -0.1% level | +1.7% faster | +1.9% faster | 2.510 / 2.510 / 2.510 |
| conc_t0 | chat | 8 | 257.9 | 255.3 | 262.0 | 262.2 | 255.1 | 255.9 | -0.7% level | +2.0% faster | +2.7% faster | 2.510 / 2.510 / 2.510 |
| conc_t0 | code | 1 | 73.5 | 71.9 | 72.9 | 72.7 | 72.6 | 72.2 | -0.8% level | -0.1% level | +0.8% level | 5.224 / 5.224 / 5.224 |
| conc_t0 | code | 2 | 139.2 | 137.2 | 139.0 | 138.8 | 137.9 | 137.1 | -0.4% level | +0.5% level | +1.0% level | 4.830 / 4.830 / 4.830 |
| conc_t0 | code | 4 | 243.7 | 239.8 | 245.5 | 245.2 | 242.1 | 240.7 | -0.5% level | +1.3% faster | +1.8% faster | 4.830 / 4.830 / 4.830 |
| conc_t0 | code | 6 | 307.5 | 304.4 | 312.1 | 312.0 | 307.8 | 305.5 | -0.1% level | +1.8% faster | +1.9% faster | 4.491 / 4.491 / 4.491 |
| conc_t0 | code | 8 | 373.9 | 369.1 | 379.3 | 379.8 | 371.9 | 369.0 | -0.3% level | +2.2% faster | +2.4% faster | 4.491 / 4.491 / 4.491 |

Verdicts (first pair): B0 vs M: 0 faster, 12 level, 0 slower; B1 vs M: 6 faster, 6 level, 0 slower; B1 vs B0: 7 faster, 5 level, 0 slower

| streams | cells | B0 vs M mean | verdicts | B1 vs M mean | verdicts |
|---|---|---|---|---|---|
| 1 | 2 | -0.52% | 0 faster, 2 level, 0 slower | +0.34% | 0 faster, 2 level, 0 slower |
| 2 | 2 | -0.42% | 0 faster, 2 level, 0 slower | +0.68% | 0 faster, 2 level, 0 slower |
| 4 | 2 | -0.40% | 0 faster, 2 level, 0 slower | +1.32% | 2 faster, 0 level, 0 slower |
| 6 | 2 | -0.12% | 0 faster, 2 level, 0 slower | +1.77% | 2 faster, 0 level, 0 slower |
| 8 | 2 | -0.46% | 0 faster, 2 level, 0 slower | +2.10% | 2 faster, 0 level, 0 slower |

Rerun (one per flagged cell; a repeat of slower is a loss):
No cell was slower in the first pair, so no rerun was taken.
Losses: 0
2 changes: 2 additions & 0 deletions zig/src/families/flashnext/cuda_batch_state.zig
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ const cuda = @import("cuda");
const gdn = @import("cuda_gdn.zig");
const ple = @import("cuda_ple.zig");
const wt = @import("cuda_prompt_wt.zig");
const gather_lanes = @import("cuda_ple_gather_lanes.zig");
const tk = @import("cuda_tile_kernels.zig");
const load = @import("cuda_prompt_load.zig");
const shared = @import("cuda_batch_side.zig");
Expand Down Expand Up @@ -575,6 +576,7 @@ pub const Gather = struct {
};
return;
}
if (gather_lanes.early(g)) return;
var row0: usize = 0;
for (g.lanes) |l| {
g.ngram.rows(l.seq.history[0..], g.ids[row0..][0..l.rows], g.emb[row0 * dims ..][0 .. l.rows * dims], g.xs[row0 * (dims / 32) ..][0 .. l.rows * (dims / 32)]) catch |err| {
Expand Down
5 changes: 3 additions & 2 deletions zig/src/families/flashnext/cuda_ple.zig
Original file line number Diff line number Diff line change
Expand Up @@ -494,13 +494,13 @@ pub const Ngram = struct {
}

/// One call's rows split into `parts` equal ranges, part i filling [i * per, (i + 1) * per).
const Split = struct {
pub const Split = struct {
g: *const Ngram,
ids: []const i64,
out: []u16,
per: usize,

fn part(ctx: *const anyopaque, i: usize) anyerror!void {
pub fn part(ctx: *const anyopaque, i: usize) anyerror!void {
const s: *const Split = @ptrCast(@alignCast(ctx));
const lo = @min(s.ids.len, i * s.per);
try s.g.fill(s.ids, s.out, lo, @min(s.ids.len, lo + s.per));
Expand Down Expand Up @@ -572,6 +572,7 @@ test "a fresh window hashes token 7 into sixteen rows" {
}

test {
_ = @import("cuda_ple_gather_lanes.zig");
_ = @import("cuda_ple_nvfp4_test.zig");
_ = @import("cuda_ple_pool.zig");
_ = @import("cuda_ple_pool_gather_test.zig");
Expand Down
Loading