﻿# llama.cpp weight prefetch: PR 21067 and the reported tradeoffs

An unmerged llama.cpp weight-prefetch proposal, pinned-memory requirements, a reported RTX 3090 slowdown and an RTX 4070 SUPER context-capacity experiment.

Author: Retrivium editorial team
Updated: 2026-11-05
Canonical URL: https://retrivium.ai/journal/llamacpp-pr21067-weight-prefetch-owner-results/
Language: en

On March 27, 2026, developer am17an opened llama.cpp [PR 21067](https://github.com/ggml-org/llama.cpp/pull/21067) with an experimental weight-prefetch mechanism. It transfers required tensors from host RAM to the GPU ahead of use, while the GPU computes the current layer. On November 5, 2026, the proposal remained open and unmerged. Initially presented as a proof of concept, it was marked ready for review in June. Its flags and results therefore concern an experimental branch or adaptations rather than a guaranteed feature of a normal release.

The proposal matters where VRAM cannot comfortably hold model weights and context. Prefetch does not create additional interconnect bandwidth or guarantee acceleration. The accessible discussion includes both a substantial slowdown and a more detailed experiment where streaming some weights released memory for longer context at a modest speed cost. These are different configurations and owner experiments, rather than a universal comparative test.

## What weight transfer involves

Neural-network weights are parameters used to compute each layer. If relevant tensors already reside in VRAM, the GPU reads them there. If some reside in system RAM, they must cross the CPU–GPU connection, such as PCIe, to support GPU computation. Waiting for transfers sequentially can leave computing resources idle.

In the [PR description](https://github.com/ggml-org/llama.cpp/pull/21067), the author proposes prefetching the next layer’s CPU-placed tensor overrides while computing the current layer. Sufficiently long computation can hide part of the copy duration. In simplified terms, copying B starts while A is being computed, instead of computing A and then transferring and computing B. If the copy has not finished, the GPU must still wait. Benefits depend on transferred weight volume, link speed, model and microbatch size.

The initial description specified a CUDA implementation, enabled through `--prefetch-weights`. It also requires `--no-mmap`: in that implementation, file-mapped weights are not pinned, and nominally asynchronous operations become serialized. This is a limitation of the approach, rather than a claim that all `mmap` memory is impossible to pin. According to [NVIDIA’s CUDA guide](https://docs.nvidia.com/cuda/cuda-programming-guide/02-basics/understanding-memory.html), ordinary allocations, including `mmap`, are initially not page-locked. Asynchronous CPU–GPU copies require pinned memory, and CUDA can register an existing allocation. Pinning also consumes a limited host resource; NVIDIA [warns against excessive use](https://docs.nvidia.com/cuda/archive/12.2.0/cuda-c-best-practices-guide/index.html).

In a March 31 comment, the author reported removing backend-specific code and suggested that backends supporting events and streams could use the mechanism. This describes an experimental-branch change, rather than establishing equivalent support on every accelerator.

The distinction also matters for mixture-of-experts models, or MoE. Only selected experts participate for a particular input. The PR author notes that ordinary prefetch cannot know the next layer’s selection in advance and can bypass the benefit of expert caching. Dense-model and large-MoE behavior therefore cannot be assumed equivalent. This is the author’s explanation, rather than a demonstrated rule for every run. The PR includes Qwen3.5-27B and GPT-OSS-20B test commands, but numerical values from its original plots were unavailable in the parsed page. Those plots cannot establish an acceleration magnitude here. [Source: PR discussion](https://github.com/ggml-org/llama.cpp/pull/21067).

## What users reported

On September 21, 2026, a participant reported testing `unsloth/Qwen3.8-Flash-Next-GGUF:UD-IQ4_XS` on an RTX 3090 with PCIe 3.0 ×16 and 64 GB DDR4. At `ub=2048`, they obtained **150 tokens/s without prefetch and 95 tokens/s with it**, approximately 37% lower than the baseline. They suggested the slower PCIe link relative to the PR author’s system as a possible cause. The accessible comment lacks enough full-configuration, methodology and repetition detail to verify causality or reproduce the measurement. It is one user’s self-report, rather than a controlled independent replication. [Source: PR comments](https://github.com/ggml-org/llama.cpp/pull/21067).

On October 22, another participant described a more detailed experiment using an RTX 4070 SUPER with 12 GB VRAM, Ryzen 5950X and PCIe 4.0; their measured transfer rate was about 24.5 GB/s. They used Qwen3.8-27B IQ3_XS with `q8_0` KV cache and ported the experimental code to commit `b76b13379`. They explained that a scheduler refactor prevented applying the PR to current master. This tests an adaptation rather than the PR’s exact version on current master. [Source: PR discussion](https://github.com/ggml-org/llama.cpp/pull/21067).

At equal total VRAM use, their fully GPU-resident configuration supported 24k context and generated 36.4–38.0 tokens/s across four control runs. Streaming `ffn_down` from 12 layers enabled 32k context at 38.3 tokens/s; using 16 layers enabled 36k at 36.3–37.1 tokens/s. They reported approximately 327 MiB and 446 MiB of streamed weights respectively and estimated equal-context generation costs of about 2–3% and 4–5%. They also identified approximately ±3% measurement noise and context-depth effects. These figures illustrate the tradeoff between weight placement and available context length; they do not prove that streaming accelerates generation. [Source: the same owner report](https://github.com/ggml-org/llama.cpp/pull/21067).

## Testing the tradeoff

Measure prompt processing and answer generation separately: their workloads and opportunities to overlap copying differ. Compare the same model, quantization, context length, microbatch settings and tensor placement, repeating runs with and without prefetch. The experiment can be useful when some weights must remain in RAM or releasing VRAM permits longer context. These reports do not establish expected performance on another machine. The original plots and part of the discussion remained inaccessible during verification.

Planning this experiment connects to the [pinned-host-RAM budget](/journal/gpu-pinned-host-memory-budget/) and [prefetch versus placement advice](/journal/learn-managed-memory-prefetch-advice/). Here the model scheduler implements weight transfers; a shared word in an API name does not make mechanisms identical. Besides timing, verify output correctness and record the adaptation’s exact commit.

## Sources

- [llama.cpp PR 21067 and discussion](https://github.com/ggml-org/llama.cpp/pull/21067): implementation, status and owner measurements.
- [NVIDIA CUDA Programming Guide: system and page-locked memory](https://docs.nvidia.com/cuda/cuda-programming-guide/02-basics/understanding-memory.html): asynchronous-copy conditions and registering memory.
- [NVIDIA CUDA C++ Best Practices Guide](https://docs.nvidia.com/cuda/archive/12.2.0/cuda-c-best-practices-guide/index.html): benefits and costs of pinning memory.
