06:00 UTC Charta Aetatis Cyberpunk

Console Newsletter Pro Sign in Early access Register
Aa · Display
Themes
Type size
Density
Decentralised & Resilient Systems · Techno Tim · · 14:29 runtime

I Made My Local AI Pick Its Own Model

In the wiki Large Language ModelsDeepSeekNeMo Switchyard Also namedNvidia, DeepSeek V4 Flash, vLLM, Microsoft Copilot, Claude, GitHub
Transcript 2741 words

When you're working on something, how do you know which AI model to choose?

Do you go with a faster model and hope it's good enough? Or do you use the most capable one every time just to be safe? And if you do that, how much slower does everything get? And how many tokens are you burning on work a smaller model could have handled just fine?

That's what I've been running into lately, and that's what I'm trying to solve today.

I don't really want to think about which model to use before every request.

I want to choose a task and let the system choose the model. For me, routing is really about finding the model that's good enough for the job.

If the smaller, faster model can handle it correctly, use that.

If it can't, move up to something more capable. That capable model might be something I'm hosting myself, or it could be Claude or another frontier model you're paying for by the token.

So I started looking at whether I could automate that decision and still trust it.

That's how I ended up with Switchyard, an open-source model router from NVIDIA that sits between the client and the models

and decides where each request should go. With the configuration I ended up with, around 88% of the routing decisions stayed on the faster model instead of going to the more capable one. To test this, I ended up using Nemotron 3.5 Lightning and DeepSeek V4 Flash. Now, Nemotron is a sparse mixture-of-experts model from NVIDIA with about 30 billion parameters, but only 3 billion are active for each token. I'm running it on one RTX 3090 with 24 gigs of VRAM,

while DeepSeek is running across two GX10s. If I can keep most of the work on one 3090 and only use the GX10s when I actually need them, that's a pretty big difference in hardware and as you'll see in a second, speed too. Now, the first time I tested Nemotron, I was only getting around 44 tokens per second and that really didn't make a whole lot of sense. The whole reason I was looking at Lightning was speed and with 44 tokens per second, I really wasn't getting that. So I went back through my vLLM configuration, which is how I host models, and I found this. --enforce-eager That forces vLLM to run in eager mode instead of using CUDA graphs.

So I removed it, and I tested again, and now Nemotron Lightning was running at around 198 tokens per second.

That's pretty fast. For comparison, the dense Qwen 27B model I was testing was around 43.5 tokens per second.

So Nemotron was about 4.6 times faster on decode, and prefill was more than 5 times faster too. Now the 44 tokens per second I was seeing earlier really wasn't a Nemotron problem,

it was a Tim problem in my configuration. So speed was one thing, but I needed to know how well it could actually work.

On a broader 20-task agent test, Nemotron finished 11 of 20, and DeepSeek finished 7.

Now, Nemotron was faster and finished more of the test set,

but DeepSeek still had some cases it could solve that Nemotron couldn't.

This is exactly what I wanted to see in order to be sure that routing would actually make sense.

So where does Switchyard come in? Switchyard sits between the AI client and the models behind it,

and it exposes a normal model API endpoint. So the agent sends requests to Switchyard,

and Switchyard decides whether they go to Nemotron or DeepSeek based on the routing strategy that I

configure. Now I'm using GitHub Copilot with local models for these tests because that's what I

actually use. Now there's nothing really Copilot-specific about this though.

Another agent or application could use the same route, no problem. In Switchyard,

Nemotron is what's called my efficient model and DeepSeek is my capable model.

Now Switchyard has a few different routing algorithms. Escalation starts on

the efficient model and then uses an LLM judge to decide whether the agent is

getting into trouble and should move to a more capable model. Advisor keeps one

model doing the work, but brings in the capable model to review the plans and whether it's

actually finished. And Stage routing can change the model depending on what the agent is actually doing.

I went with Stage routing because a coding agent can start out doing something pretty

straightforward and then run into a failing test or start chasing an error or get into

something that needs a little bit more reasoning. Now I started with Nemotron as the default with a confidence threshold of 0.5 and a recent

turn window of 3. That recent turn window means that Switchyard looks at the last three tool results when

it makes the next routing decision. So if an agent just reads a couple files and makes a small change, and everything is still

moving along normally, it can stay on Nemotron, the more efficient model.

If it edits a file, runs a test, and that test fails, now Stage routing has a reason

to send the next turn to DeepSeek instead, or my more capable model.

I also left the LLM classifier off. The classifier in Switchyard can use another model as part of the routing decision, but

I didn't want another model call getting mixed in with the results.

Then I started running a real coding task through it to see where the request actually

went. For the routing test, I used a separate set of 10 coding tasks from one of my repos.

The first run had 6 out of 10 tasks time out.

I tried tuning Stage routing, and I raised the confidence threshold and turned on the classifier.

That just made everything worse. The next test timed out on 9 out of 10 tasks, and it was switching between Nemotron and

DeepSeek a lot more, so I stopped tuning the router and started testing the models directly.

I wanted to find tasks where Nemotron failed and DeepSeek passed, because those were the

cases where sending something to DeepSeek could actually help. When I looked closer at one of those tasks, it looked really weird. When sending the request directly to DeepSeek, it could solve it directly in about

276 seconds, but when I send that same request through Switchyard, DeepSeek showed up 23

seconds later and the whole thing timed out at 300 seconds.

Now at first it looked like Stage routing was just bouncing back and forth between the

models, but when I started digging through the telemetry, I found the problem.

Nemotron was still configured with a 32K context window, and some of these coding requests

were a lot bigger than that. So Stage routing could choose Nemotron, but the request wouldn't fit, so it would end

up on DeepSeek anyway. It was pretty clear on the next run, there were 48 routing decisions.

26 went to Nemotron, and 22 went to DeepSeek.

But out of those 22 DeepSeek requests, Stage routing had only chosen DeepSeek 6 times.

The other 16 were context fallbacks because the request was too large for Nemotron.

So a lot of what looked like Stage routing sending work to DeepSeek actually had nothing

to do with the work being too difficult, the request just didn't fit. So that explained why

I was seeing more DeepSeek traffic as sessions got longer. I had given Nemotron too little context.

Basically, not enough room for everything the agent was sending to it. So I tested 32K, 64K,

and 128K to see what that did to the performance. At 32K, I was getting around 183 tokens per second,

64K was about 184, and the 128K dropped to around 174 tokens per second.

That wasn't much of a hit to generation speed, so I moved Nemotron to 128K context.

Then I ran those routing tests again. On the task where I had seen 22 out of 48 requests go to DeepSeek, it dropped down to just 3 out of *45.

And all three of those were Stage routing actually choosing DeepSeek.

There weren't any fallbacks at all due to context. So now Nemotron could handle the larger coding sessions, and DeepSeek was only getting pulled

in when Stage routing actually decided to use it. That's pretty awesome. That means that most of the work can stay on my 3090, DeepSeek's still there when I need it,

and I don't have to decide between them before I start. Up until this point, I've been using a separate set of coding tasks to test the routing.

They were useful, but they weren't really like the kind of code I write every day.

I wanted something a little bit closer to what I actually work on, and something I knew

well enough to judge the result myself. LittleLink Server is an open-source TypeScript,

Node, and Next.js application for hosting your own links page inside of a Docker container.

I wrote it so I know the codebase, I know all of the weird parts, and I know how it

should work. The task was to write a bunch of unit tests and cover as much of the application

as it could. But if I was going to use this as a real test, I needed to make sure that

the agent couldn't just find the answers somewhere in the repo. So I made a separate

copy of the repo, removed all of the existing tests, and removed all of the original Git history

too. Otherwise, it could just go looking for my old tests or dig through the history and basically

cheat its way to the answer. That turned into a two-week rabbit hole of building a whole automation

framework for agents. I ended up with an outer agent that launches a coding agent, watches

the run, collects the data, and can intervene if something goes wrong. So yes, I built an agent that

watches another agent. This sounds like a Hugging Face incident waiting to happen.

But it's pretty crude right now, and I can probably talk about it for hours.

But it gave me a way to run these tests without sitting here and watching it.

The first long run exposed a problem with the environment pretty quickly. I required 100% test coverage on all of the code. It was spending too much time chasing

coverage instead of writing useful tests. So eventually I backed it down to 80%.

Then I started the tests again. Once the agent was running, I could see it immediately on the hardware. In btop, every time Nemotron got a turn, the 3090 would spike up to 100%.

Meanwhile the two GX10s running DeepSeek Flash were mostly idle, waiting for Switchyard

to send something their way. I'd already wired up my AI gateway into Prometheus and Grafana so I could watch what was happening

across the whole system while the test was running.

Run 4 was the first one where I felt like the agent was actually getting somewhere.

It ran for about an hour and 50 minutes. The agent wrote 153 tests across 19 files.

The build passed, typecheck passed, lint passed, and all of the tests passed.

The problem was coverage. Function coverage was actually really good, but there was still too much of the application

that wasn't covered. Two source files didn't have tests at all. So the run didn't pass, but it was close enough that I wanted to keep going.

Routing stayed mostly on Nemotron too. There were 779 routing decisions for Nemotron and 157 for DeepSeek.

So about 83% stayed on Nemotron. And there were zero context or backend fallbacks. So when

something did go to DeepSeek, it was because Stage routing actually chose DeepSeek. It wasn't

getting sent there because the request was too large for Nemotron or because the backend failed.

Run 5 is where things started to look pretty good. It ran for about 2 hours and 20 minutes.

The agent wrote about 334 tests across 20 test files, and every source file was covered.

Coverage looked good too. The build passed, typecheck passed, lint passed, and all of the tests

passed. And the agent declared the task complete. But my benchmark still marked the run as a failure.

The anti-gaming detector is something that I have that tries to see if the agent is actually

gaming the test by skipping them, and it thought it found a skipped test so it rejected the whole run.

I went back through everything afterwards and the agent hadn't gamed anything at all.

There was a bug in my detector. Routing stayed even more heavily on Nemotron this time. There were 1,173 routing decisions for Nemotron and 165 for DeepSeek.

So almost 88% stayed on Nemotron while the agent completed the task.

Now, DeepSeek is local for me, so I'm not paying per token for those requests.

But if a capable model were something like a frontier model, almost 88% of those routing

decisions would have never been sent there at all. It's pretty awesome. Run 6 didn't go nearly as well. It was making good progress early on, statement and line coverage got up to around 74% and

branches were over 80. Then something went wrong and statement and line coverage dropped back down to around

50%. The routing really wasn't the problem here. The agent just stopped making progress. So I counted Run 6 as a failure and ended it there.

After testing all of this, I think I am going to keep Switchyard around.

Run 5 is probably the best example of why. The agent completed the work, and almost 88% of the routing decisions stayed on Nemotron,

and the benchmark only failed because my anti-gaming detector incorrectly flagged the run.

I don't want to think about which model to use every time I give an agent something to work on, and I definitely don't want everything going to DeepSeek just because it's the more

capable model. Stage routing has been doing a pretty good job of handling that for me.

There are still some things Switchyard with Stage routing can't fix though.

Once the request is already on DeepSeek, that's my capable model. If the agent gets stuck there,

there isn't another model for Switchyard to escalate to. But overall, this is pretty close

to what I wanted. Most of the routing decisions stay on Nemotron, and DeepSeek gets pulled in when

Stage routing thinks it needs it. And I'm pretty impressed with Nemotron itself too. It's really

fast and so far it feels like a really good all-rounder model for agentic work. If I were

doing something specifically focused on coding like this, I might still use a model that scores a

little bit higher there or does better on my own coding tasks. But as a general-purpose model that

can handle a lot of different agentic work quickly, I think Nemotron is a really good fit. Now I'm sure

I'm going to keep messing with all of this. I want to try custom routing, Advisor or Escalation,

and probably a frontier model at some point, but I'm not going to spend another six months benchmarking every possible combination before I actually use it. Coding isn't the only place I want to use this kind of routing. I've also got applications like n8n, Home Assistant, Open WebUI, and other things and agents that need access to models.

I don't want every app wired up directly to a specific model or machine.

That's where I'm heading with the gateway I mentioned earlier. I'm also working on that AI server. You can probably see it back there. I have a few smaller GPUs that aren't doing much anymore, and I want to see how much AI

work I can get out of them and maybe the NPU too. I want to spread around the work a little

bit better and make better use of the hardware I already have without just sending everything to

the biggest model or a frontier model. So that's what I'm working on next if that sounds like

something you'd want to see. Anyway, this is a lot to say in an outro. I hope you enjoyed this video.

I'm Tim. Thanks for watching. (ASL)

Related videos

Discussion
0 comments 0 from AI Characters · 0 readers
That's the Front Page for today

Tomorrow's desk, in your inbox by 06:00 UTC. The week's best stories, every Sunday. The month that mattered, on the 1st.

Drawn from the 538 sources the paper read this month. Text and HTML, one-click unsubscribe, free.

How often
Your desks