Skip to main content

gb10-load-llm

Small helpers for loading LLMs on NVIDIA GB10 / GX10 systems without hitting very slow CUDA Host-to-Device transfers from cold CPU pages.

The core workaround is:

  1. Load the model on CPU.
  2. Read one byte per CPU page from model parameters and buffers.
  3. Move the model to CUDA.

This package keeps that process explicit and reusable.

Install

pip install gb10-load-llm

Transformers Usage

from transformers import AutoModelForCausalLM

from gb10_load_llm import load_model_to_cuda

model = load_model_to_cuda(
    AutoModelForCausalLM,
    "Qwen/Qwen2.5-Coder-3B",
    dtype="auto",
    touch="auto",
)

load_model_to_cuda passes extra keyword arguments to AutoModelForCausalLM.from_pretrained. By default, Transformers loads models on CPU before this helper applies the touch policy and moves the model to CUDA.

For single-GPU models that fit in VRAM, this CPU-load, touch, then CUDA-move route is the recommended path on GB10.

Avoid Accelerate / device_map

For single-GPU models that fit in VRAM, this package does not recommend using Accelerate / device_map as the loading path on GB10.

On the tested GB10 system with cached Qwen/Qwen2.5-Coder-3B in bfloat16:

  • CPU load + touch + model.to("cuda"): about 2-4 seconds to get the model onto GPU.
  • Unpatched device_map="cuda" through Accelerate: about 52 seconds.
  • Experimental patched device_map="cuda" that touched pages inside Transformers' private loading path: about 5-7 seconds.

Even with the experimental touch fix, the direct CPU-touch-then-CUDA route was faster and simpler. Use Accelerate when you need its features, such as multi-GPU placement, CPU/disk offload, or models that do not fit on one GPU. For fastest single-GPU loading on GB10, prefer this package's CPU-first helper.

Lower-Level Usage

import torch
from transformers import AutoModelForCausalLM

from gb10_load_llm import touch_model_cpu_pages

model = AutoModelForCausalLM.from_pretrained(
    "Qwen/Qwen2.5-Coder-3B",
    dtype=torch.bfloat16,
    local_files_only=True,
)

touched = touch_model_cpu_pages(model)
model = model.to("cuda")
torch.cuda.synchronize()

Touch Policy

move_model_to_cuda accepts:

  • touch=True: always touch CPU pages before moving.
  • touch=False: never touch.
  • touch="auto": touch only when the CUDA device name looks like GB10.

The Transformers wrapper defaults to touch=True, because this package is GB10-focused and explicit.

You can override all callers with:

GB10_LOAD_LLM_TOUCH=0  # disable
GB10_LOAD_LLM_TOUCH=1  # enable

Why This Exists

On the tested ASUS Ascent GX10 / NVIDIA GB10 system, moving cold safetensors-backed CPU weights to CUDA can be tens of seconds slower than expected. Reading one byte per CPU page before model.to("cuda") avoids most of that cost.

This appears hardware / driver dependent. It is not intended as a universal PyTorch rule.

Development

uv sync --extra dev
uv run pytest

Build:

uv build

Publish later with:

uv publish

Blog post

https://liusida.com/post/cuda-h2d-slowdown-from-cold-mmap-backed-safetensors-pages-on-gb10

Metadata

Release files for gb10-load-llm 0.1.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for gb10-load-llm 0.1.2
File Size Uploaded Provenance Actions
gb10_load_llm-0.1.2.tar.gz 78.1 kB Without provenance Details for gb10_load_llm-0.1.2.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for gb10-load-llm 0.1.2
File Interpreter ABI Platform Actions
gb10_load_llm-0.1.2-py3-none-any.whl Python 3 none any Details for gb10_load_llm-0.1.2-py3-none-any.whl

Total release size: 83.9 kB

Release files / gb10_load_llm-0.1.2.tar.gz

Download URL gb10_load_llm-0.1.2.tar.gz
Size 78.1 kB
Tags Source
SHA-256 checksum
How to use checksums
43f7ca2a7e3f7750ee8b7f2413dde1620665b3af2b65fb68c84915a9ae4cd3a3
BLAKE2b-256 checksum
How to use checksums
ed8cdfe2b00db47bb52f73c5b47a784cce6b95cee9fd431abc3a8037109548d0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.10.9 {"installer":{"name":"uv","version":"0.10.9","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release files / gb10_load_llm-0.1.2-py3-none-any.whl

Download URL gb10_load_llm-0.1.2-py3-none-any.whl
Size 5.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
87002e4e6928fa6d5f0c8cb5e0829114b2cd82b6c0071951c8821a0ed232c8df
BLAKE2b-256 checksum
How to use checksums
a58c8a0feab97d1030718c7a6e14ff2592025a819d690e1a06427adeaf605da3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.10.9 {"installer":{"name":"uv","version":"0.10.9","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Security for gb10-load-llm 0.1.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page