Skip to main content

AI Model Dynamic Offloader

This project is a pytorch VRAM allocator that implements on-demand offloading of model weights when the primary pytorch VRAM allocator comes under pressure.

Support:

  • Nvidia GPUs (CUDA) and AMD GPUs (ROCm/HIP)
  • PyTorch 2.8+
  • CUDA 12.8+ (Nvidia) / ROCm 7+ (AMD)
  • Windows 11+ / Linux as per python ManyLinux support

How it works:

  • The pytorch application creates a Virtual Base Address Register (VBAR) for a model. Creating a VBAR doesn't cost any VRAM, only GPU virtual address space (which is pretty much free).
  • The pytorch application allocates tensors for model weights within the VBAR. These tensors are initially un-allocated and will segfault if touched.
  • The pytorch application faults in the tensors using the fault() API at the time the tensor is needed. This is where VRAM actually gets allocated.
If the fault() is successful (sufficient VRAM for this tensor):
  1. If the fault() resultant signature is changed or unknown:
    • The application uses tensor::_copy() to populate the weight data on the GPU.
    • The application saves the returned signature against this weight for future comparison
  2. The layer uses the weight tensor.
  3. The application calls unpin() on the tensor to allow it to be freed under pressure later if needed.
If the fault() is unsuccessful (offloaded weight):
  1. The application allocates a temporary regular GPU tensor.
  2. Uses _copy to populate weight data on the GPU.
  3. The layer uses the temporary as the weight.
  4. Pytorch garbage collects the temp when the layer is finished.

see examples/example.py


Priorities:

  • The most recent VBARs are the highest priority and lower addresses in the VBAR take priority over higher addresses.
  • Applications should order their tensor allocations in the VBAR in load-priority order with the lowest addresses for the highest priority weights.
  • Calling fault() on a weight that is higher priority than other weights will cause those lower priority weights to get freed to make space.
  • Having a weight evicted sets that VBAR's watermark to that weight's level. Any weights in the same VBAR above the watermark automatically fail the fault() API. This avoids constantly faulting in all weights each model iteration while allowing the application to just blindly call fault() every layer and check the results. There is no need for the application to manage any VRAM quotas or watermarks.
  • Existing VBARs can be pushed to top priority with the prioritize() API. This allows use of an already loaded or partially model (e.g. using the same model twice in a complex workflow). Using prioritize resets the offload watermark of that model to no offloading, giving its weights priority over any other currently loaded models.

Backend:

  • VBAR allocation is done with cuMemAddressReserve(), faulting with cuMemCreate() and cuMemMap() and all frees done with appropriate converse APIs.
  • For consistency with VBAR memory management, main pytorch allocator plugin is also implemented with cuMemAddressReserve -> cuMemCreate -> cuMemMap. This also behaves a lot better on Windows systems with System Memory fallback.

On AMD, the equivalent HIP APIs (hipMemAddressReserve -> hipMemCreate -> hipMemMap, and their converse calls) are used throughout via the same flow.

Dinkster native wheel channel

Dinkster publishes the Linux x86_64, Linux aarch64, Windows amd64, and Windows arm64 native wheels to PyPI and the matching GitHub Release. Install an exact release from PyPI with:

pip install dinkster-aimdo==0.5.5.post2

The distribution name is dinkster-aimdo; import it as dinkster_aimdo. Each GitHub Release also includes a JSON manifest that records the exact source commit and every native wheel's filename, platform tags, byte size, and SHA-256 hash. The pure-Python stub wheel is not part of this channel.

Caveats:

  • There is no real way for this allocator to tell the difference between high usage and bad fragmentation in the pytorch caching allocator. As we always return success to the pytorch caching allocator it experiences no pressure while weights are being offloaded which means it can run in an extremely fragmented mode. The assumption is model weight access patterns are reasonably regular over blocks or iterations and it finds a good set of sizes to cache. What you should generally do though, is completely flush the pytorch caching allocator before each new model run, which avoids completely un-used reservations from taking priority over the next models weights.

Metadata

Release files for dinkster-aimdo 0.5.5.post2

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

Built distributions (wheels)

Table of built distributions (wheels) for dinkster-aimdo 0.5.5.post2
File
dinkster_aimdo-0.5.5.post2-cp39-abi3-win_arm64.whl CPython 3.9 abi3 Windows ARM64 Details
dinkster_aimdo-0.5.5.post2-cp39-abi3-win_amd64.whl CPython 3.9 abi3 Windows x86-64 Details
dinkster_aimdo-0.5.5.post2-cp39-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl CPython 3.9 abi3 Linux glibc 2.17+ x86-64 Details
dinkster_aimdo-0.5.5.post2-cp39-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl CPython 3.9 abi3 Linux glibc 2.17+ ARM64 Details

Total release size: 1.6 MB

Release files / dinkster_aimdo-0.5.5.post2-cp39-abi3-win_arm64.whl

Download URL dinkster_aimdo-0.5.5.post2-cp39-abi3-win_arm64.whl
Size 255.7 kB
Tags CPython 3.9 Windows ARM64 abi3
SHA-256 checksum
How to use checksums
c346594cc384d1a814041fe7d574115dc18c26499e47112a80a6fe083fc6032c
BLAKE2b-256 checksum
How to use checksums
c840f4e02507ac2f12b93c2dac9150513dd96307d107e72ba9f6f419b179cee1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 18, 2026.

Transparency log

Release files / dinkster_aimdo-0.5.5.post2-cp39-abi3-win_amd64.whl

Download URL dinkster_aimdo-0.5.5.post2-cp39-abi3-win_amd64.whl
Size 281.5 kB
Tags CPython 3.9 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
22c3ae7dc902ebf67091cd2f4055ac9fbc9eab1713ad2f6b2d5a05072f9fe58f
BLAKE2b-256 checksum
How to use checksums
1b13e5eb80eeea037299df28564c0d95c60c9c1a1e28b1d90e72e5c6737938bc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 18, 2026.

Transparency log

Release files / dinkster_aimdo-0.5.5.post2-cp39-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl

Download URL dinkster_aimdo-0.5.5.post2-cp39-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
Size 433.4 kB
Tags CPython 3.9 Linux glibc 2.17+ x86-64 abi3
SHA-256 checksum
How to use checksums
5e78077c9b04e33e62a404f201e467124d8224043dcfce1d8ea4d5c99bff001d
BLAKE2b-256 checksum
How to use checksums
3968a1c8f47e77fef022422afb52b4873721b4f0fc5f95db27a4e684633d8eaa
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 18, 2026.

Transparency log

Release files / dinkster_aimdo-0.5.5.post2-cp39-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl

Download URL dinkster_aimdo-0.5.5.post2-cp39-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl
Size 660.0 kB
Tags CPython 3.9 Linux glibc 2.17+ ARM64 abi3
SHA-256 checksum
How to use checksums
c2476b7d4478d103c46f3be1a1db6bbface07e55f8d91bc871fa67c35310a40b
BLAKE2b-256 checksum
How to use checksums
9ebcba7bdd8aab77f579faad3bbcdf3daa621290e9f00a2b0fbd1288c48006e9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 18, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.5.5.post2 This release

4 release files

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