WebGPU issues

11 views
Skip to first unread message

graven

unread,
Jun 12, 2024, 9:40:24 PMJun 12
to nw.js
Hi,

I hope I'm posting this in the correct area.  I'm not sure if it is a bug/issue or not, but I've encountered a lot of issues viewing any demos that use WebGPU on nwjs.  In specific, the webllm demo loads like it normally would on Electron, Chrome, and MS Edge, however, instead of saying "Loaded onto gpu - nvidia" when it completes, like in the aforementioned Chromium-based browsers, in nwjs it instead prints "Loaded onto gpu - google" (and the same thing goes for the web stable diffusion wasm example.)  Update: I found more info and it's apparently a fallback adapter.

It then runs extremely slow compared to the other browsers, which, utilizing WebGPU, allow a realtime conversation with the LLM model that you choose.  When I say slow, I mean it runs 100% of the cpu (in the Windows Task Manager) and 0% of the gpu, and it takes about 5 minutes per token and is buggy and prone to just stopping output completely.  Or maybe I just didn't wait long enough for the next token.  That seems very slow even compared to other inference setups that run on the cpu alone.

The rest of the WebGPU examples, like HelloTriangle, etc. don't work either.  They usually print an error to the console.  Also, inspecting the WebGPU features in nwjs differs from the features listed in the other browsers.  Most of them are the same, but not all of them, and nwjs doesn't list support for the f16 feature yet either.  All of the browsers are running Chromium 125, except Electron which is running 124.  Is this expected or am I doing something incorrectly?  I also tried it with several flags in the Chromium-args but they didn't seem to make much difference.  I tried --enable-unsafe-webgpu --enable-features=Vulkan --enable-dawn-features=disable_robustness

Here is a link to the demo: https://chat.webllm.ai/ if you want to test it yourself.

I load the demo by opening the devtools in nwjs and just setting 'location.href = 'https://chat.webllm.ai/';'

The model loads fine, and the shaders load but I don't think it's running on the gpu at all.  It seems to be just maxing out the cpu instead.  I'm confused because I thought the gpu performance would be part of Chromium, and the version of Chromium is the same in all of them, but I also don't know if nwjs rebuilds part of the renderer.  It appears to be using a fallback adapter instead.  Is there something I'm doing incorrectly?  Is it just me with this issue?  Are you planning on parity with other WebGPU browsers?  I'm just really excited and interested in this feature so I was really hoping to test it out soon.  I know it is nascent/new, so I'm sorry if I'm jumping the gun.

When I get time I will try testing again on other platforms.

Currently, I'm running/testing on Windows 10 x64 with the nwjs sdk x64 version.  Let me know if you need any other information.

adapter info:  
-------------  
architecture  swiftshader  
description  
device        
vendor        google  

flags:  
------  
isCompatibilityMode  false  
isFallbackAdapter    true

I can print out the WebGPU features list from both Chrome/Edge/Electron and from nwjs if you want as well.  Or if you need my actual adapter info, I can provide that as well.

Also, one other thing I've noticed, is that in the more recent version (v0.88.0) a little red square shows up in the Windows sys-tray sometimes (only sometimes...maybe when I reopen it too quickly after closing it?) that allows the app to "run in the background" but I don't think I've enabled that anywhere.  When the red square shows up, I have to manually right click it to exit the app before I can restart it.  As far as I know, the earlier versions I used didn't have that behavior.  However, it could be that I've added some JS code that is causing it to run the systray icon...I just don't recall doing that and I don't understand why it would only be sometimes, if it were being executed by me.  If my code was doing it, it should probably show up on every launch but it doesn't.  It shows up about 30-40% of the time when launched.

Thanks for all of your hard work.  I hope some of this information will be useful.  I plan on digging into the nwjs code myself soon.  I just need more time to do it and set up the build process.
Reply all
Reply to author
Forward
0 new messages