Official resources for "TuneAgent: Agentic Operating System Kernel Tuning with Reinforcement Learning". Hongyu Lin, Yuchen Li, Haoran Luo, Zhenghong Lin, Libo Zhang, Mingjie Xing, Yanjun Wu. KDD 2026 [paper].
Linux kernel tuning is difficult because the kernel configuration space is large,
highly constrained, and workload-sensitive. TuneAgent formulates kernel tuning
as a constrained reinforcement learning problem over Kconfig option groups. The
agent observes a tuning target, reasons over candidate kernel options, queries a
kernel knowledge tool when needed, and emits structured configuration decisions
that can be applied to a Linux .config.
TuneAgent contains three main designs from the paper:
- Constraint-aware kernel environment. Kernel options are organized into
type-aware groups:
Bool,Menu,Choice, andValue. - Rule-based rewards. Training combines
R_format,R_answer, andR_perfto encourage structured reasoning, valid configuration actions, and performance-aware exploration. - Two-phase GRPO training. A warm-up phase learns format and semantic correctness, followed by a performance-aware exploration phase.
The camera-ready paper reports that TuneAgent improves both kernel performance and configuration validity.
| Setting | Main reported result |
|---|---|
| UnixBench overall score | TuneAgent-7B reaches 662.2, +35.0 over the default heuristic baseline |
| Overall improvement | Up to 5.6% |
| Configuration validity | Up to 93.8% for TuneAgent-7B |
| Nginx | Up to 51.8% improvement |
| PostgreSQL | About 8.6%-9.4% improvement |
| Redis | About 1.5%-3.8% improvement |
Full reproduction requires the curated TuneAgent dataset, trained checkpoints, a kernel build/boot environment, and the benchmark suites listed below.
The implementation is organized around the paper components:
| Paper component | Repository location |
|---|---|
| Configuration-group dataset construction | examples/data_preprocess/tuneagent.py |
| Tool-augmented agent interaction | tuneagent/tool/, tuneagent/llm_agent/ |
| Kernel knowledge tool backed by LightRAG | tuneagent/tool/tools/kernel_knowledge_tool.py, inference/RAG.py |
Rule rewards R_format and R_answer |
tuneagent/src/reward_score/tuneagent_score.py |
LLM-as-a-Judge reward helper R_perf |
tuneagent/src/reward_score/tuneagent_judge_score.py |
| GRPO/PPO training loop | tuneagent/src/main_agent.py, tuneagent/src/agent_ray_trainer.py |
| Kconfig traversal and final config generation | inference/Inference.py, inference/ConfigTree.py, inference/TuneAgentLLM.py |
| Paper-scale GRPO launch script | scripts/run_grpo_tuneagent.sh |
Repository layout:
TuneAgent/
tuneagent/
llm_agent/ # multi-turn generation with tool calls
src/ # Ray/FSDP training, GRPO/PPO logic, rewards, configs
tool/ # tool abstraction and TuneAgent knowledge tools
vllm_infer/ # OpenAI-compatible vLLM client utilities
examples/
data_preprocess/ # raw configuration logs to parquet training data
inference/ # Kconfig traversal and tuned .config generation
scripts/ # training, sanity-check, serving, and checkpoint scripts
tests/ # lightweight smoke tests
figs/ # figures
verl/ # required verl submodule
TuneAgent is intended for a Linux GPU environment for full training and inference. The lightweight sanity checks can run without GPUs.
git clone --recursive <repo-url> TuneAgent
cd TuneAgent
conda create -n tuneagent python=3.10
conda activate tuneagent
pip install -r requirements.txt
pip install -e ./verl
pip install vllm
pip install flash-attn --no-build-isolationInstall LightRAG for the kernel knowledge base:
git clone https://github.com/HKUDS/LightRAG.git
cd LightRAG
git checkout v1.1.1
pip install -e .
cd ../TuneAgentSet API keys if you use OpenAI-compatible judge or knowledge-base calls:
export OPENAI_API_KEY=<your_api_key>
export OPENAI_BASE_URL=<optional_openai_compatible_base_url>
export WANDB_API_KEY=<optional_wandb_key>The paper uses over 3,000 expert-curated kernel configuration samples covering CPU scheduling, memory management, file I/O, process management, networking, locking, and application scenarios.
Expected raw log structure:
data/tuneagent/
tuneagent_train/*.log
tuneagent_validate/*.log
Each log starts with a tuning target on the first line. Each following line is a JSON object:
{"question": "Bool\t<config group text>", "answer": [{"config": "CONFIG_X", "value": 2}]}Supported question types are Bool, Menu, Choice, and Value.
Preprocess logs into parquet files:
python examples/data_preprocess/tuneagent.py \
--local_dir ./data/tuneagentThe command writes:
data/tuneagent/train.parquet
data/tuneagent/validation.parquet
The curated paper dataset is not included in this checkout. Place released data
under data/tuneagent/ or pass DATA_DIR=/path/to/data to the training script.
This verifies the TuneAgent reward parser without requiring GPUs, datasets, kernel source code, LightRAG, or checkpoints.
python scripts/run_sanity_check.py
python -m pytest testsPaper-aligned GRPO training:
DATA_DIR=./data/tuneagent \
BASE_MODEL=Qwen/Qwen2.5-3B-Instruct \
PROJECT_NAME=tuneagent \
EXPERIMENT_NAME=grpo-qwen25-3b \
bash scripts/run_grpo_tuneagent.shCommon overrides:
N_GPUS=4 \
TRAIN_BATCH_SIZE=128 \
TENSOR_MODEL_PARALLEL_SIZE=4 \
LOGGER="['console','wandb']" \
bash scripts/run_grpo_tuneagent.shTrain the 7B variant:
BASE_MODEL=Qwen/Qwen2.5-7B-Instruct \
bash scripts/run_grpo_tuneagent.shscripts/run_ppo_tuneagent.sh is retained for PPO-style baseline experiments.
The main TuneAgent method in the paper uses GRPO.
The knowledge tool expects a LightRAG working directory. By default:
data/lightrag_knowledge_base/
Override it with:
export LIGHTRAG_WORKING_DIR=/path/to/lightrag_knowledge_base
export LIGHTRAG_SEARCH_MODE=hybrid
export LIGHTRAG_LLM_FUNC=gpt-4o-miniIf the knowledge base is absent, the tool disables itself and returns an error string. This is acceptable for smoke tests but not for paper-scale experiments.
The paper evaluates TuneAgent with:
- UnixBench for CPU, memory, file I/O, pipe, shell, system call, process, and overall system score.
- ApacheBench for Nginx.
- Sysbench for PostgreSQL.
- Redis Benchmark for Redis.
- Kernel compile-and-boot checks for configuration validity.
Recommended full reproduction workflow:
python examples/data_preprocess/tuneagent.py --local_dir ./data/tuneagent
DATA_DIR=./data/tuneagent bash scripts/run_grpo_tuneagent.sh
python inference/Inference.py /path/to/linux-6.2.16 \
--target "Improve overall UnixBench performance" \
--config-path tuneagent/src/config \
--config-name agent_trainer_inference \
--output outputs/unixbench.configThen compile, boot, and benchmark the tuned kernel against the default kernel configuration.
Download a Linux kernel source tree and provide a baseline .config:
wget https://www.kernel.org/pub/linux/kernel/v6.x/linux-6.2.16.tar.gz
tar -zxf linux-6.2.16.tar.gz
cp /path/to/baseline.config linux-6.2.16/.configGenerate a tuned configuration:
python inference/Inference.py /path/to/linux-6.2.16 \
--target "Improve system memory throughput" \
--config-path tuneagent/src/config \
--config-name agent_trainer_inference \
--output outputs/tuneagent.config \
--mode hybrid \
--use-knowledge 1Apply the generated configuration before kernel compilation:
cp outputs/tuneagent.config /path/to/linux-6.2.16/.config- The curated paper dataset and trained checkpoints are not included in this checkout.
- Full reproduction requires GPU training, kernel compile/boot infrastructure, and benchmark workloads.
- Existing checkpoints or parquet files produced before the camera-ready naming
cleanup may need to be regenerated with the
tuneagentdata-source name. R_perfdepends on an OpenAI-compatible judge model and is not exercised by the lightweight sanity check.- Static tests cannot prove kernel bootability; paper-scale validity requires real kernel builds and boots.
@inproceedings{lin2026tuneagent,
title = {TuneAgent: Agentic Operating System Kernel Tuning with Reinforcement Learning},
author = {Lin, Hongyu and Li, Yuchen and Luo, Haoran and Lin, Zhenghong and Zhang, Libo and Xing, Mingjie and Wu, Yanjun},
booktitle = {Proceedings of the 32nd ACM SIGKDD Conference on Knowledge Discovery and Data Mining},
year = {2026},
series = {KDD '26},
location = {Jeju Island, Republic of Korea},
publisher = {ACM},
doi = {10.1145/3770855.3817987}
}