lmstudio-ai / lmstudio-bug-tracker

Bug tracking for the LM Studio desktop application
10 stars 3 forks source link

LM-Studio 0.3.2 "clamps" the numbers of CPU cores from 16 to 8. #130

Closed gestur1976 closed 1 month ago

gestur1976 commented 2 months ago

In 0.2.x versions of LM-Studio, the defalt number of CPU cores is 4 but I am able to change the value to 16 cores and when doing inference, all of the cores are being used.

Since 0.3 version LM-Studio sets a default number of CPU cores of 6, which looks odd to me (looks like a 16 without the 1), but the slider only allows me to set a maximum of 8, and If I write 16 manually it shows the following message at the logs:

2024-09-21 20:15:47 [INFO] [LM STUDIO SERVER] Running chat completion on conversation with 2 messages. 2024-09-21 20:15:47 [DEBUG] Prediction config attempted to specify cpuparams.n_threads '16', which is greater than the number of threads in the threadpool '8.'. Clamping to '8'

Obviously I'm still using 0.2 version because inference speeds in partially offloaded models is much faster than in 0.3 version.

I'm using Arch Linux. Kernel version: Linux 6.10.10-arch1-1 #1 SMP PREEMPT_DYNAMIC Thu, 12 Sep 2024 17:21:02 +0000 x86_64 GNU/Linux

My CPU is: processor : 0 vendor_id : AuthenticAMD cpu family : 25 model : 33 model name : AMD Ryzen 7 5700X 8-Core Processor stepping : 2 microcode : 0xa201204 cpu MHz : 3719.077 cache size : 512 KB physical id : 0 siblings : 16 core id : 0 cpu cores : 8 apicid : 0 initial apicid : 0 fpu : yes fpu_exception : yes cpuid level : 16 wp : yes flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ht syscall nx mmxext fxsr_opt pdpe1gb rdtscp lm constant_tsc rep_good nopl xtopology nonstop_tsc cpuid extd_apicid aperfmperf rapl pni pclmulqdq monitor ssse3 fma cx16 sse4_1 sse4_2 movbe popcnt aes xsave avx f16c rdrand lahf_lm cmp_legacy svm extapic cr8_legacy abm sse4a misalignsse 3dnowprefetch osvw ibs skinit wdt tce topoext perfctr_core perfctr_nb bpext perfctr_llc mwaitx cpb cat_l3 cdp_l3 hw_pstate ssbd mba ibrs ibpb stibp vmmcall fsgsbase bmi1 avx2 smep bmi2 erms invpcid cqm rdt_a rdseed adx smap clflushopt clwb sha_ni xsaveopt xsavec xgetbv1 xsaves cqm_llc cqm_occup_llc cqm_mbm_total cqm_mbm_local user_shstk clzero irperf xsaveerptr rdpru wbnoinvd arat npt lbrv svm_lock nrip_save tsc_scale vmcb_clean flushbyasid decodeassists pausefilter pfthreshold avic v_vmsave_vmload vgif v_spec_ctrl umip pku ospke vaes vpclmulqdq rdpid overflow_recov succor smca fsrm debug_swap bugs : sysret_ss_attrs spectre_v1 spectre_v2 spec_store_bypass srso bogomips : 6803.72 TLB size : 2560 4K pages clflush size : 64 cache_alignment : 64 address sizes : 48 bits physical, 48 bits virtual power management: ts ttp tm hwpstate cpb eff_freq_ro [13] [14]

yagil commented 2 months ago

@gestur1976 does the app let you edit the number directly in the input box? It should allow you to go beyond the limit of the slider

gestur1976 commented 2 months ago

Yes, I can manually enter the number, but when the client connects to the API Server the first message the log shows is: 2024-09-21 20:15:47 [INFO] [LM STUDIO SERVER] Running chat completion on conversation with 2 messages. 2024-09-21 20:15:47 [DEBUG] Prediction config attempted to specify cpuparams.n_threads '16', which is greater than the number of threads in the threadpool '8.'. Clamping to '8' And in htop I can see it's only using 8 cores.

This happens both in API server mode and in Chat section. I can enter manually the number of cores but the program caps it to the half.

My CPU has 16 virtual cores but 8 physical instead, maybe the issue comes from that? Anyway, 0.2 version is twice faster when using CPU only inference.

yagil commented 2 months ago

I see. This is due to how we manage recent changes in llama.cpp threading. We will need to fix this to allow you to provide a number higher than the physical cores.

BTW: which model is this with and what are the rest of your settings? I'm surprised that this leads to 1/2 the speed.

gestur1976 commented 2 months ago

It happens for every model partially offloaded to GPU. For example: My Computer is: AMD Ryzen 7 5700X 8-Core Processor and 16 virtual cores. 64 Gb RAM 2x NVIDIA GeForce RTX 3060 12Gb -> 24GB VRAM

Model: MJaziyarPanahi/Meta-Llama-3.1-70B-Instruct-GGUF/Meta-Llama-3.1-70B-Instruct.Q4_K_M.gguf Context Length: 8192 GPU Offload: 36 / 80 Evaluation Batch Size: 512 RoPe Frequency Base: 0 RoPe Frequency Scale: 0 Keep Model in Memory: Yes Try mmap(): Yes (but I'v seen it fails due to an ulimit of 8192, I'll try to change this limit to see if it helps) Flash Attention: Yes CPU Threads: 16 Temperature: 0.3 Prompt Template: Jinja

Prompt:

Can you teach me how to solve a Rubik's cube?

This is a screenshot with nvidia-smi and htop while doing inference in 0.3.2 version:

image

This is a screenshot with the end of the generated text and statistics:

image

1055 tokens 1.45 tok/sec 4.57s to first token

yagil commented 2 months ago

@gestur1976 as an experiment, you can try to set the number of threads to 8 in LM Studio 0.2 and see if indeed you get the same slow speed. If you don't, it means some other configuration is causing this

valrr2 commented 1 month ago

I'm having the same problem with my dual xeon core Dell with 6 cores each with one thread per cpu. 512GB RAM, 16GB RXT4060, running Linux. With 0.2.31 12 CPU Threads were detected. I usually run 8. With 0.3.4 the max is 6. When I run atop I can see that with 0.2.31 8 cores are high usage. When I run 0.3.4 I see only 6 cores getting intensive use and it is slower. Just confirming gestur1976's experience. Thanks.

mercs759 commented 1 month ago

In 0.3.4b5 under Win10. Max CPU threads that I can choose using the slider is half of the existing ones.

Workaround: just manually put the number you want in the field, et voilà. No errors in log, just works.

(Anyway, also with all CPU cores/threads in use at 100%, in Llama 3.1 8b q4 time before spitting out sentences is WAY longer than under gpt4all)

valrr2 commented 1 month ago

I thought I had tried that and it didn't seem to work, but based on your advice, I took a harder more rigorous look and I think you are right.


From: mercs759 @.> Sent: Sunday, October 20, 2024 3:47 PM To: lmstudio-ai/lmstudio-bug-tracker @.> Cc: valrr2 @.>; Comment @.> Subject: Re: [lmstudio-ai/lmstudio-bug-tracker] LM-Studio 0.3.2 "clamps" the numbers of CPU cores from 16 to 8. (Issue #130)

Same in 0.3.4b5 under Win10. Max CPU threads using the slider is half of the existing ones.

Workaround: just manually put the number in the field, et voilà.

(Anyway, also with 100% CPU cores/threads in use, in Llama 3.1 8b q4 time before spitting out sentences is WAY longer than under gpt4all)

— Reply to this email directly, view it on GitHubhttps://github.com/lmstudio-ai/lmstudio-bug-tracker/issues/130#issuecomment-2425296309, or unsubscribehttps://github.com/notifications/unsubscribe-auth/BMHXS2RSOTU6M5KHRKLTO23Z4Q6JBAVCNFSM6AAAAABOTZWCHOVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDIMRVGI4TMMZQHE. You are receiving this because you commented.Message ID: @.***>

yagil commented 1 month ago

Fix for this will be included in 0.3.5, coming today / tomorrow