diff --git a/CMakeLists.txt b/CMakeLists.txt index b7d4fd1d..a82802bf 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -393,6 +393,21 @@ if(STRATA_ENABLE_CUDA OR STRATA_ENABLE_HIP) src/ngram/ple_reader.cpp src/platform/direct_file.cpp) target_link_libraries(strata_kernels PUBLIC strata_core strata_artifact) + # Exact gfx1100 prompt scorer (PR1825 method port): optional standalone test, + # also available where the published source omits tests/. + option(STRATA_PARITY_GFX1100_QSA_SCORES "Build the exact gfx1100 QSA score/ID check" OFF) + if(STRATA_ENABLE_HIP AND (STRATA_BUILD_TESTS OR STRATA_PARITY_GFX1100_QSA_SCORES)) + set_source_files_properties(src/kernels/cuda/qsa_scores_gfx1100_test.cu + src/kernels/qsa_scores_gfx1100_parity.cpp PROPERTIES LANGUAGE HIP) + add_executable(qsa_scores_gfx1100_parity src/kernels/qsa_scores_gfx1100_parity.cpp + src/kernels/cuda/qsa_scores_gfx1100_test.cu) + target_include_directories(qsa_scores_gfx1100_parity PRIVATE ${_strata_gpu_include_directories}) + target_link_libraries(qsa_scores_gfx1100_parity PRIVATE strata_kernels ${_strata_gpu_runtime_target}) + enable_testing() + add_test(NAME qsa_scores_gfx1100_parity COMMAND qsa_scores_gfx1100_parity --full) + set_tests_properties(qsa_scores_gfx1100_parity PROPERTIES SKIP_RETURN_CODE 77 TIMEOUT 180 + ENVIRONMENT "STRATA_SCORES_THREAD=1;STRATA_SCORES_THREAD_TRACE=1") + endif() # perf-review D-1: the tensor-core prompt attention vs the FP32 kernel and FP64 (GPU, synthetic, no model); with # the tests, or alone with -DSTRATA_PARITY_PROMPT_ATTN=ON. CUDA only: HIP compiles the tensor-core kernel out. if((STRATA_BUILD_TESTS OR STRATA_PARITY_PROMPT_ATTN) AND STRATA_ENABLE_CUDA) diff --git a/bench/results/2026-10-11-gfx1100-qsa-scores/README.md b/bench/results/2026-10-11-gfx1100-qsa-scores/README.md new file mode 100644 index 00000000..82e31bf7 --- /dev/null +++ b/bench/results/2026-10-11-gfx1100-qsa-scores/README.md @@ -0,0 +1,216 @@ +# Exact gfx1100 QSA scorer: measured prefill benefit, opt-in only + +Measured on 2026-10-11 on one RX 7900 XTX. This accompanies the HIP port of the +four-lanes-per-query score kernel from [PR #1825](https://github.com/Niko1221/Strata/pull/1825) +by xrip, pinned to `14bf32150490bb9f5fc4d9c7c5dcfdc96dd98797`. That PR's code excludes +HIP; its algorithm and reduction order are the source of this port. This is an +AMD extension, not a claim to invent that method. + +The measured benefit is fresh long-prompt processing. The correction-inclusive +coding pilot was 3.3% slower overall. The new path is disabled by default and was +not promoted into the tested machine's production setup. + +## Dispatch and implementation + +Set `STRATA_SCORES_THREAD=1` **before starting the engine**. Dispatch also requires: + +- HIP on the exact `gfx1100` architecture (normal feature suffixes are accepted). +- At least 64 queries and a supplied live bound of at least 16,385 index blocks. +- A live bound no larger than the allocated score capacity. Allocating a 256K + context alone does not select the new kernel. +- The already supported indexer geometry: four heads, dimension 128, block size 4. + +Otherwise the existing scorer runs. Decode, top-k, weights, expert placement, +PLE storage, and sampling are not changed by this patch. CUDA does not compile +the HIP addition. No extra persistent weights or conversation state are allocated. + +The kernel uses four wave32 lanes per query and keeps all four heads in registers. +Each key tile in LDS serves 64 queries. The original FP32 per-lane expression and +xor reduction tree are preserved; the existing tail scorer handles the final block. +The retained layout is 64 queries by 32 key blocks, 512 key blocks per workgroup, +256 threads. Four layout variants were screened; none improved stage time by the +predeclared 10% threshold over this one, so the first layout was retained. + +`STRATA_SCORES_THREAD_TRACE=1` optionally prints one engagement line per host thread. +No trace output is enabled by default. + +## Machine and shared settings + +- RX 7900 XTX, 24 GiB nominal VRAM, gfx1100; PCIe 4.0 x16 observed; fixed 272 W cap. +- Ryzen 9 7950X3D; 64 GiB installed RAM, approximately 62 GiB reported by Linux. +- Nobara 44; kernel `7.2.9-200.nobara.fc44.x86_64`; ROCm SDK 10.0.0. +- [OrcaRouter Qwen3.8 Flash Next Uncensored](https://huggingface.co/orcarouter/Qwen3.8-Flash-Next-Uncensored-GGUF), + IQ3_S. Exact shard names, pack/profile hashes, and configuration are in + [provenance.json](provenance.json). The Hugging Face revision was not recorded. +- One GPU, one server, 15 CPU expert workers; logical context 262,144; int8 KV, + 32,768 resident KV cells; prefill chunk 16,384; spec/MTP 6, floor 0.70, maximum T 6. +- Same balanced expert profile in every arm; 8,144 actual GPU expert slots, + 16,622,003,200 blob bytes; 34 GiB resident budget and 1,024 MiB conversation cache. +- NVMe model storage; PLE lookup shard on a dedicated ext4 SSD partition with + direct I/O. The lookup was not moved into RAM. GPU vision was enabled but no + image prompt was used in these measurements. +- Private experiment cgroup: 56 GiB memory cap, swap limit zero; at least 8 GiB + available host memory required. This is not a claim that system-wide swap was disabled. +- Same local prefix-cache frontend and chat template for both arms. Its hashes + are recorded. The stock latest Python frontend was not benchmarked here. + +The repeated model tests used the reconstructed tuned 0.1.40.3 engine, including +PR #1107 prefix reuse and resident-budget loans in **both** arms. They compare the +installed control against its reconstructed candidate, not two official release +binaries. A separate comparison builds current main at +`61b3fb5dd3f1e8ec09cf7e4e05208bc6d3c46406` plus this patch and uses the **same binary** +with `STRATA_SCORES_THREAD=0` and `1`. Those families are never pooled. + +## Before and after + +The full per-request values, native prompt/decode timing, token counts, output +hashes, means, medians, and ranges are in [measurements.json](measurements.json). +These are **non-streaming request times with a one-token cap**. Model loading and +queueing were excluded; streaming time to first token and sustained generation +throughput were not measured by this screen. + +Each fresh case starts a new private model worker. Actual reused prefix tokens +were zero. The OS file cache was not flushed, so these are fresh model prompts, +not cold-boot storage benchmarks. Inputs are repeated numerical source code, +greedy sampling, seed 6300, reasoning disabled. They are a prefill screen, not a +quality evaluation or representative project-completion benchmark. + +| Engine family | Actual fresh tokens | Pairs | Before mean | After mean | Less elapsed time | +| --- | ---: | ---: | ---: | ---: | ---: | +| tuned-v0.1.40.3 | 130,978 | 3 | 66.741 s | 59.769 s | 10.45% | +| tuned-v0.1.40.3 | 239,906 | 3 | 142.718 s | 110.407 s | 22.64% | +| current-main-same-binary | 130,978 | 1 | 68.872 s | 60.020 s | 12.85% | +| current-main-same-binary | 239,906 | 1 | 142.843 s | 111.828 s | 21.71% | + +| Tuned build fresh tokens | Before median (range) | After median (range) | +| --- | ---: | ---: | +| 130,978 | 67.514 (64.257–68.451) s | 59.465 (58.863–60.979) s | +| 239,906 | 142.059 (141.660–144.436) s | 110.438 (109.549–111.232) s | + +**Cached follow-ups (2,085 new tokens):** + +| Engine family | Reused prefix | Pairs | Before mean | After mean | Less elapsed time | +| --- | ---: | ---: | ---: | ---: | ---: | +| tuned-v0.1.40.3 | 130,978 | 2 | 2.829 s | 2.658 s | 6.023% | +| tuned-v0.1.40.3 | 239,906 | 2 | 3.418 s | 3.417 s | 0.035% | +| current-main-same-binary | 130,978 | 1 | 2.896 s | 2.781 s | 3.965% | +| current-main-same-binary | 239,906 | 1 | 3.522 s | 2.958 s | 16.037% | + +The repeated near240K cached result is effectively flat (0.035%). The current-main +follow-ups are single pairs and do not establish a repeatable cached-prefix gain. + +**Submitted CMake scorer microbenchmark:** + +| Scorer-only live context | Queries | Before | After | Stage speedup | +| --- | ---: | ---: | ---: | ---: | +| 131,072 | 256 | 3.065300 ms | 0.742917 ms | 4.126x | +| 240,000 | 256 | 5.264949 ms | 1.389344 ms | 3.790x | + +The repeated family used orders off/on, on/off, off/on. All three fresh request +pairs at each length had the same input hash, output hash, and output count. +Cached continuations in trials 2 and 3 added 2,085 actually processed tokens and +reused the preceding 130,978 or 239,906 tokens. Trial 1's much smaller continuation +is retained in the raw data but excluded from the 2K continuation summary. +The follow-up inserts a fixed synthetic assistant message; it does not use the +one generated token as a complete conversational answer. This isolates prefix +reuse and incremental prompt processing. + +## Correctness and build checks + +The submitted HIP CMake target passed 35 cases comparing against the unchanged +warp scorer: **223,664,777 score values bitwise equal**, and **11,895,800 ID buffer +entries equal**, including padding. Allocation guards passed. Cases cover +query counts 1/6/8/9/63/64/65/127/128/129/256/1024; the 65,535–65,539 boundary, +128K and 256K; capacity versus live extent; absent/negative/oversized bounds; +random and wide-exponent floats, ties, signed zero, NaN/Inf and cancellation. + +The same compiled CMake test provides warmed, interleaved ABBA GPU-event timings +with four trials and ten calls per trial. See [correctness.json](correctness.json). +At the real 256-query batch size, this tests the scorer stage rather than making +a claim about whole-request or whole-task speed from a microbenchmark. + +On the tuned model, the 4K/131K prefill plus first generated token matched the +control's main state byte for byte. Separate 64-token continuations and +STOP/resend output checks matched. Full internal state after 64 speculative tokens +was not always byte-identical; the original binary also produced differing +speculative states across repeats. This does not establish the cause of the coding +pilot's different repair paths. No claim of universal bitwise model output is made. + +- Current-main full HIP engine and the standalone CMake test target built with + ROCm 10.0.0, Release, gfx1100, native experts and optional prefill MMQ enabled. +- The touched `qsa_select.cu` also compiled with CUDA 13.0 for sm_89. There was no + CUDA GPU test or full CUDA-engine build. No SYCL source was changed. +- Current-main off/on model requests completed with matching input/output hashes. +- Unsupported GPU architectures were not runtime-tested on hardware. + +Build and run the standalone check even from the published tree without `tests/`: + +```bash +cmake -S . -B build-qsa -G Ninja -DCMAKE_BUILD_TYPE=Release \ + -DSTRATA_ENABLE_HIP=ON -DCMAKE_HIP_ARCHITECTURES=gfx1100 \ + -DSTRATA_BUILD_TESTS=OFF -DSTRATA_PARITY_GFX1100_QSA_SCORES=ON +cmake --build build-qsa --target qsa_scores_gfx1100_parity -j 6 +ctest --test-dir build-qsa --output-on-failure -R '^qsa_scores_gfx1100_parity$' +``` + +Supply your normal ROCm compiler/package paths if they are not discoverable. +CTest sets the opt-in and engagement-trace variables and skips non-gfx1100 cards +with return code 77. + +## Coding pilot and limitations + +Two official Exercism/Aider Polyglot tasks, Go alphametics and Rust xorcism, were +embedded in a 196,608-token source archive, leaving 65,536 tokens within the 256K +window for tool results and repairs. xhigh, 8,192 reasoning tokens, 2,048 answer +reserve, temperature 0.3, top_p 0.95, top_k 20, min_p 0; one matched trial per task, +seeds 7830/7831. Tools and full-suite checks ran until the first pass, with no +post-pass requests. This is a long-context stress pilot, **not an official Aider +leaderboard score**. Its test and correction time is included. + +| Task | Original | New scorer | Original/new turns | Result | +| --- | ---: | ---: | ---: | --- | +| go/alphametics | 209.136 s | 400.318 s | 3 / 5 | Both full suites passed | +| rust/xorcism | 473.734 s | 304.906 s | 6 / 6 | Both full suites passed | +| Total | 682.870 s | 705.225 s | | New scorer **3.27% slower** | + +The different Go run generated more tokens and took extra repair turns despite +matching normalized inputs through the first three requests. The cause remains +unresolved. The combined pilot did not meet the predeclared promotion gate. More +coding repeats, the held-out extension, and the full 24-task suite were therefore +not run. No Luna, frontier-model, or overall agent-quality superiority is claimed. + +An earlier 240K-archive pilot ran out of continuation space: the Rust history +reached 262,714 tokens, beyond 262,144. Its partial attempt is listed separately +in the data and was not reused in the 192K score. It was a benchmark-protocol +failure, not evidence of a scorer crash. + +## Reproducing the request screen + +[benchmark.py](benchmark.py) generates the exact frozen fresh/continuation request +hashes used here from the included compressed numerical-source fixture. It reads +the model pack's tokenizer and uses only Python plus the existing tokenizer's +`regex` dependency. The supplied [hipBLASLt table](hipblaslt-gfx1100-100401.txt) is +specific to this SDK/device pair; do not assume its solution IDs transfer to another +version. The balanced expert profile is identified by hash, not included; use the +same profile and other settings in your two arms. + +Run a loaded private server with the same binary and settings, changing only +`STRATA_SCORES_THREAD=0` or `1` **at startup**. Restart that worker between every +length/arm invocation, preserve every observation, and repeat in both orders: + +```bash +python bench/results/2026-10-11-gfx1100-qsa-scores/benchmark.py \ + --url http://127.0.0.1:8080 --tokenizer /path/to/pack/tokenizer \ + --model strata-qwen38-iq3s-uncensored --length 131072 \ + --variant off --output off-128k-trial1.json +``` + +Then restart with the scorer enabled and use `--variant on` and a new output file. +Repeat with `--length 240000`, then reverse arm order. Use `--prepare-only` to +check request hashes without inference. `STRATA_API_KEY` can supply an API key; +it is never written to results. The script refuses to overwrite any attempt and +records a failure if a fresh prompt reused cached tokens. + +The label does not control the server's environment: confirm the startup setting +and, in the enabled arm, the engagement trace. Measure your model's full output +and correction-inclusive workload separately before adopting the feature. diff --git a/bench/results/2026-10-11-gfx1100-qsa-scores/benchmark.py b/bench/results/2026-10-11-gfx1100-qsa-scores/benchmark.py new file mode 100644 index 00000000..e22d547a --- /dev/null +++ b/bench/results/2026-10-11-gfx1100-qsa-scores/benchmark.py @@ -0,0 +1,137 @@ +"""One fresh prompt and one cached continuation; restart the server between invocations. + +Use the same engine/config with STRATA_SCORES_THREAD=0 or 1 at server startup. +Model loading is excluded. This measures request latency, not streaming TTFT or coding quality. +""" +import argparse +import gzip +import hashlib +import importlib.util +import json +import os +from pathlib import Path +import time +import urllib.error +import urllib.request + +HERE = Path(__file__).resolve().parent +REPO = HERE.parents[2] + + +def digest(data): + return hashlib.sha256(data).hexdigest() + + +def load_tokenizer(folder): + spec = importlib.util.spec_from_file_location('qsa_bench_tokenizer', REPO / 'tools/strata_tokenizer.py') + module = importlib.util.module_from_spec(spec) + spec.loader.exec_module(module) + vocab = json.loads((folder / 'vocab.json').read_text()) + tokens = [None] * len(vocab) + for token, index in vocab.items(): + tokens[index] = token + return module.Tokenizer(tokens, (folder / 'merges.txt').read_text().split('\n'), + json.loads((folder / 'token_type.json').read_text())) + + +def make_requests(tokenizer, source, length, model, follow_tokens): + ids = tokenizer.encode(source) + if not ids or not 0 <= follow_tokens <= len(ids): + raise ValueError('Empty source or invalid continuation size') + text = tokenizer.decode((ids * (length // len(ids) + 1))[:length - 128]) + body = dict(model=model, temperature=0, top_p=1, top_k=1, seed=6300, + reasoning_effort='none', max_tokens=1, messages=[ + dict(role='system', content='You are a precise coding assistant.'), + dict(role='user', content=text + '\nReview the numerical implementation and synchronization in detail.')]) + follow = json.loads(json.dumps(body)) + follow['messages'].extend([ + dict(role='assistant', content='I will inspect the numerical implementation.'), + dict(role='user', content='Continue with a detailed review of synchronization and memory lifetime.')]) + if follow_tokens: + follow['messages'][-1]['content'] += '\nADDITIONAL_SOURCE\n' + tokenizer.decode(ids[-follow_tokens:]) + return [('fresh-' + str(length), body), ('follow-' + str(length), follow)] + + +def fetch(url, body=None): + headers = {'Content-Type': 'application/json'} + key = os.environ.get('STRATA_API_KEY') + if key: + headers['Authorization'] = 'Bearer ' + key + req = urllib.request.Request(url, data=json.dumps(body).encode() if body is not None else None, + headers=headers) + with urllib.request.urlopen(req, timeout=900) as response: + return json.load(response) + + +def main(): + parser = argparse.ArgumentParser(description=__doc__) + parser.add_argument('--url', default='http://127.0.0.1:8080') + parser.add_argument('--tokenizer', type=Path, required=True) + parser.add_argument('--model', default='strata-qwen38-iq3s-uncensored') + parser.add_argument('--length', type=int, choices=[131072, 240000], required=True) + parser.add_argument('--follow-tokens', type=int, default=2048) + parser.add_argument('--source', type=Path, default=HERE / 'prompt-source.txt.gz') + parser.add_argument('--variant', choices=['off', 'on'], required=True) + parser.add_argument('--output', type=Path, required=True) + parser.add_argument('--prepare-only', action='store_true') + args = parser.parse_args() + source = gzip.decompress(args.source.read_bytes()) if args.source.suffix == '.gz' else args.source.read_bytes() + requests = make_requests(load_tokenizer(args.tokenizer), source.decode(), args.length, + args.model, args.follow_tokens) + receipt = dict(variant=args.variant, length=args.length, output_cap=1, seed=6300, + temperature=0, reasoning_effort='none', follow_source_tokens=args.follow_tokens, + source_sha256=digest(source), script_sha256=digest(Path(__file__).read_bytes()), + prepare_only=args.prepare_only, rows=[], status='prepared') + # Refuse to overwrite previous observations, including failed attempts. + with args.output.open('x') as output: + def save(): + output.seek(0) + json.dump(receipt, output, indent=2) + output.write('\n') + output.truncate() + output.flush() + try: + save() + if args.prepare_only: + receipt['request_hashes'] = {case: digest(json.dumps(body).encode()) for case, body in requests} + save() + return + health = fetch(args.url.rstrip('/') + '/health') + if not health.get('loaded') or health.get('max_context') != 262144: + raise RuntimeError('Requires an already loaded 262144-context server') + for case, body in requests: + started = time.monotonic() + response = fetch(args.url.rstrip('/') + '/v1/chat/completions', body) + elapsed = time.monotonic() - started + metrics = fetch(args.url.rstrip('/') + '/metrics?requests=all') + native = max(metrics['requests'], key=lambda row: row['time']) + choice = response['choices'][0] + message = choice.get('message', {}) + row = dict(case=case, seconds=elapsed, usage=response.get('usage'), + finish_reason=choice['finish_reason'], + request_sha256=digest(json.dumps(body).encode()), + output_sha256=digest(((message.get('reasoning_content') or '') + '\n' + + (message.get('content') or '')).encode()), + native={k: native.get(k) for k in ( + 'prompt_tokens', 'reused', 'prompt_read', 'output_tokens', 'engine_generated', + 'prompt_ms', 'decode_ms', 'drafts_offered', 'drafts_accepted', + 'hit_rate', 'ram_blobs', 'file_blobs', 'file_mb')}) + receipt['rows'].append(row) + save() + if choice['finish_reason'] not in ('length', 'stop'): + raise RuntimeError('Request did not complete normally') + if case.startswith('fresh-') and native.get('reused') != 0: + raise RuntimeError('Fresh prompt reused a prefix: restart the server and use a NEW output file') + receipt['status'] = 'complete' + save() + except Exception as error: + receipt['status'] = 'failed' + receipt['error'] = str(error) + if isinstance(error, urllib.error.HTTPError): + receipt['http_status'] = error.code + save() + raise + + +if __name__ == '__main__': + main() diff --git a/bench/results/2026-10-11-gfx1100-qsa-scores/correctness.json b/bench/results/2026-10-11-gfx1100-qsa-scores/correctness.json new file mode 100644 index 00000000..0fc79c15 --- /dev/null +++ b/bench/results/2026-10-11-gfx1100-qsa-scores/correctness.json @@ -0,0 +1,19 @@ +{ + "returncode": 0, + "bitwise_qualification": "1: QUALIFIED cases=35 expected_thread_cases=26 scores=223664777 ids=11895800 bitwise_scores=true bitwise_ids=true guards=true", + "dispatch_observed": true, + "timings": [ + "1: TIMING ctx=131072 nq=256 baseline_ms=3.065300 candidate_ms=0.742917 speedup=4.126034 trials=4 repeats_per_trial=10", + "1: TIMING ctx=240000 nq=256 baseline_ms=5.264949 candidate_ms=1.389344 speedup=3.789521 trials=4 repeats_per_trial=10", + "1: TIMING ctx=140000 nq=1024 baseline_ms=13.833862 candidate_ms=3.112324 speedup=4.444866 trials=4 repeats_per_trial=10", + "1: TIMING ctx=240000 nq=1024 baseline_ms=25.035099 candidate_ms=4.841821 speedup=5.170596 trials=4 repeats_per_trial=10" + ], + "resource_pass": true, + "cases": 35, + "scores_checked": 223664777, + "id_entries_checked": 11895800, + "numeric_scope": "Synthetic scores/selected IDs, including padding and allocation guards", + "real_model_state_scope": "4K/131K prefill and first token byte-exact against tuned control; longer MTP sequences may have different internal speculative states even on original binary", + "continuation_scope": "64-token original/candidate output and STOP/resend output match; not full-state equality after64MTPtokens", + "unsupported_architecture_runtime_tested": false +} diff --git a/bench/results/2026-10-11-gfx1100-qsa-scores/hipblaslt-gfx1100-100401.txt b/bench/results/2026-10-11-gfx1100-qsa-scores/hipblaslt-gfx1100-100401.txt new file mode 100644 index 00000000..839434c5 --- /dev/null +++ b/bench/results/2026-10-11-gfx1100-qsa-scores/hipblaslt-gfx1100-100401.txt @@ -0,0 +1,34 @@ +# solution IDs are scoped to this hipBLASLt version and device architecture +STRATA_HIPBLASLT_TUNING_V1 gfx1100 100401 +bf16 1 2560 1 4096 1035 +bf16 4 10240 4 8192 1033 +bf16 48 2560 96 4096 1035 +bf16 48 2560 96 8192 1036 +bf16 128 2560 128 4096 1036 +bf16 128 2560 128 8192 1036 +bf16 320 10240 320 4096 1036 +bf16 320 10240 320 8192 1036 +bf16 512 2560 512 8192 1036 +bf16 2560 2560 2560 8192 1036 +bf16 10240 320 10240 4096 1036 +bf16 10240 320 10240 8192 1036 +f16 512 2560 512 4096 2106 +f16 512 2560 512 8192 2106 +f16 640 2560 640 4096 2106 +f16 640 2560 640 8192 2106 +f16 2560 640 2560 4096 2106 +f16 2560 640 2560 8192 2106 +f16 2560 6144 2560 4096 2106 +f16 2560 6144 2560 8192 2106 +f16 6144 2560 6144 4096 2106 +f16 6144 2560 6144 8192 2106 +f16 10240 2560 10240 4096 2106 +f16 10240 2560 10240 8192 2106 +f16 12288 2560 12288 4096 2106 +f16 12288 2560 12288 8192 2106 +bf16 1 2560 1 8192 1035 +bf16 10240 2560 10240 4096 1036 +bf16 10240 2560 10240 8192 1036 +bf16 2560 2560 2560 4096 1036 +bf16 4 10240 4 4096 1035 +bf16 512 2560 512 4096 1036 diff --git a/bench/results/2026-10-11-gfx1100-qsa-scores/measurements.json b/bench/results/2026-10-11-gfx1100-qsa-scores/measurements.json new file mode 100644 index 00000000..a191c647 --- /dev/null +++ b/bench/results/2026-10-11-gfx1100-qsa-scores/measurements.json @@ -0,0 +1,1091 @@ +{ + "units": { + "seconds": "client request elapsed seconds", + "native_prompt_ms": "engine prefill milliseconds", + "native_decode_ms": "engine generation milliseconds" + }, + "model_loading_included": false, + "streaming_ttft_measured": false, + "logical_context": 262144, + "settings": { + "temperature": 0, + "top_p": 1, + "top_k": 1, + "seed": 6300, + "reasoning_effort": "none", + "output_cap": 1 + }, + "fresh_os_cache_state": "uncontrolled; OS cache not flushed", + "source": { + "file": "prompt-source.txt.gz", + "uncompressed_sha256": "43caa800023d7e223629ab8c6a28bd10c50b56c2dd7232b2b5fa4c00144b2e98" + }, + "rows": [ + { + "family": "tuned-v0.1.40.3", + "trial": "qsa-exact-native1", + "arm": "0-A-131072", + "case": "fresh-131072", + "follow_source_tokens": 0, + "seconds": 64.25693084098748, + "success": true, + "finish_reason": "length", + "output_cap": 1, + "generated_tokens": 1, + "request_sha256": "029dc64c403bd9597b2a143399fa64555b40b8a4910c708fe3f7c3ddc5a1ad25", + "output_sha256": "d6fadeb81a0f0a9f23a6a06f4c0f266f0afe25f436a0aa575ac593e2d695c969", + "prompt_tokens": 130978, + "reused_tokens": 0, + "freshly_processed_tokens": 130978, + "native_prompt_ms": 64157.7, + "native_decode_ms": 27.1, + "hit_rate": 0.787, + "ram_blobs": 102, + "file_blobs": 0, + "file_mb": 0.0, + "drafts_offered": 0, + "drafts_accepted": 0, + "power_cap_w": 272.0 + }, + { + "family": "tuned-v0.1.40.3", + "trial": "qsa-exact-native1", + "arm": "0-A-131072", + "case": "follow-131072", + "follow_source_tokens": 0, + "seconds": 0.34837336000055075, + "success": true, + "finish_reason": "length", + "output_cap": 1, + "generated_tokens": 1, + "request_sha256": "04d4aba48d6b685765f804b257d6a2872758acf1c10c942ab83d93dd55649fde", + "output_sha256": "33462c6ad8d3c9823e7b43633ff1a94f7671c4d155888e47618b5f60027701e5", + "prompt_tokens": 131010, + "reused_tokens": 130978, + "freshly_processed_tokens": 32, + "native_prompt_ms": 303.6, + "native_decode_ms": 19.4, + "hit_rate": 0.769, + "ram_blobs": 111, + "file_blobs": 0, + "file_mb": 0.0, + "drafts_offered": 0, + "drafts_accepted": 0, + "power_cap_w": 272.0 + }, + { + "family": "tuned-v0.1.40.3", + "trial": "qsa-exact-native1", + "arm": "0-A-240000", + "case": "fresh-240000", + "follow_source_tokens": 0, + "seconds": 142.0591052029922, + "success": true, + "finish_reason": "length", + "output_cap": 1, + "generated_tokens": 1, + "request_sha256": "dbb6d4004af260501404a2674660c00523b1c455ba557d431395dab5cee7c4dd", + "output_sha256": "d6fadeb81a0f0a9f23a6a06f4c0f266f0afe25f436a0aa575ac593e2d695c969", + "prompt_tokens": 239906, + "reused_tokens": 0, + "freshly_processed_tokens": 239906, + "native_prompt_ms": 141910.0, + "native_decode_ms": 28.8, + "hit_rate": 0.779, + "ram_blobs": 106, + "file_blobs": 0, + "file_mb": 0.0, + "drafts_offered": 0, + "drafts_accepted": 0, + "power_cap_w": 272.0 + }, + { + "family": "tuned-v0.1.40.3", + "trial": "qsa-exact-native1", + "arm": "0-A-240000", + "case": "follow-240000", + "follow_source_tokens": 0, + "seconds": 0.3739995119976811, + "success": true, + "finish_reason": "length", + "output_cap": 1, + "generated_tokens": 1, + "request_sha256": "bd5c8f85d96ecd7db994611c323e1a644be0b8c66fd6ec2386ae2b23dbdafb34", + "output_sha256": "33462c6ad8d3c9823e7b43633ff1a94f7671c4d155888e47618b5f60027701e5", + "prompt_tokens": 239938, + "reused_tokens": 239906, + "freshly_processed_tokens": 32, + "native_prompt_ms": 302.6, + "native_decode_ms": 21.4, + "hit_rate": 0.756, + "ram_blobs": 117, + "file_blobs": 0, + "file_mb": 0.0, + "drafts_offered": 0, + "drafts_accepted": 0, + "power_cap_w": 272.0 + }, + { + "family": "tuned-v0.1.40.3", + "trial": "qsa-exact-native1", + "arm": "1-B-131072", + "case": "fresh-131072", + "follow_source_tokens": 0, + "seconds": 60.97881687400513, + "success": true, + "finish_reason": "length", + "output_cap": 1, + "generated_tokens": 1, + "request_sha256": "029dc64c403bd9597b2a143399fa64555b40b8a4910c708fe3f7c3ddc5a1ad25", + "output_sha256": "d6fadeb81a0f0a9f23a6a06f4c0f266f0afe25f436a0aa575ac593e2d695c969", + "prompt_tokens": 130978, + "reused_tokens": 0, + "freshly_processed_tokens": 130978, + "native_prompt_ms": 60863.3, + "native_decode_ms": 40.1, + "hit_rate": 0.787, + "ram_blobs": 102, + "file_blobs": 0, + "file_mb": 0.0, + "drafts_offered": 0, + "drafts_accepted": 0, + "power_cap_w": 272.0 + }, + { + "family": "tuned-v0.1.40.3", + "trial": "qsa-exact-native1", + "arm": "1-B-131072", + "case": "follow-131072", + "follow_source_tokens": 0, + "seconds": 0.36607142200227827, + "success": true, + "finish_reason": "length", + "output_cap": 1, + "generated_tokens": 1, + "request_sha256": "04d4aba48d6b685765f804b257d6a2872758acf1c10c942ab83d93dd55649fde", + "output_sha256": "33462c6ad8d3c9823e7b43633ff1a94f7671c4d155888e47618b5f60027701e5", + "prompt_tokens": 131010, + "reused_tokens": 130978, + "freshly_processed_tokens": 32, + "native_prompt_ms": 316.8, + "native_decode_ms": 20.0, + "hit_rate": 0.769, + "ram_blobs": 111, + "file_blobs": 0, + "file_mb": 0.0, + "drafts_offered": 0, + "drafts_accepted": 0, + "power_cap_w": 272.0 + }, + { + "family": "tuned-v0.1.40.3", + "trial": "qsa-exact-native1", + "arm": "1-B-240000", + "case": "fresh-240000", + "follow_source_tokens": 0, + "seconds": 109.54931649801438, + "success": true, + "finish_reason": "length", + "output_cap": 1, + "generated_tokens": 1, + "request_sha256": "dbb6d4004af260501404a2674660c00523b1c455ba557d431395dab5cee7c4dd", + "output_sha256": "d6fadeb81a0f0a9f23a6a06f4c0f266f0afe25f436a0aa575ac593e2d695c969", + "prompt_tokens": 239906, + "reused_tokens": 0, + "freshly_processed_tokens": 239906, + "native_prompt_ms": 109397.8, + "native_decode_ms": 29.1, + "hit_rate": 0.779, + "ram_blobs": 106, + "file_blobs": 0, + "file_mb": 0.0, + "drafts_offered": 0, + "drafts_accepted": 0, + "power_cap_w": 272.0 + }, + { + "family": "tuned-v0.1.40.3", + "trial": "qsa-exact-native1", + "arm": "1-B-240000", + "case": "follow-240000", + "follow_source_tokens": 0, + "seconds": 0.3701446990016848, + "success": true, + "finish_reason": "length", + "output_cap": 1, + "generated_tokens": 1, + "request_sha256": "bd5c8f85d96ecd7db994611c323e1a644be0b8c66fd6ec2386ae2b23dbdafb34", + "output_sha256": "33462c6ad8d3c9823e7b43633ff1a94f7671c4d155888e47618b5f60027701e5", + "prompt_tokens": 239938, + "reused_tokens": 239906, + "freshly_processed_tokens": 32, + "native_prompt_ms": 300.3, + "native_decode_ms": 21.4, + "hit_rate": 0.756, + "ram_blobs": 117, + "file_blobs": 0, + "file_mb": 0.0, + "drafts_offered": 0, + "drafts_accepted": 0, + "power_cap_w": 272.0 + }, + { + "family": "tuned-v0.1.40.3", + "trial": "qsa-exact-native2", + "arm": "0-B-131072", + "case": "fresh-131072", + "follow_source_tokens": 2048, + "seconds": 58.86296121100895, + "success": true, + "finish_reason": "length", + "output_cap": 1, + "generated_tokens": 1, + "request_sha256": "029dc64c403bd9597b2a143399fa64555b40b8a4910c708fe3f7c3ddc5a1ad25", + "output_sha256": "d6fadeb81a0f0a9f23a6a06f4c0f266f0afe25f436a0aa575ac593e2d695c969", + "prompt_tokens": 130978, + "reused_tokens": 0, + "freshly_processed_tokens": 130978, + "native_prompt_ms": 58764.6, + "native_decode_ms": 27.6, + "hit_rate": 0.787, + "ram_blobs": 102, + "file_blobs": 0, + "file_mb": 0.0, + "drafts_offered": 0, + "drafts_accepted": 0, + "power_cap_w": 272.0 + }, + { + "family": "tuned-v0.1.40.3", + "trial": "qsa-exact-native2", + "arm": "0-B-131072", + "case": "follow-131072", + "follow_source_tokens": 2048, + "seconds": 2.629391199006932, + "success": true, + "finish_reason": "length", + "output_cap": 1, + "generated_tokens": 1, + "request_sha256": "9f2979c0f702e087be57384d4b312a89f606961d08f0beaff64abd550b91b41d", + "output_sha256": "d6fadeb81a0f0a9f23a6a06f4c0f266f0afe25f436a0aa575ac593e2d695c969", + "prompt_tokens": 133063, + "reused_tokens": 130978, + "freshly_processed_tokens": 2085, + "native_prompt_ms": 2580.1, + "native_decode_ms": 20.5, + "hit_rate": 0.758, + "ram_blobs": 116, + "file_blobs": 0, + "file_mb": 0.0, + "drafts_offered": 0, + "drafts_accepted": 0, + "power_cap_w": 272.0 + }, + { + "family": "tuned-v0.1.40.3", + "trial": "qsa-exact-native2", + "arm": "0-B-240000", + "case": "fresh-240000", + "follow_source_tokens": 2048, + "seconds": 110.438449467998, + "success": true, + "finish_reason": "length", + "output_cap": 1, + "generated_tokens": 1, + "request_sha256": "dbb6d4004af260501404a2674660c00523b1c455ba557d431395dab5cee7c4dd", + "output_sha256": "d6fadeb81a0f0a9f23a6a06f4c0f266f0afe25f436a0aa575ac593e2d695c969", + "prompt_tokens": 239906, + "reused_tokens": 0, + "freshly_processed_tokens": 239906, + "native_prompt_ms": 110293.6, + "native_decode_ms": 29.2, + "hit_rate": 0.779, + "ram_blobs": 106, + "file_blobs": 0, + "file_mb": 0.0, + "drafts_offered": 0, + "drafts_accepted": 0, + "power_cap_w": 272.0 + }, + { + "family": "tuned-v0.1.40.3", + "trial": "qsa-exact-native2", + "arm": "0-B-240000", + "case": "follow-240000", + "follow_source_tokens": 2048, + "seconds": 3.935525797016453, + "success": true, + "finish_reason": "length", + "output_cap": 1, + "generated_tokens": 1, + "request_sha256": "523b45e7fa9be241cf0434f58ef29285c15a565df7779dae176d8f5a4df2626e", + "output_sha256": "33462c6ad8d3c9823e7b43633ff1a94f7671c4d155888e47618b5f60027701e5", + "prompt_tokens": 241991, + "reused_tokens": 239906, + "freshly_processed_tokens": 2085, + "native_prompt_ms": 3865.4, + "native_decode_ms": 22.2, + "hit_rate": 0.779, + "ram_blobs": 106, + "file_blobs": 0, + "file_mb": 0.0, + "drafts_offered": 0, + "drafts_accepted": 0, + "power_cap_w": 272.0 + }, + { + "family": "tuned-v0.1.40.3", + "trial": "qsa-exact-native2", + "arm": "1-A-131072", + "case": "fresh-131072", + "follow_source_tokens": 2048, + "seconds": 68.45079464002629, + "success": true, + "finish_reason": "length", + "output_cap": 1, + "generated_tokens": 1, + "request_sha256": "029dc64c403bd9597b2a143399fa64555b40b8a4910c708fe3f7c3ddc5a1ad25", + "output_sha256": "d6fadeb81a0f0a9f23a6a06f4c0f266f0afe25f436a0aa575ac593e2d695c969", + "prompt_tokens": 130978, + "reused_tokens": 0, + "freshly_processed_tokens": 130978, + "native_prompt_ms": 68353.8, + "native_decode_ms": 27.6, + "hit_rate": 0.787, + "ram_blobs": 102, + "file_blobs": 0, + "file_mb": 0.0, + "drafts_offered": 0, + "drafts_accepted": 0, + "power_cap_w": 272.0 + }, + { + "family": "tuned-v0.1.40.3", + "trial": "qsa-exact-native2", + "arm": "1-A-131072", + "case": "follow-131072", + "follow_source_tokens": 2048, + "seconds": 2.858728800987592, + "success": true, + "finish_reason": "length", + "output_cap": 1, + "generated_tokens": 1, + "request_sha256": "9f2979c0f702e087be57384d4b312a89f606961d08f0beaff64abd550b91b41d", + "output_sha256": "d6fadeb81a0f0a9f23a6a06f4c0f266f0afe25f436a0aa575ac593e2d695c969", + "prompt_tokens": 133063, + "reused_tokens": 130978, + "freshly_processed_tokens": 2085, + "native_prompt_ms": 2809.2, + "native_decode_ms": 20.2, + "hit_rate": 0.758, + "ram_blobs": 116, + "file_blobs": 0, + "file_mb": 0.0, + "drafts_offered": 0, + "drafts_accepted": 0, + "power_cap_w": 272.0 + }, + { + "family": "tuned-v0.1.40.3", + "trial": "qsa-exact-native2", + "arm": "1-A-240000", + "case": "fresh-240000", + "follow_source_tokens": 2048, + "seconds": 141.66012979499646, + "success": true, + "finish_reason": "length", + "output_cap": 1, + "generated_tokens": 1, + "request_sha256": "dbb6d4004af260501404a2674660c00523b1c455ba557d431395dab5cee7c4dd", + "output_sha256": "d6fadeb81a0f0a9f23a6a06f4c0f266f0afe25f436a0aa575ac593e2d695c969", + "prompt_tokens": 239906, + "reused_tokens": 0, + "freshly_processed_tokens": 239906, + "native_prompt_ms": 141512.5, + "native_decode_ms": 28.6, + "hit_rate": 0.779, + "ram_blobs": 106, + "file_blobs": 0, + "file_mb": 0.0, + "drafts_offered": 0, + "drafts_accepted": 0, + "power_cap_w": 272.0 + }, + { + "family": "tuned-v0.1.40.3", + "trial": "qsa-exact-native2", + "arm": "1-A-240000", + "case": "follow-240000", + "follow_source_tokens": 2048, + "seconds": 3.2768524099956267, + "success": true, + "finish_reason": "length", + "output_cap": 1, + "generated_tokens": 1, + "request_sha256": "523b45e7fa9be241cf0434f58ef29285c15a565df7779dae176d8f5a4df2626e", + "output_sha256": "33462c6ad8d3c9823e7b43633ff1a94f7671c4d155888e47618b5f60027701e5", + "prompt_tokens": 241991, + "reused_tokens": 239906, + "freshly_processed_tokens": 2085, + "native_prompt_ms": 3203.6, + "native_decode_ms": 21.5, + "hit_rate": 0.779, + "ram_blobs": 106, + "file_blobs": 0, + "file_mb": 0.0, + "drafts_offered": 0, + "drafts_accepted": 0, + "power_cap_w": 272.0 + }, + { + "family": "tuned-v0.1.40.3", + "trial": "qsa-exact-native3", + "arm": "0-A-131072", + "case": "fresh-131072", + "follow_source_tokens": 2048, + "seconds": 67.51405035398784, + "success": true, + "finish_reason": "length", + "output_cap": 1, + "generated_tokens": 1, + "request_sha256": "029dc64c403bd9597b2a143399fa64555b40b8a4910c708fe3f7c3ddc5a1ad25", + "output_sha256": "d6fadeb81a0f0a9f23a6a06f4c0f266f0afe25f436a0aa575ac593e2d695c969", + "prompt_tokens": 130978, + "reused_tokens": 0, + "freshly_processed_tokens": 130978, + "native_prompt_ms": 67406.7, + "native_decode_ms": 36.3, + "hit_rate": 0.792, + "ram_blobs": 100, + "file_blobs": 0, + "file_mb": 0.0, + "drafts_offered": 0, + "drafts_accepted": 0, + "power_cap_w": 272.0 + }, + { + "family": "tuned-v0.1.40.3", + "trial": "qsa-exact-native3", + "arm": "0-A-131072", + "case": "follow-131072", + "follow_source_tokens": 2048, + "seconds": 2.798884452000493, + "success": true, + "finish_reason": "length", + "output_cap": 1, + "generated_tokens": 1, + "request_sha256": "9f2979c0f702e087be57384d4b312a89f606961d08f0beaff64abd550b91b41d", + "output_sha256": "d6fadeb81a0f0a9f23a6a06f4c0f266f0afe25f436a0aa575ac593e2d695c969", + "prompt_tokens": 133063, + "reused_tokens": 130978, + "freshly_processed_tokens": 2085, + "native_prompt_ms": 2747.8, + "native_decode_ms": 20.4, + "hit_rate": 0.765, + "ram_blobs": 113, + "file_blobs": 0, + "file_mb": 0.0, + "drafts_offered": 0, + "drafts_accepted": 0, + "power_cap_w": 272.0 + }, + { + "family": "tuned-v0.1.40.3", + "trial": "qsa-exact-native3", + "arm": "0-A-240000", + "case": "fresh-240000", + "follow_source_tokens": 2048, + "seconds": 144.43555261398433, + "success": true, + "finish_reason": "length", + "output_cap": 1, + "generated_tokens": 1, + "request_sha256": "dbb6d4004af260501404a2674660c00523b1c455ba557d431395dab5cee7c4dd", + "output_sha256": "d6fadeb81a0f0a9f23a6a06f4c0f266f0afe25f436a0aa575ac593e2d695c969", + "prompt_tokens": 239906, + "reused_tokens": 0, + "freshly_processed_tokens": 239906, + "native_prompt_ms": 144288.4, + "native_decode_ms": 29.2, + "hit_rate": 0.779, + "ram_blobs": 106, + "file_blobs": 0, + "file_mb": 0.0, + "drafts_offered": 0, + "drafts_accepted": 0, + "power_cap_w": 272.0 + }, + { + "family": "tuned-v0.1.40.3", + "trial": "qsa-exact-native3", + "arm": "0-A-240000", + "case": "follow-240000", + "follow_source_tokens": 2048, + "seconds": 3.558641466021072, + "success": true, + "finish_reason": "length", + "output_cap": 1, + "generated_tokens": 1, + "request_sha256": "523b45e7fa9be241cf0434f58ef29285c15a565df7779dae176d8f5a4df2626e", + "output_sha256": "33462c6ad8d3c9823e7b43633ff1a94f7671c4d155888e47618b5f60027701e5", + "prompt_tokens": 241991, + "reused_tokens": 239906, + "freshly_processed_tokens": 2085, + "native_prompt_ms": 3486.1, + "native_decode_ms": 21.2, + "hit_rate": 0.775, + "ram_blobs": 108, + "file_blobs": 0, + "file_mb": 0.0, + "drafts_offered": 0, + "drafts_accepted": 0, + "power_cap_w": 272.0 + }, + { + "family": "tuned-v0.1.40.3", + "trial": "qsa-exact-native3", + "arm": "1-B-131072", + "case": "fresh-131072", + "follow_source_tokens": 2048, + "seconds": 59.46537054501823, + "success": true, + "finish_reason": "length", + "output_cap": 1, + "generated_tokens": 1, + "request_sha256": "029dc64c403bd9597b2a143399fa64555b40b8a4910c708fe3f7c3ddc5a1ad25", + "output_sha256": "d6fadeb81a0f0a9f23a6a06f4c0f266f0afe25f436a0aa575ac593e2d695c969", + "prompt_tokens": 130978, + "reused_tokens": 0, + "freshly_processed_tokens": 130978, + "native_prompt_ms": 59369.3, + "native_decode_ms": 27.0, + "hit_rate": 0.787, + "ram_blobs": 102, + "file_blobs": 0, + "file_mb": 0.0, + "drafts_offered": 0, + "drafts_accepted": 0, + "power_cap_w": 272.0 + }, + { + "family": "tuned-v0.1.40.3", + "trial": "qsa-exact-native3", + "arm": "1-B-131072", + "case": "follow-131072", + "follow_source_tokens": 2048, + "seconds": 2.687445471994579, + "success": true, + "finish_reason": "length", + "output_cap": 1, + "generated_tokens": 1, + "request_sha256": "9f2979c0f702e087be57384d4b312a89f606961d08f0beaff64abd550b91b41d", + "output_sha256": "d6fadeb81a0f0a9f23a6a06f4c0f266f0afe25f436a0aa575ac593e2d695c969", + "prompt_tokens": 133063, + "reused_tokens": 130978, + "freshly_processed_tokens": 2085, + "native_prompt_ms": 2634.6, + "native_decode_ms": 20.5, + "hit_rate": 0.758, + "ram_blobs": 116, + "file_blobs": 0, + "file_mb": 0.0, + "drafts_offered": 0, + "drafts_accepted": 0, + "power_cap_w": 272.0 + }, + { + "family": "tuned-v0.1.40.3", + "trial": "qsa-exact-native3", + "arm": "1-B-240000", + "case": "fresh-240000", + "follow_source_tokens": 2048, + "seconds": 111.23212432701257, + "success": true, + "finish_reason": "length", + "output_cap": 1, + "generated_tokens": 1, + "request_sha256": "dbb6d4004af260501404a2674660c00523b1c455ba557d431395dab5cee7c4dd", + "output_sha256": "d6fadeb81a0f0a9f23a6a06f4c0f266f0afe25f436a0aa575ac593e2d695c969", + "prompt_tokens": 239906, + "reused_tokens": 0, + "freshly_processed_tokens": 239906, + "native_prompt_ms": 111085.7, + "native_decode_ms": 31.8, + "hit_rate": 0.779, + "ram_blobs": 106, + "file_blobs": 0, + "file_mb": 0.0, + "drafts_offered": 0, + "drafts_accepted": 0, + "power_cap_w": 272.0 + }, + { + "family": "tuned-v0.1.40.3", + "trial": "qsa-exact-native3", + "arm": "1-B-240000", + "case": "follow-240000", + "follow_source_tokens": 2048, + "seconds": 2.8976090920041315, + "success": true, + "finish_reason": "length", + "output_cap": 1, + "generated_tokens": 1, + "request_sha256": "523b45e7fa9be241cf0434f58ef29285c15a565df7779dae176d8f5a4df2626e", + "output_sha256": "33462c6ad8d3c9823e7b43633ff1a94f7671c4d155888e47618b5f60027701e5", + "prompt_tokens": 241991, + "reused_tokens": 239906, + "freshly_processed_tokens": 2085, + "native_prompt_ms": 2821.8, + "native_decode_ms": 21.2, + "hit_rate": 0.779, + "ram_blobs": 106, + "file_blobs": 0, + "file_mb": 0.0, + "drafts_offered": 0, + "drafts_accepted": 0, + "power_cap_w": 272.0 + }, + { + "family": "current-main-same-binary", + "trial": "qsa-exact-current-main1", + "arm": "0-A-131072", + "case": "fresh-131072", + "follow_source_tokens": 2048, + "seconds": 68.87175908501376, + "success": true, + "finish_reason": "length", + "output_cap": 1, + "generated_tokens": 1, + "request_sha256": "029dc64c403bd9597b2a143399fa64555b40b8a4910c708fe3f7c3ddc5a1ad25", + "output_sha256": "d6fadeb81a0f0a9f23a6a06f4c0f266f0afe25f436a0aa575ac593e2d695c969", + "prompt_tokens": 130978, + "reused_tokens": 0, + "freshly_processed_tokens": 130978, + "native_prompt_ms": 68771.6, + "native_decode_ms": 28.8, + "hit_rate": 0.785, + "ram_blobs": 103, + "file_blobs": 0, + "file_mb": 0.0, + "drafts_offered": 0, + "drafts_accepted": 0, + "power_cap_w": 272.0 + }, + { + "family": "current-main-same-binary", + "trial": "qsa-exact-current-main1", + "arm": "0-A-131072", + "case": "follow-131072", + "follow_source_tokens": 2048, + "seconds": 2.8957397949998267, + "success": true, + "finish_reason": "length", + "output_cap": 1, + "generated_tokens": 1, + "request_sha256": "9f2979c0f702e087be57384d4b312a89f606961d08f0beaff64abd550b91b41d", + "output_sha256": "d6fadeb81a0f0a9f23a6a06f4c0f266f0afe25f436a0aa575ac593e2d695c969", + "prompt_tokens": 133063, + "reused_tokens": 130978, + "freshly_processed_tokens": 2085, + "native_prompt_ms": 2847.5, + "native_decode_ms": 20.1, + "hit_rate": 0.758, + "ram_blobs": 116, + "file_blobs": 0, + "file_mb": 0.0, + "drafts_offered": 0, + "drafts_accepted": 0, + "power_cap_w": 272.0 + }, + { + "family": "current-main-same-binary", + "trial": "qsa-exact-current-main1", + "arm": "0-A-240000", + "case": "fresh-240000", + "follow_source_tokens": 2048, + "seconds": 142.8425963030022, + "success": true, + "finish_reason": "length", + "output_cap": 1, + "generated_tokens": 1, + "request_sha256": "dbb6d4004af260501404a2674660c00523b1c455ba557d431395dab5cee7c4dd", + "output_sha256": "d6fadeb81a0f0a9f23a6a06f4c0f266f0afe25f436a0aa575ac593e2d695c969", + "prompt_tokens": 239906, + "reused_tokens": 0, + "freshly_processed_tokens": 239906, + "native_prompt_ms": 142694.7, + "native_decode_ms": 29.4, + "hit_rate": 0.779, + "ram_blobs": 106, + "file_blobs": 0, + "file_mb": 0.0, + "drafts_offered": 0, + "drafts_accepted": 0, + "power_cap_w": 272.0 + }, + { + "family": "current-main-same-binary", + "trial": "qsa-exact-current-main1", + "arm": "0-A-240000", + "case": "follow-240000", + "follow_source_tokens": 2048, + "seconds": 3.522451185999671, + "success": true, + "finish_reason": "length", + "output_cap": 1, + "generated_tokens": 1, + "request_sha256": "523b45e7fa9be241cf0434f58ef29285c15a565df7779dae176d8f5a4df2626e", + "output_sha256": "33462c6ad8d3c9823e7b43633ff1a94f7671c4d155888e47618b5f60027701e5", + "prompt_tokens": 241991, + "reused_tokens": 239906, + "freshly_processed_tokens": 2085, + "native_prompt_ms": 3445.8, + "native_decode_ms": 22.3, + "hit_rate": 0.779, + "ram_blobs": 106, + "file_blobs": 0, + "file_mb": 0.0, + "drafts_offered": 0, + "drafts_accepted": 0, + "power_cap_w": 272.0 + }, + { + "family": "current-main-same-binary", + "trial": "qsa-exact-current-main1", + "arm": "1-B-131072", + "case": "fresh-131072", + "follow_source_tokens": 2048, + "seconds": 60.01953978999518, + "success": true, + "finish_reason": "length", + "output_cap": 1, + "generated_tokens": 1, + "request_sha256": "029dc64c403bd9597b2a143399fa64555b40b8a4910c708fe3f7c3ddc5a1ad25", + "output_sha256": "d6fadeb81a0f0a9f23a6a06f4c0f266f0afe25f436a0aa575ac593e2d695c969", + "prompt_tokens": 130978, + "reused_tokens": 0, + "freshly_processed_tokens": 130978, + "native_prompt_ms": 59918.8, + "native_decode_ms": 27.0, + "hit_rate": 0.787, + "ram_blobs": 102, + "file_blobs": 0, + "file_mb": 0.0, + "drafts_offered": 0, + "drafts_accepted": 0, + "power_cap_w": 272.0 + }, + { + "family": "current-main-same-binary", + "trial": "qsa-exact-current-main1", + "arm": "1-B-131072", + "case": "follow-131072", + "follow_source_tokens": 2048, + "seconds": 2.780924443999538, + "success": true, + "finish_reason": "length", + "output_cap": 1, + "generated_tokens": 1, + "request_sha256": "9f2979c0f702e087be57384d4b312a89f606961d08f0beaff64abd550b91b41d", + "output_sha256": "d6fadeb81a0f0a9f23a6a06f4c0f266f0afe25f436a0aa575ac593e2d695c969", + "prompt_tokens": 133063, + "reused_tokens": 130978, + "freshly_processed_tokens": 2085, + "native_prompt_ms": 2730.0, + "native_decode_ms": 21.3, + "hit_rate": 0.758, + "ram_blobs": 116, + "file_blobs": 0, + "file_mb": 0.0, + "drafts_offered": 0, + "drafts_accepted": 0, + "power_cap_w": 272.0 + }, + { + "family": "current-main-same-binary", + "trial": "qsa-exact-current-main1", + "arm": "1-B-240000", + "case": "fresh-240000", + "follow_source_tokens": 2048, + "seconds": 111.82761004997883, + "success": true, + "finish_reason": "length", + "output_cap": 1, + "generated_tokens": 1, + "request_sha256": "dbb6d4004af260501404a2674660c00523b1c455ba557d431395dab5cee7c4dd", + "output_sha256": "d6fadeb81a0f0a9f23a6a06f4c0f266f0afe25f436a0aa575ac593e2d695c969", + "prompt_tokens": 239906, + "reused_tokens": 0, + "freshly_processed_tokens": 239906, + "native_prompt_ms": 111680.4, + "native_decode_ms": 28.7, + "hit_rate": 0.779, + "ram_blobs": 106, + "file_blobs": 0, + "file_mb": 0.0, + "drafts_offered": 0, + "drafts_accepted": 0, + "power_cap_w": 272.0 + }, + { + "family": "current-main-same-binary", + "trial": "qsa-exact-current-main1", + "arm": "1-B-240000", + "case": "follow-240000", + "follow_source_tokens": 2048, + "seconds": 2.957570611004485, + "success": true, + "finish_reason": "length", + "output_cap": 1, + "generated_tokens": 1, + "request_sha256": "523b45e7fa9be241cf0434f58ef29285c15a565df7779dae176d8f5a4df2626e", + "output_sha256": "33462c6ad8d3c9823e7b43633ff1a94f7671c4d155888e47618b5f60027701e5", + "prompt_tokens": 241991, + "reused_tokens": 239906, + "freshly_processed_tokens": 2085, + "native_prompt_ms": 2884.7, + "native_decode_ms": 21.3, + "hit_rate": 0.777, + "ram_blobs": 107, + "file_blobs": 0, + "file_mb": 0.0, + "drafts_offered": 0, + "drafts_accepted": 0, + "power_cap_w": 272.0 + } + ], + "summaries": [ + { + "family": "tuned-v0.1.40.3", + "case": "fresh-131072", + "off": { + "n": 3, + "mean_seconds": 66.74059194500053, + "median_seconds": 67.51405035398784, + "min_seconds": 64.25693084098748, + "max_seconds": 68.45079464002629 + }, + "on": { + "n": 3, + "mean_seconds": 59.7690495433441, + "median_seconds": 59.46537054501823, + "min_seconds": 58.86296121100895, + "max_seconds": 60.97881687400513 + }, + "mean_elapsed_reduction": 0.10445730549410659, + "median_elapsed_reduction": 0.11921488589069962 + }, + { + "family": "tuned-v0.1.40.3", + "case": "fresh-240000", + "off": { + "n": 3, + "mean_seconds": 142.71826253732434, + "median_seconds": 142.0591052029922, + "min_seconds": 141.66012979499646, + "max_seconds": 144.43555261398433 + }, + "on": { + "n": 3, + "mean_seconds": 110.40663009767498, + "median_seconds": 110.438449467998, + "min_seconds": 109.54931649801438, + "max_seconds": 111.23212432701257 + }, + "mean_elapsed_reduction": 0.22640152609200292, + "median_elapsed_reduction": 0.22258802552508394 + }, + { + "family": "current-main-same-binary", + "case": "fresh-131072", + "off": { + "n": 1, + "mean_seconds": 68.87175908501376, + "median_seconds": 68.87175908501376, + "min_seconds": 68.87175908501376, + "max_seconds": 68.87175908501376 + }, + "on": { + "n": 1, + "mean_seconds": 60.01953978999518, + "median_seconds": 60.01953978999518, + "min_seconds": 60.01953978999518, + "max_seconds": 60.01953978999518 + }, + "mean_elapsed_reduction": 0.12853191805499842, + "median_elapsed_reduction": 0.12853191805499842 + }, + { + "family": "current-main-same-binary", + "case": "fresh-240000", + "off": { + "n": 1, + "mean_seconds": 142.8425963030022, + "median_seconds": 142.8425963030022, + "min_seconds": 142.8425963030022, + "max_seconds": 142.8425963030022 + }, + "on": { + "n": 1, + "mean_seconds": 111.82761004997883, + "median_seconds": 111.82761004997883, + "min_seconds": 111.82761004997883, + "max_seconds": 111.82761004997883 + }, + "mean_elapsed_reduction": 0.2171270129201055, + "median_elapsed_reduction": 0.2171270129201055 + }, + { + "family": "tuned-v0.1.40.3", + "case": "follow-131072", + "off": { + "n": 2, + "mean_seconds": 2.8288066264940426, + "median_seconds": 2.8288066264940426, + "min_seconds": 2.798884452000493, + "max_seconds": 2.858728800987592 + }, + "on": { + "n": 2, + "mean_seconds": 2.6584183355007553, + "median_seconds": 2.6584183355007553, + "min_seconds": 2.629391199006932, + "max_seconds": 2.687445471994579 + }, + "mean_elapsed_reduction": 0.06023327625065078, + "median_elapsed_reduction": 0.06023327625065078 + }, + { + "family": "tuned-v0.1.40.3", + "case": "follow-240000", + "off": { + "n": 2, + "mean_seconds": 3.4177469380083494, + "median_seconds": 3.4177469380083494, + "min_seconds": 3.2768524099956267, + "max_seconds": 3.558641466021072 + }, + "on": { + "n": 2, + "mean_seconds": 3.4165674445102923, + "median_seconds": 3.4165674445102923, + "min_seconds": 2.8976090920041315, + "max_seconds": 3.935525797016453 + }, + "mean_elapsed_reduction": 0.00034510849382674014, + "median_elapsed_reduction": 0.00034510849382674014 + }, + { + "family": "current-main-same-binary", + "case": "follow-131072", + "off": { + "n": 1, + "mean_seconds": 2.8957397949998267, + "median_seconds": 2.8957397949998267, + "min_seconds": 2.8957397949998267, + "max_seconds": 2.8957397949998267 + }, + "on": { + "n": 1, + "mean_seconds": 2.780924443999538, + "median_seconds": 2.780924443999538, + "min_seconds": 2.780924443999538, + "max_seconds": 2.780924443999538 + }, + "mean_elapsed_reduction": 0.039649747259247525, + "median_elapsed_reduction": 0.039649747259247525 + }, + { + "family": "current-main-same-binary", + "case": "follow-240000", + "off": { + "n": 1, + "mean_seconds": 3.522451185999671, + "median_seconds": 3.522451185999671, + "min_seconds": 3.522451185999671, + "max_seconds": 3.522451185999671 + }, + "on": { + "n": 1, + "mean_seconds": 2.957570611004485, + "median_seconds": 2.957570611004485, + "min_seconds": 2.957570611004485, + "max_seconds": 2.957570611004485 + }, + "mean_elapsed_reduction": 0.1603657638295627, + "median_elapsed_reduction": 0.1603657638295627 + } + ], + "coding_pilot": { + "scope": "Two official Exercism/Aider Polyglot tasks embedded in a192K source archive; not an official leaderboard run", + "seeds": [ + 7830, + 7831 + ], + "reasoning_effort": "xhigh", + "reasoning_budget_tokens": 8192, + "answer_reserve_tokens": 2048, + "temperature": 0.3, + "top_p": 0.95, + "top_k": 20, + "min_p": 0, + "archive_context": 196608, + "logical_context": 262144, + "paired_trials_per_task": 1, + "correction_time_included": true, + "completion_policy": "stop at first full-suite pass", + "rows": [ + { + "task": "go/alphametics", + "arm": "deployed", + "seconds": 209.1360279940127, + "turns": 3, + "success": true + }, + { + "task": "go/alphametics", + "arm": "candidate", + "seconds": 400.3182297559979, + "turns": 5, + "success": true + }, + { + "task": "rust/xorcism", + "arm": "candidate", + "seconds": 304.9063483380014, + "turns": 6, + "success": true + }, + { + "task": "rust/xorcism", + "arm": "deployed", + "seconds": 473.7341761919961, + "turns": 6, + "success": true + } + ], + "totals_seconds": { + "deployed": 682.8702041860088, + "candidate": 705.2245780939993 + }, + "elapsed_reduction": -0.03273590467259768, + "all_passed": true, + "minimum_available_gib": 8.621219635009766, + "resource_pass": true, + "general_promotion": false + }, + "abandoned_240k_archive_pilot": { + "status": "infrastructure_failure", + "reason": "Insufficient continuation headroom: Rust history reached262714tokens, exceeding262144", + "go_pair_seconds": { + "off": 325.555172590015, + "on": 323.6994908300112 + }, + "both_go_passed": true, + "rust_on_model_seconds_before_failure": 311, + "rust_off_not_attempted": true, + "pooled_with_192k_family": false + }, + "full24_run": false, + "cloud_comparison_run": false +} diff --git a/bench/results/2026-10-11-gfx1100-qsa-scores/prompt-source.txt.gz b/bench/results/2026-10-11-gfx1100-qsa-scores/prompt-source.txt.gz new file mode 100644 index 00000000..436f2a82 Binary files /dev/null and b/bench/results/2026-10-11-gfx1100-qsa-scores/prompt-source.txt.gz differ diff --git a/bench/results/2026-10-11-gfx1100-qsa-scores/provenance.json b/bench/results/2026-10-11-gfx1100-qsa-scores/provenance.json new file mode 100644 index 00000000..9632255e --- /dev/null +++ b/bench/results/2026-10-11-gfx1100-qsa-scores/provenance.json @@ -0,0 +1,168 @@ +{ + "hardware": { + "measured_date": "2026-10-11", + "cpu": "AMD Ryzen 9 7950X3D", + "gpu": "AMD Radeon RX 7900 XTX", + "architecture": "gfx1100", + "gpu_vram_gib": 24, + "installed_ram_gib": 64, + "kernel": "7.2.9-200.nobara.fc44.x86_64", + "rocm": "10.0.0", + "power_cap_w": 272, + "operating_system": { + "NAME": "Nobara Linux", + "VERSION": "44 (KDE Plasma Desktop Edition)", + "VERSION_ID": "44", + "PRETTY_NAME": "Nobara Linux 44 (KDE Plasma Desktop Edition)" + }, + "current_link_speed": "16.0 GT/s PCIe", + "current_link_width": "16", + "mem_info_vram_total": "25753026560", + "storage": { + "model": "NVMe SSD", + "ple": "dedicated ext4 SSD partition, direct I/O, remains on SSD" + } + }, + "upstream_base": "61b3fb5dd3f1e8ec09cf7e4e05208bc6d3c46406", + "original_method": { + "pr": 1825, + "commit": "14bf32150490bb9f5fc4d9c7c5dcfdc96dd98797", + "author": "xrip" + }, + "tuned_control": { + "source_base": "d5ea7133741e67743c0e886bb426c0ce8d69cf6c", + "local_changes": "PR1107 prefix reuse and resident-budget-loan implementation; same in both arms", + "native_sha256": "3bbaf98d7f83c91b0a40f369e5dee6ae4273284028b98d48dccde9e554f5c80c", + "candidate_sha256": "e0708d4fe0b0e096a36d793f47aebfdd3477e6157264b5739657977937381299" + }, + "current_main": { + "native_sha256": "1338d642a7d1d1e34a8f38932aef82619a6ac0e6f5195a7f1661dd55f916b8ad", + "sole_arm_difference": "STRATA_SCORES_THREAD=0 versus1 at process startup" + }, + "submitted_source_files": { + "CMakeLists.txt": "84048b34a1065672c9d3577053611fc33e3e63815d33ae502ee15e8deefd5d6a", + "src/kernels/cuda/qsa_select.cu": "fe051b86dfb349d09f0b576f9b9e710d20334acb534021a869763a7cb59836d8", + "src/kernels/cuda/qsa_scores_gfx1100_test.cu": "2a26063e9c5c58cb36f0973b36bb590db10762515f9eda5318314162fafda588", + "src/kernels/qsa_scores_gfx1100_parity.cpp": "9d0d88a2490d41d5e059e08db0907433b63321c98b53dceffc88883174aa3e15" + }, + "compiler_checks": { + "hip_full_engine": true, + "hip_cmake_test_target": true, + "cuda_touched_module": true, + "cuda_arch": "sm_89", + "cuda_toolkit": "13.0", + "cuda_full_engine": false, + "cuda_gpu_execution": false, + "sycl_source_touched": false + }, + "frontend": { + "version": "local prefix-cache frontend based on0.1.40.3; same for all arms", + "sha256": "5963c61106ee746673c43cb69df7b6bfeff2d2ec320a00f2435e1fd6e187f9dd", + "stock_latest_frontend_tested": false, + "chat_template_sha256": "a49e6e5da2cb6d114814c9ee5079677dfd1bdc4cf6b5c1519eb73d0bcf12f02b" + }, + "model": { + "repository": "https://huggingface.co/orcarouter/Qwen3.8-Flash-Next-Uncensored-GGUF", + "quantization": "IQ3_S", + "revision": "not recorded", + "gguf_shards": [ + "Qwen3.8-Flash-Next-GSQ-RCO-abliterated-IQ3_S-00001-of-00002.gguf", + "Qwen3.8-Flash-Next-GSQ-RCO-abliterated-IQ3_S-00002-of-00002.gguf" + ], + "expert_profile_sha256": "e93f33e1cad05fc31627295b1b9a253bfa99286ec2261c01e5c39366888e69f8", + "index_sha256": "02e228d5488792b1c2cb97b7021d099f47b198f5e13d0b9f9bc8716bb0592146", + "native_experts_sha256": "adba4968661f3d59f749a676a87948e29236c81997f649f5526daf71148edc24" + }, + "shared_config": { + "args": [ + "--pack", + "", + "--native", + "/IQ3_S/Qwen3.8-Flash-Next-GSQ-RCO-abliterated-IQ3_S-00001-of-00002.gguf", + "--ple-gguf", + "/Qwen3.8-Flash-Next-GSQ-RCO-abliterated-IQ3_S-00002-of-00002.gguf", + "--mmap-experts", + "--expert-profile", + "/flash-solo-balanced-20261004.bin", + "--expert-cache", + "8247", + "--prefill", + "16384", + "--spec", + "6", + "--spec-min-p", + "0.7", + "--mtp", + "/strata/rt", + "--max-context", + "262144", + "--kv", + "int8", + "--kv-resident", + "32768", + "--vision", + "--pool-workers", + "15", + "--adapt-every", + "0", + "--pcie-frac", + "0", + "--vram-reserve-mib", + "1024", + "--resident-budget-gib", + "34", + "--mtp-max-t", + "6", + "--ple-io", + "direct", + "--conversation-cache-mib", + "1024", + "--conversation-cache-slots", + "2", + "--conversation-cache-min-free-mib", + "8192", + "--native-dense-gguf", + "/IQ3_S/Qwen3.8-Flash-Next-GSQ-RCO-abliterated-IQ3_S-00001-of-00002.gguf", + "--native-dense-gguf", + "/Qwen3.8-Flash-Next-GSQ-RCO-abliterated-IQ3_S-00002-of-00002.gguf" + ], + "environment": { + "ROCR_VISIBLE_DEVICES": "0", + "HIP_VISIBLE_DEVICES": "0", + "CUDA_VISIBLE_DEVICES": "-1", + "STRATA_GPU_BACKEND": "hip", + "STRATA_PREFILL_MMQ": "1", + "STRATA_PREFILL_RING": "96", + "STRATA_DEC_BATCH": "1", + "STRATA_PREFILL_ISSUER": "1", + "STRATA_SCORES_MULTI": "2", + "STRATA_RESIDENT_PIN": "0", + "STRATA_RESIDENT_HEADROOM_GIB": "2", + "STRATA_MMAP_STAGE_PREFETCH": "1", + "STRATA_REFILL_BLOCKING": "1", + "STRATA_WMMA_GEMM": "0", + "STRATA_PA_WMMA": "1", + "STRATA_SELECT_WMMA": "0", + "STRATA_PREFILL_GROUP_GATHER": "1", + "STRATA_STAGER_DMA_FENCE": "1", + "STRATA_IO_THREADS": "32", + "STRATA_DECODE_TIMING": "1", + "STRATA_HIP_WMMA": "1", + "STRATA_HIPBLASLT_VERBOSE": "1", + "STRATA_SH_STREAM": "0", + "STRATA_RESIDENT_BUDGET_LOANS": "1", + "STRATA_SELECT_SIMT": "0", + "STRATA_STAGE_PIN": "0", + "STRATA_VISION_BACKEND_DIR": "", + "STRATA_HIPBLASLT_TUNING": "hipblaslt-gfx1100-100401.txt" + }, + "configured_expert_slots": 8247, + "actual_gpu_expert_slots": 8144, + "actual_gpu_expert_bytes": 16622003200, + "logical_context": 262144, + "vision": "GPU enabled; no image prompt in these measurements", + "cgroup_memory_limit_gib": 56, + "cgroup_swap_limit": 0, + "available_memory_floor_gib": 8 + } +} diff --git a/docs/AMD_HIP.md b/docs/AMD_HIP.md index 47327380..d0038683 100644 --- a/docs/AMD_HIP.md +++ b/docs/AMD_HIP.md @@ -299,6 +299,17 @@ only when its version matches the installed library; otherwise it prefills on pl prompt), so keep the table and the library paired. Not worth trying (measured flat): `--kv-resident` changes, a prefill chunk above 32768, `--spec` above 4. +## gfx1100: optional exact long-prompt QSA scorer + +`STRATA_SCORES_THREAD=1` at engine startup enables a HIP port of #1825's score kernel on gfx1100, for batches of +at least 64 queries with at least 16,385 live index blocks. The default, short-prompt and decode paths keep the +existing scorer. On one RX 7900 XTX / 7950X3D / ROCm 10.0.0, three paired runs of a tuned 0.1.40.3 engine reduced +fresh one-token request time by 10.45% at 130,978 prompt tokens and 22.64% at 239,906; one same-binary current-main +pair measured 12.85% and 21.71%. Cached follow-ups did not show a repeatable large gain, and a two-task coding pilot +was 3.27% slower overall. This is opt-in, not a general coding-speed recommendation. The +[report, per-run data and standalone score/ID check](../bench/results/2026-10-11-gfx1100-qsa-scores/README.md) +give the settings, exact-parity checks and limits. `STRATA_SCORES_THREAD_TRACE=1` prints an engagement line. + ## Linux: verify timeouts while the kernel reclaims host memory (experimental workarounds) A `verify: timed out at layer N` or "no progress for 60 s" message does not by itself mean a kernel or handshake bug. Two diff --git a/src/kernels/cuda/qsa_scores_gfx1100_test.cu b/src/kernels/cuda/qsa_scores_gfx1100_test.cu new file mode 100644 index 00000000..fdc56877 --- /dev/null +++ b/src/kernels/cuda/qsa_scores_gfx1100_test.cu @@ -0,0 +1,32 @@ +// Test-only translation unit: production scorer plus the unchanged warp dispatch. +// The production library does not compile this reference wrapper. +#include "qsa_select.cu" + +namespace strata::kernels { +void qsa_block_scores_reference(const float* pooled, const float* dead, const float* q_idx, const int32_t* steps, int64_t nq, + int64_t max_blocks, const QsaShapes& s, float* scores, void* stream, int64_t active_blocks) { + if (nq <= 0) return; + if (s.idx_dim != IDX_DIM || s.idx_n_head != IDX_HEADS || s.idx_block != R || nq > 65535) { + std::fprintf(stderr, "qsa_block_scores: unsupported indexer geometry\n"); + std::exit(1); + } + // a block past a query's n_bid returns at once: the grid need only reach the batch's largest n_bid (C-1) + static const bool multi = [] { const char* v = std::getenv("STRATA_SCORES_MULTI"); return v == nullptr || std::atoi(v) != 0; }(); + if (multi && nq <= MQ && active_blocks <= 0) { // no active count: decode (captured or not) and prefill's pooled16 + // STRATA_QSA_EARLY_EXIT=0 keeps the old staging (every CTA loads the queries first); the scores are the same bits + static const bool early = [] { const char* v = std::getenv("STRATA_QSA_EARLY_EXIT"); return v == nullptr || std::atoi(v) != 0; }(); + block_scores_multi_kernel<<<256, SCORE_WARPS * 32, 0, (cudaStream_t) stream>>>(pooled, dead, q_idx, steps, (int) nq, + max_blocks, scores, early); + const cudaError_t e = cudaGetLastError(); + if (e != cudaSuccess) { std::fprintf(stderr, "qsa_block_scores multi: %s\n", cudaGetErrorString(e)); std::exit(1); } + return; + } + const int64_t reach = active_blocks > 0 && active_blocks < max_blocks ? active_blocks : max_blocks; + const dim3 grid((unsigned) ((reach + SCORE_WARPS - 1) / SCORE_WARPS), (unsigned) nq); + block_scores_kernel<<>>(pooled, dead, q_idx, steps, max_blocks, + scores); + const cudaError_t e = cudaGetLastError(); + if (e != cudaSuccess) { std::fprintf(stderr, "qsa_block_scores: %s\n", cudaGetErrorString(e)); std::exit(1); } +} + +} diff --git a/src/kernels/cuda/qsa_select.cu b/src/kernels/cuda/qsa_select.cu index a8ea4ec3..c27ca108 100644 --- a/src/kernels/cuda/qsa_select.cu +++ b/src/kernels/cuda/qsa_select.cu @@ -868,6 +868,101 @@ __global__ void __launch_bounds__(SCORE_WARPS * 32) block_scores_multi_kernel(co } } +#if defined(__HIPCC__) +// Optional gfx1100 port of PR1825 (14bf3215): same FP32 expression and reduction tree. +// Decode and the original top-k stay unchanged. No additional persistent weight/state allocation. +constexpr int TS_Q = 64; // queries per CTA (8 per wave, four lanes per query) +constexpr int TS_KB = 32; // key blocks per shared-memory tile +constexpr int TS_BR = 512; // key blocks per CTA + +__device__ __forceinline__ float ts_part(const float4 k4, const float4 q4) { + return k4.x * q4.x + k4.y * q4.y + k4.z * q4.z + k4.w * q4.w; // block_scores_kernel's per-lane expression +} + +__global__ void __launch_bounds__(256, 1) block_scores_thread_kernel(const float* __restrict__ pooled, + const float* __restrict__ q_idx, + const int32_t* __restrict__ steps, int64_t nq, + int64_t max_blocks, int64_t reach, + float* __restrict__ out) { + __shared__ __align__(16) float4 ks[TS_KB][IDX_DIM / 4]; + __shared__ float so[TS_Q][TS_KB + 1]; + __shared__ int64_t s_nbid[TS_Q]; + // Four lanes per query, lane j (0..3) one quarter of the tree for all four heads: the partials c[j] of lane 0's + // xor-shuffle sum combine groups j, j+16, j+8, j+24, j+4, j+20, j+12, j+28, and only then do the quarters meet + // (c0 + c2, c1 + c3, then their sum) - two shuffles here. A key load now feeds four heads: four times fewer + // shared-memory loads per FMA. The MIO-pipe motivation was measured by PR1825 on NVIDIA. + constexpr int QG[8] = {0, 16, 8, 24, 4, 20, 12, 28}; + const int t = threadIdx.x, lane = t & 31; + const int ql = (t >> 5) * 8 + (lane >> 2), j4 = lane & 3; // this lane's query (in the CTA) and quarter + const int64_t q0 = (int64_t) blockIdx.y * TS_Q, qi = q0 + ql; + if (t < TS_Q) s_nbid[t] = q0 + t < nq ? steps[(q0 + t) * kStepCount + kStepNBid] : -1; + float4 qv[IDX_HEADS][8]; + { + const float4* src = reinterpret_cast(q_idx + (qi < nq ? qi : 0) * IDX_HEADS * IDX_DIM); +#pragma unroll + for (int h = 0; h < IDX_HEADS; ++h) +#pragma unroll + for (int m = 0; m < 8; ++m) qv[h][m] = src[h * (IDX_DIM / 4) + j4 + QG[m]]; + } + __syncthreads(); + int64_t top = -1; // the largest n_bid of the CTA's queries: blocks at or past it are never written here + for (int i = 0; i < TS_Q; ++i) top = s_nbid[i] > top ? s_nbid[i] : top; + const int64_t b_lo = (int64_t) blockIdx.x * TS_BR; + int64_t b_hi = b_lo + TS_BR; + if (b_hi > reach) b_hi = reach; + if (b_hi > top) b_hi = top; + if (b_hi > max_blocks) b_hi = max_blocks; + for (int64_t b0 = b_lo; b0 < b_hi; b0 += TS_KB) { + const int nb = (int) (b_hi - b0 < TS_KB ? b_hi - b0 : TS_KB); + __syncthreads(); // the previous tile's reads of ks and so are done + for (int i = t; i < nb * (IDX_DIM / 4); i += blockDim.x) + ks[i / (IDX_DIM / 4)][i % (IDX_DIM / 4)] = reinterpret_cast(pooled + (b0 + i / (IDX_DIM / 4)) * IDX_DIM)[i % (IDX_DIM / 4)]; + __syncthreads(); + for (int j = 0; j < nb; ++j) { + float4 kk[8]; +#pragma unroll + for (int m = 0; m < 8; ++m) kk[m] = ks[j][j4 + QG[m]]; + float e[IDX_HEADS]; +#pragma unroll + for (int h = 0; h < IDX_HEADS; ++h) { + const float c = ((ts_part(kk[0], qv[h][0]) + ts_part(kk[1], qv[h][1])) + + (ts_part(kk[2], qv[h][2]) + ts_part(kk[3], qv[h][3]))) + + ((ts_part(kk[4], qv[h][4]) + ts_part(kk[5], qv[h][5])) + + (ts_part(kk[6], qv[h][6]) + ts_part(kk[7], qv[h][7]))); + const float d = c + __shfl_xor_sync(0xffffffffu, c, 2); // lane 0: c0 + c2, lane 1: c1 + c3 + e[h] = d + __shfl_xor_sync(0xffffffffu, d, 1); // lane 0: (c0 + c2) + (c1 + c3) + } + if (j4 == 0) { + float score = 0.0f; +#pragma unroll + for (int h = 0; h < IDX_HEADS; ++h) score += e[h] > 0.0f ? e[h] : 0.0f; + so[ql][j] = score; + } + } + __syncthreads(); + for (int i = t; i < TS_Q * nb; i += blockDim.x) { + const int q = i / nb, j = i % nb; + if (b0 + j < s_nbid[q]) out[(q0 + q) * max_blocks + b0 + j] = so[q][j]; + } + } +} + +bool scores_gfx1100_device() { + int device = -1; + if (cudaGetDevice(&device) != cudaSuccess) { cudaGetLastError(); return false; } + static thread_local int cached_device = -1; + static thread_local bool supported = false; + if (device != cached_device) { + cudaDeviceProp properties{}; + supported = cudaGetDeviceProperties(&properties, device) == cudaSuccess && + gfx_arch_is(properties.gcnArchName, "gfx1100"); + cached_device = device; + cudaGetLastError(); + } + return supported; +} +#endif + #if !defined(__HIPCC__) // ---- the decode top-k on a thread-block cluster (sm_90+; S19). One CTA per query (block_topk_reg_kernel, or // block_topk_kernel above 33,792 blocks: a --max-context over ~135K) makes four radix passes and two scans over up to @@ -1111,6 +1206,33 @@ void qsa_block_scores(const float* pooled, const float* dead, const float* q_idx return; } const int64_t reach = active_blocks > 0 && active_blocks < max_blocks ? active_blocks : max_blocks; +#if defined(__HIPCC__) + static const bool thread_scores = [] { + const char* value = std::getenv("STRATA_SCORES_THREAD"); + return value != nullptr && std::atoi(value) == 1; // experiment: off by default + }(); + // The bound is the ACTUAL live extent. A reserved 256K context never enables this by itself. + if (thread_scores && active_blocks >= 16385 && active_blocks <= max_blocks && nq >= 64 && + scores_gfx1100_device()) { + static thread_local bool logged = false; + if (!logged && std::getenv("STRATA_SCORES_THREAD_TRACE")) { + std::fprintf(stderr, "qsa exact thread: gfx1100 nq=%lld active_blocks=%lld capacity=%lld\n", + (long long)nq, (long long)active_blocks, (long long)max_blocks); + logged = true; + } + const dim3 tgrid((unsigned)((reach + TS_BR - 1) / TS_BR), (unsigned)((nq + TS_Q - 1) / TS_Q)); + block_scores_thread_kernel<<>>(pooled, q_idx, steps, nq, + max_blocks, reach, scores); + block_scores_tail_kernel<<<(unsigned)nq, 32, 0, (cudaStream_t)stream>>>(dead, q_idx, steps, + max_blocks, scores); + const cudaError_t error = cudaGetLastError(); + if (error != cudaSuccess) { + std::fprintf(stderr, "qsa exact thread: %s\n", cudaGetErrorString(error)); + std::exit(1); + } + return; + } +#endif const dim3 grid((unsigned) ((reach + SCORE_WARPS - 1) / SCORE_WARPS), (unsigned) nq); block_scores_kernel<<>>(pooled, dead, q_idx, steps, max_blocks, scores); diff --git a/src/kernels/qsa_scores_gfx1100_parity.cpp b/src/kernels/qsa_scores_gfx1100_parity.cpp new file mode 100644 index 00000000..63053d93 --- /dev/null +++ b/src/kernels/qsa_scores_gfx1100_parity.cpp @@ -0,0 +1,185 @@ +// GPU contract test for the optional gfx1100 port of PR1825. Synthetic, no model or coding score. +#include "strata/kernels/qsa.hpp" +#include "strata/kernels/qsa_select.hpp" +#include "strata/kernels/gfx_arch.hpp" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace strata::kernels { +// Test-only host wrapper copied from the unchanged baseline; both arms receive the SAME active bound. +void qsa_block_scores_reference(const float*, const float*, const float*, const int32_t*, int64_t, + int64_t, const QsaShapes&, float*, void*, int64_t); +} +namespace k = strata::kernels; +namespace { +void ck(cudaError_t e) { + if (e != cudaSuccess) { std::fprintf(stderr, "HIP: %s\n", cudaGetErrorString(e)); std::exit(2); } +} +void require(bool ok, const char* why) { + if (!ok) { std::fprintf(stderr, "FAIL: %s\n", why); std::exit(1); } +} +struct Buffer { + void* p = nullptr; size_t bytes; + explicit Buffer(size_t n): bytes(n) { ck(cudaMalloc(&p, n + 64)); ck(cudaMemset(p, 0xd3, n + 64)); } + ~Buffer() { ck(cudaFree(p)); } + template T* as() { return static_cast(p); } + void guard() { + unsigned char v[64]; + ck(cudaMemcpy(v, static_cast(p) + bytes, 64, cudaMemcpyDeviceToHost)); + for (auto c: v) require(c == 0xd3, "allocation guard modified"); + } +}; +struct Case { int64_t context, queries, capacity; int mode; int bound; bool timing; }; +int cases_done = 0, engaged = 0; +uint64_t scores_checked = 0, ids_checked = 0; + +void check(Case c) { + const auto s = k::qsa_real_shapes(); + const int64_t nb = c.capacity / s.idx_block + 2, nq = c.queries; + const int64_t active = c.context / s.idx_block + 1; + const int64_t bound = c.bound == 0 ? active : c.bound == 1 ? 0 : c.bound == 2 ? -1 : nb + 1; + const int64_t cap = k::qsa_selection_width(k::kTopkMaxCells, s); + std::mt19937 rng(91731 + (unsigned)c.context + 7*(unsigned)nq + 101*c.mode); + std::normal_distribution nd(0, 1); + std::uniform_int_distribution expo(-20, 20), small(-3, 3); + uint64_t sequence = 0; + auto value = [&]() -> float { + ++sequence; + if (c.mode == 1) return sequence % 11 == 0 ? 0.f : std::ldexp(nd(rng), expo(rng)); + if (c.mode == 2) return (float)small(rng); + if (c.mode == 3) return sequence % 2 ? 0.f : -0.f; + if (c.mode == 4) { + if (sequence % 23 == 0) return std::numeric_limits::quiet_NaN(); + if (sequence % 29 == 0) return std::numeric_limits::infinity(); + if (sequence % 31 == 0) return -std::numeric_limits::infinity(); + } + if (c.mode == 5) return sequence % 4 < 2 ? std::ldexp(1.f, 20) : -std::ldexp(1.f, 20); + return nd(rng); + }; + std::vector pooled(nb*s.idx_dim), dead(s.idx_dim), q(nq*s.idx_n_head*s.idx_dim); + for (auto& v: pooled) v = value(); + for (auto& v: dead) v = value(); + for (auto& v: q) v = value(); + // Padding after the largest live block must never affect scores or selected IDs. + for (int64_t i = active * s.idx_dim; i < (int64_t)pooled.size(); ++i) + pooled[i] = std::numeric_limits::quiet_NaN(); + std::vector steps(nq*k::kStepCount); + for (int64_t i = 0; i < nq; ++i) { + auto* st = steps.data() + i*k::kStepCount; + const int64_t n = c.context - nq + i + 1; + st[k::kStepPos] = n-1; st[k::kStepNKv] = n; + st[k::kStepNBid] = n/s.idx_block; + st[k::kStepWidth] = k::qsa_selection_width(n, s); + } + Buffer p(pooled.size()*4), d(dead.size()*4), query(q.size()*4), step(steps.size()*4); + Buffer a(nq*nb*4), b(nq*nb*4), ia(nq*cap*4), ib(nq*cap*4); + ck(cudaMemcpy(p.p, pooled.data(), p.bytes, cudaMemcpyHostToDevice)); + ck(cudaMemcpy(d.p, dead.data(), d.bytes, cudaMemcpyHostToDevice)); + ck(cudaMemcpy(query.p, q.data(), query.bytes, cudaMemcpyHostToDevice)); + ck(cudaMemcpy(step.p, steps.data(), step.bytes, cudaMemcpyHostToDevice)); + auto reference = [&] { + k::qsa_block_scores_reference(p.as(), d.as(), query.as(), step.as(), + nq, nb, s, a.as(), nullptr, bound); + }; + auto candidate = [&] { + k::qsa_block_scores(p.as(), d.as(), query.as(), step.as(), + nq, nb, s, b.as(), nullptr, bound); + }; + ck(cudaMemset(a.p, 0xa5, a.bytes)); ck(cudaMemset(b.p, 0x5a, b.bytes)); + reference(); candidate(); ck(cudaDeviceSynchronize()); + std::vector av(nq*nb), bv(nq*nb); + ck(cudaMemcpy(av.data(), a.p, a.bytes, cudaMemcpyDeviceToHost)); + ck(cudaMemcpy(bv.data(), b.p, b.bytes, cudaMemcpyDeviceToHost)); + uint64_t checked = 0; + for (int64_t i = 0; i < nq; ++i) { + const int64_t last = steps[i*k::kStepCount+k::kStepNBid]; + for (int64_t j = 0; j < nb; ++j) { + const auto at = i*nb+j; + if (j <= last) { + if (av[at] != bv[at]) { + std::fprintf(stderr, "MISMATCH ctx=%lld nq=%lld mode=%d query=%lld block=%lld bits=%08x/%08x\n", + (long long)c.context, (long long)nq, c.mode, (long long)i, (long long)j, av[at], bv[at]); + require(false, "scores differ bitwise"); + } + ++checked; + } else { + require(av[at] == 0xa5a5a5a5 && bv[at] == 0x5a5a5a5a, "inactive score padding overwritten"); + } + } + } + ck(cudaMemset(ia.p, 0xff, ia.bytes)); ck(cudaMemset(ib.p, 0xff, ib.bytes)); + k::qsa_block_topk(a.as(), step.as(), nq, nb, cap, s, ia.as(), nullptr, bound); + k::qsa_block_topk(b.as(), step.as(), nq, nb, cap, s, ib.as(), nullptr, bound); + ck(cudaDeviceSynchronize()); + std::vector iav(nq*cap), ibv(nq*cap); + ck(cudaMemcpy(iav.data(), ia.p, ia.bytes, cudaMemcpyDeviceToHost)); + ck(cudaMemcpy(ibv.data(), ib.p, ib.bytes, cudaMemcpyDeviceToHost)); + require(iav == ibv, "selected IDs differ"); + for (int64_t i = 0; i < nq; ++i) + for (int64_t j = steps[i*k::kStepCount+k::kStepWidth]; j < cap; ++j) + require(iav[i*cap+j] == -1, "ID padding overwritten"); + for (auto* v: {&p, &d, &query, &step, &a, &b, &ia, &ib}) v->guard(); + const bool branch = std::getenv("STRATA_SCORES_THREAD") && + std::atoi(std::getenv("STRATA_SCORES_THREAD")) == 1 && bound >= 16385 && bound <= nb && nq >= 64; + std::printf("PASS ctx=%lld nq=%lld capacity=%lld mode=%d bound=%lld expected_thread=%d scores=%llu ids=%lld\n", + (long long)c.context, (long long)nq, (long long)c.capacity, c.mode, (long long)bound, + (int)branch, (unsigned long long)checked, (long long)(nq*cap)); + ++cases_done; engaged += branch; scores_checked += checked; ids_checked += nq*cap; + if (c.timing) { + // Same actual bound/capacity, warmed, interleaved ABBA. Events measure GPU execution, not host fixture setup. + for (int i = 0; i < 3; ++i) { reference(); candidate(); } + ck(cudaDeviceSynchronize()); + cudaEvent_t e0, e1; ck(cudaEventCreate(&e0)); ck(cudaEventCreate(&e1)); + float times[2][4]{}; + for (int batch = 0; batch < 4; ++batch) { + const int order[4] = {0,1,1,0}; + for (int v: order) { + ck(cudaEventRecord(e0)); + for (int rep = 0; rep < 5; ++rep) { if (v == 0) reference(); else candidate(); } + ck(cudaEventRecord(e1)); ck(cudaEventSynchronize(e1)); + float ms = 0; ck(cudaEventElapsedTime(&ms, e0, e1)); times[v][batch] += ms/10; + } + } + float ta=0, tb=0; + for (int i=0; i<4; ++i) { ta+=times[0][i]/4; tb+=times[1][i]/4; } + std::printf("TIMING ctx=%lld nq=%lld baseline_ms=%.6f candidate_ms=%.6f speedup=%.6f trials=4 repeats_per_trial=10\n", + (long long)c.context, (long long)nq, ta, tb, ta/tb); + ck(cudaEventDestroy(e0)); ck(cudaEventDestroy(e1)); + } +} +} // namespace + +int main(int argc, char** argv) { + int devices = 0; + if (cudaGetDeviceCount(&devices) != cudaSuccess || devices == 0) { std::puts("SKIP no GPU"); return 77; } + cudaDeviceProp properties{}; ck(cudaGetDeviceProperties(&properties, 0)); + if (!k::gfx_arch_is(properties.gcnArchName, "gfx1100")) { std::puts("SKIP requires gfx1100"); return 77; } + require(std::getenv("STRATA_SCORES_THREAD") && std::strcmp(std::getenv("STRATA_SCORES_THREAD"), "1") == 0, + "run with STRATA_SCORES_THREAD=1 so the candidate branch is tested"); + const bool full = argc > 1 && std::strcmp(argv[1], "--full") == 0; + for (int64_t n: {1,6,8,9,63,64,65,127,128,129,256}) + check({131075,n,262144,0,0,false}); + for (int64_t context: {65535,65536,65537,65538,65539,131072,262144}) + check({context,65,262144,0,0,false}); + for (int bound: {1,2,3}) check({131075,65,262144,0,bound,false}); + for (int mode: {1,2,3,4,5}) check({131075,129,262144,mode,0,false}); + check({131075,65,131075,0,0,false}); + if (full) { + for (int64_t context: {131072,131073,131074,131075}) check({context,256,262144,2,0,false}); + check({131072,256,262144,0,0,true}); + check({240000,256,262144,0,0,true}); + check({140000,1024,262144,0,0,true}); + check({240000,1024,262144,0,0,true}); + } + std::printf("QUALIFIED cases=%d expected_thread_cases=%d scores=%llu ids=%llu bitwise_scores=true bitwise_ids=true guards=true\n", + cases_done, engaged, (unsigned long long)scores_checked, (unsigned long long)ids_checked); + return 0; +}