Skip to content

feat: Give the allocator limit of each device in EXLA.Client.get_memory_statistics/1 - #1904

Merged
polvalente merged 1 commit into
elixir-nx:mainfrom
georgeguimaraes:exla-allocator-limit
Nov 20, 2026
Merged

polvalente merged 1 commit into
elixir-nx:mainfrom
georgeguimaraes:exla-allocator-limit

Conversation

@georgeguimaraes

Copy link
Copy Markdown
Member

EXLA.Client.get_memory_statistics/1 now has a :limit key: a map of device ID to the bytes that the allocator of the device can use. It reads PjRtDevice::GetAllocatorStats().bytes_limit for each addressable device. A device whose allocator gives no limit is not in the map, so the host client gives an empty map.

Why: a library that keeps buffers on the device, such as the KV cache of a text generation server, must know how much memory the device has before it allocates them. Today EXLA gives the allocated and peak bytes, but not the limit. On CUDA, the limit is that of the BFC allocator, which :memory_fraction sets. On an RTX 3060 with the default fraction, it gives 11291066368 bytes.

…ry_statistics/1

EXLA.Client.get_memory_statistics/1 now has a :limit key: a map of device ID to the bytes that the allocator of the device can use. It reads PjRtDevice::GetAllocatorStats().bytes_limit for each addressable device. A device whose allocator gives no limit is not in the map, so the host client gives an empty map.

On CUDA, the limit is that of the BFC allocator, which :memory_fraction sets. A library can then size its buffers to the device before it allocates them.
@polvalente
polvalente merged commit 610ae74 into elixir-nx:main Nov 20, 2026
7 of 9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants