N1X: pageable cudaMemcpy H2D from a 4 KiB-page file mapping slows to ~35 MB/s as more of the file is mapped
Mantenedores costumam responder em até 1 dia
Ninguém assumiu esta issue ainda.
Avaliação
- Dificuldade
- 5/5
- Tempo estimado
- Mais de uma semana
- Facilidade para iniciantes
- 12/100
- Tipo de issue
- Bug
- Clareza
- Razoavelmente clara
- Status de atividade
- Ativa
- Domínio
- operating-systems, performance
Direção de pesquisa
Start by building and running the attached mmap_h2d_repro.cu in all three modes on a tmpfs file with 4 KiB pages and on a huge=always tmpfs, since the page-size dependence is the strongest clue. The slowdown is in the pageable H2D copy path of the open kernel modules/UVM rather than in CUDA runtime code, so read the nvidia-bug-report.log.gz and the module's memory-management sources around pageable copy handling. Done looks like plain mode holding the touch-mode rate as more of the file is mapped; the issue does not yet name the file where the fix belongs.
Escrita pelo modelo de indexação a partir do texto da issue.
Descrição
NVIDIA Open GPU Kernel Modules Version
620.70.06, built with DKMS from the release tarball. My package carries Omarchy's seven N1X display patches and one local patch that allows power management on GB20B/GB20C (needed for suspend); none of them touches memory management or UVM. Module parameters are the defaults except NVreg_EnableSystemMemoryPools=0.
Proprietary driver
Not applicable: the N1X is only supported by the open modules.
Operating System and Version
Arch Linux ARM (Omarchy)
Kernel Release
Linux 7.3.0-75-omarchy #1 SMP PREEMPT_DYNAMIC Sat, 21 Nov 2026 03:32:33 +0000 aarch64 (distribution kernel, stable)
Hardware: GPU
GPU 0: NVIDIA RTX Spark N1X (6144-core Blackwell RTX GPU), HP OmniBook X Laptop 14-ks000, BIOS F.06, VBIOS 9a.0b.3a.00.08, 128 GB. CUDA 13.4.2.
Describe the bug
A synchronous cudaMemcpy host-to-device whose source is a read-only file mapping (mmap(PROT_READ, MAP_PRIVATE)) slows down as the process maps more of the file. With 2.7 MB copies from random offsets of a file that is fully in the page cache, the first 500 copies run at several GB/s; after 2,000 copies they are at about 130 MB/s and after 8,000 at 36 MB/s. During the copies one CPU core is at 100% inside libcuda (cuMemcpyHtoD_v2) and the GPU is idle.
It depends on the page size behind the mapping. The same data on tmpfs with 4 KiB pages is slow from the first copy (168 MB/s, then about 30 MB/s); on a huge=always tmpfs it stays at 8-10 GB/s. A file on btrfs decays from about 12 GB/s to 1.7 GB/s.
Faulting the pages in before the copy avoids it. Reading one byte per 4 KiB page of the block through the same mapping and then copying runs at 20-24 GB/s and does not slow down. Copying the block into a malloc'd buffer first gives a flat 8.5 GB/s. A new process starts fast again.
This hits anything that uploads model weights from an mmapped file. Here a 12 GB model took over 10 minutes to load (about 5 s when the file is read into anonymous memory first), and a 63 GB expert cache took 36 minutes to fill.
To Reproduce
- Build the program below:
nvcc -O2 -arch=sm_121 -o mmap_h2d_repro mmap_h2d_repro.cu - Get a large file into the page cache, e.g.
cat model.bin > /dev/null, or make one on tmpfs:head -c 16G /dev/urandom > /dev/shm/t.bin - Run each mode in a fresh process:
./mmap_h2d_repro /dev/shm/t.bin plain, thentouch, thenbounce. Each does 8,000 random 2.7 MB copies into a 16 GiBcudaMallocbuffer and prints MB/s per 500 copies.
Results after a fresh boot, page cache warm, MB/s in the 500-copy window ending at each count:
| source, mode | 500 | 1,000 | 2,000 | 4,000 | 6,000 | 8,000 |
|---|---|---|---|---|---|---|
| 63 GiB file on ntfs3, plain | 7853 | 364 | 128 | 68 | 46 | 36 |
| 16 GiB file on tmpfs (4 KiB pages), plain | 168 | 77 | 38 | 31 | 28 | 41 |
16 GiB file on tmpfs huge=always, plain (3,000 copies) |
10295 | 7916 | 8263 | |||
| 32 GiB file on btrfs, plain | 11715 | 5444 | 3213 | 1941 | 1693 | 1760 |
| 63 GiB file on ntfs3, touch | 20441 | 20813 | 21068 | 21805 | 22972 | 24047 |
| 63 GiB file on ntfs3, bounce | 8355 | 8433 | 8558 | 8493 | 8736 | 8884 |
mmap_h2d_repro.cu
// Standalone repro: pageable cudaMemcpy H2D from a file mapping gets slower the more of the
// file the process has mapped (NVIDIA N1X / GB10, Linux). docs/findings.md 2026-11-22.
//
// nvcc -O2 -o mmap_h2d_repro mmap_h2d_repro.cu
// ./mmap_h2d_repro <file> <plain|touch|bounce> [copies=8000] [seed=1] [dst_gib=16]
//
// Copies <copies> random, page-aligned 2.7 MB blocks of <file> into a cudaMalloc buffer with
// one synchronous cudaMemcpy each, and prints the rate per 500-copy window.
// plain : cudaMemcpy straight from the MAP_PRIVATE, PROT_READ mapping
// touch : read one byte per 4 KiB page of the block through the mapping first, then plain
// bounce : memcpy the block from the mapping into one malloc'd (pageable, anonymous)
// buffer, then cudaMemcpy from that buffer
// The touch / memcpy is inside the timed region. Run each mode in a fresh process.
#include <cuda_runtime.h>
#include <fcntl.h>
#include <sys/mman.h>
#include <sys/stat.h>
#include <unistd.h>
#include <chrono>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <random>
#define CK(x) do { cudaError_t e_ = (x); if (e_ != cudaSuccess) { \
fprintf(stderr, "%s: %s\n", #x, cudaGetErrorString(e_)); exit(1); } } while (0)
int main(int argc, char** argv) {
if (argc < 3) { fprintf(stderr, "usage: %s <file> <plain|touch|bounce> [copies] [seed] [dst_gib]\n", argv[0]); return 2; }
const char* path = argv[1];
const char* mode = argv[2];
const long copies = argc > 3 ? atol(argv[3]) : 8000;
const unsigned seed = argc > 4 ? (unsigned)atoi(argv[4]) : 1;
const size_t dst_bytes = (size_t)(argc > 5 ? atol(argv[5]) : 16) << 30;
const size_t B = 2765295; // one block, ~2.7 MB (not page-aligned in length)
const size_t page = 4096, window = 500;
const bool touch = !strcmp(mode, "touch"), bounce = !strcmp(mode, "bounce");
if (!touch && !bounce && strcmp(mode, "plain")) { fprintf(stderr, "bad mode\n"); return 2; }
int fd = open(path, O_RDONLY);
if (fd < 0) { perror("open"); return 1; }
struct stat st; fstat(fd, &st);
const size_t sz = (size_t)st.st_size;
if (sz < B + page) { fprintf(stderr, "file too small\n"); return 1; }
const unsigned char* map = (const unsigned char*)mmap(nullptr, sz, PROT_READ, MAP_PRIVATE, fd, 0);
if (map == MAP_FAILED) { perror("mmap"); return 1; }
unsigned char* dst = nullptr;
CK(cudaMalloc(&dst, dst_bytes));
unsigned char* tmp = bounce ? (unsigned char*)malloc(B) : nullptr;
if (bounce) memset(tmp, 0, B);
CK(cudaMemcpy(dst, map, page, cudaMemcpyHostToDevice)); // context warm-up, not timed
printf("file=%s size=%.1f GiB mode=%s copies=%ld seed=%u dst=%zu GiB\n",
path, sz / 1073741824.0, mode, copies, seed, dst_bytes >> 30);
std::mt19937_64 rng(seed);
std::uniform_int_distribution<size_t> pick(0, (sz - B) / page);
volatile unsigned sink = 0;
auto t0 = std::chrono::steady_clock::now(), tw = t0;
for (long i = 0; i < copies; i++) {
const unsigned char* src = map + pick(rng) * page;
if (touch) { unsigned s = 0; for (size_t o = 0; o < B; o += page) s += src[o]; sink += s; }
if (bounce) { memcpy(tmp, src, B); }
unsigned char* d = dst + (i * B) % (dst_bytes - B);
CK(cudaMemcpy(d, bounce ? tmp : src, B, cudaMemcpyHostToDevice));
if ((i + 1) % window == 0) {
auto now = std::chrono::steady_clock::now();
double w = std::chrono::duration<double>(now - tw).count();
double c = std::chrono::duration<double>(now - t0).count();
printf("%6ld copies: window %8.0f MB/s cumulative %8.0f MB/s\n",
i + 1, window * B / w / 1e6, (i + 1) * B / c / 1e6);
fflush(stdout);
tw = now;
}
}
printf("total %.1f s\n", std::chrono::duration<double>(std::chrono::steady_clock::now() - t0).count());
return 0;
}
Bug Incidence
Always
nvidia-bug-report.log.gz
More Info
With NVreg_CoherentGPUMemoryMode=numa the ntfs3 case decays much less (12 GB/s to 1.6 GB/s over 8,000 copies instead of 1 GB/s to 40 MB/s, same test in an earlier boot); the btrfs file behaves the same in both modes.
The same problem has been reported on DGX Spark (GB10). In https://github.com/vllm-project/vllm/issues/58726 it was narrowed down to whether the source pages are already mapped in the process's page tables: a page that is in the page cache but not yet mapped is as slow as one that is not cached at all. vLLM now touches the pages before each copy on integrated GPUs (vllm-project/vllm#58868).
What I can't explain is the decay: each copy faults in only its own 2.7 MB, so why does it cost more the more of the file the process has already mapped?
- Linguagem predominante
- C
- Estrelas
- 17.7k
- Forks
- 2k
- Métricas de merge de PRs
- Nenhum PR com merge em 30d
Preparar o ambiente
- Sem Dockerfile nem arquivo Docker Compose
- Sem modelo de pull request
- Ler o guia de contribuição
Primeiros passos
- Leia a issue inteira e depois o guia de contribuição do projeto.
- Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
- Faça um fork do repositório e trabalhe em uma branch.
- Abra um pull request que referencie o número da issue.
Mais de NVIDIA/open-gpu-kernel-modules
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 78/100
NVIDIA/open-gpu-kernel-modules#1635 ·
Mantenedores costumam responder em até 1 dia
-
nvidia-drm: NULL dereference in nv_drm_create_sync_file() when sync_file_create() fails (kernel oops when fs.file-max is exhausted)Talvez livre de novo Um pull request para esta issue foi fechado sem ser mesclado. Abertabug
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 82/100
NVIDIA/open-gpu-kernel-modules#1601 ·
Mantenedores costumam responder em até 1 dia
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 76/100
NVIDIA/open-gpu-kernel-modules#1479 · 2 comentários ·
Mantenedores costumam responder em até 1 dia
-
PlatformRequestHandler: missing !bInit guard on bSystemParamLimitUpdate causes NV_ERR_INVALID_DATA at bootTalvez já em andamento @SammyTourani assumiu há 69 dias. Aberta
Dificuldade 1/5 Menos de uma hora Facilidade para iniciantes 88/100
NVIDIA/open-gpu-kernel-modules#1360 ·
Mantenedores costumam responder em até 1 dia
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 72/100
NVIDIA/open-gpu-kernel-modules#1343 · 3 comentários ·
Mantenedores costumam responder em até 1 dia
Todas as issues de NVIDIA/open-gpu-kernel-modules
Issues semelhantes
-
iOS: the "Edit controls" button never hides, even with a controller connected, and covers the gameAbertagame: 010065A014024000 ios
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 76/100
seedds/nxnative#3714 · 1 comentário ·
Mantenedores costumam responder em até 2 dias
-
area/docdb kind/enhancement mvu-pg15-pg19 priority/low
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 76/100
yugabyte/yugabyte-db#40355 ·
Mantenedores costumam responder em até 1 dia
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 76/100
Mantenedores costumam responder em até 1 dia
-
bug
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 74/100
Jstar269/nakagawa-recomp#3753 ·
Mantenedores costumam responder em até 1 dia
-
Dificuldade 1/5 Menos de uma hora Facilidade para iniciantes 72/100
ly05010419/MacNativeGames#2474 ·
Mantenedores costumam responder em até 1 dia