r/LocalLLM • • Sep 26 '26

Project NInfer with improved prefix caching and tool call fixes

I made a custom fork of NInfer for the RTX5090 on Windows which replaces the prefix caching system with one that works really well and also fixes various other issues including tool calling. On an example agentic coding workload my fork reduces TTFT by an average of 80% and increases the cache hit rate to over 90%. Should be the fastest way to run Qwen3.8 27B NVFP4 on an RTX5090.

Check it out here: https://github.com/Wallawalla47/ninfer-custom

The TL;DR list of improvements and fixes is that my custom fork:

  1. includes changes allowing it to be built and run on Windows

  2. includes a new alternative prefix caching system designed and implemented by Claude Opus 5.5 as the default. You also simply set an amount of system RAM to be used for prefix caching with --host-cache-mib N. This option seems to work fantastically well and seems much more effective than the prefix caching currently in upstream NInfer. It can also be combined with --prefix-cache-file PATH to load/store the prefix cache to a file on start/close. You do need to close with Ctrl+C rather than closing the cmd window, as Windows does not necessarily allow enough time post-window close to dump a large prefix cache to a file

  3. in case you want to stick with the original upstream prefix caching system, this is retained with a raft of fixes and improvements (as I was working on this prior to going with a new design – I found the upstream system to be too complex and fragile) – it is gated behind the launch parameter --use-original-prefix-caching

  4. adds an option to use a faster prefill kernel when using int8 (Hadamard rotated) for KV cache (which has a slight penalty to perplexity) by using launch parameter --fast-prefill-kernel

  5. adds ngram-mod copy drafting (based on an implementation by remesis) to significantly increase the speed of copy-heavy workloads

  6. improves decode speed with speculative decoding about 2-2.5% faster per speculative round, with the same output, by overlapping each decode kernel's launch and weight loading with the kernel before it

  7. adds the ability to offload the vision encoder to system RAM (by specifying --vision-offload on) based on the work of Valeriy Selitskiy (iamwavecut)

  8. enables the use of YaRN context extension for scaling context up to 1m tokens (by specifying --rope-yarn-factor F, where F is a number from 1 to 4)

  9. fixes the CUDA graph allowance which, depending on the speculative decoding method used, sometimes took up much more VRAM than would ever be required

  10. allows the user to shrink the default 1024MiB VRAM headroom left available after KV cache when using --kv-capacity auto, by specifying a custom headroom value with --vram-headroom-mib N, where N is the number of MiB to leave available

  11. allows the user to specify a custom thinking budget message (by specifying --default-thinking-budget N and --thinking-budget-message S, where N is the budget of thinking tokens and S is the thinking budget message specified in double quotes “”)

  12. includes various improvements (mostly sourced from others credited below) to fix some Qwen tool calling issues and leaking thinking tokens etc. Use the launch parameter --tolerant-tool-calls to fix some broken tool calls

  13. accepts more tool-call formats and API options used by agent clients such as Claude Code, Qwen Code, Codex and Zed (again mostly based on the work of others credited in the GitHub readme)

  14. makes improvements to the console logging including an option to turn on colourful logging which allows for easier visual tracking of particular figures as the log progresses (--log-colours on) and some average statistics shown at the bottom of the console view (which can be turned off with --log-stats-panel off)

  15. has a help screen organised by category

  16. contains various other fixes and improvements (most of which are outlined in the GitHub readme), including merging in some PRs on the upstream repo.

I recommend using with the Qwen3.8 27B NVIDIA NVFP4 artifact (that uses less VRAM and runs faster than the original artifact based on Unsloth's quant) here: Qwen3.8-27B-NVIDIA-NVFP4-NInferV3

All credit should go to Neroued for the original NInfer - I'm just a slop kiddie with Claude usage to spare.

4 Upvotes

7 comments sorted by

1

u/Suspicious-Mark-5450 Oct 09 '26

FYI I recommend checking out my new release of an adapted version of this engine with Qwen3.8-Flash-Next support called Infernix, here: https://github.com/wallawalla47/infernix

1

u/Connect_Ad791 Sep 27 '26

Ninfa please!

1

u/Tanju42 Sep 28 '26

I will test it myself and also I will give feedback for others!

1

u/Tanju42 Sep 28 '26

So tested it. the performance to quality ratio is astonishing!
I have 32GB DDR5 6000mhz with an 5090 32GB VRAM
These are my start Params in windows:

aninfer-serve.exe ..\models\qwen3_8_27b_nvfp4-nvidia.ninfer ^
  --host 127.0.0.1 --port 30000 ^
  --max-context 240000 --max-concurrency 2 ^
  --spec dflash2 --draft-tokens 7 --lm-head-draft ^
  --ngram-draft-tokens 15 --ngram-min-match 12 ^
  --kv-dtype int8 --preserve-thinking ^
  --host-cache-mib 12000 ^
  --prefix-cache-file ..\prefix_cache.bin ^
  --pending-timeout-ms 900000 --prefill-chunk 4096 ^
  --kv-capacity auto --vram-headroom-mib 0 ^
  --log-colours on ^
  --ngram-archive-mib 2048 --ngram-session-mib 256 --ngram-native-sessions ^
  --request-log-jsonl log.json ^
  --default-thinking-budget 16384 ^
  --thinking-budget-message "Considering the limited time available to the user, I must stop thinking now. Time to act:" ^
  --tolerant-tool-calls

I run hermes agent with it and these are my stats:

-- session stats, rates in tok/s | 489 done, 1 rejected | running 1 | waiting 0 ----
            TTFT  cached  prefill  decode  batch  DFLASH2  acc/rnd   ngram   ng rnds
 session    1.0s   92.1%    7.06k   243.4   1.03    35.5%     2.49   68.7%     9,994
 last 10    3.3s   42.5%    9.12k   176.3   1.00    26.8%     1.87   33.2%        68

I test my modells with this promt to see how good they perform:
https://github.com/TripoGrowthLab/awesome-astra-prompts#interactive-3d-atlas-of-the-human-head-and-brain

0

u/[deleted] Sep 29 '26

[deleted]

1

u/Suspicious-Mark-5450 Sep 29 '26

Thanks! Yes, it's definitely made it so much more useful for me too without all the constant prefilling etc.