[Calibration]: Detect PCIe link speed/topology for accurate calibration and throughput estimates
Back for more! Noticed that the code doesn’t cover setups where GPUs are in weaker PCIe slots, which could influence calibration and produce stronger results than what should actually be produced.
Problem
llmfit currently estimates GPU throughput using factors such as GPU memory bandwidth, DDR bandwidth, efficiency, and run-mode multipliers, but it does not model the GPU’s actual PCIe connection.
This can make estimates and calibration less accurate when a GPU is running on a constrained link, such as:
- PCIe 3.0 x16 vs x8 or x4
- A physical x16 slot that is electrically x4
- A link that has negotiated a slower PCIe generation
- Multi-GPU systems without direct P2P connectivity
fit.rs already notes that PCIe bandwidth can become the actual ceiling on some systems, but PCIe generation/lane width is not currently represented in GpuInfo, SystemSpecs, or the throughput calculation.
This also matters for calibration. hardware_payload_matches() currently matches community hardware using CPU and GPU identity, so systems such as:
i7-12700KF + Tesla V100 @ PCIe 3.0 x16
i7-12700KF + Tesla V100 @ PCIe 3.0 x4can be treated as the same hardware even though offload or multi-GPU performance may differ.
Local benchmarks implicitly capture a PCIe bottleneck through measured TPS, but the calibration system cannot identify PCIe as the cause. A PCIe-specific slowdown can therefore be absorbed into the general measured_tps / estimated_tps calibration factor and potentially affect estimates for workloads that are not PCIe-bound.
Proposed solution
Detect PCIe topology for discrete GPUs and expose it as hardware/estimator metadata.
Per GPU, where supported, detect:
PCIe maximum generation
PCIe maximum lane width
PCIe negotiated generation
PCIe negotiated lane width
PCI bus/device identifier
theoretical negotiated bandwidthFor example:
GPU 0: NVIDIA Tesla V100 32 GB
PCIe capability: Gen 3 x16
Negotiated link: Gen 3 x4
Theoretical bandwidth: ~3.9 GB/sWhere practical, optionally measure:
host -> GPU bandwidth
GPU -> host bandwidth
GPU <-> GPU bandwidth
P2P availabilityUse these values only for run paths where PCIe can actually be a bottleneck rather than applying a blanket PCIe penalty to fully VRAM-resident inference.
Potential estimator integration:
- CPU/GPU offload: Account for effective host↔GPU bandwidth where transfers cross PCIe.
- Multi-GPU/tensor parallel: Account for inter-GPU topology, P2P support, and effective transfer bandwidth.
- Calibration: Include relevant PCIe topology in hardware provenance/matching so significantly different PCIe configurations are not treated as identical.
- Diagnostics: Warn when a GPU capable of a larger link is currently operating at a substantially reduced generation or lane width.
For transfer-bound paths, an effective ceiling could use the minimum relevant bandwidth, for example:
effective_host_gpu_bw = min(DDR bandwidth, PCIe host-device bandwidth)when that accurately reflects the runtime’s data path.
All PCIe fields should be optional so platforms where the information cannot be detected retain current behavior.
Alternatives considered
- Continue relying on
llmfit benchcalibration. This captures the observed slowdown but does not identify PCIe as the cause and can fold a topology-specific bottleneck into the general calibration factor. - Apply a fixed penalty to CPU offload or multi-GPU modes. This is simpler but cannot distinguish PCIe x16 from x4, P2P from host-routed GPU communication, or different PCIe generations.
- Only display PCIe information without using it in estimation. This would improve diagnostics but would leave calibration and throughput estimates unaware of a potentially important bottleneck.
Feature area
Speed estimation (tok/s accuracy, new factors)
Would you be willing to contribute this?
No, just suggesting
Additional context
Relevant existing code:
llmfit-core/src/fit.rs:estimate_tps()already notes that PCIe bandwidth can be the actual ceiling on some systems.llmfit-core/src/hardware.rs:GpuInfoandSystemSpecscurrently contain GPU identity, VRAM, backend, count, etc., but no PCIe link/topology fields.llmfit-core/src/analysis.rs: Local calibration uses the medianmeasured_tps / estimated_tpsratio to scale estimates.llmfit-core/src/benchmarks.rs:hardware_payload_matches()currently considers matching CPU/GPU identity but not PCIe topology.
The main goal is to distinguish:
"This GPU should be this fast"from:
"This GPU is connected in a way that limits this particular workload"without penalizing workloads where PCIe is not on the critical path.
Source: AlexsJones/llmfit