llama: add default load-mode auto, which avoids mmap on iGPUs - #26081
Conversation
pwilkin
left a comment
There was a problem hiding this comment.
This is sorely needed for ROCm, where the --mmap mode is additionally bugged beyond 64GB.
|
I addressed the feedback and added llama-bench support. |
| if (ml.use_mmap && params.load_mode == LLAMA_LOAD_MODE_AUTO) { | ||
| for (const auto & dev : devices) { | ||
| ggml_backend_dev_props props; | ||
| ggml_backend_dev_get_props(dev.dev, &props); |
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
There was a problem hiding this comment.
Pretty sure the compiler figures this out no problem.
ORippler
left a comment
There was a problem hiding this comment.
- AI tells me we may wish to bump
APIR_PROTOCOL_MINORas we changeggml_backend_dev_propsto encode one more bool. Pinging @kpouget as I have no clue about virtgpu backend. - Please run
llama-gen-docsto regenerate/update docs to reflect this change
Validated this change on DGX Spark. Would love to change default to -dio on iGPU systems in future to achieve faster load times
thanks for the ping, |
…etal iGPU is used
Co-authored-by: Max Krasnyansky <maxk@qti.qualcomm.com>
|
LGTM for the virt-gpu part (@taronaeo) |
|
Confirming this is worth automating on gfx1151 (Strix Halo APU, Framework Desktop Ryzen AI Max+ 395, ROCm/HIP). Without |
…, multi-output backend sampling, pocket-tts Merges 45 upstream commits (0865990..ebb546b, b10362-16-gebb546b7e) into synori/llama-update-mtp-fit. Zero conflicts; all vendored patches carried over untouched. Primary motivation — new Meta architecture: * 62bf73d model: Muse Glimmer Support (ggml-org#26841) LLM_ARCH_MUSE_GLIMMER + src/models/muse-glimmer.cpp + the mtmd vision tower in tools/mtmd/models/muse-glimmer.cpp and conversion/muse_glimmer.py. Other notable changes that touch our public API surface: * dd1ea52 llama : support multi-output backend sampling (ggml-org#25532) llama_context_params gains n_outputs_max_per_seq; llama_sampler_i.backend_init takes it as a third argument; new backend_reset / copy_state vtable slots and llama_sampler_copy(). * 153d324 llama : default load-mode auto, avoids mmap on iGPUs (ggml-org#26081) llama_load_mode gains LLAMA_LOAD_MODE_AUTO = -1 (enum is now signed). * 6e62ba5 mtmd: support pocket-tts (ggml-org#26871) mtmd_gen_inp/mtmd_gen_out gain seed/temp/feats/is_eos; new mtmd_gen_inp_default(); mtmd_helper_gen_audio_step_gen() takes out_stop. * 157b81f model : Granite-Switch Architecture (ggml-org#25107) * 7a20b41 model: MTP support for Nemotron (ggml-org#26725) and cc078b4 Dflash support for nemotron-3.5 (ggml-org#26905) * e23e944 vendor : cpp-httplib 0.53.0, 4c6766f vendor : subprocess.h sync Vendored patches preserved: * 919fde3 feat(rpc): thread-local last_error accessor — intact, upstream touched ggml-rpc.cpp by one unrelated line. * 3679b23 Fixes (RPC) — intact. * 2aa76c7 fix(metal): drop stray kernel_pad_f32 — still applies; upstream has since refactored pad into a templated kernel_pad_impl<T>, so the duplicate definition that referenced the nonexistent kargs_pad.s0..s3 is gone on both sides and nothing had to be re-applied.
…rg#26081) * llama: add new default load-mode auto which picks mmap unless a non-Metal iGPU is used * Update ggml/src/ggml-hexagon/ggml-hexagon.cpp Co-authored-by: Max Krasnyansky <maxk@qti.qualcomm.com> * set mmap_support to false on OpenCL backend * fix order of load modes * use -1 for auto * resolve load mode auto earlier to correctly pick gpu host or cpu memory * add load mode auto to llama-bench * bump virtgpu api version, regenerate docs --------- Co-authored-by: Piotr Wilkin (ilintar) <piotr.wilkin@syndatis.com> Co-authored-by: Max Krasnyansky <maxk@qti.qualcomm.com> Co-authored-by: Georgi Gerganov <ggerganov@gmail.com>
Overview
Follow-up to #20834 and #26023
mmap is detrimental on iGPUs that have to copy the model to device-visible, but still shared memory, as that means during loading it will have the model in RAM twice, doubling the memory requirements temporarily and slowing down the process if it overflows. This is currently the default behaviour, leading to issues for users that don't know about this.
Add load-mode auto and default to it. It keeps the current behaviour for most cases, except when a device reports that it doesn't support mmap. This is up to the backends to flag, through a new capability boolean (apologies for the mass-pinging this causes..). I only disabled it for CUDA/ROCm and Vulkan iGPUs for now, because I'm not familiar enough with the other backends.
Please let me know if this implementation is feasible or if there's a better way to handle it, and also if there are more backends I should include.
In the future further features could be added, e.g. automatic use of direct-io, if we know when it can definitely be enabled.
Requirements