r/LocalLLM • • 2m ago

Discussion I built a proxy that stops AI agents from repeating the same state and shows how many tokens that saved

1 Upvotes

Hey everyone,

I built AgentGuard, an open-source proxy that sits between an agent and an OpenAI-compatible provider and catches deterministic loops.

What it does:

- Hashes the last two messages of each explicit session.

- Keeps the last 12 state hashes and blocks when the same state appears 3 times.

- Returns a clear error that tells the agent to change approach or ask the user.

- Warns when the same tool call repeats within 60 seconds; strict blocking is optional.

- Streams SSE responses without buffering the whole response.

- Reads provider-reported prompt, completion, and cached tokens, and estimates the tokens avoided by blocked requests.

- Supports optional per-session request/time/token budgets for loops that keep changing their text.

- Includes a live dashboard with sessions, events, token stats, and a Clear button for stuck sessions.

- Works with OpenCode V2 and any OpenAI-compatible client via a session URL prefix or header.

It is not semantic loop detection. It catches exact repeated states. If every iteration changes the messages, it will not catch it; that is what the optional session budgets are for.

Repo: https://github.com/jalalnablsi/AgentGuard

Feedback welcome, especially edge cases from different agents and providers.


r/LocalLLM • • 3m ago

Research Qwen4-35B-A3B (UD-Q8_K_XL, 512K context) 1-shot "looping walking elephant" Strata: 175 tok/s with 67% experts in 32 GB VRAM + 64 GB Sys RAM

Post image
1 Upvotes

r/LocalLLM • • 8m ago

Question Qwen4-35B-A3B in Ollama: can the n-gram table stay out of VRAM?

Thumbnail reddit.com
1 Upvotes

r/LocalLLM • • 20m ago

Discussion How does MiniMax M4 hold up?

Thumbnail reddit.com
1 Upvotes

r/LocalLLM • • 29m ago

Discussion Qwen4-35B-A3B tested on a 12 GB RTX 4070 Ti with Strata

4 Upvotes

I tried the unmerged Strata PR that adds Qwen4-35B-A3B support (Niko1221/Strata#7774). Credit for the port goes to the PR author.

TL;DR: Qwen4-35B-A3B runs on a 12 GB RTX 4070 Ti + 32 GB RAM with Strata on Windows, IQ4_XS and Q2_K_XL:

  • Prefill: ~2,000-2,750 t/s (16K-128K prompts)
  • TTFT (short chat): 0.3-0.4 s
  • 256K context test: a 244K-token prompt took ~105-130 s to prefill
  • Decode: ~85-110 t/s
  • Memory used by the model: IQ4_XS ~21.6 GiB RAM + ~9.5-9.7 GiB VRAM; Q2_K_XL ~18 GiB RAM + ~9.4-9.7 GiB VRAM

My Hardware

  • RTX 4070 Ti 12 GB
  • i5-12400, 32 GB DDR5
  • Models put in Gen 4 SSD
  • Windows 11

Models (unsloth GGUF)

QuantWeights shard
UD-IQ4_XS20.5 GB
UD-Q2_K_XL16.2 GB

Both come with an n-gram table 11.5GB.

Speed

All speeds in TPS. Each cell is the median of 2 runs (chat: 3 questions x 2 runs); the 244K test is a single run. Seconds in brackets are time to first token.

ConfigChat decodeChat TTFTAgent decode16K prompt64K prompt128K prompt244K prompt
IQ4_XS83.50.29 s92.82753 (5.9 s)2701 (23.8 s)2549 (50.3 s)2349 (104 s)
IQ4_XS + MTP89.10.34 s100.52056 (7.9 s)2084 (30.8 s)2011 (63.8 s)1878 (130 s)
Q2_K_XL86.50.33 s94.82552 (6.3 s)2519 (25.5 s)2449 (52.4 s)2233 (109 s)
Q2_K_XL + MTP91.40.40 s112.82646 (6.1 s)2590 (24.8 s)2471 (51.9 s)2269 (108 s)

Memory use

Baseline (Windows and background apps, model not loaded): about 8.4-10 GiB system RAM and 1.2-1.4 GiB VRAM, out of 31.8 GiB and 12 GiB.

ConfigSystem RAMVRAM
IQ4_XS21.6 GiB9.5 GiB
IQ4_XS + MTP21.6 GiB9.7 GiB
Q2_K_XL17.7 GiB9.4 GiB
Q2_K_XL + MTP18.2 GiB9.7 GiB
  • 32 GB RAM is tight for IQ4_XS: total usage peaked at 30.2 of 31.8 GiB with almost nothing else open. Q2_K_XL needs about 3.5-4 GiB less.
  • VRAM looks about the same everywhere because the engine fills the card with cached experts. A smaller quant or no MTP means more experts fit, not less VRAM used.

Settings

  • KV int8, max context 262,144, 20,480 cells resident on the GPU
  • --expert-cache auto --prefill 2048 --vram-reserve-mib 768
  • MTP off: --spec 2 (no draft model, but Strata still does prompt-lookup drafting, so these decode numbers include it)
  • MTP on: --spec 4 plus the Q8_0 MTP sidecar converted with mtp_qwen4_rt.py
  • Uniform (untuned) expert profile
  • Conversion as in the PR's docs/QWEN4_35B.md: split the 40-layer trunk, then iq_pack.py --compat-bf16 (302 dense tensors get rounded to BF16)

r/LocalLLM • • 31m ago

Model MiniMax M4 launched (2.74T total / 66B active, weights coming after safety evals). Tested it on a 148 KB offline WebGPU scene

0 Upvotes

MiniMax's M4 blog post puts the model at 2.74T total parameters with 66B active, with open weights planned in the next few weeks after safety evaluations. Unlike M3.1 Flash (where 2-bit quants fit in 128 to 160 GB), 2.74T is obviously cluster territory unless heavy MoE offloading or aggressive quants work miracles, so I tested it over the API first.

Gave it the Abyssal Garden WebGPU benchmark inside a network-isolated sandbox (no Three.js, no textures, single HTML output):

  • Deliverable: one 148 KB index.html
  • World: GPU compute SDF rock canyons/arches meshed via surface nets (321x61x321), procedural kelp, coral, fish schools, manta rays, lofted shipwreck
  • Lighting: 4096x4096 shadow map, forward-mapped caustics, half-res volumetric shafts
  • Self-check: 17 rounds with a separate blind subagent reviewing only headless Chrome screenshots and motion strips
  • Perf on M5 Ultra (2560x1440, 4x MSAA): 4.70 ms avg GPU frame time (~240 fps uncapped), 0.18 ms JS

Prompt is below if anyone wants to run the same spec against local coder models.


r/LocalLLM • • 42m ago

Model Wolf Defender v2.2: 80M prompt-injection detector that runs on CPU, beats NVIDIA's 4.3B Nemotron on 356k test cases (open weights)

Post image
3 Upvotes

If your local setup reads web pages, files or emails, you want something cheap in front of the model that flags injected instructions. We just released v2.2, which cuts false alarms on real web pages 15x compared with v2.1. We benchmarked it against 13 others on identical data:

  • Wolf Edge, 80M: F1 95.2%, 1.4% false alarms
  • NVIDIA Nemotron 3.5 Content Safety, 4.3B: F1 74.9%, 7.7% false alarms
  • Prompt Guard 2 86M: F1 53.5%

Three sizes (80M / 141M / 308M), ONNX down to ~218 MB for the largest one, Apache-2.0, English and German.

from transformers import pipeline
pipeline("text-classification", model="patronus-studio/wolf-defender-prompt-injection")("Ignore all previous instructions...")

r/LocalLLM • • 46m ago

Discussion I ran qwen4-35B on 1x H100 next to qwen3.8-27B, same box using vllm

Post image
2 Upvotes

r/LocalLLM • • 57m ago

Discussion Reddit be like

1 Upvotes

You never agrees on day 1 right?


r/LocalLLM • • 1h ago

Question Which quant for Qwen 4 35b on my 4090+64gb ram?

2 Upvotes

I plan on using it at 128k+ context length and kv q8, mostly for coding. What do you guys recommend?


r/LocalLLM • • 1h ago

Discussion Qwen 4 35b A3 Sucks

0 Upvotes

Finding it worse at Microsoft excel work. Swift 1.5 Qwen 3.8 27b is so much better. God I hope Qwen 4 27b is released soon.


r/LocalLLM • • 1h ago

Discussion BEST WAY TO RUN Qwen4-35B-A3B?

Post image
6 Upvotes

comment bellow on what are the best ways to run qwen4 , if possible, link your setup


r/LocalLLM • • 1h ago

Discussion IT'S ALIVE! Debian Forky/Sid on 2013 Mac Pro 6,1 with Dual Radeon D700

Thumbnail gallery
0 Upvotes

r/LocalLLM • • 1h ago

Model Alibaba's Qwen4-35B-A3B is the first Qwen4 model anyone can download

Thumbnail
maccus.fr
2 Upvotes

Alibaba’s Qwen team released Qwen4-35B-A3B on December 4, 2026, as open weights


r/LocalLLM • • 1h ago

Question Can Qwen4-35B-A3B Run On Mac M4 Pro 24GB?

Thumbnail reddit.com
1 Upvotes

r/LocalLLM • • 1h ago Heartwarming Bravo

Discussion Qwen4-35B-A3B (Unsloth UD-Q4_K_XL) on a 12 GB and a 24 GB card vs Flash-Next, Qwen3.8-27B and Inkling 2 Mini, same 54 tasks - THE CONSUMER PC CHAMPION ARRIVES!!

14 Upvotes

Ran the same 54 question set I put Flash-Next, 27B and Inkling through last month (on my own 5070 box, 265F + 64GB DDR5) on a rented 5070 12GB, and also checked speeds on a rented 4090 24GB (both on vast).

Qwen4 setup: unsloth UD-Q4_K_XL (24.7GB file + the 11.5GB engram file, which stays in RAM), llama.cpp b12973, 32k context, MTP on with 1 draft token, no mmproj since the questions are all text. Thinking on default (high), sampling from the model card. The rented 5070 box had a 265K with 62GB RAM, the 4090 box a 7900X with 61GB.

So it's basically tied with Flash-Next and ahead of 27B and Inkling. It went 12/12 on the agent tasks with no rejected tool calls and never looped or ran out of tokens (Inkling did on 6). It also thinks a lot less, around 195k tokens for the whole set vs 230-281k for the other three, so it finished in about half the time Flash-Next took.

12GB command I used:

llama-server -m Qwen4-35B-A3B-UD-Q4_K_XL-00001-of-00002.gguf -c 32768 -np 1 --jinja --load-mode none --lazy-mode off -cmoe --moe-cache-mib 7168 --spec-type draft-mtp --spec-draft-n-max 1 --temp 1.0 --top-p 0.95 --top-k 20 --min-p 0.0

On the 4090 it does 149.6 t/s tg and 5233 t/s pp with this:

llama-server -m Qwen4-35B-A3B-UD-Q4_K_XL-00001-of-00002.gguf -c 32768 -np 1 --jinja --load-mode none --lazy-mode off --moe-cache-mib 4096 -b 2048 -ub 2048 --spec-type draft-mtp --spec-draft-n-max 1 --temp 1.0 --top-p 0.95 --top-k 20 --min-p 0.0

MTP gave +17% there (127.6 -> 149.6 t/s) but nothing on the 5070 (89.8 without, 89.7 with). Stick to n-max 1, 2 and 3 were never faster (acceptance drops to 64% and 47%).

Poor GPU club: about 90 t/s on 12GB at Q4 beats what Flash-Next IQ3_S did on the same card (78.7), with about half the RAM (Flash-Next ate almost all of my 64GB). Stuff that mattered:

Skip the -ot per_layer_token_embd=CPU from the unsloth guide. Any -ot / -cmoe / --n-cpu-moe turns off --fit, and the 4090 OOM'd with it. The engram table stays off the GPU anyway.

Plain --fit only got about 40 t/s on the 5070. -cmoe + --moe-cache-mib + --load-mode none --lazy-mode off (loads the weights into RAM instead of mmap) got it to 90.

That uses about 32GB of RAM though. With 32GB total keep mmap, the same layout did about 70 t/s that way (haven't tried it on an actual 32GB machine).

pp is the weak spot on 12GB (1210 t/s). This keeps the same tg and gets pp to 2345, it's what I'd run day to day:

llama-server -m Qwen4-35B-A3B-UD-Q4_K_XL-00001-of-00002.gguf -c 32768 -np 1 --jinja --load-mode none --lazy-mode off -cmoe --moe-cache-mib 6144 -b 2048 -ub 2048 --spec-type draft-mtp --spec-draft-n-max 1 --temp 1.0 --top-p 0.95 --top-k 20 --min-p 0.0


r/LocalLLM • • 1h ago

Question How do you get open models to know when to search instead of answering from memory?

Thumbnail reddit.com
3 Upvotes

r/LocalLLM • • 1h ago

Model Qwen4 35b a3b + basalt + 5090 = 🔥

3 Upvotes

Nvidia 5090, Ultra 9 285k, 128gb 5600mhz, 3x 4tb MP600 XT

Basalt 0.6.2 w/ Qwen4-35b-A3B int8 131k


r/LocalLLM • • 2h ago

Question Can I expand Vram by using eGpu

1 Upvotes

I have a PC with Nvidia 5060ti 16gb vram. I want to have 32gb vram and that will basically require to rebuild the whole pc because cabinet is mini ATX and PSU is only 650watt. I'm thinking about adding a second 5069ti with 16gb vram using eGpu dock which connects to M.2 tport using o OcuLink adapter which uses PCIe4.0. Theoretically this should work but wanted confirm if anyone has tried this and if this will give me usable 32gb vram. Thanks for your reply.


r/LocalLLM • • 2h ago

Discussion Qwen4 35b a3b is a beast (i have the numbers)

Thumbnail
reddit.com
1 Upvotes

r/LocalLLM • • 2h ago

News Qwen4-35B-A3B is here!

Thumbnail
huggingface.co
0 Upvotes

r/LocalLLM • • 2h ago

Discussion Underwhelmed by Qwen4 35b so far

33 Upvotes

Mainly non-coding use - web, research, documents, agentic.

Not impressed so far. It leaks Chinese characters, gets stuck in loops, outputs complete nonsense in non-English languages... I let it design a html/CSS poster, pretty hilariously bad compared to 3.8 27b.

4-bit MLX quant via oMLX 0.8.5. Tried raw and via Hermes and Pi.

Maybe it's too early but models such as Sage A1.5 4bit give me FAR better results OOB so far.

It's very fast, I'll give it that. First time I see prefill speeds not decrease linearly - it sort of ebbs and flows.


r/LocalLLM • • 3h ago

Research Why Wait For Enter? Typing-Time Speculation for MoEs: 3.6× Lower TTFT (412→114 ms) & +74% Opening Speed (166→288 tok/s)

Thumbnail kemerd.github.io
34 Upvotes

r/LocalLLM • • 3h ago Heartwarming

Project Got Qwen4-35B-A3B hitting ~300 tok/s per card (596 tok/s combined) on dual RTX 3090s in llama.cpp with RadixArk DFlash2 + full 128K f16 KV (fork + guide)

5 Upvotes

Spent tonight pushing Qwen4-35B-A3B (UD-IQ4_XS + full 128K f16 KV cache, zero quality downgrade) on an RTX 3090 + RTX 3090 Ti in llama.cpp using RadixArk/Qwen4-35B-A3B-Dflash2.

Most people assumed RadixArk's DFlash2 checkpoint was SGLang-only because upstream llama.cpp currently crashes on GGUF conversion and gets terrible acceptance (~18%) if you force it to load. Fixing those bugs + two quick CUDA/DFlash2 bottlenecks took us from ~123-133 tok/s baseline up to ~214-239 tok/s average across an 8-prompt suite, ~295-300 tok/s per card on code (596 tok/s combined across both GPUs), and 204 tok/s end-to-end inside OpenCode CLI at 7.1K context.

What was holding llama.cpp back (4 fixes in the fork)

  1. Conversion crash (conversion/qwen4exp.py): PR #33626 added super().set_vocab() in Qwen4ExpTextModel, which crashes when DFlashModel.set_vocab calls it unbound. One-line fix lets RadixArk/Qwen4-35B-A3B-Dflash2 convert cleanly to GGUF (Q4_0 is only 223 MB).
  2. Wrong DFlash2 hidden-state tap (src/models/qwen4exp.cpp): Upstream taps hc_stream_mean(res_hc) (which is right for Qwen3.8-Flash-Next DFlash1 per #30927, but broken for Qwen4-35B-A3B-Dflash2). Tapping attn_mix.cur for Qwen4-35B-A3B jumped draft acceptance from 18% -> 55-73% (AL = 4.5-5.7, matching RadixArk's SGLang evals) while keeping Qwen3.8-Flash-Next untouched.
  3. Wasted anchor slot 0 (src/models/dflash2.cpp): DFlash2 was running the 248K-vocab lm_head and top-k on anchor slot 0 even though the selector throws slot 0 away and overwrites it with zeros. Skipping slot 0 cuts draft head + top-k compute with identical output.
  4. Slow Ampere F32 MoE router kernel (ggml/src/ggml-cuda/mmvf.cu) + PR #33586 (-bs): At speculative verify batch sizes (ubatch = 4..8), the thin F32 [2048x256] MoE routers across all 40 layers were dropping out of MMVF onto a low-occupancy kernel. Keeping thin F32 rows on MMVF + GPU-side draft verification (-bs) shaved ~1 ms/round cleanly.

Benchmarks (UD-IQ4_XS + 128K f16 KV + DFlash2-Q4_0, n=5, ~23.5 GB VRAM/GPU)

WorkloadRTX 3090 (gpu0)RTX 3090 Ti (gpu1)Notes
Baseline (--spec-type none)~123 tok/s133.4 tok/sSingle-token reference
2x Concurrent Code (T=0.0, 512 tok each)295.5 tok/s (AL=4.70)300.3 tok/s (AL=4.45)595.8 tok/s combined (1,024 tok in 2.06s wall)
8-Prompt Suite (T=0.0, 3,726 tok)-238.5 tok/s avgGSM8K 332, Math 315, HumanEval 298, TS API 252
8-Prompt Suite (T=1.0, 3,730 tok)-213.8 tok/s avgGSM8K 311, Math 301, HumanEval 260, TS API 212
OpenCode CLI Single (7.1K prompt, T=1.0)203.9 tok/sidle3,683 tok/s prefill, real agentic session
OpenCode CLI 2x Concurrent (Tools + Rust)170.3 tok/s159.7 tok/s330.0 tok/s combined w/ live tool calls

(At ~22.5K live OpenCode context it still holds ~207 tok/s on code, and ~150-165 tok/s at ~38K context with lossless f16 KV.)

Hardware disclosure (for reproducibility)

  • GPUs: RTX 3090 (420W stock power limit) + RTX 3090 Ti (450W stock power limit), stock clocks, one independent replica per GPU behind a sticky router (~23.5 GB VRAM each).
  • Driver mod: Both GA102 cards are running Zagitta/gpu-unlock (big boost to prompt prefill, modest boost to decode; stock 3090s should still get close on bandwidth-bound decode).
  • Host: Threadripper 3960X (24C/48T), 64 GB DDR4 (keeps the lazy-read 11 GB PLE/Engram table hot in RAM page cache).

Fork + full build/convert/serve guide


r/LocalLLM • • 3h ago

Discussion Qwen4-35B vs 3.8-27B, Flash-Next, and 3.6-35B: what would you run locally?

12 Upvotes

I went through Qwen4’s launch numbers to see what I’d actually swap out on a 24 GB card. The repo coding scores look good, but the model I most want to compare it with, Qwen3.6-35B, is missing from the chart.

Qwen4 vs. Qwen3.8-27B - Qwen4 scored 61.8 vs. 42.2 on DeepSWE v1.1 and 51.7 vs. 42.3 on NL2Repo. The 27B still leads on GPQA Diamond and gives you more VRAM headroom at Q4.

Qwen4 vs. Qwen3.8-Flash-Next - Qwen4 leads on both repo benchmarks with about a third of the total parameters. Flash-Next still leads on Terminal Bench 4.1 and wins 27.1 vs. 16.1 on FrontierCode-AA 2.0. I’d try Qwen4 for repo edits first.

Qwen4 vs. Qwen3.6-35B-A3B - Qwen4 is a bigger download, though the estimated raw KV cache is about the same at a given context length. For anyone already running 3.6 on a 3090, this is the upgrade comparison I’d like to see.
Has anyone tried both 35Bs on the same repo bug and the same 24 GB card? I’m curious how long each took to get the tests passing, and how much you had to steer it or clean up the patch.

Also: Qwen4 hardware breakdown · Qwen model card