Skip to main content

AI Model Dynamic Offloader for ComfyUI

Project description

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 only
  • Pytorch 2.6+
  • Cuda 12.8+
  • 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.
  • This allocator is incompatible with the pytorch cudaMallocAsync backend or expandable segments backends (as the plugin interface does not exist on these backends as of this writing).

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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

comfy_aimdo-0.0.4-py3-none-any.whl (17.5 kB view details)

Uploaded Python 3

comfy_aimdo-0.0.4-cp313-cp313-win_amd64.whl (105.9 kB view details)

Uploaded CPython 3.13Windows x86-64

comfy_aimdo-0.0.4-cp313-cp313-manylinux1_x86_64.manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_5_x86_64.whl (38.2 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ x86-64manylinux: glibc 2.5+ x86-64

comfy_aimdo-0.0.4-cp312-cp312-win_amd64.whl (105.9 kB view details)

Uploaded CPython 3.12Windows x86-64

comfy_aimdo-0.0.4-cp312-cp312-manylinux1_x86_64.manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_5_x86_64.whl (38.2 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ x86-64manylinux: glibc 2.5+ x86-64

comfy_aimdo-0.0.4-cp311-cp311-win_amd64.whl (105.9 kB view details)

Uploaded CPython 3.11Windows x86-64

comfy_aimdo-0.0.4-cp311-cp311-manylinux1_x86_64.manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_5_x86_64.whl (38.2 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ x86-64manylinux: glibc 2.5+ x86-64

comfy_aimdo-0.0.4-cp310-cp310-win_amd64.whl (105.9 kB view details)

Uploaded CPython 3.10Windows x86-64

comfy_aimdo-0.0.4-cp310-cp310-manylinux1_x86_64.manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_5_x86_64.whl (38.2 kB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ x86-64manylinux: glibc 2.5+ x86-64

comfy_aimdo-0.0.4-cp39-cp39-win_amd64.whl (105.9 kB view details)

Uploaded CPython 3.9Windows x86-64

comfy_aimdo-0.0.4-cp39-cp39-manylinux1_x86_64.manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_5_x86_64.whl (38.2 kB view details)

Uploaded CPython 3.9manylinux: glibc 2.17+ x86-64manylinux: glibc 2.5+ x86-64

File details

Details for the file comfy_aimdo-0.0.4-py3-none-any.whl.

File metadata

  • Download URL: comfy_aimdo-0.0.4-py3-none-any.whl
  • Upload date:
  • Size: 17.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for comfy_aimdo-0.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 00bf6a99cd3375cd7a355402603f0cada22ce0f354c93202612963d7e76c945f
MD5 93fad407fc1e0af59161e77d92cfeffd
BLAKE2b-256 29368326a07ed5bc829688680b355766ccba6109fd28a9075aa3bd5c61eba5f6

See more details on using hashes here.

Provenance

The following attestation bundles were made for comfy_aimdo-0.0.4-py3-none-any.whl:

Publisher: build-wheels.yml on Comfy-Org/comfy-aimdo

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file comfy_aimdo-0.0.4-cp313-cp313-win_amd64.whl.

File metadata

  • Download URL: comfy_aimdo-0.0.4-cp313-cp313-win_amd64.whl
  • Upload date:
  • Size: 105.9 kB
  • Tags: CPython 3.13, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for comfy_aimdo-0.0.4-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 4bb33315f9c938d7cc55513e3fdc9b6171e90bf1fcda83e01e3c75d92ad3c2df
MD5 c3951be96014b9968df0faad28593f56
BLAKE2b-256 608c491164c09dd6092223384eca659441fdcba7bf0fce8844699e985b09086e

See more details on using hashes here.

Provenance

The following attestation bundles were made for comfy_aimdo-0.0.4-cp313-cp313-win_amd64.whl:

Publisher: build-wheels.yml on Comfy-Org/comfy-aimdo

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file comfy_aimdo-0.0.4-cp313-cp313-manylinux1_x86_64.manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_5_x86_64.whl.

File metadata

File hashes

Hashes for comfy_aimdo-0.0.4-cp313-cp313-manylinux1_x86_64.manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_5_x86_64.whl
Algorithm Hash digest
SHA256 cc9fa87ef15a763e9d2984a41b39073788a893c100b7cf7abd7ff2a70d3d8da5
MD5 8f705c93f995d1bae0d52e3ab8b52228
BLAKE2b-256 e724de46961fe555cbf4b6e58157c861b95ccabd7b986d42e04627729f8909c8

See more details on using hashes here.

Provenance

The following attestation bundles were made for comfy_aimdo-0.0.4-cp313-cp313-manylinux1_x86_64.manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_5_x86_64.whl:

Publisher: build-wheels.yml on Comfy-Org/comfy-aimdo

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file comfy_aimdo-0.0.4-cp312-cp312-win_amd64.whl.

File metadata

  • Download URL: comfy_aimdo-0.0.4-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 105.9 kB
  • Tags: CPython 3.12, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for comfy_aimdo-0.0.4-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 3f80bcb93a2bce140b6d4bcbc2861b20c607ca2ff3b9a968c74e2769e06fe686
MD5 9e7de36fbd5addb378858ae73dcc5290
BLAKE2b-256 366859e9f8714a303e89c39af831ac578c1109a747b6f6646cdec33161f9a26f

See more details on using hashes here.

Provenance

The following attestation bundles were made for comfy_aimdo-0.0.4-cp312-cp312-win_amd64.whl:

Publisher: build-wheels.yml on Comfy-Org/comfy-aimdo

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file comfy_aimdo-0.0.4-cp312-cp312-manylinux1_x86_64.manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_5_x86_64.whl.

File metadata

File hashes

Hashes for comfy_aimdo-0.0.4-cp312-cp312-manylinux1_x86_64.manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_5_x86_64.whl
Algorithm Hash digest
SHA256 448fc0eca964e9b2cf45794e5b77f25cfa1b0b7052e27d88e8966faa13bcb0b2
MD5 2be5d4f04729bc076a383e42e82ba9e3
BLAKE2b-256 867f7845a531f858d4aefb7f8f3e07b04d2e2a5ec7493450c7fced36d6aa8457

See more details on using hashes here.

Provenance

The following attestation bundles were made for comfy_aimdo-0.0.4-cp312-cp312-manylinux1_x86_64.manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_5_x86_64.whl:

Publisher: build-wheels.yml on Comfy-Org/comfy-aimdo

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file comfy_aimdo-0.0.4-cp311-cp311-win_amd64.whl.

File metadata

  • Download URL: comfy_aimdo-0.0.4-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 105.9 kB
  • Tags: CPython 3.11, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for comfy_aimdo-0.0.4-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 0748bcfd01476c3494e9497d5179e883304c380c48ab3e9825cc0c76b4a73586
MD5 9b85968ccc2106c4a4f2d72a3cc77c4a
BLAKE2b-256 21a006dd26d96c931cd2970bfac388f744618a4e64af1efe8e9277244199cc9a

See more details on using hashes here.

Provenance

The following attestation bundles were made for comfy_aimdo-0.0.4-cp311-cp311-win_amd64.whl:

Publisher: build-wheels.yml on Comfy-Org/comfy-aimdo

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file comfy_aimdo-0.0.4-cp311-cp311-manylinux1_x86_64.manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_5_x86_64.whl.

File metadata

File hashes

Hashes for comfy_aimdo-0.0.4-cp311-cp311-manylinux1_x86_64.manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_5_x86_64.whl
Algorithm Hash digest
SHA256 6440675ee896fecb596b012fdb3f6f5e1e92f3c9c567e47dc857e893a5a5e568
MD5 686cf43edb2340fc16e3623e17a32879
BLAKE2b-256 7956943edb42556356a66957b8a825584954595a52e9e7dbfd3e1c3d7ef4f3bb

See more details on using hashes here.

Provenance

The following attestation bundles were made for comfy_aimdo-0.0.4-cp311-cp311-manylinux1_x86_64.manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_5_x86_64.whl:

Publisher: build-wheels.yml on Comfy-Org/comfy-aimdo

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file comfy_aimdo-0.0.4-cp310-cp310-win_amd64.whl.

File metadata

  • Download URL: comfy_aimdo-0.0.4-cp310-cp310-win_amd64.whl
  • Upload date:
  • Size: 105.9 kB
  • Tags: CPython 3.10, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for comfy_aimdo-0.0.4-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 1af6d23cf78665bd9ab65b0cfa7fb775cb5570e3e1ad60bd5523ce6c554e23d6
MD5 78b9538ac1b67a1152e07b0bd49e2dc3
BLAKE2b-256 3bc0e45d0e5fac540e97e1c07a986aa4c64731e715c5f07d3d4ae55ac4be33d3

See more details on using hashes here.

Provenance

The following attestation bundles were made for comfy_aimdo-0.0.4-cp310-cp310-win_amd64.whl:

Publisher: build-wheels.yml on Comfy-Org/comfy-aimdo

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file comfy_aimdo-0.0.4-cp310-cp310-manylinux1_x86_64.manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_5_x86_64.whl.

File metadata

File hashes

Hashes for comfy_aimdo-0.0.4-cp310-cp310-manylinux1_x86_64.manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_5_x86_64.whl
Algorithm Hash digest
SHA256 84e527ca4fb88bde4266305556bee1fd8307d5682ac4bead3375235904ebaceb
MD5 30de73f7e93d58132dd91f2a6b491f86
BLAKE2b-256 7d079f8db7723edf62329632f09b160e5772c3c5c61e191df23142e1f611f71f

See more details on using hashes here.

Provenance

The following attestation bundles were made for comfy_aimdo-0.0.4-cp310-cp310-manylinux1_x86_64.manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_5_x86_64.whl:

Publisher: build-wheels.yml on Comfy-Org/comfy-aimdo

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file comfy_aimdo-0.0.4-cp39-cp39-win_amd64.whl.

File metadata

  • Download URL: comfy_aimdo-0.0.4-cp39-cp39-win_amd64.whl
  • Upload date:
  • Size: 105.9 kB
  • Tags: CPython 3.9, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for comfy_aimdo-0.0.4-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 ca5dc1f6662adc7ded02e349d771ea4f532f44b54284da4a9d289dc9fa9123b0
MD5 588052024cfe9ec0dfbc9e379882a174
BLAKE2b-256 0e91f68860b6a06d23a12e6a42bc833cfcbf97cc370310dda7ab277ac23f4583

See more details on using hashes here.

Provenance

The following attestation bundles were made for comfy_aimdo-0.0.4-cp39-cp39-win_amd64.whl:

Publisher: build-wheels.yml on Comfy-Org/comfy-aimdo

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file comfy_aimdo-0.0.4-cp39-cp39-manylinux1_x86_64.manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_5_x86_64.whl.

File metadata

File hashes

Hashes for comfy_aimdo-0.0.4-cp39-cp39-manylinux1_x86_64.manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_5_x86_64.whl
Algorithm Hash digest
SHA256 20a8a6a6a9d5019fba770a34af8b5f2bd4c7e97866c1339afcb52c60f17c2d6c
MD5 582d1202ea70ff73462e2e005b16756f
BLAKE2b-256 3fd27bb048d3b04ff7e1e136d8a23c991ba9b30c159bfe9d65fe16e7e6925a1a

See more details on using hashes here.

Provenance

The following attestation bundles were made for comfy_aimdo-0.0.4-cp39-cp39-manylinux1_x86_64.manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_5_x86_64.whl:

Publisher: build-wheels.yml on Comfy-Org/comfy-aimdo

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page