Skip to content

armgit / Soup

Public Imported from GitHub
0

Fine-tune LLMs from one YAML. Layer streaming trains an 8B model on a 4 GB laptop GPU.

bench: record post-#331 8B NF4 post-repair row (#361) (#1103)

UmranPros812441deb1b0
diff --git a/benchmarks/README.md b/benchmarks/README.md
index 05efbe65..458d7bed 100644
--- a/benchmarks/README.md
+++ b/benchmarks/README.md
@@ -20,7 +20,7 @@ They are the evidence behind the preprint:
| [`gate-674-quest-w4a4-sft.md`](gate-674-quest-w4a4-sft.md) | Experimental QuEST W4A4 SFT feasibility ([#674](https://github.com/MakazhanAlpamys/Soup/issues/674)); not an integration | **Gate failed:** 0.114 nat [0.099, 0.130] above the strongest retained FP on the same panel. One training seed, one model, fake quantization; no parity or efficiency claim. Retains failed directions, costs, source/result hashes and spent-panel history; FINAL256 remains untouched. |
| [`gate-655-pinned-store-accounting.md`](gate-655-pinned-store-accounting.md) | Pinned host-memory accounting and the `/dev/shm` preflight decision ([#655](https://github.com/MakazhanAlpamys/Soup/issues/655)) | Two pinned 4 GiB allocations on an L4/Linux/CUDA stack each add exactly 4 GiB to `RssShmem` without using `/dev/shm`; the pageable control adds 4 GiB to `RssAnon`. Preserves the original host-counter drift and probe. |
| [`gate-v0.72.0-layer-streaming.md`](gate-v0.72.0-layer-streaming.md) | The streaming path itself | Bit-exactness vs a resident reference; 3B bf16 trained on a 4 GB card |
-| [`gate-v0.72.2-nf4.md`](gate-v0.72.2-nf4.md) | NF4 quantised streaming | Llama-3.1-8B at 119.6 tok/s in a 3.32 GB peak |
+| [`gate-v0.72.2-nf4.md`](gate-v0.72.2-nf4.md) | NF4 quantised streaming | Llama-3.1-8B at 119.6 tok/s at 952 MHz in a 3.32 GB peak (pre-repair); post-#331 row measured 2026-09-19 ([#361](https://github.com/MakazhanAlpamys/Soup/issues/361)): 208.6 tok/s in a 2.40 GB peak at 1935 MHz — read with its clock, not directly comparable |
| [`gate-v0.72.3-breadth.md`](gate-v0.72.3-breadth.md) | Nine architectures, batching, accumulation, resume, disk tier | Peak-VRAM predictor at 0.85% worst-case error; accumulation is per-token I/O-neutral |
| [`gate-v0.72.4-preference-losses.md`](gate-v0.72.4-preference-losses.md) | DPO / ORPO / SimPO / KTO over the streaming engine | DPO's reference model costs no extra weights — 0.914x the SFT peak, against +730.44 MB for a real second instance |
| [`probe-v0.73.0-what-bounds-streaming.md`](probe-v0.73.0-what-bounds-streaming.md) | What the streamed step is actually bound by, and Cut Cross-Entropy on top of it | **Not** transfer-bound: 71.3% of the card's same-session GEMM ceiling, and deleting every host-to-device byte buys 1.4%. CCE triples the usable microbatch for +9.6% |
@@ -61,7 +61,7 @@ only in a scratchpad on a machine that is gone, which is
| [`fsdp_sharding_probe.py`](harness/fsdp_sharding_probe.py) | STEP 20 / [#373](https://github.com/MakazhanAlpamys/Soup/issues/373) | Is the base actually **sharded**, or was the flag merely accepted? Per-rank `local == total / world_size` asserted, with the single-GPU control expecting the *full* count so a probe that always divides fails instead of passing everything. Repairs the STEP 20 probe, which raised `TypeError('FullyShardedDataParallel does not support len()')` on all eight ranks at 70B — a `torch.compile` wrapper, not FSDP | Accounting is pure-Python and CPU-tested; a real reading needs the multi-GPU box under test |
| [`mlx_sft_smoke.py`](harness/mlx_sft_smoke.py) | [#23](https://github.com/MakazhanAlpamys/Soup/issues/23) / [`run-m1-8gb-mlx-sft.md`](run-m1-8gb-mlx-sft.md) | Does `MLXSFTTrainerWrapper.train()` actually run against a real MLX runtime, and what does it peak at? Asserts MLX **dispatch before measuring**, so a transformers-path number cannot be published as an MLX one (#363). Generates its own fixture; prints host memory and swap either side | Apple Silicon + `pip install -e ".[mlx]"`; downloads the chosen model; 20 s at 0.5B, ~6 min at 8B including the Hub fetch |
| [`issue395_second_stack_vram.py`](harness/issue395_second_stack_vram.py) | #395 / [`gate-395-second-stack-vram.md`](gate-395-second-stack-vram.md) | Does the long-sequence under-prediction reproduce on a second stack, and is the gap the logits multiplier? Answer: no and no — the loss term measures 12.000000 (spread 0), and `14 x E` alone exceeds the whole real peak on every row, so the `+2` retained copy is absent. Three modes: sweep, `--measure`, `--sdpa` | 24 GB card (largest arm peaks 11.85 GB); downloads SmolLM2-135M and Qwen2.5-0.5B; needs `jinja2>=3.1.0`; a few minutes |
-| [`issue361_nf4_throughput.py`](harness/issue361_nf4_throughput.py) | [#361](https://github.com/MakazhanAlpamys/Soup/issues/361) / [`gate-v0.72.2-nf4.md`](gate-v0.72.2-nf4.md) | Re-run the v0.72.2 8B NF4 protocol on repaired code (batch 1, S=512, 50 steps after 10 warm-up, `PagedAdamW8bit`, same-session GEMM ceiling)? **No post-repair number yet** — the harness is the protocol, awaiting the RTX 3050 run | RTX 3050 Laptop 4 GB; Llama-3.1-8B weights; CPU-tested protocol guards only |
+| [`issue361_nf4_throughput.py`](harness/issue361_nf4_throughput.py) | [#361](https://github.com/MakazhanAlpamys/Soup/issues/361) / [`gate-v0.72.2-nf4.md`](gate-v0.72.2-nf4.md) | Re-run the v0.72.2 8B NF4 protocol on repaired code (batch 1, S=512, 50 steps after 10 warm-up, `PagedAdamW8bit`, same-session GEMM ceiling)? Answer: recorded as the post-#331 row in `gate-v0.72.2-nf4.md`: 208.6 tok/s at 1935 MHz, 59% of the same-session ceiling against 68% pre-repair; read it with its clock. | RTX 3050 Laptop 4 GB; Llama-3.1-8B weights; CPU-tested protocol guards only |
| [`stream_probe.py`](harness/stream_probe.py) | [`probe-rtx5070-what-bounds-streaming.md`](probe-rtx5070-what-bounds-streaming.md), [`gate-971-async-nvme-source.md`](gate-971-async-nvme-source.md) | What bounds the streamed step on THIS card? Builds the model through the shipped path, replicates the two shipped copy paths with CUDA events added (a source guard refuses to run if the shipped body drifts), and runs the ceiling / step / sweep / interleaved-ablation modes of the v0.73.0 probe, writing JSON after every point. `--tier disk` measures the ASYNC source (#971) at the depth `--read-ahead N` sets, and `--control-sync-source` swaps in the shipped synchronous `DiskSource` for a same-session control; every run prints and records the source class it actually built and refuses when that disagrees with the flag, so a control cannot be published as a measurement. `--no-pin` selects pageable host memory on EITHER tier. `--lazy-shard-handles` **was** the sharding workaround for the Windows mapping limit and is no longer needed: [#934](https://github.com/MakazhanAlpamys/Soup/pull/934) (merged 2026-09-14) bounds the shipped sharder's live mappings, and its gate re-sharded the 138 GB 70B-shaped fixture with no workaround at all — 80/80 layers in 221.4 s against 216.9 s with the flag, and 83 output files / 36.39 GB byte-identical to the workaround's cache, `index.json` included. The flag is kept so the 2026-09-12 record can be re-run as it was measured. Since #974 every JSON's `meta` also records `soup_cli_file`, the source tree the run actually imported — an arm that claims to be "the old code" is only evidence if the JSON says where it came from — and `--skip-events` runs only the uninstrumented `step_plain` point (halves a cold 70B block; not used by the #974 record, whose blocks run both points as gate-971 did) | CUDA GPU; model weights; a 7B NF4 run is ~10 min all modes; the 70B-shaped cold-disk run is 10-60 min |
| [`layer0_wait.py`](harness/layer0_wait.py) | [`gate-971-async-nvme-source.md`](gate-971-async-nvme-source.md) §8 | Which layer pays for the vocabulary-sized read planned at the head of every step? `stream_probe.py` brackets every load with CUDA events but SUMS them per step; this drives the probe's own instruments from outside and labels each bracket with its layer. Answer: **layer 0's forward load is the fastest of the step** (16-17 ms against a 213-252 ms mean), because the reader stages it during the build and embedding phase — so the behaviour is not material and needs no fix. The largest single compute-stream stall is the **vocabulary fetch itself**, 32.6-32.9 ms in every step against layer 0's 0.17/14.99/14.35 ms and a 0.002 ms mean over the other 79 decoder layers: the whole step-head stall is 33/48/48 ms, 0.07-0.12% of the step, so it does not change the answer either. Instruments from step 0 with no warm-up, so its absolute step times are deliberately NOT throughput evidence | CUDA GPU; model weights; minutes |
| [`synth_checkpoint.py`](harness/synth_checkpoint.py) | [`probe-rtx5070-what-bounds-streaming.md`](probe-rtx5070-what-bounds-streaming.md) §3; [`gate-901-14b-on-8gb.md`](gate-901-14b-on-8gb.md) §1 | Writes a Llama- or Qwen2-SHAPED synthetic checkpoint (random N(0, 0.02) weights, real shapes) so a store larger than RAM can be built without a Hub token or a 140 GB download, and so an out-of-memory report can be reproduced from shapes alone (`--shape qwen2.5-14b --arch qwen2` is #901's). Timing and memory only — never a correctness or quality claim | ~155 s and 138 GB for the 70B shape, 29.5 GB for the 14B one; needs a GPU for the random draw to be fast |
diff --git a/benchmarks/gate-v0.72.2-nf4.md b/benchmarks/gate-v0.72.2-nf4.md
index 2a9fb2e6..f8544b2a 100644
--- a/benchmarks/gate-v0.72.2-nf4.md
+++ b/benchmarks/gate-v0.72.2-nf4.md
@@ -297,7 +297,7 @@ valid resident baseline at 3B on this box** — resident bf16 OOMs (v0.72.0) and
resident NF4 spills. The honest claim remains the one v0.72.0 made at 0.5B, not
a 3B speed-up ratio.
-Remaining row pending: the 8B headline.
+Remaining row pending: the 8B headline. — SATISFIED, measured 2026-09-19 and recorded 2026-09-20; see the measured post-#331 row below.
---
@@ -340,7 +340,103 @@ have printed ~52 B.
---
-## Post-#331 re-measurement — PENDING ([#361](https://github.com/MakazhanAlpamys/Soup/issues/361))
+## Post-#331 re-measurement — MEASURED 2026-09-19 ([#361](https://github.com/MakazhanAlpamys/Soup/issues/361))
+
+The run date is recovered from the machine, not from the JSON (which carries no
+timestamp): `row-361.json`, the harness's `--json` output, still sits on
+@umran666's laptop with creation time **2026-09-19 05:17:12 IST** and last
+write **05:19:13 IST** (UTC+05:30), i.e. 2026-09-18 23:47–23:49 UTC. The
+harness rewrites that file after every measured step
+(`harness/issue361_nf4_throughput.py:489-492`) and once more after the
+same-session ceiling (`:548-551`), so the 121 s between the two file times is
+measured steps 2–50 plus the ceiling: 49 × 2454.5 ms, the mean implied by
+208.6 tok/s, is 120.3 s. No printed timestamp is quoted here, because the
+harness could not have printed one — its only write-path output is
+`row written -> <path>` (`:601`) and no `print` in it emits a wall clock, which
+is why the date comes from the file and not the console. The committed JSON is
+that file: 1387 bytes on disk against the 1326-byte blob with 61 line breaks
+here, the difference being the carriage return `Path.write_text` adds per line
+break on Windows, and with the carriage returns stripped the two are identical
+character for character. The row reached #361 at 2026-09-19 00:24 UTC, 35
+minutes after the run ended. This record was written 2026-09-20, when this PR
+opened; the heading carries the measurement date, as every other heading in
+this file does.
+
+Measured post-#331 row, added — the rows above stay verbatim:
+
+| Model | Quant | Store | tok/s | GPU util | Peak VRAM | SM clock | eff TFLOPS | % of same-session ceiling |
+|---|---|---|---|---|---|---|---|---|
+| **Llama-3.1-8B-Instruct** | NF4 | **5.70 GB pinned** | **208.6** | 100% | **2.40 GB** | 1935 MHz / 59 C | 9.17 | 59% |
+
+Machine row: `results/issue361-post-repair-8b-nf4.json` (`--json` output of
+[`harness/issue361_nf4_throughput.py`](harness/issue361_nf4_throughput.py),
+committed as written).
+
+Hardware for **this** row, stated separately because it is not the gate box at
+the top of this record: **Windows 11 · RTX 3050 Laptop 4 GB (CC 8.6) ·
+16.8 GB RAM · NVMe** · Python 3.10.11 (the JSON's `versions`), measured by
+@umran666 on their own laptop. The gate box is a different machine with the
+**same GPU model** — 16.9 GB RAM, Python 3.10.8 — and every row above was
+measured on it.
+
+Run-from note, reconciling the SHAs. The machine row records the harness
+commit `9635673`; the run was from `main` at `1f1f1438` plus the #1014
+harness, which landed on `main` as `3e610c68` — both above the `f8226214`
+floor. An earlier issue comment said `main` at `2d1714b`; the numbers are
+identical, so it is one run with two SHAs attached, and this record
+governs.
+
+Invocation: `python benchmarks/harness/issue361_nf4_throughput.py --weights
+C:\llama31-8b-instruct --shards <scratch dir> --json row-361.json`, every other
+flag the protocol default (batch 1, S=512, 10 warm-up + 50 measured,
+`PagedAdamW8bit`, double buffering, same-session ceiling). The `--json` target
+was `row-361.json` in the laptop's home directory, not the committed path: the
+JSON records neither the shard dir nor its own output path, so this line is
+recovered from the file itself — the same file whose file times give the run
+date above — and not from a shell history, which no longer reaches the run. It
+reached `benchmarks/results/issue361-post-repair-8b-nf4.json` as a copy,
+unchanged, and the byte and content tie above is the evidence for
+"unchanged". `--weights` is not memory either: it is the JSON's own `weights`
+field. The shard dir was a scratch location, since deleted. No run was
+discarded: the slowest measured step (3479 ms against a 2431.5 ms median) is
+retained in the JSON's `step_time_ms.max`.
+
+**Read this row with its clock.** The pre-repair row ran at 952 MHz / 70 C, this
+one at 1935–1957 MHz / 59 C on a different laptop with the same GPU model; the
+old row is the one at roughly half the clock, running hotter. Two readings of
+the old 952 MHz fit the evidence and this comparison cannot tell them apart: a
+throttled or power-limited session (AC/power plan not recorded for the old row),
+or simply a lower power limit and weaker cooling on that laptop. The 1.74x
+raw gain (208.6 / 119.6) is therefore a clock, not a speedup: per unit clock
+the new code is ~14% slower (1.744 / 2.033 = 0.858), matching the same-session
+ceiling fraction moving 68% -> 59% to within 1% (59/68 = 0.868). Do not compare
+the two tok/s figures directly.
+
+**Large-layer-streaming asterisk, kept attached to the 68% -> 59% number.**
+The memory pattern changed between the rows: large-layer streaming moved
+`embed_tokens` + `lm_head` into the pinned store, so the store grew by exactly
+two 0.525B bf16 tensors (2 x 0.525e9 x 2B = 2.10 GB, matching the 5.70 - 3.60
+GB delta) while peak VRAM *fell* (3.32 GB allocated on the old row, 2.40 GB
+allocated / 2.66 GB reserved on this one). Even the ceiling-fraction
+comparison is therefore not like-for-like on efficiency — stated here, not
+only in the issue thread.
+
+**Stack delta, recorded without attribution.** The old row ran torch
+2.5.1+cu121 · bitsandbytes 0.49.2 · transformers 4.57.6 · peft 0.18.1 ·
+trl 0.19.1 · accelerate 1.12.0 · Python 3.10.8; this one ran torch
+2.6.0+cu124 · bitsandbytes 0.50.2 · transformers 5.16.1 · peft 0.21.0 ·
+trl 0.29.1 · accelerate 1.15.0 · Python 3.10.11 (see the JSON's `versions`).
+The clock accounts for the tok/s delta and the memory-pattern change for
+the store/peak delta; the residual ~14% per-clock shortfall is **not
+attributed** — it could be the #331 repair, the memory-pattern change, or
+the stack delta just listed, and this record claims none of the three. No
+attribution to the bitsandbytes minor move is claimed either — but the
+version is stated here because the gate's NF4 claim rests on
+identical bitsandbytes kernels, and the two 4-bit compute paths'
+disagreement is an open finding (#776).
+
+The rest of this section (the PENDING text, the owed-by line, the expected
+direction) stays as it was written:
The 119.6 tok/s / 3.32 GB row above predates the #331 repair and has not been
re-run on repaired code. The protocol to repeat is
@@ -361,3 +457,13 @@ figure above it is not impossible, but it needs its own explanation before it
is recorded rather than after. The 3.32 GB peak is re-measured rather than
carried over, because large-layer streaming moved `embed_tokens` and `lm_head`
out of the resident allocation (see `docs/performance-and-quantization.md`).
+
+**Outcome vs the expected direction, recorded rather than edited away.** The
+figure came in *above* 119.6 tok/s, and it has its explanation before it, as
+required: a 952 → 1935 MHz clock change accounts for the whole excess and then
+some. Per unit clock the pre-registered direction holds (about −14%, not
+attributed — see the stack delta above), so it is not comparable in size to the
+−4.8% at 32B: different clocks, different memory patterns, same-direction only.
+
+Both run-it-from floors from #361 are satisfied: the run landed above
+`f8226214` and above the later `76c23541`.
diff --git a/benchmarks/results/issue361-post-repair-8b-nf4.json b/benchmarks/results/issue361-post-repair-8b-nf4.json
new file mode 100644
index 00000000..9f38271b
--- /dev/null
+++ b/benchmarks/results/issue361-post-repair-8b-nf4.json
@@ -0,0 +1,62 @@
+{
+ "status": "ok",
+ "issue": 361,
+ "weights": "C:\\llama31-8b-instruct",
+ "quant": "nf4",
+ "stream_dtype": "bfloat16",
+ "seq": 512,
+ "batch": 1,
+ "warmup_steps": 10,
+ "measured_steps": 50,
+ "buffers": 2,
+ "lora_r": 16,
+ "targets": "q_proj,v_proj",
+ "pin_required": true,
+ "store_gb_pinned": 5.702,
+ "param_split": {
+ "decoder": 6979588096,
+ "embed": 525336576,
+ "lm_head_file": 525336576,
+ "lm_head_effective": 525336576,
+ "tied": false
+ },
+ "tokens_per_s": 208.6,
+ "step_time_ms": {
+ "median": 2431.5,
+ "min": 2421.4,
+ "max": 3479.0,
+ "stdev": 146.7
+ },
+ "loss_first": 11.704187393188477,
+ "loss_last": 0.11134996265172958,
+ "peak_vram_gb": {
+ "allocated": 2.397,
+ "reserved": 2.661
+ },
+ "gpu": {
+ "util": 100,
+ "clock": 1935,
+ "temp_max": 59,
+ "n": 208
+ },
+ "sm_clock_mhz_end": 1957,
+ "gflop_per_token": 43.9789,
+ "effective_tflops": 9.174,
+ "gemm_ceiling": {
+ "tflops": 15.635,
+ "sm_clock_mhz": 1957
+ },
+ "shard_build_s": 58.3,
+ "model_build_s": 20.3,
+ "versions": {
+ "python": "3.10.11",
+ "soup-cli": "0.75.0",
+ "commit": "9635673c58767ba5b850d70f3ea56fdc1ac7d8f6",
+ "torch": "2.6.0+cu124",
+ "bitsandbytes": "0.50.2",
+ "transformers": "5.16.1",
+ "peft": "0.21.0",
+ "trl": "0.29.1",
+ "accelerate": "1.15.0"
+ }
+}
\ No newline at end of file
diff --git a/changelog.d/0.75.1/1014.changed.md b/changelog.d/0.75.1/1014.changed.md
index eb18b3a0..2741c328 100644
--- a/changelog.d/0.75.1/1014.changed.md
+++ b/changelog.d/0.75.1/1014.changed.md
@@ -1,10 +1,16 @@
-- **The v0.72.2 8B NF4 throughput protocol is now re-runnable on repaired code, but the post-repair number is still missing (#361 by @umran666 in #1014).**
- No post-repair tok/s / peak VRAM / util / SM clock exists yet: the RTX 3050
- run has not happened, and nothing here invents one. `benchmarks/harness/
+- **The v0.72.2 8B NF4 throughput protocol is now re-runnable on repaired code, and the post-repair row is recorded (#361 by @umran666 in #1014, measured in #1103).**
+ The RTX 3050 run has happened: Llama-3.1-8B-Instruct NF4 streamed at
+ **208.6 tok/s** in a 2.40 GB peak (5.70 GB pinned store) at 1935 MHz / 59 C,
+ 100% util, 59% of the same-session GEMM ceiling against 68% pre-repair — the
+ row and its clock in `benchmarks/gate-v0.72.2-nf4.md`, the raw numbers in
+ `benchmarks/results/issue361-post-repair-8b-nf4.json`. It ran at roughly twice
+ the pre-repair row's 952 MHz, so its 208.6 tok/s and the published 119.6 are
+ not comparable directly and the record says so. `benchmarks/harness/
issue361_nf4_throughput.py` repeats the step-6 protocol unchanged (batch 1,
S=512, 50 steps after 10 warm-up, `PagedAdamW8bit`, same-session GEMM
ceiling) with `require_pin=True` so a pageable fallback refuses instead of
recording the lower-bound shape, and the 119.6 tok/s / 3.32 GB copies in the
- README, the benchmarks index and the perf docs are now labelled pre-repair
- with a pending row reserved in `benchmarks/gate-v0.72.2-nf4.md`. CPU-tested
- protocol guards live in `tests/test_issue361_nf4_throughput.py`.
+ README, the benchmarks index and the perf docs are now labelled pre-repair,
+ with the reserved row in `benchmarks/gate-v0.72.2-nf4.md` now filled rather
+ than pending. CPU-tested protocol guards live in
+ `tests/test_issue361_nf4_throughput.py`.
diff --git a/tests/test_issue361_nf4_throughput.py b/tests/test_issue361_nf4_throughput.py
index ac52d17d..63c664c7 100644
--- a/tests/test_issue361_nf4_throughput.py
+++ b/tests/test_issue361_nf4_throughput.py
@@ -370,7 +370,13 @@ class TestThePinGuardIsWired:
class TestGateRecordCarriesThePendingLabel:
"""The gate file is the row's future home: it must keep saying the
headline predates the #331 repair and name this harness as the protocol,
- so a number pasted there before the card run has something to contradict."""
+ so a number pasted there before the card run has something to contradict.
+
+ The reservation is satisfied as of 2026-09-19 — the run date, recovered
+ from `row-361.json`'s file time — so this class now pins
+ the pre-registration as history: the pending wording stays verbatim
+ (marked satisfied) beside the measured row rather than being rewritten.
+ """
def test_the_pending_label_and_harness_pointer_are_present(self) -> None:
gate = _REPO_ROOT / "benchmarks" / "gate-v0.72.2-nf4.md"