{"slug": "run-glm-5-3-flash-on-a-24-gb-gpu-at-up-to-17-5-tokens-s", "title": "Run GLM 5.3 Flash on a 24 GB GPU at up to 17.5 tokens/s", "summary": "Tensward published a kit that runs the 109 GB GLM-5.3-Flash model (UD-Q2_K_XL, 2-bit) on a single 24 GB NVIDIA GPU using llama.cpp release b12722, measuring about 12 tokens per second on replies versus 7.7 with the engine's defaults on one L4 with 128 GB of RAM, and a 4,000-token prompt read in 15 seconds versus 139. The kit requires Linux, a 24 GB card, the CUDA 12 runtime libraries, about 128 GB of RAM for its pinned mode (about 64 GB in a slower mapped mode that reads from a local SSD) and about 120 GB of free disk. It offers exact, fast, routing and mapped presets, and an --experts flag that uses fewer than the model's 8 experts per token for more speed at the cost of changed answers.", "body_md": "A 109 GB model on a single 24 GB card. On one L4 with 128 GB of RAM we measured about **12 tokens per second** on replies against 7.7 with the engine's defaults, and a 4,000-token prompt read in **15 seconds** against 139. Details and conditions are in [What we measured](#what-we-measured).\n\nIf you liked the recipe, we would appreicaitae a star!\n[https://github.com/Tensward/tensward](https://github.com/Tensward/tensward)\n\n```\ngit clone https://github.com/Tensward/tensward\ncd tensward/examples/glm-5.3-flash-24gb\n./run.sh\n```\n\nThat one command checks your machine, asks before downloading, starts the server and shows its speed. It stops with a clear message at anything only you can do.\n\n- Linux with one NVIDIA card of 24 GB, a recent driver, and the CUDA 12 runtime libraries (without them the prebuilt engine silently runs on the CPU; the kit checks).\n- About 128 GB of RAM for the fast mode. About 64 GB works in a slower mode that reads part of the file from a fast local SSD. Sizes in between are untested.\n- About 120 GB of free disk space.\n- `bash` ,`curl` ,`tar` ,`python3` . The kit never uses`sudo` and never installs packages.\n\nThis kit runs the public 2-bit model GLM-5.3-Flash (`UD-Q2_K_XL`, about 109 GB) with the public llama.cpp release b12722. It also works well behind a coding agent.\n\n```\n./run.sh chat      # talk to it in the terminal\n./run.sh agent     # set up a coding agent (OpenCode)\n./run.sh bench     # a few minutes of speed numbers, written to result.json\n./run.sh status    # is it running?\n./run.sh stop\n./run.sh serve     # start it again (later starts are faster)\n```\n\nEvery command ends with a short \"Next:\" list. `./run.sh help` shows all options.\n\nThe two modes: **pinned** (about 128 GB of RAM: the expert weights stay in RAM and the card holds a cache of the experts in use) and **mapped** (less RAM: the file is mapped and read from the SSD as needed). The kit picks by your RAM; `--mode pinned|mapped` overrides.\n\nThe first start in pinned mode measures the card once and starts twice (about 8 minutes). The size is saved, so later starts take about 3 to 4 minutes on a fast SSD. `--resize` measures again; `--cache-mib N` sets it yourself.\n\n`./run.sh check` also prints one `sudo` command for the pinned mode (`vm.compaction_proactiveness`): with a very large pinned area the kernel can keep a core busy and slow replies. Our measurements were taken with it set to 0, and on our machine replies were slower without it. You run it yourself; the kit continues without it.\n\n| Preset | What it changes | Answers change? | \n|---|---|---|\n| `exact` | Experts held in RAM, expert cache on the card, tuned miss split. The model's own routing, no draft head. | No model change. The text can differ slightly from the engine's defaults | \n| `fast` (default in pinned mode) | `exact` plus the engine's built-in draft head, one token ahead. Context and cache are sized so a long prompt cannot exhaust the card. | Slightly: the arithmetic differs, not the model | \n| `fast --routing` | Our routing patch (needs the optional build). Replaces a missing expert by a cached one with a close score. The draft head is turned off: the two do not combine. | Slightly | \n| `--experts N` | Uses N experts per token instead of the model's 8. | Yes, more. See below | \n| `jobs4` | Four parallel jobs, a somewhat smaller cache. More tokens per hour overall, slower per job. | No model change | \n| `mapped` | The low-RAM mode. One stream only: four jobs were slower than one. | No model change | \n\nChanging the preset, the cache size or the draft head changes the text slightly. Identical flags give identical text.\n\nKeep the server's prompt cache on. Never pass `--cache-ram 0`: a coding agent then re-reads its long opening prompt on every turn.\n\n```\n./run.sh serve fast --experts 6\n```\n\nThis uses 6 experts per token instead of the model's own 8. It is faster, but **answers change** and quality can drop. It is off unless you ask. Check the answers on your own tasks first.\n\nThe release alone gives you every preset except `--routing`, the warm start and the read-ahead. These three come from patches in `patches/`. They are our own patches for you to apply yourself. They are tied to llama.cpp b12722, they are not part of llama.cpp, and they are not submitted to it.\n\n```\n./run.sh fetch /path/to/folder --source\n./run.sh build --patches routing,warm        # choose from advise, routing, warm\n```\n\nThe build fetches the source at the pinned commit, applies only the patches you name (always in the order advise, routing, warm), builds for your card (the compute capability is detected), and installs beside the release. The built engine is then used automatically; `--engine release` forces the release.\n\n- `advise` : read-ahead for the mapped mode. In our test under a memory cap the first reply after a prompt was faster and steady reply speed was unchanged. It has not been measured on a real 64 GB machine yet. Do not use it in pinned mode.\n- `routing` : switch for`fast --routing` . In one measured block on our own build: replies 4 to 8% faster for a 0.7% rise in perplexity. It changes answers.\n- `warm` : saves the list of hot experts when the server stops and loads it at the next start, so the cache does not start empty. In our test the effect on the first tokens was within run-to-run variation.\n\n```\n./run.sh warm [--file some-text-of-yours.txt]\n```\n\n- Expert cache: with the warm patch built, nothing to do: the list is saved at stop and loaded at start. Without it, `warm` generates a few hundred tokens on text like your work so the cache fills with the right experts.\n- Prompt cache: run `./run.sh agent --warm` from the folder you work in. The agent's opening prompt is long and fixed; it is read once and kept. It only helps if the next requests start with the same text, which is why the same folder and the same day matter: the opening prompt contains the folder and the date.\n\n```\n./run.sh agent          # writes opencode.json here, prints the start command\n./run.sh agent --warm   # also sends one throwaway request to warm the prompt cache\n```\n\nThe kit does not install any agent. If you do not have it: `npm install -g opencode-ai` (Node 22).\n\n- `--jinja` : use the model's own chat template.\n- `-fa on` : flash attention.\n- `-np 1` /`-np 4 -kvu` : parallel jobs;`-kvu` shares one context memory.\n- `-c 40960` : context length. A longer one with the draft head can run the card out of memory on a long prompt.\n- `-ngl all --cpu-moe` : all layers on the card, expert weights in RAM.\n- `--fit on` lets llama.cpp choose the placement itself;`--fit off` uses the placement given by the other flags.\n- `-lm none` : load the model into RAM instead of mapping the file.\n- `--moe-cache-mib` ,`--moe-cache-cpu-share` : size of the expert cache on the card, and how misses are split between card and CPU.\n- `-b 4096 -ub 4096` : big batches for fast prompt reading.\n- `--chat-template-kwargs '{\"reasoning_effort\":\"low\"}'` : short thinking.\n- `--spec-type draft-mtp --spec-draft-n-max 1` : the built-in draft head, one token ahead.\n\n- **\"no CUDA card in use\"** : the CUDA 12 runtime is missing and the engine would run on the CPU. Install it, or set`CUDA_LIB_DIR` , then run`./run.sh check` .\n- **Out of card memory while serving** : use a smaller cache (`--cache-mib` ) or context (`--ctx` ), or use`exact` .\n- **`cudaMalloc failed` right after a restart** : the old server's memory was not yet free.`./run.sh stop` waits for it; do not start before it reports stopped.\n- **The source download fails or restarts** : the source host does not support resuming. Run`fetch --source` again for one plain download. Model files resume.\n- **Slow first prompt in mapped mode** : the file is read from the SSD the first time.\n- **Replies slower than expected in pinned mode** : set`vm.compaction_proactiveness` to 0 (see`./run.sh check` ).\n- **A tool call is refused when testing with `ignore_eos`** : the engine does not allow` ignore_eos` together with`tools` .\n- Logs: `.state/server.log` . A different release file name: set`ARCHIVE` (and`ARCHIVE_URL` ) before`fetch` .\n\nOne NVIDIA L4 (24 GB), 128 GB of RAM, 16 cores, a local NVMe SSD; the public llama.cpp release b12722; one stream; `vm.compaction_proactiveness` set to 0. Figures were recomputed from the raw logs by an independent check. Your numbers depend on the card, the CPU, RAM speed and the SSD: run `./run.sh bench`.\n\n|  | Replies, tok/s | 256-token prompt | 4,000-token prompt | \n|---|---|---|---|\n| Release defaults | 7.7 | 15.4 s | 139 s | \n| `fast` (the default preset) | 12.2 to 17.5 | 6.9 s | 15.0 s | \n| `exact` | not yet checked | 6.7 to 6.9 s | 14.6 to 14.9 s | \n\n- `fast` against the defaults: three default starts and two`fast` starts, alternating. The draft head accepted about 86% of its guesses. The exact text differs from the default engine's; we have not measured its quality separately.\n- Coding agent, prompt cache on (a 13,000 to 15,000-token conversation): the turn after a helper request answered in 8.1 to 8.6 s. With the prompt cache turned off it took 59 to 63 s.\n- `jobs4` : 1.43 times the reply tokens per hour of one job.\n- `fast --routing` (our patch, our own build): replies 4 to 8% faster than the same build without it, for a 0.7% rise in perplexity, in one measured block.\n- `mapped` , measured on another machine (one L4, 62 GB of RAM, 8 cores): 3.0 to 3.5 tok/s; a 4,000-token prompt in 81 s.\n- The card was not throttled by heat. A 4,000-token prompt runs at the card's power limit.\n\nNot measured yet: more than one client with the draft head, contexts longer than 40,960 tokens, other cards.\n\nTested on a real machine: `check`, `serve` with the default preset on the public release, `bench`, `stop`.\n\nNot yet tested from this kit: the downloads, `build` with patches, `agent`, `warm`, the mapped mode, `jobs4`, `chat`, `up` (plain `./run.sh`).\n\n- This kit: Apache-2.0 (this repository's licence).\n- llama.cpp: MIT. The patches in `patches/` carry a pointer to its licence text (`patches/LICENSE-llama.cpp` ).\n- Model: MIT (the licence tag of the quantised model repository).", "url": "https://wpnews.pro/news/run-glm-5-3-flash-on-a-24-gb-gpu-at-up-to-17-5-tokens-s", "canonical_source": "https://github.com/Tensward/tensward/tree/main/examples/glm-5.3-flash-24gb", "published_at": "2026-11-26 23:24:50+00:00", "updated_at": "2026-11-26 23:42:33.465533+00:00", "lang": "en", "topics": ["large-language-models", "ai-infrastructure", "ai-tools", "mlops", "developer-tools"], "entities": ["Tensward", "GLM-5.3-Flash", "llama.cpp", "NVIDIA", "OpenCode", "GitHub"], "also_reported_by": [], "takeaway": "Keeping expert weights pinned in 128 GB of RAM with a GPU-side expert cache and the engine's draft head raised reply speed to about 12 tokens/s from 7.7 on a single 24 GB L4, and cut a 4,000-token prompt read to 15 seconds from 139.", "recommendation": {"advice": "Pin expert weights in RAM with a GPU expert cache and enable the draft head for 2-bit MoE models; the source measured 12 vs 7.7 tokens/s and 15s vs 139s prompt reads on one 24 GB L4.", "playbook": "inference-serving", "playbook_url": "https://wpnews.pro/playbooks/inference-serving"}, "alternates": {"html": "https://wpnews.pro/news/run-glm-5-3-flash-on-a-24-gb-gpu-at-up-to-17-5-tokens-s", "markdown": "https://wpnews.pro/news/run-glm-5-3-flash-on-a-24-gb-gpu-at-up-to-17-5-tokens-s.md", "text": "https://wpnews.pro/news/run-glm-5-3-flash-on-a-24-gb-gpu-at-up-to-17-5-tokens-s.txt", "jsonld": "https://wpnews.pro/news/run-glm-5-3-flash-on-a-24-gb-gpu-at-up-to-17-5-tokens-s.jsonld"}}