# qwenlm/qwen3-coder architecture

> Architecture diagram of the GitHub repository qwenlm/qwen3-coder, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-05-27). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/qwenlm/qwen3-coder
- Repository: https://github.com/qwenlm/qwen3-coder

## Overview

1. This repository is a model-centric monorepo for Qwen3-Coder: it contains the model README, demo apps, training scripts, and a large evaluation harness rather than a single product service. The main architectural split is between model development, model consumption, and benchmark/evaluation infrastructure.

2. The root README is effectively the public entrypoint. It describes the model family, supported context length, chat/FIM usage patterns, and external distribution channels. The repo itself does not host model weights; it hosts the code, prompts, and evaluation assets needed to use and measure the models.

3. The `demo/` and `assets/` areas are lightweight presentation layers. `demo/chatbot` and `demo/artifacts` suggest small runnable examples with static frontend assets plus a Python app/config bundle, while `assets/qwen3-coder-next-demo` stores demo media used in the README. These are isolated from the training/evaluation pipelines.

4. The `examples/` directory is a usage cookbook for inference patterns: normal chat completion, streaming, fill-in-the-middle, and repo-level code completion. These scripts are thin integration examples and sit at the boundary between the tokenizer/model API and the consumer application.

5. `finetuning/sft` is the supervised fine-tuning pipeline. It includes data preparation, binary data conversion, model download/merge utilities, LoRA support, and training entrypoints. The important flow here is: raw code/execution data → preprocessing/binarization → training → optional adapter merge → released weights or adapters.

6. `finetuning/dpo` is a separate preference-optimization pipeline. Its configuration files, DeepSpeed zero configs, shell scripts, and `train.py` indicate a distributed training path for alignment after SFT. This subsystem is narrower than SFT: it consumes prepared preference data and produces a better-aligned checkpoint.

7. The largest architectural block is `qwencoder-eval/`, which contains multiple benchmark families and orchestration code. It is organized by evaluation mode (`base`, `instruct`, `reasoning`, `tool_calling_eval`) and by benchmark suite, so it acts as an umbrella over many semi-independent evaluation subsystems.

8. `qwencoder-eval/base` and `qwencoder-eval/instruct` hold many benchmark adapters and their output artifacts. Common benchmark families include BigCodeBench, EvalPlus, CruxEval, FIM-Bench, MultiPL-E, Aider, Bird/Spider, CodeArena, PlotCraft, LiveCodeBench, and others. Each family typically includes prompt generation, inference runners, execution/evaluation code, and stored results, so the repo preserves both code and benchmark outputs.

9. The evaluation harnesses are intentionally multi-language and sandboxed. There are Python runners for most benchmarks, a Go-based core in `instruct/eval-dev-quality`, plus language-specific evaluators and “safe_subprocess” sandboxes to control untrusted code execution. This is a key architectural boundary: model-generated code is executed only inside constrained runners with separate evaluation logic per language/task type.

10. `qwencoder-eval/instruct/eval-dev-quality` is its own substantial product-like subsystem. It has Go modules for CLI, evaluation, reporting, language abstraction, model/provider abstraction, and tooling. The data flow is: repository tasks and test fixtures → model/provider invocation → task execution and scoring → CSV/Markdown report generation. It also stores historical report snapshots under `docs/reports/`.

11. That Go-based evaluation system is layered by concern: `language/` models language-specific behavior, `model/` describes model capabilities and prompt parsing, `provider/` wraps external/local inference backends, `evaluate/` runs tasks and computes metrics, `tools/` installs or configures external utilities, and `util/` contains execution and I/O helpers. This makes it a clean architecture diagram candidate with explicit domain, provider, and reporting boundaries.

12. External inference backends are a material part of the architecture. Across the eval suites and BFCL/Tau-Bench, the repo integrates with OpenAI-compatible APIs, Anthropic, OpenRouter, Ollama, vLLM, Symflower, and model-specific handlers. These are not just optional adapters; they determine how prompts are sent, how tool calls are parsed, and whether evaluation runs locally or against hosted APIs.

13. `qwencoder-eval/tool_calling_eval` focuses on tool/function-calling benchmarks. It vendors the Berkeley Function Calling Leaderboard and TAU-Bench, including model handlers, parsers, task definitions, and datasets for multi-turn and tool-using scenarios. This subsystem is centered on structured output validation rather than pure code generation.

14. The repo also commits benchmark corpora, cached outputs, and result tables alongside the code. That means the architecture includes an artifact layer: datasets in `data/` and `testdata/`, generated generations/results in `results/`, and summarized CSV/JSON reports in `docs/reports/`, `outptus/`, and other output directories. For diagramming, treat these as persistent evaluation artifacts flowing from the runners.

15. In short, the repository is organized as: model usage examples and demos at the edge; SFT/DPO pipelines for model improvement; and a large, benchmark-heavy evaluation platform with isolated task runners, sandboxed execution, and provider adapters. The strongest architectural boundaries are between data preparation, model invocation, code execution, and report aggregation.

Main entry points: [`qwencoder-eval/instruct/README.md`](https://github.com/qwenlm/qwen3-coder/blob/main/qwencoder-eval/instruct/README.md) (Eval hub), [`finetuning/sft/train.py`](https://github.com/qwenlm/qwen3-coder/blob/main/finetuning/sft/train.py) (SFT), [`README.md`](https://github.com/qwenlm/qwen3-coder/blob/main/README.md) (README), [`qwencoder-eval/instruct/eval-dev-quality/cmd/eval-dev-quality/main.go`](https://github.com/qwenlm/qwen3-coder/blob/main/qwencoder-eval/instruct/eval-dev-quality/cmd/eval-dev-quality/main.go) (Dev quality)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["Entry & usage"]
  node_readme["README<br/>repo entry<br/>[README.md]"]
  node_demo_chatbot["Chatbot<br/>demo app<br/>[app.py]"]
  node_demo_artifacts["Artifacts<br/>demo app<br/>[app.py]"]
  node_examples["Examples<br/>inference cookbook<br/>[Qwen2.5-Coder.py]"]
end

subgraph group_train["Training"]
  node_sft["SFT<br/>pretrain pipeline<br/>[train.py]"]
  node_sft_data["Data prep<br/>sft preprocessing"]
  node_sft_lora["LoRA merge<br/>adapter ops<br/>[merge_adapter.py]"]
  node_dpo["DPO<br/>alignment pipeline<br/>[train.py]"]
end

subgraph group_eval["Evaluation"]
  node_eval_root["Eval hub<br/>benchmark umbrella<br/>[README.md]"]
  node_eval_dev_quality["Dev quality<br/>go eval system<br/>[main.go]"]
  node_eval_base["Base evals<br/>codegen benchmarks<br/>[readme.md]"]
  node_eval_instruct["Instruct evals<br/>chat benchmarks<br/>[evaluate.sh]"]
  node_eval_reasoning["Reasoning<br/>cot benchmarks<br/>[README.md]"]
  node_language_layer["Languages<br/>exec abstraction<br/>[language.go]"]
  node_reporting["Reports<br/>result aggregation<br/>[markdown.go]"]
  node_base_benchmarks["Base suites<br/>benchmark suites<br/>[generate.py]"]
  node_instruct_benchmarks["Instruct suites<br/>benchmark suites<br/>[benchmark.py]"]
end

subgraph group_tooling["Tool calling"]
  node_eval_toolcall["Tool calling<br/>tool-call eval<br/>[README.md]"]
  node_provider_layer["Providers<br/>backend adapters<br/>[provider.go]"]
  node_bfcl["BFCL<br/>function-calling bench<br/>[__main__.py]"]
  node_tau_bench["TAU-Bench<br/>agent bench<br/>[run.py]"]
end

node_readme -->|"introduces"| node_demo_chatbot
node_readme -->|"documents"| node_examples
node_readme -->|"describes"| node_sft
node_readme -->|"orients"| node_eval_root
node_demo_chatbot -->|"shares UI layer"| node_demo_artifacts
node_examples -.->|"consumes model"| node_sft
node_sft_data -->|"feeds"| node_sft
node_sft -->|"produces"| node_sft_lora
node_dpo -.->|"refines"| node_sft
node_eval_root -->|"organizes"| node_eval_base
node_eval_root -->|"organizes"| node_eval_instruct
node_eval_root -->|"organizes"| node_eval_reasoning
node_eval_root -->|"organizes"| node_eval_toolcall
node_eval_base -->|"contains"| node_base_benchmarks
node_eval_instruct -->|"contains"| node_instruct_benchmarks
node_eval_reasoning -.->|"reuses runner"| node_instruct_benchmarks
node_eval_toolcall -->|"vendors"| node_bfcl
node_eval_toolcall -->|"vendors"| node_tau_bench
node_eval_dev_quality -->|"adapts"| node_provider_layer
node_eval_dev_quality -->|"abstracts"| node_language_layer
node_eval_dev_quality -->|"emits"| node_reporting
node_provider_layer -.->|"drives runs"| node_reporting
node_language_layer -.->|"constrains execution"| node_eval_dev_quality

click node_readme "https://github.com/qwenlm/qwen3-coder/blob/main/README.md"
click node_demo_chatbot "https://github.com/qwenlm/qwen3-coder/blob/main/demo/chatbot/app.py"
click node_demo_artifacts "https://github.com/qwenlm/qwen3-coder/blob/main/demo/artifacts/app.py"
click node_examples "https://github.com/qwenlm/qwen3-coder/blob/main/examples/Qwen2.5-Coder.py"
click node_sft "https://github.com/qwenlm/qwen3-coder/blob/main/finetuning/sft/train.py"
click node_sft_data "https://github.com/qwenlm/qwen3-coder/blob/main/finetuning/sft/prepare_code_execution_data.py"
click node_sft_lora "https://github.com/qwenlm/qwen3-coder/blob/main/finetuning/sft/merge_adapter.py"
click node_dpo "https://github.com/qwenlm/qwen3-coder/blob/main/finetuning/dpo/train.py"
click node_eval_root "https://github.com/qwenlm/qwen3-coder/blob/main/qwencoder-eval/instruct/README.md"
click node_eval_dev_quality "https://github.com/qwenlm/qwen3-coder/blob/main/qwencoder-eval/instruct/eval-dev-quality/cmd/eval-dev-quality/main.go"
click node_eval_base "https://github.com/qwenlm/qwen3-coder/blob/main/qwencoder-eval/base/readme.md"
click node_eval_instruct "https://github.com/qwenlm/qwen3-coder/blob/main/qwencoder-eval/instruct/evaluate.sh"
click node_eval_reasoning "https://github.com/qwenlm/qwen3-coder/blob/main/qwencoder-eval/reasoning/livecode_bench_cot/README.md"
click node_eval_toolcall "https://github.com/qwenlm/qwen3-coder/blob/main/qwencoder-eval/tool_calling_eval/README.md"
click node_provider_layer "https://github.com/qwenlm/qwen3-coder/blob/main/qwencoder-eval/instruct/eval-dev-quality/provider/provider.go"
click node_language_layer "https://github.com/qwenlm/qwen3-coder/blob/main/qwencoder-eval/instruct/eval-dev-quality/language/language.go"
click node_reporting "https://github.com/qwenlm/qwen3-coder/blob/main/qwencoder-eval/instruct/eval-dev-quality/evaluate/report/markdown.go"
click node_base_benchmarks "https://github.com/qwenlm/qwen3-coder/blob/main/qwencoder-eval/base/benchmarks/bigcodebench/generate.py"
click node_instruct_benchmarks "https://github.com/qwenlm/qwen3-coder/blob/main/qwencoder-eval/instruct/aider/benchmark/benchmark.py"
click node_bfcl "https://github.com/qwenlm/qwen3-coder/blob/main/qwencoder-eval/tool_calling_eval/berkeley-function-call-leaderboard/bfcl_eval/__main__.py"
click node_tau_bench "https://github.com/qwenlm/qwen3-coder/blob/main/qwencoder-eval/tool_calling_eval/tau-bench/tau_bench/run.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_readme,node_demo_chatbot,node_demo_artifacts,node_examples toneBlue
class node_sft,node_sft_data,node_sft_lora,node_dpo toneAmber
class node_eval_root,node_eval_dev_quality,node_eval_base,node_eval_instruct,node_eval_reasoning,node_language_layer,node_reporting,node_base_benchmarks,node_instruct_benchmarks toneMint
class node_eval_toolcall,node_provider_layer,node_bfcl,node_tau_bench toneRose
```

## Components

### Entry & usage

Public docs, demos, and consumer examples

- [README](https://github.com/qwenlm/qwen3-coder/blob/main/README.md): repo entry · Public overview and usage entrypoint for Qwen3-Coder. · `README.md`
- [Chatbot](https://github.com/qwenlm/qwen3-coder/blob/main/demo/chatbot/app.py): demo app · Runnable chat demo wrapper. · `demo/chatbot/app.py`
- [Artifacts](https://github.com/qwenlm/qwen3-coder/blob/main/demo/artifacts/app.py): demo app · Small presentation app with static assets and config. · `demo/artifacts/app.py`
- [Examples](https://github.com/qwenlm/qwen3-coder/blob/main/examples/Qwen2.5-Coder.py): inference cookbook · Thin scripts showing chat, streaming, FIM, and repo-level completion patterns. · `examples/Qwen2.5-Coder.py`

### Training

Supervised and preference optimization pipelines

- [SFT](https://github.com/qwenlm/qwen3-coder/blob/main/finetuning/sft/train.py): pretrain pipeline · Supervised fine-tuning pipeline for code execution data and adapters. · `finetuning/sft/train.py`
- [Data prep](https://github.com/qwenlm/qwen3-coder/blob/main/finetuning/sft/prepare_code_execution_data.py): sft preprocessing · Prepares, binarizes, and decontaminates training data. · `finetuning/sft/prepare_code_execution_data.py`
- [LoRA merge](https://github.com/qwenlm/qwen3-coder/blob/main/finetuning/sft/merge_adapter.py): adapter ops · Downloads models and merges adapters after fine-tuning. · `finetuning/sft/merge_adapter.py`
- [DPO](https://github.com/qwenlm/qwen3-coder/blob/main/finetuning/dpo/train.py): alignment pipeline · Distributed preference-optimization stage after SFT. · `finetuning/dpo/train.py`

### Evaluation

Benchmark harnesses, runners, and stored results

- [Eval hub](https://github.com/qwenlm/qwen3-coder/blob/main/qwencoder-eval/instruct/README.md): benchmark umbrella · Top-level evaluation workspace spanning multiple benchmark families and modes. · `qwencoder-eval/instruct/README.md`
- [Dev quality](https://github.com/qwenlm/qwen3-coder/blob/main/qwencoder-eval/instruct/eval-dev-quality/cmd/eval-dev-quality/main.go): go eval system · Go-based quality evaluation system with CLI, language, model, provider, and reporting layers. · `qwencoder-eval/instruct/eval-dev-quality/cmd/eval-dev-quality/main.go`
- [Base evals](https://github.com/qwenlm/qwen3-coder/blob/main/qwencoder-eval/base/readme.md): codegen benchmarks · Base-generation benchmark adapters and stored outputs. · `qwencoder-eval/base/readme.md`
- [Instruct evals](https://github.com/qwenlm/qwen3-coder/blob/main/qwencoder-eval/instruct/evaluate.sh): chat benchmarks · Instruction-following benchmark adapters and outputs. · `qwencoder-eval/instruct/evaluate.sh`
- [Reasoning](https://github.com/qwenlm/qwen3-coder/blob/main/qwencoder-eval/reasoning/livecode_bench_cot/README.md): cot benchmarks · Reasoning-oriented LiveCodeBench CoT evaluation flow. · `qwencoder-eval/reasoning/livecode_bench_cot/README.md`
- [Languages](https://github.com/qwenlm/qwen3-coder/blob/main/qwencoder-eval/instruct/eval-dev-quality/language/language.go): exec abstraction · Language-specific execution, coverage, and test semantics for eval tasks. · `qwencoder-eval/instruct/eval-dev-quality/language/language.go`
- [Reports](https://github.com/qwenlm/qwen3-coder/blob/main/qwencoder-eval/instruct/eval-dev-quality/evaluate/report/markdown.go): result aggregation · CSV/Markdown report generation and stored historical reports. · `qwencoder-eval/instruct/eval-dev-quality/evaluate/report/markdown.go`
- [Base suites](https://github.com/qwenlm/qwen3-coder/blob/main/qwencoder-eval/base/benchmarks/bigcodebench/generate.py): benchmark suites · Core code-generation suites such as BigCodeBench, EvalPlus, CruxEval, FIM-Bench, and MultiPL-E. · `qwencoder-eval/base/benchmarks/bigcodebench/generate.py`
- [Instruct suites](https://github.com/qwenlm/qwen3-coder/blob/main/qwencoder-eval/instruct/aider/benchmark/benchmark.py): benchmark suites · Instruction benchmarks such as Aider, Bird/Spider, CodeArena, PlotCraft, LiveCodeBench, and MultiPL-E chat. · `qwencoder-eval/instruct/aider/benchmark/benchmark.py`

### Tool calling

Structured-function-calling evaluation stacks

- [Tool calling](https://github.com/qwenlm/qwen3-coder/blob/main/qwencoder-eval/tool_calling_eval/README.md): tool-call eval · Function-calling and agentic benchmark harnesses. · `qwencoder-eval/tool_calling_eval/README.md`
- [Providers](https://github.com/qwenlm/qwen3-coder/blob/main/qwencoder-eval/instruct/eval-dev-quality/provider/provider.go): backend adapters · API and local inference backends used by evaluation harnesses. · `qwencoder-eval/instruct/eval-dev-quality/provider/provider.go`
- [BFCL](https://github.com/qwenlm/qwen3-coder/blob/main/qwencoder-eval/tool_calling_eval/berkeley-function-call-leaderboard/bfcl_eval/__main__.py): function-calling bench · Berkeley Function Calling Leaderboard adapters, parsers, and model handlers. · `qwencoder-eval/tool_calling_eval/berkeley-function-call-leaderboard/bfcl_eval/__main__.py`
- [TAU-Bench](https://github.com/qwenlm/qwen3-coder/blob/main/qwencoder-eval/tool_calling_eval/tau-bench/tau_bench/run.py): agent bench · Tool-using airline and retail environments with agents and model utilities. · `qwencoder-eval/tool_calling_eval/tau-bench/tau_bench/run.py`

## Connections

- README → Chatbot: introduces · The root README points users to runnable demos.
- README → Examples: documents · README describes chat, streaming, and FIM usage patterns.
- README → SFT: describes · The repository frames SFT as a core model-improvement path.
- README → Eval hub: orients · The README is the entrypoint for the evaluation-heavy monorepo.
- Chatbot → Artifacts: shares UI layer · Both demos are lightweight presentation surfaces.
- Examples → SFT: consumes model · Examples exercise the model interface at inference time.
- Data prep → SFT: feeds · Prepared and binarized data flows into training.
- SFT → LoRA merge: produces · Training can emit adapters that are later merged.
- DPO → SFT: refines · DPO consumes a prior SFT checkpoint.
- Eval hub → Base evals: organizes · Evaluation is split into base, instruct, reasoning, and tool-calling modes.
- Eval hub → Instruct evals: organizes · Evaluation is split into base, instruct, reasoning, and tool-calling modes.
- Eval hub → Reasoning: organizes · Evaluation is split into base, instruct, reasoning, and tool-calling modes.
- Eval hub → Tool calling: organizes · Evaluation is split into base, instruct, reasoning, and tool-calling modes.
- Base evals → Base suites: contains · Base evaluation aggregates multiple code-generation suites.
- Instruct evals → Instruct suites: contains · Instruct evaluation aggregates many task-specific suites.
- Reasoning → Instruct suites: reuses runner · Reasoning evaluation reuses the code-generation runner pattern with CoT flows.
- Tool calling → BFCL: vendors · BFCL is one of the main tool-calling benchmarks.
- Tool calling → TAU-Bench: vendors · TAU-Bench provides multi-turn tool-using environments.
- Dev quality → Providers: adapts · The Go evaluator wraps local and remote inference providers.
- Dev quality → Languages: abstracts · Language-specific execution behavior is isolated in its own layer.
- Dev quality → Reports: emits · Evaluation results are summarized into CSV and Markdown reports.
- Providers → Reports: drives runs · Backend choice determines how prompts are executed and recorded.
- Languages → Dev quality: constrains execution · Execution and scoring depend on language-specific semantics and sandboxes.
