OpenFlowLM-Next icon indicating copy to clipboard operation
OpenFlowLM-Next copied to clipboard

Memory allocation issue

Open derjohn opened this issue 2 weeks ago • 3 comments

Trying to run qwen3.8-distilled:35b-a3b i get:

oflm run qwen3.8-distilled:35b-a3b --ctx-len 4096
[OFLM]  Qwen3.5 pre-resize image height to 720 pixels if larger than that
[OFLM]  Loading model: /home/aj/.config/oflm/models/Qwen3.8-Distilled-35B-A3B-NPU2
[ERROR]  Failed to load model: std::bad_alloc

Is that supposed to run? I have about 45g unified mem free.

derjohn avatar Nov 15 '26 20:11 derjohn

Trying to run qwen3.8-distilled:35b-a3b i get:

oflm run qwen3.8-distilled:35b-a3b --ctx-len 4096
[OFLM]  Qwen3.5 pre-resize image height to 720 pixels if larger than that
[OFLM]  Loading model: /home/aj/.config/oflm/models/Qwen3.8-Distilled-35B-A3B-NPU2
[ERROR]  Failed to load model: std::bad_alloc

Is that supposed to run? I have about 45g unified mem free.

linux? Also, what quant are you using? I believe you are limited to 50% of system ram on linux. I can't remember if that's a driver limit or configurable.

Cyronius avatar Nov 17 '26 22:11 Cyronius

Yes, Linux (nixos( on a GOD Pocket4 (Ryzen AI) with 64 GB system RAM, 16 of it allocated to GPU. I'll try to lower GPU alloc.

derjohn avatar Nov 17 '26 22:11 derjohn

@derjohn -- on linux it's best to set the igpu dedicated to as low as it goes, and let the uma handle it. But this is still not right, I have 48gb total system ram and I can run that model with 32k context. Try the #245 branch (very not stable, don't just install it and go), I may have fixed something along the line there. It may actually have to be gguf, oflm add with a gguf repo (q4_1 preferably)

and @Cyronius that's configurable

$ oflm run qwen3.8-distill:35b-a3b
[OFLM]  Qwen3.6 pre-resize image height to 720 pixels if larger than that
[OFLM]  Loading model: /home/atomic-germ/.config/oflm/models/Qwen3.8-35B-A3B-Distill-i1-GGUF
[OFLM]  Qwen3.6-MoE on the open kernels (/home/atomic-germ/.config/oflm/models/Qwen3.8-35B-A3B-Distill-i1-GGUF/open_kernels)
open_qwen36: kernels /home/atomic-germ/.config/oflm/models/Qwen3.8-35B-A3B-Distill-i1-GGUF/open_kernels (beside the model)
open_qwen36: host threads: 12 (OMP_WAIT_POLICY=PASSIVE)
open_qwen36: prefill precision: paired (4 products per projection)
open_qwen36: GGUF-direct block prefill unavailable (full); using step prefill
open_qwen36: GGUF weights on the q4_1 twin (chunk 5120, pool 512 MB) ; OFLM_GGUF_POOL_F32=1 runs the f32-scale twin instead
open_qwen36: model Qwen3.8-35B-A3B-Distill-i1-GGUF (qwen36moe, sha256:2c88bfdc8ca3): 40 of 40 layers, 10 attention, context capacity 32768
open_qwen36: block prefill route: T = 0 (no gemm_block program in this kernel set, or its layer types disagree)
open_qwen36: decode route selector: runtime (npu|host|auto; initial npu, auto npu-first [fast attention promoted, stage 2.10; OFLM_DECODE_AUTO_THRESHOLD forces a position split])
open_qwen36: decode route: submit-ahead within a hardware context
open_qwen36: 10/40 layers resident (7 s)
open_qwen36: 20/40 layers resident (16 s)
open_qwen36: 30/40 layers resident (23 s)
open_qwen36: 40/40 layers resident (31 s)
open_qwen36: weights resident: 40 pools + lm_head, 33 s
[OFLM]  Loading model: qwen3.8-distill:35b-a3b
[OFLM]  Type /? for help
>>> 

and after a short run:

ChatCompletionChunk: {"id":"chatcmpl-a428ba09198e08765463a048","object":"chat.completion.chunk","created":1795062425,"model":"qwen3.8-distill:35b-a3b","system_fingerprint":"fp_35c231f8ddde331e","choices":[{"index":0,"delta":{"content":null},"finish_reason":"stop"}],"usage":{"prompt_tokens":15,"completion_tokens":1120,"total_tokens":1135,"active_kv_tokens":1135,"max_kv_token_capacity":32768,"kv_token_occupancy_rate_percentage":3.4637451171875,"load_duration":3.737e-06,"prefill_duration_ttft":0.943260928,"decoding_duration":90.107856,"prefill_speed_tps":15.902280646569936,"decoding_speed_tps":12.429548873074951}}
[🔒 ]  Closing TCP connection (streaming, non-keep-alive)
[🔵 ]  NPU Lock Released!

So it isn't your ram, you definitely have enough. Can you run other models or is it just this one? And do you have * soft memlock unlimited and * hard memlock unlimited in /etc/security/limits.conf?

Atomic-Germ avatar Nov 19 '26 04:11 Atomic-Germ