Skip to content

misc : prevent RAM peaking at model loading stage - #27483

Merged
ggerganov merged 1 commit into
ggml-org:masterfrom
tdakhran:tarek/feat/peak-ram-shift
Sep 3, 2026
Merged

misc : prevent RAM peaking at model loading stage#27483
ggerganov merged 1 commit into
ggml-org:masterfrom
tdakhran:tarek/feat/peak-ram-shift

Conversation

@tdakhran

Copy link
Copy Markdown
Contributor

Overview

For models where embeddings have a larger memory footprint than context, peak RAM occurs during model loading when repack is enabled. This makes peak RAM constant across different context lengths.

E.g. here
image

This PR changes the order of tensors during repack and move the peak to the beginning. I also moved from a single always-growing buffer to per-tensor buffers. There will be more allocations, but no peak.

Here is how it looks after the change
peak-ram-phone-sortfix-p512

Additional information

The first thing I tried was an in-place repack, and indeed it worked, but the changes were very intrusive and required changes to ggml and backends.

Requirements

@tdakhran

tdakhran commented Sep 2, 2026

Copy link
Copy Markdown
Contributor Author

@CISC @ggerganov gentle reminder

@CISC

CISC commented Sep 3, 2026

Copy link
Copy Markdown
Member

I have no particular stake in this, LGTM though, @ggerganov?

@ggerganov
ggerganov merged commit 5ec4eab into ggml-org:master Sep 3, 2026
23 of 26 checks passed
fewtarius pushed a commit to fewtarius/CachyLLama that referenced this pull request Sep 5, 2026
thecodacus pushed a commit to thecodacus/llama.cpp that referenced this pull request Sep 7, 2026
SteelPh0enix pushed a commit to SteelPh0enix/llama.cpp-qwen4exp that referenced this pull request Sep 8, 2026
SteelPh0enix pushed a commit to SteelPh0enix/llama.cpp-qwen4exp that referenced this pull request Sep 8, 2026
x1250 pushed a commit to x1250/llama.cpp that referenced this pull request Sep 9, 2026
zbrad pushed a commit to zbrad/llama.cpp that referenced this pull request Sep 10, 2026
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