One model, six aliases: how I'm tuning Basalt and Qwen4 to work with agents

Yesterday I published my tests of Qwen4 on Basalt, vLLM and Strata and ended by saying I was sticking with Basalt and that the next step was optimizing it. Well, that's what my Saturday went on.

Picking an engine is the easy part. What really changes your day-to-day is how you configure it to work well with agents, and how you connect it to everything else. In my case, OpenCode doesn't call one model, it calls six, even though underneath they're all the same Qwen4 loaded once on the GPU.

So this article covers two things: what I've changed in Basalt (and what I've left alone), and how I've set up LiteLLM so a single model behaves like six.

First things first

This is how I'm setting it up, not the right way to do it. I'm not an inference expert. I'm a Drupal developer who built a server to work with agents, and a lot of the decisions in this article come from what Claude Code suggests as we configure and measure things together. So there may be mistakes, and in fact further down I'll tell you about a couple we made along the way.

On top of that, everything is still in beta. Basalt runs from the main branch, with no release, and the model is two days old. I'll keep polishing this setup as new versions come out and, above all, once I've been working with it for a few weeks and see what breaks on real tasks.

What I didn't touch: temperature

The first thing you think of when using a model to generate code is lowering the temperature. With this model, that would be a mistake.

Basalt serves Qwen4 with temperature 1.0, top_p 0.95 and top_k 20, which is exactly what Qwen recommends for reasoning mode. And they explicitly warn against using temperature 0 when the model thinks a lot, because it ends up falling into loops and repetition. The more conservative values they also publish are for non-reasoning mode, which is a different thing and comes up further down.

Effort levels aren't what they seem

Qwen4 accepts six reasoning effort levels. I measured all of them with the same question:

LevelTokens generatedTime
off1,6134.3 s
low6,31318.7 s
medium18,39451.3 s
high19,54355.6 s
xhigh22,08667.2 s
max22,29368.9 s

medium and high are almost the same, barely 6% apart. And xhigh and max are indistinguishable. The only really big jump is between low and medium, which nearly triples the tokens.

In other words, in practice there are four steps, not six. And it caught me out completely: I had two aliases set to medium, thinking they were one step below high, and they were practically the same.

Capping reasoning, but not everywhere

Yesterday's article already showed that capping reasoning tokens is what moves the needle most on time: with a 20,000-token cap, the Drupal migration task took half the time with an equally complete answer.

But there's a nuance I don't want to skip. All of that was measured on single-turn tasks, and Qwen's documentation warns that in multi-turn agentic work, thinking less doesn't always save time: if the model doesn't analyze enough, it can end up retrying again and again and taking longer overall.

That's why I haven't set a global cap on the engine. I've set it per alias, in the layer in front, which is what the second half of this article is about.

Basalt settings meant for agents

Basalt has a couple of options that only make sense when the model works with tools, and I've turned them on:

  • --force-call-on-reopen: if the model has tools available and starts thinking again without saying anything or calling anything, it cuts that block and forces it to act. It avoids those turns where the agent just keeps mulling things over.
  • --thinking-loop-tokens 256: cuts the reasoning if it repeats the same thing 256 times in a row. It's a safety net for when I leave it working alone overnight.

I haven't been able to measure whether they help, because they're for situations that don't show up in a benchmark. But they cost nothing, and the problem they prevent shows up right when you're not looking.

I also raised the number of concurrent requests from 8 to 16. With 16 requests at once, total throughput went from 899 to 1,015 tok/s, 13% more. To be honest, with 8 requests it came out a bit worse than before, so part of that difference may be run-to-run noise. I'm leaving it at 16 because OpenCode launches subagents and I'd rather they didn't sit waiting for a slot.

Prompt caching, what surprised me most

When you work with an agent, the whole conversation gets resent on every turn: the system prompt, all the previous messages and the new one. If the engine had to read all of it every time, a 100,000-token conversation would take about eight seconds per turn before writing anything.

Basalt doesn't do that. I measured it with a growing conversation, using what the engine's own log reports:

TurnPrompt tokensReusedPrompt read time
110,21301.1 s
210,35910,3320.0 s
310,50510,4780.0 s
410,65110,6240.0 s

From the second turn on, reading the prompt is free. Basalt also recognizes the session headers from OpenCode and Claude Code, so each session and each subagent keeps its own slot.

The practical question is when that cache gets lost. And the answer isn't what I expected: it doesn't expire over time. I left a conversation idle for five minutes and when I picked it back up it reused practically everything. What kills it is other conversations pushing it out. With 16 slots, I launched 20 different conversations and when I went back to the first one there was nothing left. Conversation number 17 kicks out the oldest one.

Parking large conversations in RAM

For that, Basalt has an option, off by default, that instead of throwing away the evicted conversation, stores it in RAM and restores it when it comes back. With it turned on, the conversation from the previous example came back with 98% reused.

The question I asked myself before turning it on was how much RAM it uses. Measured, it comes to about 16 KB per parked token:

Conversation ofRAM when parkedCost of re-reading it
10,000 tokens~160 MB0.8 s
100,000 tokens~1.6 GB7.7 s
1,000,000 tokens~16 GB77 s

That's where the setting comes from. Parking a small conversation isn't worth it, because it gets re-read in under a second. So I only park the ones over 16,384 tokens, which are the ones that actually cost seconds, with a cap of 32 GB of RAM for this. I checked both sides: a 28,500-token conversation came back whole, and a 6,000-token one wasn't parked and used nothing.

What I tried that didn't work

This is where I learned the most, because intuition gets it wrong quite a bit.

Moving the n-gram table to RAM. The model file takes up 43 GiB, but only 19.4 of that is weights. The rest is a table Basalt reads from the SSD, and it looks like the obvious candidate to load into memory. The option exists, I tried it and it gains nothing: same speed reading and generating, and 19 GB more RAM. The explanation is that those reads already go through the kernel's file cache, so the table ends up in RAM anyway as it's used.

Saving conversations to disk. According to the documentation, it should let you restore conversations even after a restart. It writes the files, but after restarting and continuing the conversation it re-reads the whole thing. I haven't turned it on.

Using the free VRAM. With everything loaded there are about 73 GiB free on the GPU, and the temptation is to put something there. But it isn't really free, it's the space for the context cache, which in this setup is enough for almost 8 million tokens shared across all the agents. Filling it would mean taking away context.

And the memory placement was already right out of the box: the weights and all the model's experts are on the GPU, with none left outside. That's what would really affect speed, and there was nothing to move.

This is the configuration I'm running now:

basalt serve /modelos/Qwen4-35B-A3B-NVFP4.basalt \
  --max-running 16 --vision dynamic --max-context 1048576 --kv int8 \
  --force-call-on-reopen --thinking-loop-tokens 256 \
  --conversation-cache-mib 32768 --conversation-cache-slots 24 \
  --conversation-cache-min-tokens 16384

One model served as six

The other half of the work isn't in the engine, it's in the layer in front of it.

My OpenCode agents don't call a specific model. They call six generic names and use each one for something different: MODEL_GENIUS for architecture and hard debugging, MODEL_SMART for serious work, MODEL_NORMAL for day-to-day stuff, MODEL_VISION for anything with images, MODEL_CHEAP for narrow tasks and MODEL_APPLIER for applying code edits and compacting conversations.

Until now all six pointed to the same local model, and the difference between them, basically how much each one thinks, was written in OpenCode's configuration. It worked, but to change anything I had to edit the agent and restart it, and that configuration only worked for that client.

Now LiteLLM handles it. It has six entries pointing to the same Basalt, each with its own reasoning level, cap and sampling, plus a map that translates each generic name to its entry:

AliasEffortReasoning capTokens generated (same question)
MODEL_GENIUSxhigh40,00027,464
MODEL_SMARThigh20,00017,716
MODEL_VISIONhigh12,00014,154
MODEL_NORMALlow8,0007,677
MODEL_CHEAPlow4,0005,334
MODEL_APPLIERno reasoning-1,010

I asked all six the same question going through OpenCode, LiteLLM and Basalt, and you get a clean scale, from 1,010 to 27,464 tokens, with a single model loaded on the GPU. Before, with the two medium ones, I really only had four distinct aliases.

Look at the last row. The alias that applies edits doesn't think, so it uses the model's non-reasoning mode, and for that mode Qwen recommends different parameters: temperature 0.7, top_p 0.8 and some repetition penalty. Before, it was inheriting the 1.0 temperature from reasoning mode without me noticing. It's one of those details you only spot when you have the whole configuration in one place.

This setup gets me three things. Changing how an alias thinks means editing one entry in LiteLLM, without touching or restarting the agent, and the change applies to any client using that name. OpenCode's configuration stays clean, with just capabilities and context limits. And the model underneath is swappable: I have several containers with different engines and models on the same IP, only one of which can be running at a time, so shutting one down and starting another changes the model for the whole system without any client noticing.

A heads-up if you set it up this way: in LiteLLM, what you put in the entry are defaults, not hard rules. If the client sends its own reasoning level, the client wins. It works for me because I've removed those parameters from OpenCode, but it's worth knowing.

Mistakes along the way

I warned you at the start that I rely a lot on what Claude Code suggests. Here are two examples of why you have to measure before believing anything.

Reading Basalt's documentation, we saw that one type of drafter for speculative decoding was 54% faster than the other, and concluded we needed to turn it on. It turned out the model already had it on by default, and that on this GPU the real difference between the two is 6%. The documentation's numbers came from a different card and different tests.

And we nearly concluded that prompt caching didn't work, because the first tests showed zero reuse. The problem was the test: we were sending the system prompt and a new question without including the previous answer, so there was no conversation to continue. With the full history, the way a real agent does it, reuse was almost total.

And now, time to work with it

From now on, I'm going to use Qwen4 with this setup for local development, and I'll be on it for a good few weeks.

My feeling so far is that it works better for me than Qwen3.8. But that's all it is, a feeling. Between comparing engines and tuning the configuration, I've barely done any real work with it yet. The good thing is I've got something to compare it against: I've spent weeks and months doing similar tasks with the previous model, so as I use it I'll be able to see whether the work is really comparable and whether it comes out better or not.

I'm not sharing all this because I think it's the way to do it. It's because when I started building my server, it would have helped me a lot to see how other people had theirs configured. So if you're another nerd like me building your own server, and you're curious how someone else configures Basalt or uses Qwen with OpenCode, I hope you get an idea or two out of it. And if you've set yours up differently, I'd love to hear how.

Before it was a ticket. Now it's a prompt.

Does your Drupal leak?

Tell me what you are working on and what worries you. I'll reply personally and, if I'm not the right person, I'll tell you too.