Free · Daily brief + weekly playbookDaily 60-sec AI Voice Brief + Weekly Production AI Agent PlaybookGet the brief →
ReleaseInsight · On RadarHabr AI→ original

Slonik-27B Learns to Write PostgreSQL Kernel Code: Solves 55.6% of Tasks, Up from 31.2%

A Habr team fine-tuned the open Qwen3.8-27B, and the resulting model, Slonik-27B, can fix bugs and write C functions for the PostgreSQL kernel. On a test of 36 PostgreSQL 17 tasks, it solves 55.6% on the first attempt, compared with 31.2% for the original Qwen and 51.9% for GLM-5.3-Flash. Training took a week on eight NVIDIA H200 GPUs. For a narrow code domain, this is an argument for fine-tuning a compact open model.

AI-processed from Habr AI; edited by Hamidun News
Slonik-27B Learns to Write PostgreSQL Kernel Code: Solves 55.6% of Tasks, Up from 31.2%
Source: Habr AI. Collage: Hamidun News.
Listen to article
Article Fact Sheet & Key Figures
ParameterDetails
Primary sourceHabr AI ↗
Editor-in-Chief
PostgreSQL 1843.4% of tasks solved, versus 8.8% for base Qwen
SWE-bench Verified73.3% versus 53.4%, even though the model was not trained on it
On Terminal-Bench 2.0, GLM-5.3-Flash leads47.3% versus 45.8%

Imagine asking an AI agent to fix a bug in the PostgreSQL kernel. Writing code that merely runs is not enough: it has to follow the database's internal rules, keep to the project's style, and survive strict review on the community mailing lists. Agents are usually evaluated on general benchmarks such as SWE-bench, or asked to build something flashy like a game, while development inside a DBMS almost never appears in such tests.

The team that wrote about this on Habr wanted to find out whether an open model could be fine-tuned to handle the PostgreSQL kernel no worse than large open competitors. The result is Slonik-27B, based on Qwen3.8-27B.

On a test of 36 PostgreSQL 17 tasks (18 bugs and 18 built-in SQL functions in C), it solves 55.6% of tasks on the first attempt, while the original Qwen solves 31.2%.

This metric is called pass@1: the share of tasks solved in a single attempt. The weights and a technical report are published on Hugging Face, and the first results have been accepted to the AAAI2027 conference.

How It Was Trained: Three Stages in One Week

The team started from the dense models Qwen3.5-9B and Qwen3.8-27B. The whole process takes about a week on eight NVIDIA H200 GPUs.

The first stage is Continual Pre-Training, which means additional "reading" of domain material. The model was fed about 0.5 billion tokens: PostgreSQL documentation and mailing lists, texts about other DBMSs, systems programming, and SQL. To measure progress, the team built a test of 995 four-option questions based on the PostgreSQL 17.11 source code and documentation. The share of correct answers for the 27B model rose from 60.8% to 67.1%. The authors acknowledge that 0.5 billion tokens is not much, and they promise to increase both the volume and the quality of the data.

The second stage is Supervised Fine-Tuning, meaning training on ready-made examples. The authors ran GLM-5.3-Flash and DeepSeek-V4-Flash on the training tasks and kept only the successful attempts, no more than three per task. This yielded 725 trajectories across 372 tasks, totaling 17.2 million tokens. Full fine-tuning of all weights reached 41.2% on the validation set, while the lighter LoRA variant reached 37.0%. The NoRA variant scored 42.3%, but that falls within the spread between runs, so there is no stable advantage.

The third stage is reinforcement learning with the DAPO algorithm. The model attempts each task itself, and the reward is binary: 1 if the regression tests pass, otherwise 0. At each step, the team sampled 16 tasks with 8 attempts each. Only groups containing both successes and failures went into training, since such a comparison shows which solutions are worth reinforcing. To keep the GPUs from sitting idle, they used a Colocate Async RL scheme, in which the same GPUs take turns generating attempts and updating weights.

Results

The benchmarks for PostgreSQL 17, PostgreSQL 18, and the Apache AGE extension were prepared by active developers of the kernel and extensions. The agent had up to 30 minutes to work in a container with no internet access and no git, so it could not look up the solution. The average share of solved tasks for Slonik-27B versus base Qwen3.8-27B:

  • PostgreSQL 17: 55.6% versus 31.2%;
  • PostgreSQL 18 (53 tasks): 43.4% versus 8.8%;
  • Apache AGE (57 tasks): 36.6% versus 14.6%;
  • SWE-bench Verified (58 tasks): 73.3% versus 53.4%;
  • Terminal-Bench 2.0 (56 tasks): 45.8% versus 32.1%.

For comparison, GLM-5.3-Flash scored 51.9% on PostgreSQL 17, and DeepSeek-V4-Flash scored 50.9%. But the win is not complete: on Apache AGE, GLM-5.3-Flash is better (42.1% versus 36.6%), and it also leads on Terminal-Bench 2.0 (47.3%).

The order of the stages matters. On PostgreSQL 17, the model solved 32.6% of tasks after the first stage and 39.1% after the first and second. Reinforcement learning added another 10.7 percentage points on PostgreSQL 17 and 20.5 points on PostgreSQL 18. The pipeline was repeated on a 9B model: Slonik-9B rose from 15.0% to 40.3% on PostgreSQL 17.

The most practical observation concerns skill transfer. The SWE-bench Verified and Terminal-Bench 2.0 tasks were not used in SFT or RL, yet results on them improved. This means that narrow fine-tuning on DBMS code did not erase general development skills and, in this case, even improved them.

Limitations and Takeaways for Practitioners

The samples are small: 36, 53, and 57 tasks for PostgreSQL and Apache AGE, and 56–58 for the general benchmarks. Each autonomous run is long, so differences of a few points should be read with caution. The tests are internal, and passing them does not guarantee that a patch will be accepted by the community. The agent scaffolding was minimal, with no knowledge base. For an honest measurement of the model, this is good, but in real work the scaffolding noticeably affects results.

For teams working in a narrow code domain, the approach looks like this: build your own benchmarks with experts, warm up the model with trajectories from strong models, and then apply reinforcement learning where the reward is passing tests. With this approach, even a 27B model on a single machine with eight H200s can compete with larger open competitors.

Story

Key Questions Answered

How It Was Trained: Three Stages in One Week?

The team started from the dense models Qwen3.5-9B and Qwen3.8-27B. The whole process takes about a week on eight NVIDIA H200 GPUs. The first stage is Continual Pre-Training, which means additional "reading" of domain material. The model was fed about 0.5 billion tokens: PostgreSQL documentation and mailing lists, texts about other DBMSs, systems programming, and SQL. To measure progress, the team built a test of 995 four-option questions based on the PostgreSQL 17.11 source code and documentation.

What are the key details on Results?

The benchmarks for PostgreSQL 17, PostgreSQL 18, and the Apache AGE extension were prepared by active developers of the kernel and extensions. The agent had up to 30 minutes to work in a container with no internet access and no git, so it could not look up the solution.

What are the key details on Limitations and Takeaways for Practitioners?

The samples are small: 36, 53, and 57 tasks for PostgreSQL and Apache AGE, and 56–58 for the general benchmarks. Each autonomous run is long, so differences of a few points should be read with caution. The tests are internal, and passing them does not guarantee that a patch will be accepted by the community. The agent scaffolding was minimal, with no knowledge base. For an honest measurement of the model, this is good, but in real work the scaffolding noticeably affects results.

ZK
Zhemal Khamidun — Head of AI at Alpina Digital · MIPT (academic supervisor of the Tech Entrepreneurship department). Building AI products since 2019. Hamidun News is a pet project that grew into a production aggregator with 6,000+ readers.
✦ Free · Waitlist · Hermes + DeepSeek

Free 2-Day Vibecoding & AI Agents Intensive

Day 1: the autonomous Hermes + DeepSeek AI agent — vibecoding and development on par with Claude Code / Codex / Gemini. Led by Jemal Hamidun, Head of AI at Alpina Digital and academic supervisor at MIPT. Right after you register with our bot Nika: the recording + 11 materials from the previous intensive.

Join the waitlist →Nomad AI Workspace
Jemal Hamidun

Editor-in-chief · Cite this analysis

Jemal Hamidun

Head of AI at Alpina Digital · Academic Supervisor of the Tech Entrepreneurship Department at MIPT

Head of AI & CPO of AlpinaGPT at Alpina Digital, Academic Lead of Tech Entrepreneurship at MIPT. Founder of Hamidun News and Vibe Academy.

Ready-to-paste citation for journalists, blogs and Telegram channels

Source: Hamidun News — Slonik-27B Learns to Write PostgreSQL Kernel Code: Solves 55.6% of Tasks, Up from 31.2% https://news.hamidun.com/en/news/18463/slonik-27b-learns-to-write-postgresql-kernel-code-solves-55

What do you think?
Loading comments…