Skip to content

[Bug] Extremely laggy/slow webUI #7522

Closed

Description

@StudioNirin

Note: Please do not remove the questions. Answer beside them.

  1. Did you update? - No, because I just installed it on windows 20 minutes ago, and the update command is the same as the install command.
  2. Colab or Kaggle or local / cloud - Local, windows install.
  3. Number GPUs used, use nvidia-smi - Only have 1 GPU. 5090.
  4. Which notebook? Please link! - N/A
  5. Which Unsloth version, TRL version, transformers version, PyTorch version?

Unsloth = 2026.7.5
Transformers = pre-installing transformers 5.3.0 for newer model support...
transformers 5.3.0 pre-installed
pre-installing transformers 5.5.0 for Gemma 4 support...
transformers 5.5.0 pre-installed
pre-installing transformers 5.10.2 for Gemma 4 Unified support...
transformers 5.10.2 pre-installed
PyTorch: 2.10.0+cu130
CUDA: 13.0
CUDA available: True

  1. Which trainer? SFTTrainer, GRPOTrainer etc - N/A

I'm just using unsloth for chat at the moment, testing existing models I have. It seems to be significantly faster than llama.cpp, giving me significant performance gains (not sure why yet, I wonder if there's some setting happening I could replicate on llama.cpp).

However, while the tok/s results are great, the issue is how laggy the webUI is.

Simply typing in the text box is slow/laggy. Each word I type doesn't appear in the box until I'm already halfway through typing the next word.

It's also visible during actual inference, as letters/words don't appear as they are generated one at a time, but instead the inference will stop updating for a second and then an entire chunk of text will spawn in.

Edit:
If I do a full restart (which also means updating, cos I used the install command again), and then start a new chat window, then typing in text works fine. Happens at normal speed. The text being generated also appears at the speed I would expect - at first.

But after a few lines it slows down and begins to lag, and any further prompts in that chat are very laggy. So it seems to be some kind of memory bug I would assume.

I have tested on chrome as well as edge, identical behaviour.

System is currently sitting at about 30gb of unused memory out of 64 so it's not a memory issue on my end. Could be a browser issue of course, but as llama.cpp and other frontends I have tried all use the same browser, and none of those have this issue, it seems more likely the issue is with unsloth-studios handling of whatever is causing the lag.

Edit 2:

I've realised that my standard test I've been doing for all llm frontends etc has been to "write a html flappy bird game with no dependencies" because it's a standard easy coding task so I can get consistent speed tests.

However on unsloth studio, this also spawns a canvas box, with a working version of the code in it you can open up. Which is great. But this seems like it might be the cause of the lag.

Activity

  1. Lyxot commented on Jul 28, 2026

    @Lyxot
    Collaborator

    Can you check VRAM usage?

  2. StudioNirin commented on Jul 28, 2026

    @StudioNirin
    Author

    Can you check VRAM usage?

    Vram usage is high, around 30gb on a 5090, but its the same as when I do other prompts (or the same prompts on llama.cpp) and the issue doesnt happen then.
    Its a bug involving the html canvas tool that pops up it seems

  3. shimmyshimmer commented on Jul 28, 2026

    @shimmyshimmer
    Member

    Thanks for the video and the log, both were the key to tracking this down.

    Your instinct that it was the canvas turned out to be a red herring, but the thing you spotted in the video was exactly right: reasoning text streams fluidly, code does not. That is the whole bug.

    While a code fence is still streaming, our Shiki plugin gets called on every animation frame with the entire block and re-tokenizes it from scratch. So the work per frame grows with the size of the block. Instrumenting one generation:

    highlight() calls:  808        (~50/sec, i.e. every frame)
    chars tokenized:    5,504,216
    rendered block:     13,561 chars
    

    That is 5.5MB of tokenizing to render a 13.5KB block. A CPU profile put about half the renderer main thread inside the syntax tokenizer. Plain prose has no tokenizer, which is why the thinking section stayed smooth.

    The canvas is not involved. A Python block of the same size stalls identically, and a canvas panel sitting open with the game running costs nothing measurable (the preview iframe runs out of process, so it cannot starve the tab). "write a html flappy bird game" is just a prompt that reliably produces a big code block very fast, and your snake run was worse because your 5090 was pushing 230 tok/s so the block got large much sooner.

    Your "CPU barely at 7%" observation also fits. That is one saturated renderer thread on a many core CPU, not an idle machine.

    Fix is in #7537. Reproducing your setup by replaying a stream at 230 tok/s, dropped frames over a generation went from 460 to 63, and frame pacing stays at a steady 16.7ms instead of collapsing into lumps.

    Two related things I found while measuring, which are separate and not fixed by that PR:

    • Large markdown tables are actually worse than this was. Fine under about 200 rows, but a 600 row table spent 40.5s of a 72s stream blocked. If you ever ask for a big table you will see the same chunking.
    • Text with a lot of inline code is mildly affected. Part of that was ours and is fixed in perf(studio): remove quadratic region scan in LaTeX preprocessing #7538.

    If you can, please try the branch in #7537 and confirm it matches what you see on Windows. I verified on macOS, and your report is the only data point on a 5090 so far.

  4. StudioNirin commented on Jul 28, 2026

    @StudioNirin
    Author

    Im just about to get some sleep so ill try and give it a try later today and ill report back 😀

  5. shimmyshimmer commented on Jul 28, 2026

    @shimmyshimmer
    Member

    Im just about to get some sleep so ill try and give it a try later today and ill report back 😀

    Oop it's not in unsloth main yet and we havent merged yet but feel free to download those specific PRs :)

  6. shimmyshimmer commented on Jul 29, 2026

    @shimmyshimmer
    Member

    @StudioNirin new release today ish - hopefully when the new release comes out it will be fixed :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions