1c2efd789a92ad3a4b7c19dea16f7fe4e4dfeca9
4524
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
1c2efd789a | Merge f-027-gh-eng-d again (9d85432b8: QFUSE one-token self-commit) | ||
|
|
0d4b2cdd43 | Merge f-027-gh-eng-lm up to 0c7de9868 (#3976 layer-major split prefill, opt-in: STRATA_PREFILL_LAYER_MAJOR=1) | ||
|
|
789d83903b |
STRATA_QFUSE=1: a one-token window did not self-commit, but commit() skipped the commit graph as if it had (#3948)
Problem. #3948: with STRATA_QFUSE=1 the verified text changes and MTP acceptance drops, on CUDA. The QFUSE kernels are bit-exact (gr_parity, gdn_parity, 10,500 random windows each on sm_86 and sm_120, after 91a4b8a67), yet the engine's greedy text still differed from QFUSE off on every prompt tried. Model run, l620 (RTX PRO 5000, sm_120), Qwen3.8-Flash-Next IQ3_S, MTP --spec 6, identity-gate flags, 4 prompts of 4K and 12K tokens, 96 greedy tokens: QFUSE on differed from off on 4 of 4 (the off-vs-off control was identical). Cause. A window of one token advances the GDN state and the indexer tail itself ("self-commit") so that commit() needs no commit graph. Verifier::record_window decides this with `T == 1 && !always_publish_ && !batch_rec_ && !g_qfuse() && one_token_self_commit()`: with STRATA_QFUSE the fused GDN output kernel takes the q8_1 destination and the window does not self-commit. Verifier::commit() skipped the commit graph with `last_t_ == 1 && !always_publish_ && one_token_self_commit()`, without the QFUSE term. So with QFUSE on, every accepted one-token window left the recurrent state (and the indexer tail) one token behind. Windows of one token are the ordinary case when the drafter offers nothing, which matches the report: fewer drafts offered, lower acceptance, different text, and an unchanged text where no window of one token occurs. On HIP (where QFUSE is the default on gfx1151) one_token_self_commit() is off unless STRATA_ONE_TOKEN_COMMIT=1, so the two sides agreed there. Change. commit() takes the same condition: `... && one_token_self_commit() && !g_qfuse()`. Without STRATA_QFUSE nothing changes. Result (same l620 run). QFUSE on with this change against QFUSE off, same build: logits md5 and the 96 greedy tokens byte-identical on all 4 prompts (IDENTITY PASS); the build without the change differs on all 4. The default path (QFUSE unset) of the merged head against the f-027-int2 head (2a2264c21): first-window logits and greedy tokens byte-identical on the same 4 prompts. Not covered. Serve answers and draft counters (3948-qfuse.sh step 2, SERVE=1), sm_86, and the reporter's 40-prompt set. |
||
|
|
9c624c75a9 |
Merge f-027-gh-eng-d (#3602 #3948 #3638 #3702 #3797 #2409 #3844: audits, fixes and tests)
# Conflicts: # src/core/verify.cpp # src/kernels/cuda/fused_gr.cu |
||
|
|
8dd297d0f1 |
PLE table: STRATA_PLE_CHECK=1 names the first row that decodes to an implausible value and says whether the delivered bytes are the file's (#3602)
The report asks for the first data mismatch between the GGUF row bytes and what the direct reader delivered, and for an early check of the gathered values; neither exists. Its trace stops at "the embedding has 96 non-finite values" without saying whether the reader gave a wrong row or the table holds one. With STRATA_PLE_CHECK=1 (a tester switch, off by default; one static flag read per gather call when off) every direct-mode decode (read_row, collect, gather_batch, also from the prefetched slots) checks the row's 160 values. For a value that is not finite or beyond 1e5 (an IQ4_NL row cannot decode beyond 8.3e6; real PLE values are orders smaller) it re-reads that row from the file with a buffered read and prints one line to stderr (at most 8 per table): the row, its file offset and page offset, the value, and either "the delivered bytes ARE the file's bytes" or "THE DELIVERED BYTES DIFFER FROM THE FILE from byte N" with the first 8 bytes of each. That separates a reader fault (the bug) from a damaged table. gates/3602-ple-direct.sh sets it in its direct arms. Checked: ple_reader_test --selftest on z440 with the switch on prints the "ARE the file's bytes" line for the synthetic table's random rows (which decode to huge values); with it off the output and the bytes are unchanged (ple_reader_selftest passes). Not checked: the "DIFFER" branch has no natural trigger (that is the point); it was read, not run. |
||
|
|
7d1016f3f4 |
QFUSE: the fused q8_1 producers divide the way the separate quantiser does; they gave a different code at about one element in a million (#3948)
Problem. #3948: with STRATA_QFUSE=1 the verified text changes and MTP acceptance drops (RTX 3080, sm_86). The report suspected the group counter or the nat_xq_ offsets of fused_gr.cu; the audit and the new two-group test (previous commit of this stream) rule those out. What the new test found instead, on an RTX 5070 (sm_120, CUDA 13.0, MSVC), over 10,500 random windows of two groups: in about 1 run of 400 one q8_1 code of the fused image differs by exactly one from native_quantize_q8_1's, in every mode (group-relative, window-indexed, direct, graph replay). The scale/sum pair and the other codes agree. Cause. native_mmvq.cu, which holds native_quantize_q8_1 (the quantiser every consumer of a q8_1 image was written for), is compiled with --use_fast_math (CMakeLists.txt, the native_* list), so its `amax / 127` and `x / d` are the fast full-range division (div.full.f32, up to 2 ulp off). fused_gr.cu (the hyper-connection read's tail, gr_up_q32_kernel) and verify_kernels.cu (the GDN output norm, gdn_q8_1_store) are not in that list and divide with IEEE rounding. roundf(x / d) then lands on the other side of a .5 at the rare element whose quotient is next to a boundary. One changed activation code per ~10^6 values is about one per few hundred tokens at 80 hyper-connection reads of 2560 values per token: enough to move a near-tie in the verify, and the draft (which quantises with the separate kernel) disagrees with the verifier a little more often, which lowers acceptance. That matches the report (acceptance 0.755 against 0.79, different text, and an unchanged text where no draft is made). Change. include/strata/kernels/q8_1_finite.hpp: q81_div(a, b) is `a / b`, except in a translation unit that defines STRATA_Q81_FASTMATH_DIV (CUDA device code only, never HIP), where it is the same PTX division the fast-math file gets (div.full.f32). q8_1_quant and the scale use it. fused_gr.cu and verify_kernels.cu define the macro; nothing else does, so every other kernel, the separate quantiser and every HIP build compile to what they did. STRATA_QFUSE is off by default on CUDA (it is on by default on gfx1151, which is HIP and unchanged), so the default path is bit-identical. Result (RTX 5070, sm_120): gr_parity's two-group window test: 10,500 runs with 1,500 random inputs for each T, all modes, zero differences (before: dozens); the whole of gr_parity, gdn_parity and gdn_parity with STRATA_GDN_SPLIT=1 pass. Tests. gr_parity: the two-group test prints the first differing bytes (block, field), and STRATA_GRP_REPS=N / STRATA_GRP_KEEP_GOING=1 repeat it longer and count every failure. gdn_parity: the q8_1 destination check uses its own stream (native_quantize_q8_1 refuses the null stream, which crashed the test on Windows), unbuffered stdout and STRATA_GDN_PARITY_TRACE=1. Not covered. sm_86 (the report's card) has not run the new test yet (z440 was reserved for other jobs); the cause is not architecture specific. The model run (gates/3948-qfuse.sh) is still owed: QFUSE on against off must now be byte-identical, and the draft counters equal. |
||
|
|
e0d47034df |
Presets: a value outside the range the tuner tries is kept with a warning, not dropped (#3844)
Problem. #3844: --spec 5 measured +6.1% decode on an RTX 5060 Ti, but a saved preset that carries it was left out entirely ("outside the safe values [3, 4]"), and an imported one was refused. The tuner's BOUNDS are the values it tries; they are not a finding that a value is harmful. The never list (--spec 6 and wider: 4% to 16% slower, --expert-cache 0, ...) is. Change (Terminal / Control; touches strata_control/tune_knobs.py, strata_control/presets.py, strata_cli/tune_commands.py and serve/server.py). - tune_knobs.check_setting_parts(args, env, ctx) returns (never, bounds). check_setting is the two lists together, in the order it had, so the tuner still skips --spec 5 and its tests are unchanged. - presets.overlay applies a preset whose only problems are outside BOUNDS and returns info["warnings"], one short line each ("--spec 5: not tried by the tuner, kept because it is your setting"). A never-list setting still means "not applied". presets.create and import_preset refuse only never-list settings. - serve/server.py prints each warning as "[strata] warning: ..." when the preset is applied; strata_cli tune_commands _effective adds "warnings" to its payload. Tests. tests/tuning/test_presets.py: a preset with --spec 5 is saved, applied (the flag becomes 5, the input config is not modified), warns once, and an in-range preset has no warnings; the never list still refuses --spec 6; import of --spec 5 works. tests/tuning/test_autotune.py: --spec 5 stays in the tuner's refused list. python -m pytest tests/tuning: 274 passed; tests/terminal -k "tun or preset or overlay": passed. Not covered. The app's Details text does not show the warning yet (it reads the payload key above). |
||
|
|
8c0301484e |
Conversation cache: skip a restore only when a card would have to create its copy stream and has no room for it (#2409)
Problem. #2408 / PR #2409: restoring a large parked conversation on a layer split ended the server with a CUDA out of memory on a later card. The PR checks the free VRAM of every card against --vram-reserve-mib before a restore. Its own review points out that a loaded card is always below that reserve, so the check would skip nearly every restore on a split (and on one GPU). It is not ported. What a restore allocates. conversation_snapshot_restore writes into the session's existing buffers (pools(st), the GDN state, the indexer tails); refresh_residency only launches kv_stream_reset or copies into the existing ring. The elastic K/V growth (kvg_ensure) allocates, but only on one GPU. The one thing a restore can create on a card is the calling thread's private copy stream for it (conversation_copy.hpp private_stream), which it takes from the pool of finished threads when there is one (#3350). A failed restore is fatal by contract (the session may be half written). So the need is one stream and one event, and only for a card whose stream does not exist yet (a snapshot loaded from disk, or a restore on a thread that never copied on that card). Change. conv_cache.hpp: kRestoreFirstUseMib (64) and restore_fits(free, stream_ready, n, need): a restore is refused only for a card that has no copy stream yet and less than 64 MiB free. conversation_copy_stream_ready(device) says whether a card has one. generate.cpp: before the restore, each card of the run is checked; a snapshot that would not fit goes back to the cache and the prompt is read again, with a log line. A card that has its stream is never refused, however full. No sample (a failed cudaMemGetInfo) means the restore goes ahead as it did. Tests. conv_cache_test: the predicate (cards with a stream are admitted at any free size; the edge at the need; no sample / no cards / no need). conversation_copy_streams_test: copy_stream_ready before and after the first copy, in the pool after a thread ends, and the measured cost of a card's first copy stream and event (printed; the test requires under 16 MiB, so 64 MiB leaves a wide margin). conversation_snapshot_test: after the first restore, six more restores of two images leave the free VRAM where it was. Not covered. The pure predicate and the generate.cpp code build on z440 (CUDA 13.0); the GPU tests are listed in the stream notes. No model run: gates/2409-restore-guard.sh (a held-VRAM start on a layer split) shows the skip line and an unchanged answer on the second turn. |
||
|
|
2a9a67c174 |
Later-card VRAM: audit fixes for failed allocations, the reserve arithmetic as a tested helper, a per-card out-of-memory report (#3638 #3702 #3797)
Problem. On a layer split the later cards are left with very little VRAM after loading (#3702: 68 MiB on the last card; #3638: 268 and 666 MiB, then every batched prompt read of more than ~400 tokens ends non-finite after hours; #3797: the weight arena fails with 320 MiB free and the message does not say who holds the rest). The window-graph eviction (12b0bce95) and the copy stream pool (#3350) are in already; this is the rest of the code audit of what is allocated after load. Audit. The table of every lazy allocation after load (what, when, size, how a failure is handled) is in phaseA-tests/notes-027-gh-eng-d.md. Bugs found and fixed here, each small: - verify.cpp capture / capture_batch and mtp.cpp finish_capture: the cudaGraphUpload and its sync were only printed. The upload is a warm-up, but a failure (no VRAM) stayed as the thread's pending error and the next kernel wrapper's cudaGetLastError ended the engine. The error is now cleared and the first launch uploads the graph. - verify.cpp capture_commit and mtp.cpp finish_capture: the commit graph called cudaGraphInstantiate directly (no eviction of older layouts, unlike the window graphs) and reported the status of the end-of-capture call, which is success, so the message read "no error". capture_commit now goes through instantiate_evicting and reports the instantiate's status. - instantiate_evicting instantiates into a local and sets the member only on success (what a failed instantiate leaves in its output is not specified, and a non-null member means "captured"). - prefill.cpp carve: after a failed take of the shared region the sub-allocators had no base and each cudaMalloc'd its buffer (hundreds of MiB in all) on the card that had just run out. carve now returns at once; the caller reports the failure as before. - generate.cpp: a failed set_stage_helper / set_peer is reported and the run goes on, but its CUDA error stayed pending; cleared. Found and not changed: relend() re-plans only the first participant (#3638 comment). Read: it runs only from the VRAM command, which is off on a layer split, so it cannot touch a later stage's loan. Other candidates (ignored cudaEventCreate for the pipelined fences, unchecked expert copies, cudaFuncSetAttribute flags set before success) are in the notes. Changes for the report of #3797 and the reserve (#3702). - include/strata/program/gpu_report.hpp: on a failed weight-arena allocation (first card and each stage) the engine now also prints, for every card of the run, the free and total memory and the largest other programs that hold memory on it (NVML, loaded at run time; where the driver does not list them it says so). Text only; the failure is the same. tests/program/gpu_report_test.cpp pins the text. - include/strata/program/stage_reserve.hpp: the arithmetic of stage_room (what the split keeps free on a card) moved out of generate.cpp unchanged; tests/program/stage_reserve_test.cpp compares it with the old expression over a grid. The file also holds a PROPOSAL for a larger window term on a later card (96 MiB + 6 MiB per further window size + 48 MiB, 174 MiB for --spec 4) which nothing calls: the default placement is not changed. gates/3702-later-reserve.sh measures it. - The low-VRAM warning of a later card now adds how many MiB the plan meant to keep free there and how far off that was. Tests: gpu_report_test, stage_reserve_test (host only, built on z440). Not covered: no model was run. What the ~700 MiB the plan does not count on the last card is (window graph sets, kernel code loads) needs the run in gates/3702-later-reserve.sh. |
||
|
|
11b0490228 |
tests: STRATA_QFUSE parity for a window of two groups and for the GDN q8_1 destination (#3948)
Problem. #3948 reports that STRATA_QFUSE=1 changes the verified text and lowers MTP acceptance on an RTX 3080 (sm_86); the control (QFUSE off against off) was noisy too. The reporter read the code and suspects the per-group counter in fused_gr.cu gr_q8_tail (not reset when a graph replays with another T) or the nat_xq_ offsets of a window of two groups. Audit (no model run). The counter is reset by the block that finishes the group (atomicExch before it reads the 32 values), so a launch leaves it at zero whatever T is; two blocks own a 32-column group in every kernel that calls gr_q8_tail, the 32-column kernel (gr_up_q32_kernel) quantises on its own without a counter; the fence pattern is the usual threadFenceReduction one. The two destinations are consistent with their consumers in verify.cpp: the attention half's xq_ is indexed from the group's first token (the projections read it from row 0), the expert half's nat_xq_ by the window's token (the experts read it from tb). The GDN side (verify_kernels.cu gdn_q8_1_store, rows from t_out_begin) matches its consumer too. I found no defect by reading. One thing the tests below will show if it matters: nvcc ignores the `#pragma clang fp contract(off)` in gdn_q8_1_store, so on CUDA the ds.sum field could differ by one ulp from the separate quantiser (the q8 bytes would not). Tests (synthetic data, no model). - gr_parity: the engine's G = 2 call pattern - the window split at (T + 1) / 2, two fused_gr_read_multi calls in a row on one stream with the same counters, group-relative destinations (xq_) and window-indexed ones (nat_xq_), direct and as a graph replay; fresh random inputs for every one of 200 repetitions for each T = 2..8; after every run both groups' q8_1 bytes equal native_quantize_q8_1 of `mixed`, nothing outside the written ranges changed, and all counters are back at zero. - gdn_parity: gdn_step_norm_multi with a q8_1 destination for every T and t_out_begin (verify and commit calls): the bytes equal native_quantize_q8_1 of the output rows, the outputs and the state are the ones of the call without it, and nothing is written past the rows. A second ctest, gdn_parity_split, runs all of gdn_parity with STRATA_GDN_SPLIT=1 (the 4-blocks-a-head step, which has its own output-norm kernel). Not covered. The reporter's model run (QFUSE on/off, MTP, 40 prompts): gates/3948-qfuse.sh. The tests were built on z440 (CUDA 13.0, sm_86); their GPU run is listed in the stream notes. |
||
|
|
ebe3383a3f |
PLE reader: a failed read no longer leaves the next ticket waiting for ever; stress test for the direct table reader (#3602)
Problem. #3602 reports a deterministic all-logits NaN with --ple-io direct on IQ3_S (Windows, two GGUF shards) where --ple-io mmap passes; a diagnostic build found non-finite values already in the gathered PLE embedding of one token. The bytes the model got were not the file's (the largest finite value, 7.9e6, is what a random fp16 scale gives an IQ4_NL row). This commit audits the reader and builds the test the report asks for; it does not claim to have found that fault. Audit (no model run). src/ngram/ple_reader.cpp, src/platform/direct_file.cpp and the consumers (PleTable gather_batch / prefetch_rows / collect, prefill's double-buffered ple_gather, verify's windows): rows are copied and cached under the reader's mutex after a complete read, short reads are checked per row, straddling rows get a two-page read, the offset arithmetic is 64-bit, the set-associative cache and the slot buffers are only touched under the lock, and prefill's two host buffers are ordered by the ple_copied events. I found no way to hand out a row before its read completed or from a stale buffer. One real bug, in the error path. After a failed read the I/O worker parks for good (worker_loop), but issue() went on queueing jobs, so the next collect() waited for them for ever. issue() now returns a ticket with no jobs once the reader has failed, and collect() returns the error at once (and drops the ticket). Same change in the SYCL copy (sycl/src/ngram/ple_reader.cpp). Tests. - src/ngram/ple_reader_stress_test.cpp (ctest ple_reader_stress): 7 table shapes (header 0/192/4000/4051, rows of 1, 90, 110, 160 and 4096 bytes, with and without bytes after the table) x 15 reader configurations (io thread or caller, in-flight 1/2/3/64, row cache of 0, 16 and 100000 rows, injected completion delays, keep-alive), four client threads with one to three tickets outstanding collected in any order; every delivered row is compared byte for byte with a buffered read of the file; collected buffers are compared again later (a late write would show); rows on every page phase, the last rows, out-of-range rows; the reader after a failed read (the file is cut short under it); with --big a 5 GiB sparse table with rows around 2^31 and 2^32 and at its end. - table_is_consistent_under_concurrent_use in src/ngram/ple_reader_test.cpp: one PleTable used by a prompt thread (big gather_batch), a decode window (prefetch_rows, gather_batch) and single gathers at once, against the mapped reader. Results (z440, Linux, g++ 13, reader + direct_file + test built alone): plain build with --big OK; ASan+UBSan OK. The error-path test against the unchanged reader hangs (the test exits 3 after 20 s); with the change it passes. ThreadSanitizer flagged a data race that was a mistake in the test (the delay changed from a second thread in the caller-thread mode, which has no lock); fixed in the test. Not covered. The NaN itself: it needs a run on the reporter's configuration (gate script gates/3602-ple-direct.sh). The Windows run of the new test is listed in the stream notes. |
||
|
|
ba8b2bcb9c |
Merge f-027-gh-eng-a (#3622 ARM64 / DGX Spark port, #3806 Gyro-L TQP5/6/7)
# Conflicts: # cmake/ggml_tq_overlay_test.cmake # src/core/verify.cpp |
||
|
|
38b06316ef |
Gyro-L: read the pair-trellis types TQP5/TQP6/TQP7 (ggml 147-149) on the CPU, CUDA and the MMQ prompt path (#3806)
Gyro-L (agentionai's 50 GiB file) stores its experts as a pair trellis: 128 values per block, a fp16 scale and 64 steps of K bits (K = 5, 6, 7), two weights per step taken from the first pair of the TQ2_T codebook entry the step's state selects. The engine refused the file because it did not know the three type ids. This adds them next to the existing trellis types 144-146 without changing those. What changed: - gguf_reader.hpp / tools/gguf_reader.py: names and block sizes (42 / 50 / 58 bytes). - tq_cpu.*, tq_states.hpp, tq_avx2.cpp: tq_supported / tq_kbits / tq_block_bytes for the new ids (the bytes per block are 2 + 8K for the pair layout, 2 + 4K for the others), a scalar pair kernel (the reference) and an AVX2 pair kernel that is bit for bit equal to it; AVX-512 uses the AVX2 pair kernel. - iq_kernels.cu: TqInfo, the lane decode (tqp_states8, a byte window), the dot product, the decode-once Split, the fp16 dequantizer and the format lists for 147-149. They are reached only by a pack that holds these types. - moe_mmq.cu, strata_ggml_tq_overlay.cmake, third_party/ggml-tq/tq.cuh, ggml-common-tq.h: the MMQ prompt path for the three types (overlay enumerators, traits, tile loader branch, instances). - native_expert_parity: names tqp5-7 and skips its synthetic check, with a message, on a ggml that has no trellis traits. - docs/GYRO.md: the "not supported" sentence now says how Gyro-L is read. Changes to the contributor's patch: - tq_cpu.cpp called the AVX2 pair kernel without the x86 guard the rest of the file has, which breaks the Metal build (it compiles tq_cpu.cpp without tq_avx2.cpp): the pair rows go through one helper that falls back to the scalar kernel. - moe_mmq.cu named GGML_TYPE_TQP5-7 under STRATA_MMQ_TQ, but the public agentionai llama.cpp has the older trellis types and not these: a new STRATA_MMQ_TQP (set for the overlay and for a tree that has the tqp instances) guards them, so that tree still builds. The HIP overlay lists get the three instances too, and ggml_tq_overlay_test checks them (and sets the CMake policy its IN_LIST needs). - native_expert_parity: the skip test compared a type-name pointer to null, but ggml_type_name of an id past the table reads past it (the test crashed on an upstream ggml); it compares against GGML_TYPE_COUNT. - docs/GYRO.md keeps the plain description and leaves out the contributor's measured speeds (we have not repeated them). Tests added: src/kernels/cpu/tqp_cpu_test.cpp (no ggml, no model: the scalar kernel against a bit-by-bit reference from the format definition, every ISA equal to scalar for 1-8 tokens and for gate/up rows, the type predicates for ids 0-299 against the old formulas), the pair types in tq_pascal_bench (fp16 dequantizer bit for bit against the definition, decode kernels within 3e-2, decode-once == per-column), tools/test_gguf_tqp.py, and native_expert_parity tqp5/6/7 registered when the ggml tree has the tqp instances. Checked (no model): tqp_cpu_test passes on x86 (AVX2 on z440; AVX2 and AVX-512 on the owner PC with MSVC); tq_pascal_bench on an RTX 5070 (sm_120, MSVC build): 0 failures, the TQP dequantizer matches the definition in all bits, and the checksum lines of TQ2_T/TQK6/TQK7 are byte-identical to the build without this change. Builds: CUDA sm_86 (gcc), sm_60 (CUDA 12.9), sm_120 (MSVC), SYCL, and the CPU files for aarch64. Not covered: the contributor's own parity runs need a ggml tree that carries the types (not public here), and the 50 GiB model run (load check, coherent answer, 32K prompt, MTP, Gyro-S/M identity) is still to be done. Metal, SYCL and HIP have no kernels for the types; HIP was read, not built. |
||
|
|
1e57a924d0 |
Merge f-027-gh-eng-m (#3416 gated MTP: opt-in proposal law, window-invariant CPU dispatch, draft policy)
# Conflicts: # docs/DETAILS.md |
||
|
|
ca17d0f5cd |
spec: a gated request's lookup policy learns from committed rounds only, DraftPolicy choose() unchanged otherwise (#3416)
Problem (KeyanHu-git): the gated proposal needs the choice between the MTP window and a lookup window to be fixed by the history, not by the draws of the rounds it will verify. Freezing the policy for the whole request (the first commit) does that, but also freezes the cost table, so a repeat-heavy request kept the window sizes it inherited. In the author's diagnostic workload the frozen policy chose mean lookup windows of 5.87 and 3.38 on two repeat requests; with this change 4.31 and 4.05 (from the PR text; not reproduced here). Change: the request's copy of the DraftPolicy (source_policy) gets three calls, used only when gated_proposal is on: - observe_committed(): the round's accept and probe counts, applied at once. A lookup window counts as a probe of its size (tried_), so a size whose cost is only guessed is tried kProbes times, not every round. - defer_cost(end, t, ms): the round's time is held. A time covers the window and the next MTP draft, so it depends on every Philox counter up to max(p + T - 1, p + a + 1 + S_mtp). - apply_costs(committed): applies, in order, the held times whose end is behind the committed position, with the same update observe() makes (including the STRATA_SPEC_COST clamp), in the context bucket the round ran in; delayed_n_ keeps a held time from counting as a second probe. choose() counts the probes as cost_n_ - delayed_n_ + tried_. Port note: the DraftPolicy on the current tree keeps its costs per context bucket (STRATA_SPEC_COST), so tried_, delayed_n_ and the held times carry the bucket. A gated request does not run with STRATA_SPEC_COST (it falls back to the older rule), so its copy stays in bucket 0. Default path: unchanged. choose() reads two new terms; on any path that never calls the new functions tried_ and delayed_n_ are +0.0 and cost_n_ - 0.0 + 0.0 == cost_n_ exactly. Checked by driving the old DraftPolicy (namespace-renamed copy of f-027-gh-eng) and the new one with the same random call sequences (observe, observe_chain, observe_probs, set_context, seed_costs, set_robust, choose, chain, keep_draft; 400 sequences of 3000 steps): 25,983,538 bitwise comparisons of picks, costs and rates, 0 mismatches; one observe_committed call makes the same harness report 60,528 mismatches. generate.cpp: nothing calls the new functions when gated_proposal is false. Tests: draft_policy_test (the PR's added assertions, on the bucketed class) and spec_admission_test pass on z440 and on the owner PC. Not covered: the sampling argument for the delay boundary (that a held time cannot steer a window through a counter that is drawn again) is the author's; a unit test cannot show it, only the distribution run (gate script 3416-spec-prob-dist.sh, arm NEWLK) can. |
||
|
|
499e963593 |
native experts: window-invariant CPU arithmetic for STRATA_SPEC_PROB decode, Default dispatch unchanged (#3416)
Problem (KeyanHu-git): the rejection rule of the previous commit judges each row against the target's probabilities p. For a native (IQ) pack the CPU experts round a token's rows differently depending on how many tokens share its expert in the window (the grouped kernels against ggml's one-token dot, #152). So p of one row moved with the window width, and the same sampled text could depend on the draft length. On random blocks a grouped Default call differs from the token alone in 700 to 12000 of about 18000 output floats for the IQ gate/up and IQ4_NL down formats. Change: NativeArithmetic { Default, WindowInvariant }, fixed for one pool batch. native_gu_rows / native_down_rows become thin wrappers of one template with the arithmetic as a parameter. The Default instance keeps every old branch (the new conditions are compile-time true there). WindowInvariant gives each token the bits of the one-token call on this build and CPU: kernels that already match it stay grouped (NVFP4, Trellis and Hadamard rows, KQ256 when ggml runs its AVX2/FMA dot); the IQ rows that differ use iq512_reference_gu_rows (types 18, 21, 22: the same decode, ggml AVX2's accumulation order, one weight decode per group) or iq4nl_reference_rows (IQ4_NL down), and anything else falls to the one-token dot per token. ExpertPool::run_split_multi_native takes the arithmetic and expert_pool_dispatch_multi passes it; generate.cpp uses the invariant pool only when the MTP drafts probabilistically (mtp.prob(), i.e. only with STRATA_SPEC_PROB=1). Prefill, greedy decode and every other decode run Default. The pool picks the entry point with one compare and a direct call per chunk. Default path (STRATA_SPEC_PROB unset): unchanged, shown by running the old and the new native_gu_rows / native_down_rows (Default) on the same random blocks: 61 format, width and amplitude lines (IQ2_XXS/XS/S, IQ3_XXS/S, IQ4_XS, NVFP4, Q4_K, Trellis with and without folded Hadamard, IQ4_NL / Q2_0 / Q5_1 / Q8_0 down; widths 1 to 8; row sub-ranges), output hashes identical in 10 settings of the environment switches on z440 (AVX2) and in 13 on the owner PC (Zen4, AVX-512, MSVC), including STRATA_NO_IQ512, STRATA_IQ_GATHER and STRATA_IQ_MT_MIN=1. g++ codegen of the AVX-512 row kernels is not byte-identical for 5 of 87 functions (inlining and register allocation of the same source); the AVX-512 kernels were run only under MSVC. Tests: native_arithmetic_parity, eight ctest configurations (default, AVX, KQ256, IQ_MT_MIN=1, no512, ggml only, NVFP4 AVX2, NVFP4 ggml), registered in CMakeLists.txt and sycl/CMakeLists.txt. It compares the invariant entry points at every group width 1..8 with the one-token calls, bitwise, for the IQ, NVFP4, Q4_K/Q5_1/Q8_0, Trellis and Hadamard formats. All eight pass on z440 and on the owner PC; the existing CPU expert tests (iq_avx2_parity, iq_avx1_parity, iq512_gather_parity, pool_tasks_test, nvfp4_cpu_parity, router_dot_parity, q2_bitplane_parity) pass. Not covered: an ARM CPU (not built here), an AVX-512 machine with fast gathers (Sapphire Rapids), the layer-split call site, and any model run. |
||
|
|
f4612b1add |
spec: STRATA_SPEC_PROB=1 keeps the confidence gate in the proposal law, opt-in (#3416)
Problem (KeyanHu-git, refs #2028, #2591): with STRATA_SPEC_PROB=1 the default --spec-min-p gate tests the token drawn from the draft head's distribution q, but the verifier still judged the draft against the unfiltered q and treated a failed gate as a plain sample from p. That shifts the output distribution: with p = (0.5, 0.5), q = (0.875, 0.125) and threshold 0.5 it emits (0.5625, 0.4375). Change: the gate is part of the proposal. Keep q's mass on the tokens that pass the gate without renormalising (mu); a draw that fails the gate becomes NULL. An offered token D is accepted with min(1, p(D)/mu(D)); a rejection and NULL draw from the normalised positive part of p - mu; a position with no attempted proposal is a plain sample from p. Serve and the CLI build the same packet (core/gated_proposal.hpp) and give it to the verifier explicitly (Verifier::set_spec_proposal, sample_tokens_proposal). The explicit call has no plain-p fallback: an invalid packet row is reported, not sampled around. STRATA_SPEC_PROB_GATE=top keeps its normalised-q rule. Default path (STRATA_SPEC_PROB unset): unchanged. mtp.prob() is false, so gated_proposal is false, the new draft-result argument is null, GatedDraftLimit does nothing, Verifier::run takes the old branch (set_spec_q clears the measure flag), and the sampler kernel's old instance is the old code with the new branches compiled out. Read hunk by hunk; no hunk runs a new branch or a new allocation per token. The default-identity model run is written as a gate script and not run yet. Port notes against the PR as submitted: - Unsupported combinations (parallel or multi-device decode, --lookup-chain, --adapt-swaps, PCIe share, --spec-min-p not finite, STRATA_SPEC_COST, DFlash2, STRATA_SPEC_T_CYCLE, --spec-corrupt, Metal) used to be an error that ended the request or the server. They now warn once and keep the older rule, so setting the variable never stops a run. --adapt-swaps 96 and the PCIe share are on by default, so the exact rule needs --lookup-chain 0 --adapt-swaps 0 --pcie-frac 0. - The lookup source of a probabilistic window is chosen by a copy of the policy fixed at the request start, without asking whether the MTP's first guess agrees. Learning from committed rounds inside a request is the policy commit of this series. - The CLI loop on the current tree has the out-of-memory window retry, DFlash2 and STRATA_SPEC_T_CYCLE; the gated path does not use the retry (a narrower window would change the room the packet was built for). Serve keeps merged first windows (STRATA_ADMIT_MERGE_FIRST) at their length. - docs/DETAILS.md: two short bullets instead of the PR's long paragraph (that paragraph no longer exists on this tree). bench/results and the PNGs are not ported. Tests: gated_proposal_test and spec_admission_test (default, pick, top, exact-top-only) pass on z440 (CPU, g++ 13) and on the owner PC (MSVC). On the owner PC's RTX 5070 (sm_120, MSVC build, synthetic data, no model) spec_proposal_parity, spec_verify_parity and sampler_parity (default, one-block and old-kernel configurations) pass. Also built: CUDA sm_86 on z440 and boston, SYCL on P1006 (engine and host tests). The Metal path is not built here. Not covered: a model-level distribution test (chi-square of the first tokens against plain sampling) and the identity run with the variable unset. Both are written as gate scripts (3416-spec-prob-dist.sh, 3416-default-identity.sh) and not run. |
||
|
|
9e20319069 |
layer-major prefill: declines on STRATA_EXPERT_NIBBLE builds (#3976)
f-027-gh-eng gained STRATA_EXPERT_NIBBLE (4-bit expert slots, the sm_60 experimental build): only run_impl gathers such a layer for MMQ. The layer-major walk would read the slot as GGUF blocks, so lm_prepare now declines when any layer is converted and the prompt takes the chunk-major path. Compiled out of every build without STRATA_EXPERT_NIBBLE_BUILT. |
||
|
|
0959545e21 | Merge f-027-gh-eng into f-027-gh-eng-lm | ||
|
|
a4c41a92ee |
Build the engine for ARM64 (DGX Spark / GB10) without changing the x86 build (#3622)
The engine did not build on aarch64: the CPU expert path assumed the x86 AVX kernels, the CPUID probes and the x86 spin/fence intrinsics. After this change the strata target compiles on aarch64 (CUDA host code, native GGUF packs). On x86 nothing is selected differently. What changed: - CMake: STRATA_CPU_X86 is decided from CMAKE_SYSTEM_PROCESSOR (an unset processor stays the x86 build). On aarch64 src/kernels/cpu/portable.cpp stands in for the AVX kernel sources; native experts run on ggml-cpu's NEON dot products. -ffp-contract=off on aarch64. STRATA_ISA_FLOOR is ignored with a warning there. - include/strata/platform/cpu_relax.hpp: strata_cpu_pause / strata_store_fence map to _mm_pause / _mm_sfence on x86 and to yield / dmb oshst on aarch64. verify.cpp, pool.cpp, session.cpp, mtp.cpp and graph.cpp use them. - expert_layout.cpp: the CPUID/XCR0 probes compile on x86 only and report no AVX on other CPUs. - generate.cpp: --cpu-oracle-q8-0 is rejected on a non-x86 CPU. - setup.py: nvidia-smi's "[N/A]" memory on GB10 (unified memory) takes the pool size from /proc/meminfo on ARM64 only; the CPU probe no longer needs the x86 "flags" line; setup warns that the ARM64 engine is compiled on the PC and which packs work. Changes to the contributor's patch, found while moving it onto the 0.2.7 line: - portable.cpp had no iq512x_rows / iq512x_supported / iq512_gather_on (added to the x86 kernels after the PR was written): the aarch64 link would fail. - The Metal build (Apple silicon) shares these files. It keeps its barrier (dmb ishst), its plain router loop (its bf16_rows_dot_multi is a stub), its Metal start-up block in generate.cpp and its "unknown" CPU name. - The CPU side of the GPU doorbell: strata_load_fence() after the spins that wait for a flag the GPU raised (dmb ishld on ARM, nothing on x86 and on Apple silicon), so the data written before the flag is not read early. - A card whose memory nvidia-smi does not report stays unlisted on x86 (the new fallback is for ARM64 only). - tests/terminal/test_setup_arm64.py. Checked: with the x86 CUDA build (sm_86, gcc 13 -O3, z440) the objects of verify, session, mtp, graph, expert_source, pool, expert_layout and generate are byte-identical before and after (the x86 wrappers are macros for the same intrinsics). Every C++ file of the strata target compiles for aarch64 with clang, and the symbols of the CPU kernel library link up (syntax and symbols only: no ARM machine, no ARM run). The Metal-shared files compile for aarch64-macos with STRATA_GPU_METAL. Not covered: no ARM hardware here. The tests that include x86 headers (iq_avx2_parity and the other AVX parity tools) and the DeepSeek target do not build on aarch64; the strata target does not need them. Memory ordering on ARM is reasoned, not run. The Q2_0 and Gyro packs need the x86 kernels. |
||
|
|
2651c4a96b |
Merge f-027-int2 (2a2264c21) into f-027-gh-eng
# Conflicts: # tools/calibrate.py |
||
|
|
2579635138 | sm_80 defaults of #3779 (wide dense dequant, MMVQ-IL sm_80 tables) follow STRATA_DEFAULTS=026: back to the 0.2.6 kernels and the shared table; explicit =1 and =0 still win; arch_defaults_test checks the rule; release-notes line | ||
|
|
1e278a280d |
Merge f-027-gh-eng-n (#3779 sm_80 tuning: wide dequant, MMVQ-IL sm_80 tables and the opt-ins)
# Conflicts: # CMakeLists.txt # docs/MMVQ_IL_TABLE.md # src/kernels/cuda/native_mmvq.cu # src/kernels/mmvq_il_parity.cpp # src/program/generate.cpp |
||
|
|
56d98f164e |
docs: the sm_80 defaults and the opt-in sm_80 switches of #3779, STRATA_GRAPH_PRIO and STRATA_MMVQ_IL_PF (#3779, #3712)
DETAILS.md gets two sections: the decode switches (GRAPH_PRIO, MMVQ_IL_PF) with the two sm_80-only defaults named, and the prompt switches (PF_FUSED_NT / BATCH / F16 / WS, GDN_TC, PLE_COMPACT / PLE_COPY_STREAM, EMBED_VRAM, DEQUANT_SIDE) with what is bitwise and what is rounding-level. MMVQ_IL_TABLE.md gets the sm_80 row of the table list and a paragraph on the hoisted-load tables (kIlPf_80 / kIlPf58_80, Q6_K only) and on measuring a card with mmvq_il_parity --bench --emit-table --pf 0,3,4. Rewritten from the PR's text: every figure is labelled as the reporter's (one CMP 170HX; we have no sm_80 card and measured none of them), and the prompt-switch section is new (the PR documented only the decode switches and the conversation cache). Original docs by linxuhao (PR #3779, commit 6d6f0f39). |
||
|
|
8b95bffb0b |
Decode: opt-in STRATA_MMVQ_IL_PF=1 hoisted-load, exact-integer interleaved GEMV kernels for Q6_K (#3779, #3712)
Problem: the interleaved small-batch matvec (native_mmvq_il) has one weight block in flight per warp: its four `if (kbx < bpr)` sections each sit behind their own branch, so on a GA100 (ncu: 432 GB/s on the qkv Q6_K matrix) the loads of a group are not issued together. Change, opt-in (every variant is bitwise native_mmvq): native_mmvq_il_pf_kernel issues every weight load of a group (4 virtual warps x R rows) before any of the group's dots, with the addresses clamped to the row's last block for a tail, and with the ring variants the next group's loads before this group's dots. The per-lane accumulation order is the plain kernel's. P2's forms replace conversions by exact ones where the value is a small integer: (float)p becomes p + 1.5 * 2^23 minus 1.5 * 2^23 for |p| < 2^22, and the saturating byte subtract of Q6_K's codes (0..63, so nothing saturates) becomes two instructions. Q4_K, Q5_K, IQ4_XS and Q6_K have the variants; Q3_K (the Q2_0 pack's type) keeps the plain kernel. - STRATA_MMVQ_IL_PF=1: the measured table (kIlPf_80 / kIlPf58_80: Q6_K only, read only when the card is sm_80; on every other card 1 does nothing); =2..6: one variant for every type and shape (A/B only, any CUDA card). - Unset or 0: the plain kernels through the same launch code (the variant argument is 0, and the added code is one cached environment read and a switch). - CUDA only; HIP has no interleaved path. Tests: mmvq_il_parity --pf a,b,.. bit-checks each listed variant against native_mmvq for every type and shape, T = 1..8 and rows 0/1/2/4, and with --bench times them interleaved (PFBENCH lines) and prints the joint (variant, rows) table in the source form of kIlPf_<cc>. New ctest entry mmvq_il_parity_pf runs it with --pf 0,2,3,4,5,6 on whatever card is present. Reporter's numbers (linxuhao, CMP 170HX): decode +1.4 % (two reference / on / reference / on sets) over the plain kernels; with STRATA_GRAPH_PRIO decode +1.3 % in their per-feature pair (4K prompts +3.9 %, 16K +1.2 %, 52K +0.2 % in the same pair, which the reporter reads as noise). Q4_K, Q5_K and IQ4_XS variants tie the plain kernels there. Theirs, not measured here. Original change by linxuhao (PR #3779, commit 116992ab). |
||
|
|
c2d3fe5000 |
mmvq_il_parity: the L2-residency arms (--hot / --gap / --persist / --ab), the clock warm-up and MMVQ_IL_TMIN (#3779, #3712)
Harness only; no engine code. The bench part of mmvq_il_parity times the interleaved matvec cold (24 copies of the weights rotated past the L2), hot (one copy), hot with other weights' reads in between (--gap MB, what a window's GEMVs do between a prefetch and its consumer), and with the timed weights in a persisting L2 set-aside (--persist); --ab runs the five arms per case in one process, because the clocks ramp over the first ~100 ms of a run. A 150 ms warm-up of launches runs before the first timed case, and MMVQ_IL_TMIN bounds T from below. The parity part is unchanged: without --bench the same checks run in the same order (every rows choice against native_mmvq, bitwise). The bench code is CUDA only (the test is built with STRATA_ENABLE_CUDA); the persisting-L2 calls are left out under STRATA_HIP_GFX906. Original change by linxuhao (PR #3779, commit 1f4b8139). |
||
|
|
0049fa73ff |
Decode window: opt-in STRATA_GRAPH_PRIO=1 gives the window graph's kernel nodes their stream's priority (#3779, #3712)
Problem: the decode window graph runs every kernel node at the launch stream's priority, so the one-block indexer kernels of the side branch wait behind the queued blocks of the big q GEMV, and the shared expert competes with the routed experts. Change, opt-in (bitwise by construction: no kernel changes, the same launches on the same inputs; only the dispatch order moves): with STRATA_GRAPH_PRIO=1 the side mixer's branch stream (GDN gates, QSA indexer chain) is created at the device's highest priority, cs_ and side2_ in the middle, the shared expert's stream at the lowest, and the window graph is instantiated with cudaGraphInstantiateFlagUseNodePriority. If a driver did not copy the stream priority into the nodes, the capture-time notes (the branch forks and the priority streams' tails) set the attribute per node. One log line per captured window prints the node priority histogram. A card whose priority range is 0..0 changes nothing. CUDA only: the members and the three methods sit under !STRATA_USE_HIP && !STRATA_HIP_GFX906 && !STRATA_GPU_METAL; graph_prio_on() is false there. Merged by hand with #3702 (the window-graph eviction): instantiate_evicting now takes both keep_t and the flags, and the retry after freeing other window sizes keeps the flags (the merged code would otherwise have dropped the node priorities on that retry). With the variable unset: every stream is created as before and the capture-time notes return at once. Tests: none of its own (a priority is a scheduling hint with no value to compare). The window graphs are exercised by the engine; see the checklist for the reporter's greedy-answer identity check. Reporter's numbers (linxuhao, CMP 170HX, IQ3_S, --spec 3, 3K context, interleaved in one session, each arm with STRATA_QIL=1): reference 125.3 / 126.6, GRAPH_PRIO 127.8 / 129.0, reference 125.0 / 126.8 tok/s, +1.8 %. Greedy 11 of 11 identical. In the later per-feature pair together with STRATA_MMVQ_IL_PF: decode +1.3 %. Theirs, not measured here. Original change by linxuhao (PR #3779, commit 68c487c3). |
||
|
|
0e63d59c01 |
docs: conversation cache copies on a slow host link, STRATA_CKPT_ASYNC and the park switches (#3779, #3712)
One section in DETAILS.md for the switches the four conversation-cache commits add: what each copies where, its VRAM and host memory cost, that they stay off on HIP, gfx906 and Metal, and the measured times. Rewritten from the PR's section: the times are labelled as the reporter's (linxuhao, one CMP 170HX on PCIe Gen2 x4; we have no sm_80 card and measured none of them), the independent RTX 3090 data of bitaccesscomau is added, and the pool row describes STRATA_CKPT_POOL_READY=N instead of the PR's change to the meaning of STRATA_CKPT_POOL=N (STRATA_CKPT_POOL=1 is unchanged). Original section by linxuhao (PR #3779, commit a04f4399). |
||
|
|
85e3dde522 |
Conversation cache: opt-in STRATA_PARK_VRAM_MIB=N keeps parked conversations' K/V in VRAM in front of the host copy (#3779, #3712)
Problem: restoring a parked conversation copies its K/V from the host over the link: 27-107 ms over a PCIe Gen2 x4 link. Change, opt-in and only with STRATA_PARK_ASYNC=1 (CUDA only): a park also keeps the whole K/V of its image in a VRAM slot of its own (64 MiB granules, up to N MiB in all, only while 1.5 GB of VRAM stays free beside it); the background copy to the host reads from the slot, and a restore of that image copies device to device from the slot (about 1 ms) without waiting for the background copy. Each K/V layer carries its own join-and-release token, so any order of destruction is safe (the layers outlive their image when they are retained for the next park). Under VRAM pressure the elastic K/V's growth releases every slot and the stage, then retries once (both growth sites in generate.cpp). With the variable unset the slot code is not reached: the budget is 0, a restore finds dev_tag 0 and takes the host path, and the growth sites see conversation_park_vram_release_all() return 0 and behave as before. Tests: none of its own (it needs a card with the VRAM for the slot and a parked conversation); see the checklist for the reporters' A/B/A conversation check with STRATA_PARK_VRAM_MIB set. Reporter's numbers (linxuhao, CMP 170HX): restore of a 3K conversation 28-47 -> 7-12 ms; outputs identical. The first restore of a run is slower (41.6 / 56.9 ms) than later ones (6.5-12.6 ms) and they have not found why. Theirs, not measured here. Original change by linxuhao (PR #3779, commit bafca410). |
||
|
|
ca378670b2 |
Conversation cache: opt-in ready checkpoint pool STRATA_CKPT_POOL_READY=N, gathered small checkpoint copies STRATA_CKPT_GATHER=1, park traces (#3779, #3712)
Problem (reporter, CMP 170HX, PCIe Gen2 x4): a conversation switch's park still paid 38-52 ms for the live state, because the STRATA_CKPT_POOL pool was empty at every park (a switch takes two checkpoints), so the 118 MB GDN vector was allocated fresh and page-faulted; and a checkpoint's 37 small synchronous device-to-host copies queue behind the 4 MiB DMA pieces of STRATA_CKPT_ASYNC. Change: - STRATA_CKPT_POOL_READY=N (opt-in, 1..16, with STRATA_CKPT_POOL on): the pool keeps N ready checkpoints, pre-sized to the session's state sizes with their pages in, topped up on a background thread after any take (not with a layer split). - STRATA_CKPT_GATHER=1 (CUDA, opt-in): the small running-state vectors (ple, and each layer's indexer tail, dead row and block position) are gathered device to device into one buffer and fetched with one copy into a pinned buffer. - The park stage is allocated rounded up to 64 MiB (a growing conversation does not cudaFree/cudaMalloc it every time) and a VRAM-resident K/V skips the pointer attribute query. - The background helpers (pool top-up, the checkpoint DMA, the park DMA) leave the host's pinned core (aux_cpus.hpp); no output depends on where a thread runs. - A parked image whose live GDN state is still being copied joins before its buffers are freed (SavedConversation::live_pending). - STRATA_PARK_TRACE prints the joins, the live-state vectors' readiness and the K/V sub-timers. Differs from the PR as submitted: the PR made STRATA_CKPT_POOL=1 allocate two ready checkpoints at startup (+236 MB of host RSS) and read STRATA_CKPT_POOL=N as a count. That changes what an existing switch does, so here STRATA_CKPT_POOL=1 keeps its meaning (the pool holds dropped checkpoints only, nothing is allocated ahead of time) and the ready pool has its own variable, STRATA_CKPT_POOL_READY. A user of the PR's STRATA_CKPT_POOL=2 sets STRATA_CKPT_POOL=1 STRATA_CKPT_POOL_READY=2. The PR's one-checkpoint refill after a park with STRATA_PARK_ASYNC is replaced by the top-up, as in the PR, and so is only active with the new variable. Merged by hand into #2526's park_source. With none of the new variables set: the stage size is rounded up only when the park stage is on, the extra code is trace output behind STRATA_PARK_TRACE and the join calls. Reporter's numbers (linxuhao, CMP 170HX): park at a 3K context 64-75 -> 21-40 ms (all park switches together, A/B/A conversation check identical, greedy 11 of 11 identical). Theirs, not measured here. Original change by linxuhao (PR #3779, commit 56088e71). |
||
|
|
f73b3c86a4 |
Conversation cache: opt-in STRATA_PARK_ASYNC=1 parks the K/V in the background and moves the dropped checkpoints (#3779, #3712)
Problem: parking the outgoing conversation copies its K/V device to host and deep-copies its checkpoints before the next prompt can start: 213 ms at a 3K context, 334 ms at 13K on a PCIe Gen2 x4 card (the reporter's CMP 170HX). Change, opt-in and CUDA only (off on HIP, gfx906 and Metal): - STRATA_PARK_ASYNC=1: conversation_kv_save copies the device K/V device to device into a VRAM stage (only while 1.5 GB stay free beside it; otherwise the save copies as before), and a background thread moves the stage into the host buffers in 4 MiB pieces through two pinned buffers. conversation_park_join waits for it: every reader of a parked image's K/V, the cache before it frees an entry, and the image itself (SavedConversation::pending) before its buffers go. ConversationBuffer::resize_for_overwrite leaves the added bytes unfilled for that copy; the buffer's segments use an allocator that value-initializes only when a fill value is given, and resize(n, value) is unchanged for every other caller. - With it, the checkpoints this request drops right after the park (all of them when another state comes in, else the ones off this prompt's path) move into the parked image instead of being copied, and a background allocation refills STRATA_CKPT_POOL for the next save. Only the main session's checkpoints move, not an idle batch slot's (the park_source of #2526 serves both). - conversation_snapshot_save takes dropped checkpoints' storage (the existing STRATA_CKPT_POOL) for its copies; with the pool off, nothing is taken. - Unset: park_drops is null, no storage is taken, the K/V copies are the synchronous ones; the added work is the K/V size sum for the stage request and a few join calls. Differs from the PR as submitted: the PR's join in conversation_file.cpp (put_payload) is not ported; the SAVE/RESTORE handler of generate.cpp joins the park first (see the previous commit, which carries the PR's 33a8146a fix). Hand-merged into the park_source / ParkSource refactor of #2526. Not covered: if the background copy fails after resize_for_overwrite, the parked image keeps unfilled bytes; the failure is logged. A restore of such an image would read them. No test of the park path with a failing copy. Tests: the PARK_ASYNC path has no unit test in this commit (it needs a card with 1.5 GB free for the stage); the reporter's A/B/A conversation check covers it, see the checklist. Reporter's numbers (linxuhao, CMP 170HX): park 213 -> 64-75 ms (3K), 334 -> 68 ms (13K); greedy answers identical on their 11 prompts and the A/B/A conversation check. Theirs, not measured here. Original change by linxuhao (PR #3779, commit 3e0c141c). |
||
|
|
0f7224d168 |
Conversation checkpoints: opt-in STRATA_CKPT_ASYNC (background device-to-host copy) and STRATA_CKPT_VRAM_SLOTS (#3779, #3712)
Problem: on a slow host link a turn checkpoint copies the whole GDN state to the host on the request path (118 MB at 1.64 GB/s on a PCIe Gen2 x4 card, 72 ms; an independent RTX 3090 on PCIe 3.0 x16 showed 73 ms to 62 ms with the switch). Restoring a parked conversation copies it back. Change, both opt-in and CUDA only (off on HIP, gfx906 and Metal): - STRATA_CKPT_ASYNC=1: the GDN state is copied device to device into a VRAM stage (one buffer the size of the state, allocated at the first checkpoint save, plus a pinned host buffer of the same size; if either allocation fails the save falls back to the synchronous copy), and a background thread moves it in 4 MiB pieces into the checkpoint's host vector. Every reader joins first and only for the copy it needs (restore, snapshot save and restore, the parked copies, the serve loop at each request start, the SAVE/RESTORE session handler). - STRATA_CKPT_VRAM_SLOTS=N (with ASYNC): the last N saved GDN states stay in VRAM, tag-checked, only allocated while 1.5 GB stays free; a restore of a checkpoint whose tag a slot holds copies device to device. - STRATA_TRACE lines carry a steady-clock timestamp; STRATA_PARK_TRACE prints the timing of the save steps. - Unset: the code adds a mutex-guarded no-op join per checkpoint save, restore and snapshot, a tag field that stays 0 and a few clock reads; the copies are the synchronous ones as before. Differs from the PR as submitted: the PR put a join into conversation_file.cpp (put_checkpoint), which broke the conversation_file_test and session_save_reclaim_test builds without CUDA and matched only the copied vector, not the one the copy in flight writes, so a SAVE within one checkpoint copy after a turn could write an incomplete GDN state (found by bitaccesscomau; fixed in the PR's last commit 33a8146a). This commit carries that fix: conversation_file.cpp stays as it is and the join runs first in the SAVE/RESTORE handler of generate.cpp. The commit 33a8146a is therefore not a separate commit here. One more join, found by running the new ctest entries: conversation_snapshot_sources (the SAVE path of a session file) saves the running state with the background copy and the caller writes it to the file at once, after the handler's join has already run. It now joins the copy of that checkpoint before it returns; without it a session file written with STRATA_CKPT_ASYNC=1 could hold an incomplete GDN state (conversation_snapshot_test failed at "both files read" before the join). Tests: conversation_snapshot_test now joins after each save and, with STRATA_TEST_BIG_GDN=1 (a GDN state over 1 MiB, so the async path is taken), runs as the new ctest entries conversation_snapshot_test_ckpt_async and conversation_snapshot_test_ckpt_vram_slots: every checkpoint, capture and restore must give the same bytes as the plain run. Not covered: no test destroys a checkpoint while its copy is in flight (readers join; the cache's eviction paths do not); the reporter saw 3 of about 35 engine starts stop answering after a park with evictions, on the paths with the switches off, and could not reproduce it in 15 reruns. The VRAM stage has no headroom check of its own (an RTX 3090 with 147 MiB minimum free showed no failure in 42 of 42 saves; the allocation failure falls back silently). Reporter's numbers (linxuhao, CMP 170HX): turn checkpoint 71.4 -> 0.9 ms, restore 114-126 -> 28-47 ms. Independent data (bitaccesscomau, RTX 3090 24 GB, PCIe 3.0 x16, release defaults, 4 pairs): checkpoint save 73.2 -> 62.4 ms, tiny-prompt time to first token median ratio 1.038, outputs byte-identical. Theirs, not measured here. Original change by linxuhao (PR #3779, commits 0d512925 and 33a8146a). |
||
|
|
8c2a846947 |
Prefill GDN: opt-in STRATA_GDN_TC=1 runs the DeltaNet recurrence as a chunked scan on the tensor cores, sm_80 (#3779, #3712)
Problem: the prompt path's DeltaNet recurrence is a large part of the prompt time of a GA100 card. Change, opt-in and rounding-level (the output is not the FP32 kernels' bits): src/prefill/gdn_tc.cuh holds the chunked WY-form recurrence with every product on the tensor cores (f16x3 splits with power-of-two scaling, one block per value head) and its prep kernel; kernels.cu dispatches it before the STRATA_GDN_CHUNKED branch for prompt chunks of 128+ tokens when STRATA_GDN_TC is set. Where it runs and where it does not: - gdn_rec_tc returns "not supported" and the existing kernels run unchanged on a card below sm_80, with fewer than 48 SMs, or with less than 122 KB of shared memory a block (the kernel needs 124,944 B). That excludes sm_86, sm_89 and sm_120 (99 KB opt-in): the code is compiled into those builds and never launched there. It runs on sm_80 and sm_90. A failed scratch allocation (60.3 MB a device) also falls back. - Device code for cards below sm_80 compiles to trapping stubs behind STRATA_GDN_TC_SM80; the whole header sits under !__HIPCC__. - Unset, the dispatch costs one cached flag test per call. Tests: gdn_rec_parity gains the tc variant (T = 1..4099, 8192, 32768, six stress inputs against gdn_rec_kh_kernel, gate 1e-4; "not on this card" where it cannot run), --selftest-frag (each tensor-core helper on one warp against a double reference) and --bench-tc. The new ctest entry gdn_rec_parity_selftest_frag runs the helper self-test, which any sm_80+ card can run (77 below sm_80). The full tc variant can only run on an sm_80 or sm_90 card. Reporter's numbers (linxuhao, CMP 170HX): recurrence 105 -> 34 ms at 3.3K tokens and 1,705 -> 547 ms at 52K; prompts +3.9 % (4K), +6.0 % (16K), +6.7 % (52K) over the same base; within 2.3e-6 of the FP32 kernel in gdn_rec_parity; teacher-forced KL against the bitwise base mean 0.0157, median 0.0011, max 0.098, top-1 100 %; 1 of 5 conversation checks identical and decode -2.6 % in their pair (they think draft acceptance moves with the rounding; not checked). Theirs, not measured here. Original change by linxuhao (PR #3779, commit f1cabc99). |
||
|
|
10c8cc629f |
Prefill fused IQ experts: opt-in f16 mma path STRATA_PF_FUSED_F16=1 and warp-specialized kernel STRATA_PF_FUSED_WS=1 (#3779, #3712)
Problem: the NT = 256 kernels still decode every 32 values to int8 and scale the int32 products in FP32. Change, both opt-in and both rounding-level (the output is not bit-identical to the int8 kernels; they are the PR's "rounding-level" switches): - STRATA_PF_FUSED_F16=1 (implies the NT = 256 set): the decoded weights times their block scales and the activations times theirs as F16, m16n8k16 F16 products into FP32 accumulators. The k order inside a 16-value group is permuted the same way for both operands. - STRATA_PF_FUSED_WS=1: native_ws_kernel, producer warps decode into an F16 ring in shared memory and consumer warps run the same F16 products (named barriers), so it has the F16 path's rounding. One block per multiprocessor; about 101 KB of shared memory at its defaults, so it is set up on sm_80 / sm_90 cards and says "not available" and keeps the 512-thread kernels on an sm_86 / sm_89 / sm_120 card (99 KB). Compile-time knobs STRATA_WS_PROD / _SLOTS / _NB / _KS / _HTAB. - Both take a WideBatch like the NT = 256 kernels, so STRATA_PF_BATCH above 128 reaches them. CUDA only (under !__HIPCC__); the Turing pass compiles the F16 instances against __trap() stubs and never runs them (dev_info stops before the NT = 256 setup on Turing). - With neither variable set the kernels, their launches and their shared-memory sizes are as before (the F16 template parameter defaults to false). Differs from the PR as submitted: when STRATA_PF_FUSED_Q2N=1 is on as well (#3809, after the PR was written) the WS setup also sets up the Q2_0 gate/up instance. Tests: prefill_fused_iq_test_f16 and prefill_fused_iq_test_ws (ctest) run the fused-experts test (double-precision reference and MMQ) with the switch set. The test now skips (77) when a requested NT / F16 / WS kernel set is not set up on the device, so a card that cannot run WS does not report a pass for the 512-thread kernels. Limits of the test for these two arms only: with STRATA_PF_FUSED_F16=1 or _WS=1 the test uses the limits it already has for STRATA_PF_F16 (F16 products): fused against the int8-rounded model rel RMS 5e-3 (2e-3 otherwise) and against MMQ 5e-3 (1e-3 otherwise). Measured with F16 on an RTX A4000 (sm_86, z440), over the 11 pairs: against the int8-rounded model rel RMS 2.85e-3 to 2.90e-3 and worst row 5.9e-3 to 8.1e-3; against MMQ the same; against the FP32 reference 1.438e-2 to 1.480e-2 with MMQ at 1.435e-2 to 1.478e-2 (the fused path stays within 1.003x of MMQ's rel RMS and 1.03x of its worst row). The rounding is the F16 rounding of the weights times their scales and of the activations times theirs (an 11-bit mantissa, about 2^-11 relative per operand), which the int8-rounded model does not have; it is not a different summation order. The same arm on an RTX PRO 5000 (sm_120): up to 2.90e-3 (rel RMS), worst row up to 8.1e-3. The default path and the NT=256 arm keep the old limits and their printed errors are unchanged: with no switch set the test prints identical output (52 lines) from the base tree and this tree, on an RTX A4000 (sm_86) and on an RTX PRO 5000 (sm_120). Reporter's numbers (linxuhao, CMP 170HX): one MoE layer of 3,256 tokens 8.27 ms (NT = 256) to 7.90 ms (F16) and 7.65 ms (WS); prompts +2..+6 % over the 256-thread kernels, 1 of 11 greedy answers changes. Teacher-forced KL against the bitwise base on their 20-prompt set: F16 / WS mean 0.0062, median 0.00006, max 0.076, top-1 100 %. Theirs, not measured here. Original change by linxuhao (PR #3779, commit 579cbfbb). |
||
|
|
1d45da3a8a |
Merge f-027-rp15: route-prior default 1.5 on discrete NVIDIA cards of 13 GiB or less (owner decision)
2.0 showed copy and code defects on the RTX 3060 (IQ3_XXS); 1.5 showed none in 19 tasks and keeps the speed (story +15%, code +37% vs off). The 61-task check decides 1.5 vs a 1.0 fallback. |
||
|
|
0afaaa399e | Route prior: the 0.2.7 default on a discrete NVIDIA card of 13 GiB or less drops from 2.0 to 1.5 (owner decision 2026-10-26). On the RTX 3060 12 GB (IQ3_XXS) the copy and code check found real defects at 2.0 and none in 19 tasks at 1.5 or 1.0; 1.5 keeps story +15% and code +37% against off. The value lives in strata::kRoutePriorSmallCard (sm120_series.hpp); scope (CUDA discrete <= 13 GiB), STRATA_ROUTE_PRIOR=0, an explicit value and STRATA_DEFAULTS=026 are unchanged. arch_defaults_test, verify.cpp comments, DETAILS.md and the 0.2.7 release notes follow. | ||
|
|
b1bea3a17c |
Merge f-027-shs: STRATA_SH_STREAM off by default on Windows gfx1151 (owner decision)
+6.9% Qwen IQ3_S decode on Strix Halo Windows, prompts unchanged; token ids identical in 4 starts x 5 prompts. Linux gfx1151 and other cards unchanged; STRATA_DEFAULTS=026 restores it. Docs label the DeepSeek Strix numbers by build. |
||
|
|
f932e410e6 |
docs: Windows Strix Halo leaves STRATA_SH_STREAM off, with the token-id check; DeepSeek numbers say which build they come from
The Windows guide says what 0.2.7 does and how to turn the switch back on, backed by five fixed greedy prompts (895 ids) run four times with the switch on, off, on, off: identical ids. STRIX_HALO.md and the 0.2.7 release notes get a line. The DeepSeek 4K prompt figures of 2026-10-25 (78.7, 87.2) stay and are labelled with their build; a table of the 0.2.7 candidate changes one thing at a time (chunk size, DS4_DEFAULTS=026). |
||
|
|
c77292f09d |
gfx1151 on Windows: the shared-expert fork (STRATA_SH_STREAM) is off by default
Interleaved A/B on a Strix Halo Windows PC (Qwen IQ3_S, engine 0.1.51): chat decode 43.6 tok/s with the fork, 46.6 without (+6.9%), prompts unchanged. Linux gfx1151 and every other architecture keep their table. STRATA_SH_STREAM=1 turns it back on, STRATA_DEFAULTS=026 keeps v0.2.6's table. arch_default_env(arch, defaults026, windows) is a pure rule; arch_defaults_test checks both platforms. |
||
|
|
e240850324 | Docs: Strix Halo Windows guide, plain emphasis and a stray blank line | ||
|
|
538acd098c |
Merge f-027-gh-ctl: GitHub setup, Docker, docs and bench items for 0.2.7
Ported PRs (authors kept) and our fixes, plus the owner's part-2 items: the restored TROUBLESHOOTING entries with a link check, #3895 (no shared-expert fork calibration on Windows HIP with --kv-resident; a warning on a hand-set STRATA_SH_STREAM=1), #3930 (docs), #3421 (Docker stops when models are present and MODEL_PATH is unset), #3570 (launch --show-key reads setup's config), #3311 (engine paragraph only) and #3029 (Strix Halo Windows guide, re-measured on 0.2.7). |
||
|
|
ee1a6efd5c |
docs/STRIX_HALO_WINDOWS.md: a Strix Halo Windows guide, measured again on 0.2.7 (#3029)
Structure from the guide in PR #3029 by HaiYunChuang (what the PC reaches, memory and the BIOS, the configuration, what is on by default, traps), rewritten for the 0.2.7 install and with every number measured again: the Terminal and the gfx1151 engines built from f-027-int2 (3e468f5de), a local signed test feed, strata launch as a standard test user on the NucBox EVO-X2 (Adrenalin 26.10.1), tools/strata_bench.py over a tunnel. Qwen IQ3_S: 44 tok/s chat, prompts 755 / 821 / 792 tok/s at 4K / 16K / 32K. DeepSeek 2.00 bpw: 12 to 14 tok/s chat, prompts 214 to 342 tok/s. An interleaved A/B of STRATA_SH_STREAM on Windows gfx1151 (three pairs): off is 6.9% faster in chat decode, prompts unchanged. What launch chose and logged is quoted instead of a hand-made config. The first guide's tuning rows (engines 0.1.41 to 0.1.47) are not repeated. Co-authored-by: HaiYunChuang <97429634+HaiYunChuang@users.noreply.github.com> |
||
|
|
f1dadd1710 | fused_gr: the persistent hyper-connection read's barrier only calls __nanosleep on sm_70 and newer (the sm_60 build of f-027-int2 failed on it) | ||
|
|
3cabb9e3fe |
Merge f-027-gh-app: GitHub app and Terminal items for 0.2.7
Part 1 fixes and 12 ported PRs (authors kept), and the owner's part-2 items: the Monitor readings strip with local currency (#3628), approval notification + opt-in minimise to tray (#3477), opt-in done sound (#3586), app port setting with a busy warning (#3402) and interface size up to 200% (#3970). Host tests: only the two known base failures on Linux; connector-setup and the new tests pass on Windows. |
||
|
|
3b908cc4f7 | Tests: the new catalog is checked in nine languages, French included | ||
|
|
0d0ec83b7d | Merge f-027-int2 into f-027-gh-app | ||
|
|
c17a6f4ce1 | App: the Monitor's readings strip (energy since start, cost in the person's own currency, GPU fan and clock, CPU and SSD temperature) with the Electricity price setting (#3628, PR #3628 by hash13 as the starting idea); a sound when work finishes (#3586); desktop notification and tray, pinned port and interface size settings with their host routes (#3477, #3402, #3970); the gh-<lang> catalog in nine languages | ||
|
|
902dc814d6 | Desktop shell: a pinned app port with a warning when it is busy (#3402); minimise to tray with Tauri's own tray icon and a native desktop notification through the loopback bridge (#3477) | ||
|
|
59b4be2a54 | App: French for the four new DeepSeek card and 12 GB NVIDIA strings (fx80-fx83) | ||
|
|
98e35984c6 |
Merge f-027-dscard: the DeepSeek card names the free disk the set needs (owner-approved wording)
# Conflicts: # apps/host/src/locales/fix-de.json # apps/host/src/locales/fix-en.json # apps/host/src/locales/fix-es.json # apps/host/src/locales/fix-ja.json # apps/host/src/locales/fix-ko.json # apps/host/src/locales/fix-pt.json # apps/host/src/locales/fix-ru.json # apps/host/src/locales/fix-zh.json |