[PR #44] [MERGED] generate: probe the real host->device bandwidth for pcie_frac #2430

Closed
opened 2026-11-04 02:00:03 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Niko1221/Strata/pull/44
Author: @pipeob0
Created: 9/28/2026
Status: ✅ Merged
Merged: 9/28/2026
Merged by: @Niko1221

Base: main ← Head: gh/pcie-standalone


📝 Commits (1)

  • 7a4b627 generate: probe the real host->device bandwidth for the PCIe share

📊 Changes

1 file changed (+49 additions, -2 deletions)

View changed files

📝 src/program/generate.cpp (+49 -2)

📄 Description

Independent of #43 — no stacking needed. It applies on plain main: it adds one function and replaces the pcie_frac default line, while #43 touches only the expert kernels run on notice a few lines below. Verified by cherry-picking this commit onto origin/main with no conflicts.

Why

pcie_frac's defaults (0.55 native / 0.2 canonical) were measured on a PCIe 4.0 x16 link (~26 GB/s).
The comment right above them says the copy engine's share has to shrink with the link — but nothing measured
the link, and a x8 card in a x8 slot is very common: it is what a 16 GB card with a big expert cache lands on
on most AM4/AM5 boards. There the share was being set to 2× what the wire can carry, so the GPU waits for DMA
that has not arrived. The only user-facing knob was --pcie-frac, i.e. a per-user guess.

What

Probe the host→device bandwidth once at startup, the way the engine actually uses it — DMA reads from
pinned host memory, 4 × 256 MiB, copy engine warmed — then scale the default by it:

o.pcie_frac = std::min(base, std::max(0.05, base * (bw / 26.0)));

Clamped so it can only shrink the share relative to the measured link and never below 0.05, and never above
the current default (a x16 machine keeps exactly today's behaviour). --pcie-frac still wins when given, and
if the probe cannot run at all the default is kept and the log says so.

On this box (RTX 5060 Ti 16 GB at PCIe 4.0 x8):

strata generate: PCIe probe: 14.1 GB/s host->device -> pcie_frac 0.30 (default 0.55)

Cost and risk

One-time at startup: ~1 GB of copies over a 14 GB/s link ≈ 75 ms, plus a 256 MiB pinned buffer and a 256 MiB
device allocation that are freed again before the arena is built. If either allocation fails, the probe
returns "could not run" and nothing changes. The probe runs after CUDA context setup, so it measures the same
path the expert fetches use.

Behaviour change is confined to machines whose link is slower than x16 PCIe 4.0 — the population the current
default is wrong for. It is also self-documenting: the log now states the measured bandwidth and both the
probed and the stock value, so a report can say whether the share was probed or guessed.

Not claimed: an end-to-end speed number for this. It moves the copy-engine share on x8 links; the round-time
effect on this machine was inside the noise of the other work in progress, so I am not attaching a number
that the method (±5% acceptance-driven round counts) cannot support.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/Niko1221/Strata/pull/44 **Author:** [@pipeob0](https://github.com/pipeob0) **Created:** 9/28/2026 **Status:** ✅ Merged **Merged:** 9/28/2026 **Merged by:** [@Niko1221](https://github.com/Niko1221) **Base:** `main` ← **Head:** `gh/pcie-standalone` --- ### 📝 Commits (1) - [`7a4b627`](https://github.com/Niko1221/Strata/commit/7a4b627946277b55c0547e3adb91797a6c009613) generate: probe the real host->device bandwidth for the PCIe share ### 📊 Changes **1 file changed** (+49 additions, -2 deletions) <details> <summary>View changed files</summary> 📝 `src/program/generate.cpp` (+49 -2) </details> ### 📄 Description **Independent of #43 — no stacking needed.** It applies on plain `main`: it adds one function and replaces the `pcie_frac` default line, while #43 touches only the `expert kernels run on` notice a few lines below. Verified by cherry-picking this commit onto `origin/main` with no conflicts. ### Why `pcie_frac`'s defaults (0.55 native / 0.2 canonical) were measured on a PCIe 4.0 **x16** link (~26 GB/s). The comment right above them says the copy engine's share has to shrink with the link — but nothing measured the link, and a x8 card in a x8 slot is very common: it is what a 16 GB card with a big expert cache lands on on most AM4/AM5 boards. There the share was being set to 2× what the wire can carry, so the GPU waits for DMA that has not arrived. The only user-facing knob was `--pcie-frac`, i.e. a per-user guess. ### What Probe the host→device bandwidth **once at startup, the way the engine actually uses it** — DMA reads from pinned host memory, 4 × 256 MiB, copy engine warmed — then scale the default by it: ```c o.pcie_frac = std::min(base, std::max(0.05, base * (bw / 26.0))); ``` Clamped so it can only shrink the share relative to the measured link and never below 0.05, and never above the current default (a x16 machine keeps exactly today's behaviour). `--pcie-frac` still wins when given, and if the probe cannot run at all the default is kept and the log says so. On this box (RTX 5060 Ti 16 GB at PCIe 4.0 x8): ``` strata generate: PCIe probe: 14.1 GB/s host->device -> pcie_frac 0.30 (default 0.55) ``` ### Cost and risk One-time at startup: ~1 GB of copies over a 14 GB/s link ≈ 75 ms, plus a 256 MiB pinned buffer and a 256 MiB device allocation that are freed again before the arena is built. If either allocation fails, the probe returns "could not run" and nothing changes. The probe runs after CUDA context setup, so it measures the same path the expert fetches use. Behaviour change is confined to machines whose link is slower than x16 PCIe 4.0 — the population the current default is wrong for. It is also self-documenting: the log now states the measured bandwidth and both the probed and the stock value, so a report can say whether the share was probed or guessed. Not claimed: an end-to-end speed number for this. It moves the copy-engine share on x8 links; the round-time effect on this machine was inside the noise of the other work in progress, so I am not attaching a number that the method (±5% acceptance-driven round counts) cannot support. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-04 02:00:03 +07:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Niko1221/Strata#2430
No description provided.