beckon
Beckon blog

LoRA Adapters for Coding Agents: Qwen3.8-27B in pi Explained

ยท Beau Johnson

In shortThe same open model scores differently in different coding agents because each has its own tools, prompt and loop. Hugging Face's 640 MB LoRA adapter took Qwen3.8-27B in pi from 39.5% to 55.8% on Terminal-Bench 2.1 (their own numbers) without changing a single base weight.

In this video I look at why the same open model scores differently depending on which coding agent runs it, and at the fix Hugging Face tried: a 640 MB LoRA adapter that teaches Qwen3.8-27B the habits of one specific agent, pi. I walk through how LoRA and QLoRA work, where the training data comes from, what the scoreboard really says, and when you shouldn't bother. It's for anyone who runs an open model inside a coding agent and wonders whether training is worth it.

What I cover in this video

  • 0:00 Same model, same benchmark, two agents, two scores.
  • 0:45 What a harness is, and why every agent names and formats its tools differently.
  • 2:16 What a prompt can change, and the habits it can't.
  • 3:47 LoRA in three steps, with the real numbers from the pi adapter.
  • 5:18 Merging or swapping adapters, and how QLoRA fits training on one GPU.
  • 6:50 Where the training data comes from: saved sessions versus reinforcement learning.
  • 9:05 The scoreboard, including the correction to the launch numbers.
  • 10:36 Should you train your own adapter?

Why the same model fumbles in one agent

A harness is the program wrapped around the model: its tools, its system prompt and its loop. The model asks for a tool, the harness runs it and sends back the result, and they go again until the job is done. (I cover that loop in more detail in Claude Tool Calls Explained.)

Every harness does this a little differently. pi gives the model four tools: read, bash, edit and write. Claude Code has its own set, and its edit tool takes different fields. Codex wants file edits written as a patch in its own diff format. The labs train on their own formats too: Anthropic says it trains Claude on its own bash and text editor tools, and OpenAI says GPT-4.1 was trained heavily on its patch format.

So a model gets good at the tools it practiced on. In Hugging Face's own runs, Qwen3.8-27B solves 39.5% of Terminal-Bench 2.1 inside pi and 46.4% inside OpenCode. Frontier models do it too: on the Terminal-Bench 2.0 leaderboard, Claude Opus 4.6 scores 58.0 in Claude Code and 76.4 in Meta-Harness. pi isn't bad. The model just isn't at home there yet. I ran a similar comparison myself in Claude Code vs Codex with the Same Model.

The obvious fix is to explain pi in the prompt. That helps, but it eats context every turn and it's only a suggestion. The habits stay the same: which tool the model grabs first, how long it thinks before it acts, when it decides it's done. Training moves those habits into the weights.

How LoRA and QLoRA get this into a 640 MB file

Training a 27 billion parameter model the normal way means updating all 27 billion numbers. LoRA (low-rank adaptation, a 2021 paper from Hu et al. at Microsoft) avoids that in three steps:

  1. Freeze the model. Every base weight stays exactly where it is.
  2. Add two thin matrices, A and B, next to each weight matrix you want to change. One feed-forward matrix in Qwen3.8 is about 89 million numbers. The rank 32 pair beside it is about 720,000 numbers, under 1% of the matrix it's changing. The input goes through the frozen matrix and the thin pair, and the two results get added together.
  3. Start the correction at zero. B starts as all zeros, so on the first training step the model is exactly the base model. Training only moves A and B.

Do that across all 64 layers and you get the whole pi adapter: 159,383,552 trainable numbers, about 0.6% of the model, in a file of about 640 MB next to a base of about 55 GB. Because it just adds on top, you can merge it into a regular checkpoint or keep it separate and swap. One server holds the base model once, and every harness gets its own little file.

LoRA cuts what you train, not what you have to hold. 27 billion weights at 16 bits is about 54 GB just to load. QLoRA (Dettmers et al., 2023) stores the frozen base in 4 bits instead, about 13.5 GB, and trains the adapter on top. In the paper, they fine-tuned a 65B model on a single 48 GB GPU. So a 27B model on one card is very doable.

Where the training data comes from

There are two ways to teach a model your harness:

  • Fine-tuning on examples. You collect sessions where the agent got the job done (every request, tool call and result) and train the model to copy them. pi already saves every session as a file on your machine.
  • Reinforcement learning. You give the model a task with hidden tests, let it try eight times, and the tests grade every attempt. That's GRPO. Since the attempts get compared with each other, it only learns from tasks where some pass and some fail.

Hugging Face's adapter is the RL kind: over a thousand tasks run inside the real pi, graded by each task's own checker, plus a small bonus for using fewer tool calls. There's a second, separate project on the same base: bytkim's Qwen3.8-27B-pi is a full fine-tune on successful pi sessions, then RL on top.

The examples route can backfire. bytkim's first QLoRA run on Qwen3.6 27B dropped from 42.70% to 28.09% in pi (Terminal-Bench 2.0, their own single run). A second version trained with the reasoning included got back to 40.4, still under the base. In OpenHands, a similar tune gained about 10 points.

The scoreboard, and whether you should train your own

These are the authors' own numbers from their own cards. I didn't run them, and none of this is independently measured yet. If the benchmark names are new to you, start with Coding Agent Benchmarks Explained.

  • Thinking off, one try per task, inside pi: SWE-bench Pro (the 51 hardest tasks) went from 39.2% to 64.7%, with 15 tasks newly solved and two lost.
  • Terminal-Bench 2.1 went from 39.5% to 55.8%. On tasks both versions solved, the adapter needed less than half the turns.
  • The launch post said 29.4% to 62.7%. The card corrected that: nine base runs had failed because a network tunnel went down. Credit to them for fixing it in public.
  • Part of the gain is just finishing in time. 20 of the base model's 31 failures on those hard tasks hit the hundred-step limit.
  • With thinking at max, base and adapter both reach 74.5% on the same SWE-bench Pro tasks.

So the real win is getting most of the way there without thinking, with about four and a half times fewer tokens.

If you run one open model in one harness every day and you have tasks with real tests, training can be worth it. But check the cheap fixes first. Try your own tasks in a couple of agents, since the base model scored about seven points higher on Terminal-Bench in OpenCode than in pi, while on SWE-bench Pro it went the other way. Turn thinking on. Or pick a bigger model and skip all of this. And remember an adapter only works on the exact base it was trained on.

Key takeaways

  • A model is good at the tools it practiced on. Different tool names, edit formats and prompts are enough to change its score.
  • A prompt tells the model what the tools are. An adapter teaches it the habits.
  • LoRA freezes the base and trains two thin matrices beside each weight matrix, which is how a 27B model's harness habits fit in about 640 MB.
  • The adapter's gain is mostly efficiency: with thinking at max, the base model reaches the same 74.5% on the hard SWE-bench Pro tasks.
  • If you do train, measure before and after on tasks you didn't train on. One builder's first run went about 15 points the wrong way.

FAQ

Why does the same model score differently in different coding agents?

Each agent harness has its own tools, system prompt and control flow, and a model gets good at the formats it practiced on. In Hugging Face's own runs, Qwen3.8-27B solves 39.5% of Terminal-Bench 2.1 inside pi and 46.4% inside OpenCode.

What is a LoRA adapter?

LoRA freezes the base model and trains two thin matrices beside each weight matrix, so the output is the base answer plus a small correction. Hugging Face's pi adapter for Qwen3.8-27B is 159,383,552 trainable numbers, about 0.6% of the model, in a file of about 640 MB.

What is the difference between LoRA and QLoRA?

LoRA cuts how many numbers you train, but you still have to load the full base model. QLoRA stores the frozen base in 4 bits instead of 16 and trains the LoRA adapter on top, which let the paper's authors fine-tune a 65B model on a single 48 GB GPU.

Should I train a LoRA adapter for my own coding agent?

It can be worth it if you run one open model in one harness every day and have tasks with real tests. Check the cheap fixes first: try your tasks in a couple of agents, turn thinking on, or use a bigger model, and if you do train, measure before and after on tasks you didn't train on.

Run your agents in Beckon

A workspace for your coding agents. Get more work done in less time.

Download BeckonSubscribe on YouTube
Full video transcript

0:00Same open model, same benchmark, two coding agents. In Hugging Face's own runs, Quen 3.8 scores 39 a half on Terminal Bench inside PI and 46 inside Open Code. Then they clipped a 640 megabyte file onto it and PI jumped to 55.8. Not one weight of the base model changed. But one builder's first try at this made their model worse. So, in this video, how Laura works, where the data comes from, the real scoreboard, and when to skip it. I run coding agents all day, so I had to know. Let's jump right into it. So, what is a harness exactly? It's the program wrapped around the model. The model only writes text. The harness hands it a list of tools, a

0:45system prompt, and a loop. The model asks for a tool. The harness runs it, sends back the result, and they go again until the job's done. So every harness does that a little differently. Pi gives the model four tools. Read, bash, edit, and write. That's it. Claude code has its own set, and its edit tool takes different fields. Codeex wants file edits written as a patch in its own diff format. Same job, different words for it. And the labs train on their own formats. Anthropic says it trains Claude on its own bash and text editor tools. And OpenAI says GPT4.1 was trained heavily on that patch format. So a model gets good at the tools it practiced on. Put it in a harness with different names, a different edit format, and a different prompt, and it fumbles.

1:30Hugging Face says it straight in their blog, the same model behaves differently in different agent harnesses because each one has its own tools, prompt, and control flow. You can see it on their model card. A real SWEBench Pro task inside PI fix one function. The base model searches, reruns little snippets, searches again, and hits the hundredstep limit. On those hard sbench tasks, 20 of the base models 31 failures ended exactly like that. Frontier models do it, too. On the terminal bench 2 leaderboard, Claude Opus 4.6 scores 58 inside Claude code and 76.4 in a harness called Metaharness. Same model. So, when Quen scores lower in PI on Terminal Bench, PI isn't bad. The model just

2:16isn't at home there yet. So, the obvious fix is to explain PI in the prompt, right? Well, not quite. Want to make videos like this one with Claude Code? That's what I teach step by step inside Shipping School Premium. New lessons every single day, live calls every week, a full course library, and over 500 hours of replays. 263 builders are already in. Join free link below. So, what can a prompt actually change? It's just words the model reads every turn. You can list the tools and explain the edit format and that helps, but it eats context every turn and it's only a suggestion. The habits stay the same. Which tool it grabs first, how long it thinks before it acts, when it decides it's done. So training changes actual

3:02weights instead of words, and the habit moves into the model itself. With thinking turned off, HuggingFac's Pi adapter matches the base model thinking at its highest effort on Terminal Bench, 56.6 versus 54.2, and it writes about 4 1/2 times fewer tokens to get there. I don't know a prompt that does that. But training a 27 billion parameter model the normal way means updating all 27 billion numbers. That takes a cluster. So, how did they get it into a file that small? That's Laura. Laura stands for low rank adaptation. It's a 2021 paper from Edward H and a team at Microsoft and it comes down to three steps. Step one, freeze the model. Every weight in

3:47the base stays exactly where it is. Nothing moves. Step two, next to each weight matrix you want to change, you add two thin matrices called A and B. On this exact model, one feed forward matrix in Quen 3.8 8 is 5,120x7,48. That's about 89 million numbers. The adapter's pair for it is rank 32. One matrix is 32 numbers tall. The other is 32 numbers wide. Together about 720,000 numbers, under 1% of the matrix it's changing. So when the model runs, the input goes through the frozen matrix like always and also through the thin pair and the two results get added together. So you get the answer the

4:32model always gave plus a small correction on top. Step three, start that correction at zero. B starts as all zeros. So on the first training step, the model is exactly the base model. Then training only moves A and B. So do that across all 64 layers and you get the whole PI adapter, 159 million trainable numbers. That's about 6/10 of 1% of the model. The file is about 640 MGB. The base model is about 55 GB. And I almost missed this. In the Laura paper on GPT3, that meant 10,000 times fewer trainable parameters, three times less GPU memory, and the saved checkpoint went from 350 GB to 35 MGB. And because

5:18it just adds on top, you can merge it into a regular checkpoint or keep it separate and swap. One server holds the base model once, and every harness gets its own little file. Hugging Face's blog does exactly that with its smaller models, PI, Open Code, and Hermes adapters, all running off one server. So, Laura cuts what you train. It doesn't cut what you have to hold. 27 billion weights at 16 bits each is about 54 GB just to load the thing. Qura fixes that part. It's a 2023 paper from Tim Deet and the team at the University of Washington. Store the frozen base in four bits instead of 16 and train the Laura adapter on top of it. 27 billion weights at four bits is about 13 1/2 GB.

6:04So, three tricks make it work. A 4-bit number format built for how model weights are spread out called normal float. Double quantization, which compresses the bookkeeping numbers, too, about 3 GB saved on a 65 billion parameter model. and paged optimizers, which move the optimizer's memory over to regular CPU RAM when a long example spikes it instead of crashing. In the paper, they fine-tuned a 65 billion parameter model on a single 48 GB GPU. Normally, that's more than 780 GB. Their Guanako model got to 99.3% of chat GPT on the Vikuna benchmark after 24 hours on one GPU. So a 27B model on one card is very doable. A builder named Bitekim

6:50used Qura on Quen 3.6. Hugging face used two big GPUs per harness. One making attempts and one training because of where their data came from. So there are two ways to teach a model your harness. The first one is fine-tuning on examples. So you collect sessions where the agent got the job done, every request, every tool call, every result and you train the model to copy them. PI already saves every session as a file on your machine. And the PI readme asks people to share their open- source sessions on HuggingFace for exactly this. The second one is reinforcement learning. You don't hand it answers. You give it a task with hidden tests, let it try eight times, and the tests grade every attempt. Then it gets pushed

7:35toward what passed and away from what failed. That's gpo. And since the eight attempts get compared with each other, it only learns from tasks where some pass and some fail. So Hugging Fac's PI adapter is the RL kind. Over a thousand tasks run inside the real PI, graded by each task's own checker, plus a small bonus for using fewer tool calls. This one surprised me. At step zero of one of their test runs, a small model went looking for the place the task's data came from to dig up the answer instead of doing the work. Come on now. Their proxy called safe agents checks every tool call. It blocked it and that attempt scored zero. So why do sources disagree on how the Pyune was trained? There are two of them. Back in

8:20September, Bitekim put out a Quen 3.8 8 PI model fine-tuned on filtered successful PI sessions, then RL on top, full weights. The hugging face one is a Laura adapter RL only. Two different projects on the same base model. And the examples route can backfire. On Quen 3.6, Bitekim's first Qura run in PI trained on about 1,600 sessions from Frontier models dropped from 42.7 to 28.1, about 15 points worse. The second version trained with the reasoning included got back to 40.4 still under the bass but in open hands a similar tune gained about 10 points. So this kind of training helped in one harness and hurt in the other. Okay. So the

9:05scoreboard these are the author's own numbers from their own cards. We didn't run it. So Hugging Face's PI adapter thinking off one try per task inside Pi. On the 51 hardest SWEBench pro tasks 39.2 2% up to 64.7. 15 tasks newly solved, two lost. On terminal bench 2.1, 39 12 up to 55.8. Even on the 68 terminal bench tasks they didn't use to pick the checkpoint, almost the exact same jump. And on tasks both solved, it needed less than half the turns. Now, the fine print. The viral post said 29.4 to 62.7. The card corrected that. Nine of the base models runs had failed because a network tunnel

9:51went down mid-run. They reran those on both sides and the base went up to 39.2. Credit to them for fixing it in public. So, the card also says part of the gain is just finishing in time. Remember those 20 failures that ran out of steps? And if you turn thinking on at max effort, the base model hits 74 1/2 on those same tasks. The adapter with thinking also 74 1/2. So, the real win is getting most of the way there without thinking with about four and a half times fewer tokens. So, what about Quen's own number? Their card says 61.7 on SWEBench Pro. That's the full benchmark inside Claude Code thinking at max. Different test, different harness, so you can't line those up. And the adapter card says that itself. None of

10:36this is independently measured yet. So, should you actually do this yourself? So, if you run one open model in one harness every day, and you've got tasks with real tests, yes, it can be worth it. The file is small, it loads with a couple of flags, and you keep the base model. An adapter only works on the exact base it was trained on. Hugging face says so on the card, and the more you compress that base, the further it drifts from what the adapter learned. So, check the cheap fixes first. Like I showed you, the base model scored about seven points higher on Terminal Bench in Open Code than in PI. But on SWEBench Pro, it went the other way. So try your own tasks in a couple of agents before you train anything. Turning thinking on got the base to the same SWE score as

11:22the adapter with thinking. It just burns way more tokens. Or pick a bigger model and skip all of this. And if you do train, measure before and after on tasks you didn't train on. Bite Kim's first run went about 15 points the wrong way. The way I think about it, the prompt tells the model what the tools are and the adapter teaches it the habits. Everybody needs the first one. The second one is for when you're living in one agent all day. So, if you could train your model on one tool first, which one would it be? The edit tool, bash, something custom you built? Let me know down below. Have a blessed day.