Doubling synthetic env tasks solve rate using Beam
Distil a SWE agent into Gemma 4 E4B by fine-tuning on Beam’s golden traces
Twice as many held-out software-engineering environments solved, from one afternoon of training on one node. The teacher is Beam, the student is Gemma 4 E4B, and the only judge is each environment’s hidden test.
How it works
The data is golden traces from the companion recipe, Synthetic SWE environments with Beam (recipes/customization/data-synthesis/synthetic-environment-gen): Beam’s reasoning, every bash command it ran and every output it saw, kept only when the environment’s hidden test passed.
The prompts are swapped for the evaluation prompts. The teacher ran with extra editing rules; the student is served without them. Strip them from the data and the habits transfer to the plain prompt.
The student is graded only on what Beam wrote. The thought, the command and the tag that ends the turn are trained; the prompts and the terminal output are masked.
Training is plain supervised fine-tuning, all language-model weights, two epochs. A generation check gates the export, because a scrambled save has normal tensor statistics.
What the student learns
Not the answers: the evaluation environments are new. It learns a way of working. One environment side by side; the task is a broken vendored audit package to fix and run over 200 JSONL events.
stock
this recipe
reads the code
edits the Makefile three times from the task text
dumps every file in the package, counts the real events
finds the bug
deletes the failing import
runs make all, renames one module to the name the imports expect
checks its work
overwrites the input file with ten fake rows so the pipeline runs
re-runs the target, prints the report to check its schema
result
verifier fails on record_count: 6 == 200, 0 of 4 attempts
6 of 6 tests, 4 of 4 attempts, 53 commands
What to expect
Four attempts per environment, plain agent configuration: temperature 1.0, 16k output tokens, thinking on, no decoding tricks. pass@k is the chance that at least one of k attempts passes the hidden tests, averaged over environments.
Attempts are sampled and training is not deterministic. A second training run with the scripts in this folder scored 13.6% / 20.0% / 24.0% / 26.9% and solved 46 environments, 38 shared with the first. Treat gaps under 3 points as noise; rank candidates on a subset of 60 environments at two attempts each before spending a day on the full set.
The obvious data is not the best data. Students trained only on traces rolled out through the evaluation harness collapsed into repetition from the first step; the same rollouts mixed beside Beam’s corpus traces gave the best model. Keep the corpus traces as the base of the mix.
Before you start
google/gemma-4-E4B-it at revision ee0ef6023621cff504d758262d4e04895a5af4a2. Gemma is gated: accept the license on the model page and set HF_TOKEN (the cookbook’s .env.example lists it).
Golden traces as the companion recipe writes them, traces/<source>/<env_id>/trace_<n>.json, each {"task": "<env_id>", "messages": [...]}. Our run used two sources from the same teacher on 500 training environments: 895 traces Beam wrote when the environments were created (corpus) and 295 from running Beam again with stricter editing instructions (rollouts). The second source raised pass@1 from 13.6% to 16.4%.
Held-out environments as Harbor task folders, the companion recipe’s output/harbor/, never used for training.
requirements.txt, pinned. Training ran with Python 3.12 and CUDA 13.
Stage
Hardware
What it took
Train
1 node, 8x NVIDIA B300 (NUM_GPUS=4 also works, same effective batch)
3 h 27 min, 66 optimizer steps
Serve
4 GPUs, SGLang
Evaluate
Docker, about one CPU core per parallel attempt; we used 32 cores and 24 attempts
train.sh runs three scripts into runs/e4b-distil/. Extra arguments go to the trainer, for example --epochs 3.1. Prepare.prepare.py keeps at most two traces per environment from each source, cuts every thought to about 2,000 characters at a sentence boundary, swaps in the standard prompts, renders with Gemma 4’s chat template and builds the loss mask. Traces above 220,000 characters, containing Gemma’s control tags, or above 65,536 tokens once rendered are left out; a tenth of the rest is held out for the eval loss. From our traces:
2. Train.train_sft.py with FSDP: 2 epochs, learning rate 1e-5, cosine with 3% warmup, one conversation per GPU per step and an effective batch of 32, bf16, gradient checkpointing, vision and audio towers frozen. One weights-only checkpoint per epoch; every logged value in checkpoints/log_history.json.The training loss drops below 1.0 in 20 steps and flattens near 0.85; the eval loss keeps falling through the second epoch (0.886, then 0.860). Three epochs did not help.3. Export.export.py re-saves the last checkpoint in bf16 with the base model’s config files, loads it on one GPU and answers a tool-calling question with thinking on. The run fails unless the text is readable and the thought channel opens.
EXPORT_OK runs/e4b-distil/export
4. Serve. Four single-GPU SGLang replicas behind one port, with Gemma 4’s tool-call and reasoning parsers:
5. Evaluate. mini-swe-agent through Harbor, four attempts per environment, then pass@k. Run it against the stock model, served the same way, for your own baseline.
Smoke test.python smoke_test.py writes five invented traces and checks the prompt normalization, the thought cap, the per-environment limit, the control-tag filter and the loss mask, in a second without a GPU or the model:
ok: rows: per-env limit, prompts normalized, thought capped, tag droppedok: loss mask covers thoughts, calls, stop tags and the turn endok: smoke test passed
Adapt it
Your own environments and teacher: prepare.py only needs the trace layout above, and the teacher can be any model mini-swe-agent can drive. Keep the held-out environments apart from the ones the teacher saw.
Gemma 4 12B: MODEL_DIR is the only change; train.sh picks the decoder layer class for FSDP from the model config. Expect about twice the time per step.
A cheaper agent: the student’s solves come from working longer. A step limit of 100 keeps about 94% of them at about 85% of the tokens.
{"docsConfig":{"theme":"mint","$schema":"https://mintlify.com/docs.json","name":"Reflection Developer Docs","colors":{"primary":"#1e3207","light":"#bdc8b5","dark":"#1e3207"},"logo":{"light":"https://mintcdn.com/reflection-ai/QTuxzl6PxhZZjLhq/logo/light.svg?fit=max\u0026auto=format\u0026n=QTuxzl6PxhZZjLhq\u0026q=85\u0026s=58c942f905cb3bd4c0a14b113a3aee89","dark":"https://mintcdn.com/reflection-ai/QTuxzl6PxhZZjLhq/logo/dark.svg?fit=max\u0026auto=format\u0026n=QTuxzl6PxhZZjLhq\u0026q=85\u0026s=72f108f3de1233371ba966d2f4ff3754"},"favicon":{"light":"https://mintcdn.com/reflection-ai/JsnqP0KHndVcbl2Y/favicon-light.svg?fit=max\u0026auto=format\u0026n=JsnqP0KHndVcbl2Y\u0026q=85\u0026s=d06a05d3592404faa659b9776f0c897e","dark":"https://mintcdn.com/reflection-ai/JsnqP0KHndVcbl2Y/favicon-dark.svg?fit=max\u0026auto=format\u0026n=JsnqP0KHndVcbl2Y\u0026q=85\u0026s=890ef9e453a694b505f70db674199964"},"api":{"playground":{"display":"interactive"},"examples":{"languages":["curl","python","javascript"]}},"background":{"color":{"light":"#f8f6f0","dark":"#1a1b1a"}},"navbar":{"links":[{"href":"https://platform.reflection.ai","label":"Platform"},{"href":"https://status.reflection.ai","label":"Status"}],"primary":{"type":"button","label":"Get an API key","href":"https://platform.reflection.ai/api-keys"}},"footer":{"socials":{"github":"https://github.com/reflection-oss","discord":"https://discord.gg/GyNwCVQf6U"}},"fonts":{"heading":{"family":"NaN Serf Sans","weight":600,"source":"fonts/nan-serf-sans-600.woff2","format":"woff2"},"body":{"family":"Reflection Inter","source":"fonts/inter-400.woff2","format":"woff2"}},"styling":{"eyebrows":"breadcrumbs","codeblocks":{"theme":{"light":"vitesse-light","dark":"vitesse-dark"}},"latex":false},"banner":{"content":"Beam 1.0 is out, with open weights, the Reflection API, and Mirror CLI (beta). [Read the announcement](https://reflection.ai/blog/beam-is-available)","dismissible":true},"errors":{"404":{"redirect":false,"title":"Page not found","description":"This page may have moved. Search the docs, or start from the [home page](/introduction), the [API quickstart](/quickstart), or the [Mirror quickstart](/coding-agents-quickstart)."}},"contextual":{"options":["copy","view","chatgpt","claude","perplexity","mcp","cursor","vscode"],"display":"header"},"thumbnails":{"preset":"headline","surface":"brand","fonts":{"family":"NaN Serf Sans","source":"fonts/nan-serf-sans-600.woff","format":"woff"},"eyebrow":{"source":"tab","style":"bar","color":"#1e3207"}},"metadata":{"timestamp":true},"navigation":{"pages":[]}},"deployment":{"deploymentMetadataValue":{"subdomain":"reflection-ai","hasAudioNarration":false,"actualSubdomain":"reflection-ai","customDomains":["developers.reflection.ai"],"gitSource":{"type":"github","owner":"reflectionai","repo":"developer-docs-web","deployBranch":"main","contentDirectory":"","isPrivate":true,"mountPath":"","label":"","_id":"6b10fff79ffae5051c41d71e"},"entitlements":{"AI_CHAT":{"status":"ENABLED"},"REMOVE_BRANDING":{"status":"ENABLED"},"CONTEXTUAL_FEEDBACK":{"status":"ENABLED"},"CODE_SNIPPET_FEEDBACK":{"status":"ENABLED"},"WEB_MCP":{"status":"ENABLED"},"NARRATION":{"status":"ENABLED"}},"buildId":"6b0d8b281ad4e02b275395f9","clientVersion":"0.0.4458","searchFilterCounts":[{"language":"default","tag":"API","count":17},{"language":"default","tag":"Customization","count":17},{"language":"default","tag":"Safety","count":16},{"language":"default","tag":"Deployment","count":14},{"language":"default","tag":"Self-hosting","count":11},{"language":"default","tag":"Guides","count":10},{"language":"default","tag":"Get started","count":9},{"language":"default","tag":"Supervised fine-tuning","count":9},{"language":"default","tag":"Integration stacks","count":9},{"language":"default","tag":"Mirror","count":8}]},"assistantConfig":{"enableAskAiButton":false,"enableStarterQuestions":false,"enableContextualStarterQuestions":false,"enableAskAiSearchBar":true},"basePath":"","hasChatPermissions":true,"hasWebMcpPermissions":true,"toggles":[{"name":"kill-isr","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"agent-mintlify-slack","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"agent-integrations-settings","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"rbac-expansion","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"automations-pr-grouping","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"custom-prefix","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"analytics-v7","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"user-flows-analytics","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"no-publish-flow","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"snapshot-serving-live","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"stripTemperatureMiddleware","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"support-platform-pylon-zendesk","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"snapshot-serving","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"instant-rollback","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"granular-notifications-server","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"granular-notifications","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"automations-fable","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"fixed-ai-action-pricing","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"automation-resolve-merge-conflict","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"scoped-publishing","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"mintql","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"page-level-analytics","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"editor-version-history-v2","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"billing-page-v2","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"full-page-search","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workspace-projects","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"fork-pr-previews","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"revalidation-jwt","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"hobby-abuse-scan","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"dashboard-inbox","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"turbopuffer-dual-write","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"approve-review-flow","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"editor-metadata","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"turbopuffer-serve","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"live-agents","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"starter-pricing","enabled":true,"variant":{"name":"control","enabled":true,"payload":{"type":"string","value":"control"},"feature_enabled":true},"impressionData":false},{"name":"llms-txt-v2","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false}],"starterQuestions":[],"googleFontsInlined":false},"customCss":[{"filePath":"fonts.css","content":"@font-face{font-family:\"Reflection Inter\";font-style:normal;font-weight:500;font-display:swap;src:url(\"/fonts/inter-500.woff2\") format(\"woff2\")}@font-face{font-family:\"Reflection Inter\";font-style:normal;font-weight:600;font-display:swap;src:url(\"/fonts/inter-600.woff2\") format(\"woff2\")}@font-face{font-family:\"NaN Serf Sans\";font-style:normal;font-weight:500;font-display:swap;src:url(\"/fonts/nan-serf-sans-500.woff2\") format(\"woff2\")}"},{"filePath":"callout-tables.css","content":"#content-area [data-component-part=\"callout-content\"]>[data-component-part=\"scroll-area\"]:first-child{margin-top:0!important;padding-top:0!important}#content-area [data-component-part=\"callout-content\"]>[data-component-part=\"scroll-area\"]:last-child{margin-bottom:0!important;padding-bottom:0!important}#content-area thead:not(:has(th:not(:empty))){display:none}"},{"filePath":"code-links.css","content":"#content-area a.link:has(>code){border-bottom-width:0!important}#content-area a.link>code{text-decoration-line:underline!important;text-decoration-thickness:1px!important;text-decoration-color:rgb(var(--primary))!important;text-underline-offset:3px!important}.dark #content-area a.link>code{text-decoration-color:rgb(var(--primary-light))!important}#content-area [data-component-part=\"callout-content\"] a.link>code{text-decoration-color:currentcolor!important}"}]}
{"page":{"pagePath":"distil-swe-agent","slug":"/distil-swe-agent","pageMetadata":{"title":"Doubling synthetic env tasks solve rate using Beam","sidebarTitle":"Distil a SWE agent","description":"Distil a SWE agent into Gemma 4 E4B by fine-tuning on Beam's golden traces","href":"/distil-swe-agent"},"description":{"compiledSource":"\"use strict\";\nconst {jsx: _jsx} = arguments[0];\nconst {useMDXComponents: _provideComponents} = arguments[0];\nfunction _createMdxContent(props) {\n const _components = {\n p: \"p\",\n ..._provideComponents(),\n ...props.components\n };\n return _jsx(_components.p, {\n children: \"Distil a SWE agent into Gemma 4 E4B by fine-tuning on Beam’s golden traces\"\n });\n}\nfunction MDXContent(props = {}) {\n const {wrapper: MDXLayout} = {\n ..._provideComponents(),\n ...props.components\n };\n return MDXLayout ? _jsx(MDXLayout, {\n ...props,\n children: _jsx(_createMdxContent, {\n ...props\n })\n }) : _createMdxContent(props);\n}\nreturn {\n default: MDXContent\n};\n","frontmatter":{},"scope":{}},"pageType":"default","mdx":{"mdxSource":{"compiledSource":"\"use strict\";const{Fragment:_Fragment,jsx:_jsx,jsxs:_jsxs}=arguments[0];const{useMDXComponents:_provideComponents}=arguments[0];const ViewOnGitHub=({href,label=`View on GitHub`,note})=>{const _components={a:`a`,..._provideComponents()};return _jsxs(`div`,{className:`vgh not-prose`,children:[_jsx(`style`,{children:`\n .vgh { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; margin: 0 0 20px; }\n .vgh-btn { flex: none; }\n .vgh-note { flex: 1 1 220px; min-width: 0; font-size: 13px; font-style: italic; line-height: 1.4; color: #5c6255; }\n .dark .vgh-note { color: #a8ad9f; }\n .vgh-btn { display: inline-flex; align-items: center; gap: 8px; padding: 7px 16px; border-radius: 999px; border: 1px solid rgba(27, 29, 23, 0.24); color: #1b1d17; font-size: 14px; font-weight: 500; line-height: 1.2; text-decoration: none; transition: border-color 0.15s, background-color 0.15s; }\n .vgh-btn:hover { border-color: #1e3207; background-color: rgba(30, 50, 7, 0.04); }\n .dark .vgh-btn { border-color: rgba(236, 235, 228, 0.24); color: #ecebe4; }\n .dark .vgh-btn:hover { border-color: #bdc8b5; background-color: rgba(189, 200, 181, 0.06); }\n .vgh-btn svg { width: 16px; height: 16px; fill: currentColor; flex: none; }\n `}),_jsxs(_components.a,{className:`vgh-btn`,href,target:`_blank`,rel:`noopener noreferrer`,children:[href.startsWith(`https://github.com/`)?_jsx(`svg`,{viewBox:`0 0 16 16`,\"aria-hidden\":`true`,children:_jsx(`path`,{d:`M8 0c4.42 0 8 3.58 8 8a8.013 8.013 0 0 1-5.45 7.59c-.4.08-.55-.17-.55-.38 0-.27.01-1.13.01-2.2 0-.75-.25-1.23-.54-1.48 1.78-.2 3.65-.88 3.65-3.95 0-.88-.31-1.59-.82-2.15.08-.2.36-1.02-.08-2.12 0 0-.67-.22-2.2.82-.64-.18-1.32-.27-2-.27-.68 0-1.36.09-2 .27-1.53-1.03-2.2-.82-2.2-.82-.44 1.1-.16 1.92-.08 2.12-.51.56-.82 1.28-.82 2.15 0 3.06 1.86 3.75 3.64 3.95-.23.2-.44.55-.51 1.07-.46.21-1.61.55-2.33-.66-.15-.24-.6-.83-1.23-.82-.67.01-.27.38.01.53.34.19.73.9.82 1.13.16.45.68 1.31 2.69.94 0 .67.01 1.3.01 1.49 0 .21-.15.45-.55.38A7.995 7.995 0 0 1 0 8c0-4.42 3.58-8 8-8Z`})}):_jsx(`svg`,{viewBox:`0 0 16 16`,\"aria-hidden\":`true`,children:_jsx(`path`,{d:`M3.75 2h3.5a.75.75 0 0 1 0 1.5h-3.5a.25.25 0 0 0-.25.25v8.5c0 .138.112.25.25.25h8.5a.25.25 0 0 0 .25-.25v-3.5a.75.75 0 0 1 1.5 0v3.5A1.75 1.75 0 0 1 12.25 14h-8.5A1.75 1.75 0 0 1 2 12.25v-8.5C2 2.784 2.784 2 3.75 2Zm6.854-1h4.146a.25.25 0 0 1 .25.25v4.146a.25.25 0 0 1-.427.177L13.03 4.03 9.28 7.78a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042l3.75-3.75-1.543-1.543A.25.25 0 0 1 10.604 1Z`})}),label]}),note?_jsx(`span`,{className:`vgh-note`,children:note}):null]})};function _createMdxContent(props){const _components={a:`a`,code:`code`,li:`li`,p:`p`,pre:`pre`,span:`span`,strong:`strong`,tbody:`tbody`,td:`td`,th:`th`,thead:`thead`,tr:`tr`,ul:`ul`,..._provideComponents(),...props.components},{CodeBlock,Heading,OptimizedImage,Table,_MdxComponentBoundary}=_components;if(!CodeBlock)_missingMdxReference(`CodeBlock`,true);if(!Heading)_missingMdxReference(`Heading`,true);if(!OptimizedImage)_missingMdxReference(`OptimizedImage`,true);if(!Table)_missingMdxReference(`Table`,true);if(!_MdxComponentBoundary)_missingMdxReference(`_MdxComponentBoundary`,true);return _jsxs(_Fragment,{children:[_jsx(_MdxComponentBoundary,{name:`ViewOnGitHub`,children:_jsx(ViewOnGitHub,{href:`https://github.com/reflection-oss/cookbook/tree/main/recipes/customization/sft/distil-swe-agent`})}),`\n`,_jsx(_components.p,{children:`Twice as many held-out software-engineering environments solved, from one afternoon of training on one node. The teacher is Beam, the student is Gemma 4 E4B, and the only judge is each environment’s hidden test.`}),`\n`,_jsx(OptimizedImage,{src:`https://mintcdn.com/reflection-ai/ngEEhG9LrYJzE2WI/images/customization/distil-swe-agent/distillation-path.svg?fit=max\u0026auto=format\u0026n=ngEEhG9LrYJzE2WI\u0026q=85\u0026s=436fc65c6bb4cbfc20dc161b3f17ea5b`,alt:`Beam solves terminal environments, the passing traces are kept, Gemma 4 E4B is fine-tuned on them and evaluated on held-out environments with the same hidden tests.`,\"data-og-width\":`1000`,width:`1000`,\"data-og-height\":`250`,height:`250`,\"data-path\":`images/customization/distil-swe-agent/distillation-path.svg`,\"data-optimize\":`true`,\"data-opv\":`3`,srcset:`https://mintcdn.com/reflection-ai/ngEEhG9LrYJzE2WI/images/customization/distil-swe-agent/distillation-path.svg?w=280\u0026fit=max\u0026auto=format\u0026n=ngEEhG9LrYJzE2WI\u0026q=85\u0026s=dba597be070d747e0d7ca4a05622f20d 280w, https://mintcdn.com/reflection-ai/ngEEhG9LrYJzE2WI/images/customization/distil-swe-agent/distillation-path.svg?w=560\u0026fit=max\u0026auto=format\u0026n=ngEEhG9LrYJzE2WI\u0026q=85\u0026s=be05caa4813fe2696cac631f36e0b66c 560w, https://mintcdn.com/reflection-ai/ngEEhG9LrYJzE2WI/images/customization/distil-swe-agent/distillation-path.svg?w=840\u0026fit=max\u0026auto=format\u0026n=ngEEhG9LrYJzE2WI\u0026q=85\u0026s=790872a35b4a473a45422d9c1079f3ff 840w, https://mintcdn.com/reflection-ai/ngEEhG9LrYJzE2WI/images/customization/distil-swe-agent/distillation-path.svg?w=1100\u0026fit=max\u0026auto=format\u0026n=ngEEhG9LrYJzE2WI\u0026q=85\u0026s=d21c3b796e172d11699172ac6b622c19 1100w, https://mintcdn.com/reflection-ai/ngEEhG9LrYJzE2WI/images/customization/distil-swe-agent/distillation-path.svg?w=1650\u0026fit=max\u0026auto=format\u0026n=ngEEhG9LrYJzE2WI\u0026q=85\u0026s=6762ccfd6d1bdd03e10cff8528698e44 1650w, https://mintcdn.com/reflection-ai/ngEEhG9LrYJzE2WI/images/customization/distil-swe-agent/distillation-path.svg?w=2500\u0026fit=max\u0026auto=format\u0026n=ngEEhG9LrYJzE2WI\u0026q=85\u0026s=c9f23690991becb5ba91cf50e7ca320c 2500w`}),`\n`,_jsx(Heading,{level:`2`,id:`how-it-works`,children:`How it works`}),`\n`,_jsxs(_components.ul,{children:[`\n`,_jsxs(_components.li,{children:[_jsx(_components.strong,{children:`The data is golden traces`}),` from the companion recipe, Synthetic SWE environments with Beam (`,_jsx(_components.code,{children:`recipes/customization/data-synthesis/synthetic-environment-gen`}),`): Beam’s reasoning, every bash command it ran and every output it saw, kept only when the environment’s hidden test passed.`]}),`\n`,_jsxs(_components.li,{children:[_jsx(_components.strong,{children:`The prompts are swapped for the evaluation prompts.`}),` The teacher ran with extra editing rules; the student is served without them. Strip them from the data and the habits transfer to the plain prompt.`]}),`\n`,_jsxs(_components.li,{children:[_jsx(_components.strong,{children:`The student is graded only on what Beam wrote.`}),` The thought, the command and the tag that ends the turn are trained; the prompts and the terminal output are masked.`]}),`\n`,_jsxs(_components.li,{children:[_jsx(_components.strong,{children:`Training is plain supervised fine-tuning`}),`, all language-model weights, two epochs. A generation check gates the export, because a scrambled save has normal tensor statistics.`]}),`\n`]}),`\n`,_jsx(OptimizedImage,{src:`https://mintcdn.com/reflection-ai/ngEEhG9LrYJzE2WI/images/customization/distil-swe-agent/loss-mask.svg?fit=max\u0026auto=format\u0026n=ngEEhG9LrYJzE2WI\u0026q=85\u0026s=bd78ce06c8e54608cfbacf1331de2483`,alt:`One rendered conversation: the prompt and tool outputs are masked, the thought, bash call, stop tag and turn end are trained; 41% of the tokens.`,\"data-og-width\":`1000`,width:`1000`,\"data-og-height\":`300`,height:`300`,\"data-path\":`images/customization/distil-swe-agent/loss-mask.svg`,\"data-optimize\":`true`,\"data-opv\":`3`,srcset:`https://mintcdn.com/reflection-ai/ngEEhG9LrYJzE2WI/images/customization/distil-swe-agent/loss-mask.svg?w=280\u0026fit=max\u0026auto=format\u0026n=ngEEhG9LrYJzE2WI\u0026q=85\u0026s=706fd57d1dc26b18d04c5e3a6f36e362 280w, https://mintcdn.com/reflection-ai/ngEEhG9LrYJzE2WI/images/customization/distil-swe-agent/loss-mask.svg?w=560\u0026fit=max\u0026auto=format\u0026n=ngEEhG9LrYJzE2WI\u0026q=85\u0026s=77225e8e060c42e336f3b04c851d2c42 560w, https://mintcdn.com/reflection-ai/ngEEhG9LrYJzE2WI/images/customization/distil-swe-agent/loss-mask.svg?w=840\u0026fit=max\u0026auto=format\u0026n=ngEEhG9LrYJzE2WI\u0026q=85\u0026s=8c32d2394918170718194cec5e00d1d9 840w, https://mintcdn.com/reflection-ai/ngEEhG9LrYJzE2WI/images/customization/distil-swe-agent/loss-mask.svg?w=1100\u0026fit=max\u0026auto=format\u0026n=ngEEhG9LrYJzE2WI\u0026q=85\u0026s=5fead46fc7e7d48d7e91045c662df35b 1100w, https://mintcdn.com/reflection-ai/ngEEhG9LrYJzE2WI/images/customization/distil-swe-agent/loss-mask.svg?w=1650\u0026fit=max\u0026auto=format\u0026n=ngEEhG9LrYJzE2WI\u0026q=85\u0026s=8cf58b71cc1592aeeb5e7d348dc4ad81 1650w, https://mintcdn.com/reflection-ai/ngEEhG9LrYJzE2WI/images/customization/distil-swe-agent/loss-mask.svg?w=2500\u0026fit=max\u0026auto=format\u0026n=ngEEhG9LrYJzE2WI\u0026q=85\u0026s=f96e5bee2ec6cc9e6ff4af23bd428c5d 2500w`}),`\n`,_jsx(Heading,{level:`2`,id:`what-the-student-learns`,children:`What the student learns`}),`\n`,_jsx(_components.p,{children:`Not the answers: the evaluation environments are new. It learns a way of working. One environment side by side; the task is a broken vendored audit package to fix and run over 200 JSONL events.`}),`\n`,_jsxs(Table,{children:[_jsx(_components.thead,{children:_jsxs(_components.tr,{children:[_jsx(_components.th,{}),_jsx(_components.th,{children:`stock`}),_jsx(_components.th,{children:`this recipe`})]})}),_jsxs(_components.tbody,{children:[_jsxs(_components.tr,{children:[_jsx(_components.td,{children:`reads the code`}),_jsx(_components.td,{children:`edits the Makefile three times from the task text`}),_jsx(_components.td,{children:`dumps every file in the package, counts the real events`})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:`finds the bug`}),_jsx(_components.td,{children:`deletes the failing import`}),_jsxs(_components.td,{children:[`runs `,_jsx(_components.code,{children:`make all`}),`, renames one module to the name the imports expect`]})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:`checks its work`}),_jsx(_components.td,{children:`overwrites the input file with ten fake rows so the pipeline runs`}),_jsx(_components.td,{children:`re-runs the target, prints the report to check its schema`})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:`result`}),_jsxs(_components.td,{children:[`verifier fails on `,_jsx(_components.code,{children:`record_count: 6 == 200`}),`, 0 of 4 attempts`]}),_jsx(_components.td,{children:`6 of 6 tests, 4 of 4 attempts, 53 commands`})]})]})]}),`\n`,_jsx(OptimizedImage,{src:`https://mintcdn.com/reflection-ai/ngEEhG9LrYJzE2WI/images/customization/distil-swe-agent/cost-per-solve.svg?fit=max\u0026auto=format\u0026n=ngEEhG9LrYJzE2WI\u0026q=85\u0026s=23ecde37df8966b2ccc35b565b328914`,alt:`Per attempt and per solve: 12 against 78 commands, 14 against 6.1 attempts per solve, 119k against 279k output tokens per solve.`,\"data-og-width\":`1000`,width:`1000`,\"data-og-height\":`330`,height:`330`,\"data-path\":`images/customization/distil-swe-agent/cost-per-solve.svg`,\"data-optimize\":`true`,\"data-opv\":`3`,srcset:`https://mintcdn.com/reflection-ai/ngEEhG9LrYJzE2WI/images/customization/distil-swe-agent/cost-per-solve.svg?w=280\u0026fit=max\u0026auto=format\u0026n=ngEEhG9LrYJzE2WI\u0026q=85\u0026s=3bf182f81d9750b10e28c35738dbd2eb 280w, https://mintcdn.com/reflection-ai/ngEEhG9LrYJzE2WI/images/customization/distil-swe-agent/cost-per-solve.svg?w=560\u0026fit=max\u0026auto=format\u0026n=ngEEhG9LrYJzE2WI\u0026q=85\u0026s=f109b2f38a783c920b309315f4315f36 560w, https://mintcdn.com/reflection-ai/ngEEhG9LrYJzE2WI/images/customization/distil-swe-agent/cost-per-solve.svg?w=840\u0026fit=max\u0026auto=format\u0026n=ngEEhG9LrYJzE2WI\u0026q=85\u0026s=97cc6234a1b482d5cdffd324cb780776 840w, https://mintcdn.com/reflection-ai/ngEEhG9LrYJzE2WI/images/customization/distil-swe-agent/cost-per-solve.svg?w=1100\u0026fit=max\u0026auto=format\u0026n=ngEEhG9LrYJzE2WI\u0026q=85\u0026s=5f4dc7f657436ed78363942092638e61 1100w, https://mintcdn.com/reflection-ai/ngEEhG9LrYJzE2WI/images/customization/distil-swe-agent/cost-per-solve.svg?w=1650\u0026fit=max\u0026auto=format\u0026n=ngEEhG9LrYJzE2WI\u0026q=85\u0026s=bc5997e4ac267688d953f9901f9cc267 1650w, https://mintcdn.com/reflection-ai/ngEEhG9LrYJzE2WI/images/customization/distil-swe-agent/cost-per-solve.svg?w=2500\u0026fit=max\u0026auto=format\u0026n=ngEEhG9LrYJzE2WI\u0026q=85\u0026s=e6fd0d7d65a8f8d723087fc1b60159e3 2500w`}),`\n`,_jsx(Heading,{level:`2`,id:`what-to-expect`,children:`What to expect`}),`\n`,_jsx(OptimizedImage,{src:`https://mintcdn.com/reflection-ai/ngEEhG9LrYJzE2WI/images/customization/distil-swe-agent/passk.svg?fit=max\u0026auto=format\u0026n=ngEEhG9LrYJzE2WI\u0026q=85\u0026s=aa897895b12bc9d55307ea7b5394d57e`,alt:`pass@1 to pass@4 on 171 held-out environments: 7.2, 10.2, 12.6 and 14.6 percent stock; 16.4, 23.6, 28.2 and 31.6 percent after this recipe.`,\"data-og-width\":`1000`,width:`1000`,\"data-og-height\":`360`,height:`360`,\"data-path\":`images/customization/distil-swe-agent/passk.svg`,\"data-optimize\":`true`,\"data-opv\":`3`,srcset:`https://mintcdn.com/reflection-ai/ngEEhG9LrYJzE2WI/images/customization/distil-swe-agent/passk.svg?w=280\u0026fit=max\u0026auto=format\u0026n=ngEEhG9LrYJzE2WI\u0026q=85\u0026s=7cf26f05854780763b0b9987ac16fc77 280w, https://mintcdn.com/reflection-ai/ngEEhG9LrYJzE2WI/images/customization/distil-swe-agent/passk.svg?w=560\u0026fit=max\u0026auto=format\u0026n=ngEEhG9LrYJzE2WI\u0026q=85\u0026s=8de19126a6ffa5f626b42778b8b5f577 560w, https://mintcdn.com/reflection-ai/ngEEhG9LrYJzE2WI/images/customization/distil-swe-agent/passk.svg?w=840\u0026fit=max\u0026auto=format\u0026n=ngEEhG9LrYJzE2WI\u0026q=85\u0026s=a6ab32347c698b9a478874110f2b15cb 840w, https://mintcdn.com/reflection-ai/ngEEhG9LrYJzE2WI/images/customization/distil-swe-agent/passk.svg?w=1100\u0026fit=max\u0026auto=format\u0026n=ngEEhG9LrYJzE2WI\u0026q=85\u0026s=d006f2e0c293bc9661763a6be090d810 1100w, https://mintcdn.com/reflection-ai/ngEEhG9LrYJzE2WI/images/customization/distil-swe-agent/passk.svg?w=1650\u0026fit=max\u0026auto=format\u0026n=ngEEhG9LrYJzE2WI\u0026q=85\u0026s=8fe62e5f863ec8613b204481429147b0 1650w, https://mintcdn.com/reflection-ai/ngEEhG9LrYJzE2WI/images/customization/distil-swe-agent/passk.svg?w=2500\u0026fit=max\u0026auto=format\u0026n=ngEEhG9LrYJzE2WI\u0026q=85\u0026s=37b0ec43a567aa0b0b793ec8c1411c76 2500w`}),`\n`,_jsxs(_components.ul,{children:[`\n`,_jsx(_components.li,{children:`Four attempts per environment, plain agent configuration: temperature 1.0, 16k output tokens, thinking on, no decoding tricks. pass@k is the chance that at least one of k attempts passes the hidden tests, averaged over environments.`}),`\n`,_jsx(_components.li,{children:`Attempts are sampled and training is not deterministic. A second training run with the scripts in this folder scored 13.6% / 20.0% / 24.0% / 26.9% and solved 46 environments, 38 shared with the first. Treat gaps under 3 points as noise; rank candidates on a subset of 60 environments at two attempts each before spending a day on the full set.`}),`\n`,_jsx(_components.li,{children:`The obvious data is not the best data. Students trained only on traces rolled out through the evaluation harness collapsed into repetition from the first step; the same rollouts mixed beside Beam’s corpus traces gave the best model. Keep the corpus traces as the base of the mix.`}),`\n`]}),`\n`,_jsx(Heading,{level:`2`,id:`before-you-start`,children:`Before you start`}),`\n`,_jsxs(_components.ul,{children:[`\n`,_jsxs(_components.li,{children:[_jsx(_components.code,{children:`google/gemma-4-E4B-it`}),` at revision `,_jsx(_components.code,{children:`ee0ef6023621cff504d758262d4e04895a5af4a2`}),`. Gemma is gated: accept the license on the model page and set `,_jsx(_components.code,{children:`HF_TOKEN`}),` (the cookbook’s `,_jsx(_components.code,{children:`.env.example`}),` lists it).`]}),`\n`,_jsxs(_components.li,{children:[`Golden traces as the companion recipe writes them, `,_jsx(_components.code,{children:`traces/\u003csource>/\u003cenv_id>/trace_\u003cn>.json`}),`, each `,_jsx(_components.code,{children:`{\"task\": \"\u003cenv_id>\", \"messages\": [...]}`}),`. Our run used two sources from the same teacher on 500 training environments: 895 traces Beam wrote when the environments were created (`,_jsx(_components.code,{children:`corpus`}),`) and 295 from running Beam again with stricter editing instructions (`,_jsx(_components.code,{children:`rollouts`}),`). The second source raised pass@1 from 13.6% to 16.4%.`]}),`\n`,_jsxs(_components.li,{children:[`Held-out environments as Harbor task folders, the companion recipe’s `,_jsx(_components.code,{children:`output/harbor/`}),`, never used for training.`]}),`\n`,_jsxs(_components.li,{children:[_jsx(_components.code,{children:`requirements.txt`}),`, pinned. Training ran with Python 3.12 and CUDA 13.`]}),`\n`]}),`\n`,_jsxs(Table,{children:[_jsx(_components.thead,{children:_jsxs(_components.tr,{children:[_jsx(_components.th,{children:`Stage`}),_jsx(_components.th,{children:`Hardware`}),_jsx(_components.th,{children:`What it took`})]})}),_jsxs(_components.tbody,{children:[_jsxs(_components.tr,{children:[_jsx(_components.td,{children:`Train`}),_jsxs(_components.td,{children:[`1 node, 8x NVIDIA B300 (`,_jsx(_components.code,{children:`NUM_GPUS=4`}),` also works, same effective batch)`]}),_jsx(_components.td,{children:`3 h 27 min, 66 optimizer steps`})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:`Serve`}),_jsx(_components.td,{children:`4 GPUs, SGLang`}),_jsx(_components.td,{})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:`Evaluate`}),_jsx(_components.td,{children:`Docker, about one CPU core per parallel attempt; we used 32 cores and 24 attempts`}),_jsx(_components.td,{children:`7 h 40 min for 684 attempts`})]})]})]}),`\n`,_jsx(Heading,{level:`2`,id:`run-it`,children:`Run it`}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`3`,language:`shellscript`,children:_jsx(_components.pre,{className:`shiki shiki-themes vitesse-light vitesse-dark`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#121212`,color:`#393a34`,\"--shiki-dark\":`#dbd7caee`},language:`shellscript`,children:_jsxs(_components.code,{language:`shellscript`,numberOfLines:`3`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#59873A`,\"--shiki-dark\":`#80A665`},children:`pip`}),_jsx(_components.span,{style:{color:`#B56959`,\"--shiki-dark\":`#C98A7D`},children:` install`}),_jsx(_components.span,{style:{color:`#A65E2B`,\"--shiki-dark\":`#C99076`},children:` -r`}),_jsx(_components.span,{style:{color:`#B56959`,\"--shiki-dark\":`#C98A7D`},children:` requirements.txt`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#59873A`,\"--shiki-dark\":`#80A665`},children:`hf`}),_jsx(_components.span,{style:{color:`#B56959`,\"--shiki-dark\":`#C98A7D`},children:` download`}),_jsx(_components.span,{style:{color:`#B56959`,\"--shiki-dark\":`#C98A7D`},children:` google/gemma-4-E4B-it`}),_jsx(_components.span,{style:{color:`#A65E2B`,\"--shiki-dark\":`#C99076`},children:` --revision`}),_jsx(_components.span,{style:{color:`#B56959`,\"--shiki-dark\":`#C98A7D`},children:` ee0ef6023621cff504d758262d4e04895a5af4a2`}),_jsx(_components.span,{style:{color:`#A65E2B`,\"--shiki-dark\":`#C99076`},children:` --local-dir`}),_jsx(_components.span,{style:{color:`#B56959`,\"--shiki-dark\":`#C98A7D`},children:` models/gemma-4-E4B-it`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#B07D48`,\"--shiki-dark\":`#BD976A`},children:`TRACES`}),_jsx(_components.span,{style:{color:`#999999`,\"--shiki-dark\":`#666666`},children:`=`}),_jsx(_components.span,{style:{color:`#B5695977`,\"--shiki-dark\":`#C98A7D77`},children:`\"`}),_jsx(_components.span,{style:{color:`#B56959`,\"--shiki-dark\":`#C98A7D`},children:`corpus=traces/corpus rollouts=traces/rollouts`}),_jsx(_components.span,{style:{color:`#B5695977`,\"--shiki-dark\":`#C98A7D77`},children:`\"`}),_jsx(_components.span,{style:{color:`#B07D48`,\"--shiki-dark\":`#BD976A`},children:` NUM_GPUS`}),_jsx(_components.span,{style:{color:`#999999`,\"--shiki-dark\":`#666666`},children:`=`}),_jsx(_components.span,{style:{color:`#B56959`,\"--shiki-dark\":`#C98A7D`},children:`8`}),_jsx(_components.span,{style:{color:`#59873A`,\"--shiki-dark\":`#80A665`},children:` bash`}),_jsx(_components.span,{style:{color:`#B56959`,\"--shiki-dark\":`#C98A7D`},children:` train.sh`})]}),`\n`]})})}),`\n`,_jsxs(_components.p,{children:[_jsx(_components.code,{children:`train.sh`}),` runs three scripts into `,_jsx(_components.code,{children:`runs/e4b-distil/`}),`. Extra arguments go to the trainer, for example `,_jsx(_components.code,{children:`--epochs 3`}),`.`]}),`\n`,_jsxs(_components.p,{children:[_jsx(_components.strong,{children:`1. Prepare.`}),` `,_jsx(_components.code,{children:`prepare.py`}),` keeps at most two traces per environment from each source, cuts every thought to about 2,000 characters at a sentence boundary, swaps in the standard prompts, renders with Gemma 4’s chat template and builds the loss mask. Traces above 220,000 characters, containing Gemma’s control tags, or above 65,536 tokens once rendered are left out; a tenth of the rest is held out for the eval loss. From our traces:`]}),`\n`,_jsx(CodeBlock,{numberOfLines:`2`,language:`text`,children:_jsx(_components.pre,{className:`shiki shiki-themes vitesse-light vitesse-dark`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#121212`,color:`#393a34`,\"--shiki-dark\":`#dbd7caee`},language:`text`,children:_jsxs(_components.code,{language:`text`,numberOfLines:`2`,children:[_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:`{\"rows\": 1190, \"environments\": 499, \"dropped_too_long\": 43, \"train\": 1033, \"val\": 114, \"tokens_mean\": 21660, \"tokens_max\": 65489, \"total_tokens\": 24844002}`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{})})]})})}),`\n`,_jsx(OptimizedImage,{src:`https://mintcdn.com/reflection-ai/ngEEhG9LrYJzE2WI/images/customization/distil-swe-agent/data-funnel.svg?fit=max\u0026auto=format\u0026n=ngEEhG9LrYJzE2WI\u0026q=85\u0026s=6cf086fda9ca506c4d934ec817d37a8b`,alt:`1,190 golden traces, 1,147 fit in 65k tokens, 1,033 trained on, 114 held out.`,\"data-og-width\":`1000`,width:`1000`,\"data-og-height\":`320`,height:`320`,\"data-path\":`images/customization/distil-swe-agent/data-funnel.svg`,\"data-optimize\":`true`,\"data-opv\":`3`,srcset:`https://mintcdn.com/reflection-ai/ngEEhG9LrYJzE2WI/images/customization/distil-swe-agent/data-funnel.svg?w=280\u0026fit=max\u0026auto=format\u0026n=ngEEhG9LrYJzE2WI\u0026q=85\u0026s=8447d280f810a9649571c1f6eb086388 280w, https://mintcdn.com/reflection-ai/ngEEhG9LrYJzE2WI/images/customization/distil-swe-agent/data-funnel.svg?w=560\u0026fit=max\u0026auto=format\u0026n=ngEEhG9LrYJzE2WI\u0026q=85\u0026s=14dff259da4b8613501a1d6f90611b60 560w, https://mintcdn.com/reflection-ai/ngEEhG9LrYJzE2WI/images/customization/distil-swe-agent/data-funnel.svg?w=840\u0026fit=max\u0026auto=format\u0026n=ngEEhG9LrYJzE2WI\u0026q=85\u0026s=00787192d0ff72f8ae29c8317919ddd1 840w, https://mintcdn.com/reflection-ai/ngEEhG9LrYJzE2WI/images/customization/distil-swe-agent/data-funnel.svg?w=1100\u0026fit=max\u0026auto=format\u0026n=ngEEhG9LrYJzE2WI\u0026q=85\u0026s=057f22f7d10384b184b83fc0274d337b 1100w, https://mintcdn.com/reflection-ai/ngEEhG9LrYJzE2WI/images/customization/distil-swe-agent/data-funnel.svg?w=1650\u0026fit=max\u0026auto=format\u0026n=ngEEhG9LrYJzE2WI\u0026q=85\u0026s=9d892f08daafa3812700cd744a3e5d96 1650w, https://mintcdn.com/reflection-ai/ngEEhG9LrYJzE2WI/images/customization/distil-swe-agent/data-funnel.svg?w=2500\u0026fit=max\u0026auto=format\u0026n=ngEEhG9LrYJzE2WI\u0026q=85\u0026s=d118216433b838a943dc1126e3e4ea42 2500w`}),`\n`,_jsxs(_components.p,{children:[_jsx(_components.strong,{children:`2. Train.`}),` `,_jsx(_components.code,{children:`train_sft.py`}),` with FSDP: 2 epochs, learning rate 1e-5, cosine with 3% warmup, one conversation per GPU per step and an effective batch of 32, bf16, gradient checkpointing, vision and audio towers frozen. One weights-only checkpoint per epoch; every logged value in `,_jsx(_components.code,{children:`checkpoints/log_history.json`}),`.`]}),`\n`,_jsx(OptimizedImage,{src:`https://mintcdn.com/reflection-ai/ngEEhG9LrYJzE2WI/images/customization/distil-swe-agent/loss_curve.png?fit=max\u0026auto=format\u0026n=ngEEhG9LrYJzE2WI\u0026q=85\u0026s=19bb189089b2ceb41425e7bb8e4ed9b8`,alt:`Training loss every 5 steps and the eval loss on 114 held-out conversations, from our run on 8 B300 GPUs`,\"data-og-width\":`1280`,width:`1280`,\"data-og-height\":`736`,height:`736`,\"data-path\":`images/customization/distil-swe-agent/loss_curve.png`,\"data-optimize\":`true`,\"data-opv\":`3`,srcset:`https://mintcdn.com/reflection-ai/ngEEhG9LrYJzE2WI/images/customization/distil-swe-agent/loss_curve.png?w=280\u0026fit=max\u0026auto=format\u0026n=ngEEhG9LrYJzE2WI\u0026q=85\u0026s=eff23dd33aca52972c3bfaa11a7728bd 280w, https://mintcdn.com/reflection-ai/ngEEhG9LrYJzE2WI/images/customization/distil-swe-agent/loss_curve.png?w=560\u0026fit=max\u0026auto=format\u0026n=ngEEhG9LrYJzE2WI\u0026q=85\u0026s=cf3a4a65bea7d218c254356c70b35e9a 560w, https://mintcdn.com/reflection-ai/ngEEhG9LrYJzE2WI/images/customization/distil-swe-agent/loss_curve.png?w=840\u0026fit=max\u0026auto=format\u0026n=ngEEhG9LrYJzE2WI\u0026q=85\u0026s=6a35994fe84741889b9bc0e2626cc8d7 840w, https://mintcdn.com/reflection-ai/ngEEhG9LrYJzE2WI/images/customization/distil-swe-agent/loss_curve.png?w=1100\u0026fit=max\u0026auto=format\u0026n=ngEEhG9LrYJzE2WI\u0026q=85\u0026s=4f2cdc5ab1df6c9f0c543dc08b3fef8e 1100w, https://mintcdn.com/reflection-ai/ngEEhG9LrYJzE2WI/images/customization/distil-swe-agent/loss_curve.png?w=1650\u0026fit=max\u0026auto=format\u0026n=ngEEhG9LrYJzE2WI\u0026q=85\u0026s=fbe29bfef162012f66d4c46958bd8176 1650w, https://mintcdn.com/reflection-ai/ngEEhG9LrYJzE2WI/images/customization/distil-swe-agent/loss_curve.png?w=2500\u0026fit=max\u0026auto=format\u0026n=ngEEhG9LrYJzE2WI\u0026q=85\u0026s=a3cd72a4d8f04d0dc7c5c485ea0da7ec 2500w`}),`\n`,_jsx(_components.p,{children:`The training loss drops below 1.0 in 20 steps and flattens near 0.85; the eval loss keeps falling through the second epoch (0.886, then 0.860). Three epochs did not help.`}),`\n`,_jsxs(_components.p,{children:[_jsx(_components.strong,{children:`3. Export.`}),` `,_jsx(_components.code,{children:`export.py`}),` re-saves the last checkpoint in bf16 with the base model’s config files, loads it on one GPU and answers a tool-calling question with thinking on. The run fails unless the text is readable and the thought channel opens.`]}),`\n`,_jsx(CodeBlock,{numberOfLines:`2`,language:`text`,children:_jsx(_components.pre,{className:`shiki shiki-themes vitesse-light vitesse-dark`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#121212`,color:`#393a34`,\"--shiki-dark\":`#dbd7caee`},language:`text`,children:_jsxs(_components.code,{language:`text`,numberOfLines:`2`,children:[_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:`EXPORT_OK runs/e4b-distil/export`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{})})]})})}),`\n`,_jsxs(_components.p,{children:[_jsx(_components.strong,{children:`4. Serve.`}),` Four single-GPU SGLang replicas behind one port, with Gemma 4’s tool-call and reasoning parsers:`]}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`5`,language:`shellscript`,children:_jsx(_components.pre,{className:`shiki shiki-themes vitesse-light vitesse-dark`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#121212`,color:`#393a34`,\"--shiki-dark\":`#dbd7caee`},language:`shellscript`,children:_jsxs(_components.code,{language:`shellscript`,numberOfLines:`5`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#59873A`,\"--shiki-dark\":`#80A665`},children:`docker`}),_jsx(_components.span,{style:{color:`#B56959`,\"--shiki-dark\":`#C98A7D`},children:` run`}),_jsx(_components.span,{style:{color:`#A65E2B`,\"--shiki-dark\":`#C99076`},children:` --rm`}),_jsx(_components.span,{style:{color:`#A65E2B`,\"--shiki-dark\":`#C99076`},children:` --gpus`}),_jsx(_components.span,{style:{color:`#B56959`,\"--shiki-dark\":`#C98A7D`},children:` all`}),_jsx(_components.span,{style:{color:`#A65E2B`,\"--shiki-dark\":`#C99076`},children:` --shm-size=16g`}),_jsx(_components.span,{style:{color:`#A65E2B`,\"--shiki-dark\":`#C99076`},children:` --ipc=host`}),_jsx(_components.span,{style:{color:`#A65E2B`,\"--shiki-dark\":`#C99076`},children:` -p`}),_jsx(_components.span,{style:{color:`#B56959`,\"--shiki-dark\":`#C98A7D`},children:` 30000:30000`}),_jsx(_components.span,{style:{color:`#A65E2B`,\"--shiki-dark\":`#C99076`},children:` \\\\`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#A65E2B`,\"--shiki-dark\":`#C99076`},children:` -v`}),_jsx(_components.span,{style:{color:`#B5695977`,\"--shiki-dark\":`#C98A7D77`},children:` \"`}),_jsx(_components.span,{style:{color:`#B56959`,\"--shiki-dark\":`#C98A7D`},children:`$PWD/runs/e4b-distil/export:/model:ro`}),_jsx(_components.span,{style:{color:`#B5695977`,\"--shiki-dark\":`#C98A7D77`},children:`\"`}),_jsx(_components.span,{style:{color:`#B56959`,\"--shiki-dark\":`#C98A7D`},children:` lmsysorg/sglang:nightly-dev-20261002-67eab570`}),_jsx(_components.span,{style:{color:`#A65E2B`,\"--shiki-dark\":`#C99076`},children:` \\\\`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#B56959`,\"--shiki-dark\":`#C98A7D`},children:` python3`}),_jsx(_components.span,{style:{color:`#A65E2B`,\"--shiki-dark\":`#C99076`},children:` -m`}),_jsx(_components.span,{style:{color:`#B56959`,\"--shiki-dark\":`#C98A7D`},children:` sglang.launch_server`}),_jsx(_components.span,{style:{color:`#A65E2B`,\"--shiki-dark\":`#C99076`},children:` --model-path`}),_jsx(_components.span,{style:{color:`#B56959`,\"--shiki-dark\":`#C98A7D`},children:` /model`}),_jsx(_components.span,{style:{color:`#A65E2B`,\"--shiki-dark\":`#C99076`},children:` --served-model-name`}),_jsx(_components.span,{style:{color:`#B56959`,\"--shiki-dark\":`#C98A7D`},children:` gemma-4-e4b-distil`}),_jsx(_components.span,{style:{color:`#A65E2B`,\"--shiki-dark\":`#C99076`},children:` \\\\`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#A65E2B`,\"--shiki-dark\":`#C99076`},children:` --host`}),_jsx(_components.span,{style:{color:`#2F798A`,\"--shiki-dark\":`#4C9A91`},children:` 0.0.0.0`}),_jsx(_components.span,{style:{color:`#A65E2B`,\"--shiki-dark\":`#C99076`},children:` --port`}),_jsx(_components.span,{style:{color:`#2F798A`,\"--shiki-dark\":`#4C9A91`},children:` 30000`}),_jsx(_components.span,{style:{color:`#A65E2B`,\"--shiki-dark\":`#C99076`},children:` --dp-size`}),_jsx(_components.span,{style:{color:`#2F798A`,\"--shiki-dark\":`#4C9A91`},children:` 4`}),_jsx(_components.span,{style:{color:`#A65E2B`,\"--shiki-dark\":`#C99076`},children:` --mem-fraction-static`}),_jsx(_components.span,{style:{color:`#2F798A`,\"--shiki-dark\":`#4C9A91`},children:` 0.85`}),_jsx(_components.span,{style:{color:`#A65E2B`,\"--shiki-dark\":`#C99076`},children:` --trust-remote-code`}),_jsx(_components.span,{style:{color:`#A65E2B`,\"--shiki-dark\":`#C99076`},children:` \\\\`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#A65E2B`,\"--shiki-dark\":`#C99076`},children:` --tool-call-parser`}),_jsx(_components.span,{style:{color:`#B56959`,\"--shiki-dark\":`#C98A7D`},children:` gemma4`}),_jsx(_components.span,{style:{color:`#A65E2B`,\"--shiki-dark\":`#C99076`},children:` --reasoning-parser`}),_jsx(_components.span,{style:{color:`#B56959`,\"--shiki-dark\":`#C98A7D`},children:` gemma4`})]}),`\n`]})})}),`\n`,_jsxs(_components.p,{children:[_jsx(_components.strong,{children:`5. Evaluate.`}),` mini-swe-agent through Harbor, four attempts per environment, then pass@k. Run it against the stock model, served the same way, for your own baseline.`]}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`1`,language:`shellscript`,children:_jsx(_components.pre,{className:`shiki shiki-themes vitesse-light vitesse-dark`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#121212`,color:`#393a34`,\"--shiki-dark\":`#dbd7caee`},language:`shellscript`,children:_jsxs(_components.code,{language:`shellscript`,numberOfLines:`1`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#B07D48`,\"--shiki-dark\":`#BD976A`},children:`TASKS_DIR`}),_jsx(_components.span,{style:{color:`#999999`,\"--shiki-dark\":`#666666`},children:`=`}),_jsx(_components.span,{style:{color:`#B56959`,\"--shiki-dark\":`#C98A7D`},children:`/path/to/heldout-tasks`}),_jsx(_components.span,{style:{color:`#59873A`,\"--shiki-dark\":`#80A665`},children:` bash`}),_jsx(_components.span,{style:{color:`#B56959`,\"--shiki-dark\":`#C98A7D`},children:` evaluate.sh`})]}),`\n`]})})}),`\n`,_jsx(CodeBlock,{numberOfLines:`3`,language:`text`,children:_jsx(_components.pre,{className:`shiki shiki-themes vitesse-light vitesse-dark`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#121212`,color:`#393a34`,\"--shiki-dark\":`#dbd7caee`},language:`text`,children:_jsxs(_components.code,{language:`text`,numberOfLines:`3`,children:[_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:`environments=171 attempts=684`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:`pass@1=16.4% pass@2=23.6% pass@3=28.2% pass@4=31.6%`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{})})]})})}),`\n`,_jsxs(_components.p,{children:[_jsx(_components.strong,{children:`Smoke test.`}),` `,_jsx(_components.code,{children:`python smoke_test.py`}),` writes five invented traces and checks the prompt normalization, the thought cap, the per-environment limit, the control-tag filter and the loss mask, in a second without a GPU or the model:`]}),`\n`,_jsx(CodeBlock,{numberOfLines:`4`,language:`text`,children:_jsx(_components.pre,{className:`shiki shiki-themes vitesse-light vitesse-dark`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#121212`,color:`#393a34`,\"--shiki-dark\":`#dbd7caee`},language:`text`,children:_jsxs(_components.code,{language:`text`,numberOfLines:`4`,children:[_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:`ok: rows: per-env limit, prompts normalized, thought capped, tag dropped`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:`ok: loss mask covers thoughts, calls, stop tags and the turn end`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:`ok: smoke test passed`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{})})]})})}),`\n`,_jsx(Heading,{level:`2`,id:`adapt-it`,children:`Adapt it`}),`\n`,_jsxs(_components.ul,{children:[`\n`,_jsxs(_components.li,{children:[_jsx(_components.strong,{children:`Your own environments and teacher`}),`: `,_jsx(_components.code,{children:`prepare.py`}),` only needs the trace layout above, and the teacher can be any model mini-swe-agent can drive. Keep the held-out environments apart from the ones the teacher saw.`]}),`\n`,_jsxs(_components.li,{children:[_jsx(_components.strong,{children:`Gemma 4 12B`}),`: `,_jsx(_components.code,{children:`MODEL_DIR`}),` is the only change; `,_jsx(_components.code,{children:`train.sh`}),` picks the decoder layer class for FSDP from the model config. Expect about twice the time per step.`]}),`\n`,_jsxs(_components.li,{children:[_jsx(_components.strong,{children:`A cheaper agent`}),`: the student’s solves come from working longer. A step limit of 100 keeps about 94% of them at about 85% of the tokens.`]}),`\n`]}),`\n`,_jsxs(_components.p,{children:[`Problems you may hit while running are in `,_jsx(_components.a,{href:`https://github.com/reflection-oss/cookbook/blob/main/recipes/customization/sft/distil-swe-agent/TROUBLESHOOTING.md`,children:`TROUBLESHOOTING.md`}),`.`]})]})}function MDXContent(props={}){const{wrapper:MDXLayout}={..._provideComponents(),...props.components};return MDXLayout?_jsx(MDXLayout,{...props,children:_jsx(_createMdxContent,{...props})}):_createMdxContent(props)}return{ViewOnGitHub,default:MDXContent};function _missingMdxReference(id,component){throw new Error(`Expected `+(component?`component`:`object`)+\" `\"+id+\"` to be defined: you likely forgot to import, pass, or provide it.\")}","frontmatter":{},"scope":{"codeStyling":{"theme":{"light":"vitesse-light","dark":"vitesse-dark"}},"config":{},"pageMetadata":{"title":"Doubling synthetic env tasks solve rate using Beam","sidebarTitle":"Distil a SWE agent","description":"Distil a SWE agent into Gemma 4 E4B by fine-tuning on Beam's golden traces","href":"/distil-swe-agent"}}},"mdxSourceWithNoJs":null,"noJsSplices":[[148,2631,")=>null;function _cr"]]},"mdxExtracts":{"tableOfContents":[{"title":"How it works","slug":"how-it-works","depth":2,"children":[]},{"title":"What the student learns","slug":"what-the-student-learns","depth":2,"children":[]},{"title":"What to expect","slug":"what-to-expect","depth":2,"children":[]},{"title":"Before you start","slug":"before-you-start","depth":2,"children":[]},{"title":"Run it","slug":"run-it","depth":2,"children":[]},{"title":"Adapt it","slug":"adapt-it","depth":2,"children":[]}],"codeExamples":{}},"jsLinks":[],"subdomain":"reflection-ai","siteName":"Reflection Developer Docs","title":"Doubling synthetic env tasks solve rate using Beam - Reflection Developer Docs","contextualStarterQuestions":[],"navMaps":{"firstHrefInVersion":{},"firstHrefInLanguage":{}},"lastModified":"2026-11-16T22:58:51.093Z","gitLastModified":"2026-10-20T19:37:54.000Z","originalFileLocation":"distil-swe-agent.mdx"},"headHtml":"\u003cscript data-mint-head>(function(){var d=document.documentElement,p=null;if(!p){try{p=localStorage.getItem(\"isDarkMode\")}catch(e){}if(p==='true')p='dark';else if(p==='false')p='light';if(p!=='light'\u0026\u0026p!=='dark'\u0026\u0026p!=='system')p=\"system\"}var r=p==='system'?(matchMedia(\"(prefers-color-scheme: dark)\").matches?'dark':'light'):p;d.classList.remove(r==='dark'?'light':'dark');d.classList.add(r);d.setAttribute(\"data-theme-preference\",p)})();\u003c/script>\u003cmeta data-mint-head name=\"description\" content=\"Distil a SWE agent into Gemma 4 E4B by fine-tuning on Beam\u0026#x27;s golden traces\">\u003cmeta data-mint-head name=\"application-name\" content=\"Reflection Developer Docs\">\u003cmeta data-mint-head name=\"generator\" content=\"Mintlify\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"192x192\" href=\"/mintlify-assets/_mintlify/favicons/reflection-ai/jwXyL2gkH91EW3EL/_generated/favicon/android-chrome-192x192.png\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"apple-touch-icon\" type=\"image/png\" sizes=\"180x180\" href=\"/mintlify-assets/_mintlify/favicons/reflection-ai/jwXyL2gkH91EW3EL/_generated/favicon/apple-touch-icon.png\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"16x16\" href=\"/mintlify-assets/_mintlify/favicons/reflection-ai/jwXyL2gkH91EW3EL/_generated/favicon/favicon-16x16.png\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"32x32\" href=\"/mintlify-assets/_mintlify/favicons/reflection-ai/jwXyL2gkH91EW3EL/_generated/favicon/favicon-32x32.png\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"shortcut icon\" type=\"image/x-icon\" href=\"/mintlify-assets/_mintlify/favicons/reflection-ai/jwXyL2gkH91EW3EL/_generated/favicon/favicon.ico\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"192x192\" href=\"/mintlify-assets/_mintlify/favicons/reflection-ai/jwXyL2gkH91EW3EL/_generated/favicon-dark/android-chrome-192x192.png\" media=\"(prefers-color-scheme: dark)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"16x16\" href=\"/mintlify-assets/_mintlify/favicons/reflection-ai/jwXyL2gkH91EW3EL/_generated/favicon-dark/favicon-16x16.png\" media=\"(prefers-color-scheme: dark)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"32x32\" href=\"/mintlify-assets/_mintlify/favicons/reflection-ai/jwXyL2gkH91EW3EL/_generated/favicon-dark/favicon-32x32.png\" media=\"(prefers-color-scheme: dark)\">\u003clink data-mint-head rel=\"shortcut icon\" type=\"image/x-icon\" href=\"/mintlify-assets/_mintlify/favicons/reflection-ai/jwXyL2gkH91EW3EL/_generated/favicon-dark/favicon.ico\" media=\"(prefers-color-scheme: dark)\">\u003cmeta data-mint-head property=\"og:title\" content=\"Doubling synthetic env tasks solve rate using Beam - Reflection Developer Docs\">\u003cmeta data-mint-head property=\"og:description\" content=\"Distil a SWE agent into Gemma 4 E4B by fine-tuning on Beam\u0026#x27;s golden traces\">\u003cmeta data-mint-head property=\"og:site_name\" content=\"Reflection Developer Docs\">\u003cmeta data-mint-head property=\"og:url\" content=\"https://developers.reflection.ai/distil-swe-agent\">\u003cmeta data-mint-head property=\"og:type\" content=\"website\">\u003cmeta data-mint-head property=\"og:image\" content=\"https://reflection-ai.mintlify.site/_mintlify/api/og/v2?division=Customization\u0026amp;title=Doubling+synthetic+env+tasks+solve+rate+using+Beam\u0026amp;description=Distil+a+SWE+agent+into+Gemma+4+E4B+by+fine-tuning+on+Beam%27s+golden+traces\u0026amp;theme=042e12ebdcff97fefb737062\u0026amp;signature=d304dbaefd2fa3839782161a6f78a305aab2b42b3565f8820bfb91006a8a4b33\">\u003cmeta data-mint-head property=\"og:image:width\" content=\"1200\">\u003cmeta data-mint-head property=\"og:image:height\" content=\"630\">\u003cmeta data-mint-head name=\"twitter:card\" content=\"summary_large_image\">\u003cmeta data-mint-head name=\"twitter:title\" content=\"Doubling synthetic env tasks solve rate using Beam - Reflection Developer Docs\">\u003cmeta data-mint-head name=\"twitter:description\" content=\"Distil a SWE agent into Gemma 4 E4B by fine-tuning on Beam\u0026#x27;s golden traces\">\u003cmeta data-mint-head name=\"twitter:image\" content=\"https://reflection-ai.mintlify.site/_mintlify/api/og/v2?division=Customization\u0026amp;title=Doubling+synthetic+env+tasks+solve+rate+using+Beam\u0026amp;description=Distil+a+SWE+agent+into+Gemma+4+E4B+by+fine-tuning+on+Beam%27s+golden+traces\u0026amp;theme=042e12ebdcff97fefb737062\u0026amp;signature=d304dbaefd2fa3839782161a6f78a305aab2b42b3565f8820bfb91006a8a4b33\">\u003cmeta data-mint-head name=\"twitter:image:width\" content=\"1200\">\u003cmeta data-mint-head name=\"twitter:image:height\" content=\"630\">\u003cmeta data-mint-head name=\"msapplication-config\" content=\"/mintlify-assets/_mintlify/favicons/reflection-ai/jwXyL2gkH91EW3EL/_generated/favicon/browserconfig.xml\">\u003cmeta data-mint-head name=\"apple-mobile-web-app-title\" content=\"Reflection Developer Docs\">\u003cmeta data-mint-head name=\"msapplication-TileColor\" content=\"#1e3207\">\u003clink data-mint-head rel=\"canonical\" href=\"https://developers.reflection.ai/distil-swe-agent\">\u003clink data-mint-head rel=\"alternate\" type=\"application/xml\" href=\"/sitemap.xml\">\u003clink data-mint-head rel=\"alternate\" type=\"text/markdown\" href=\"/distil-swe-agent.md\">\u003cscript data-mint-head type=\"application/ld+json\">{\"@context\":\"https://schema.org\",\"@graph\":[{\"@type\":\"Organization\",\"@id\":\"https://developers.reflection.ai/#organization\",\"name\":\"Reflection Developer Docs\",\"url\":\"https://developers.reflection.ai\",\"logo\":{\"@type\":\"ImageObject\",\"url\":\"https://mintcdn.com/reflection-ai/QTuxzl6PxhZZjLhq/logo/light.svg?fit=max\u0026auto=format\u0026n=QTuxzl6PxhZZjLhq\u0026q=85\u0026s=58c942f905cb3bd4c0a14b113a3aee89\"}},{\"@type\":\"WebSite\",\"@id\":\"https://developers.reflection.ai#website\",\"name\":\"Reflection Developer Docs\",\"url\":\"https://developers.reflection.ai\",\"publisher\":{\"@id\":\"https://developers.reflection.ai/#organization\"}},{\"@type\":\"WebPage\",\"@id\":\"https://developers.reflection.ai/distil-swe-agent#webpage\",\"url\":\"https://developers.reflection.ai/distil-swe-agent\",\"name\":\"Doubling synthetic env tasks solve rate using Beam\",\"description\":\"Distil a SWE agent into Gemma 4 E4B by fine-tuning on Beam's golden traces\",\"dateModified\":\"2026-10-20T19:37:54.000Z\",\"isPartOf\":{\"@id\":\"https://developers.reflection.ai#website\"},\"breadcrumb\":{\"@id\":\"https://developers.reflection.ai/distil-swe-agent#breadcrumb\"}},{\"@type\":\"BreadcrumbList\",\"@id\":\"https://developers.reflection.ai/distil-swe-agent#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Supervised fine-tuning\",\"item\":\"https://developers.reflection.ai/automodel-lora\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Use cases\",\"item\":\"https://developers.reflection.ai/sft-use-cases\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Doubling synthetic env tasks solve rate using Beam\",\"item\":\"https://developers.reflection.ai/distil-swe-agent\"}]},{\"@type\":[\"Article\",\"TechArticle\"],\"@id\":\"https://developers.reflection.ai/distil-swe-agent#article\",\"headline\":\"Doubling synthetic env tasks solve rate using Beam\",\"name\":\"Doubling synthetic env tasks solve rate using Beam\",\"description\":\"Distil a SWE agent into Gemma 4 E4B by fine-tuning on Beam's golden traces\",\"url\":\"https://developers.reflection.ai/distil-swe-agent\",\"mainEntityOfPage\":{\"@id\":\"https://developers.reflection.ai/distil-swe-agent#webpage\"},\"dateModified\":\"2026-10-20T19:37:54.000Z\",\"publisher\":{\"@id\":\"https://developers.reflection.ai/#organization\"},\"isPartOf\":{\"@id\":\"https://developers.reflection.ai#website\"}}]}\u003c/script>","agentPointerHref":"/distil-swe-agent.md","siteName":"Reflection Developer Docs","nav":{"global":null,"tabs":[{"tab":"Home","icon":"house","pages":[{"title":"Home","href":"/introduction"}]},{"tab":"API","icon":"code","pages":[{"title":"API","href":"/api-overview"}]},{"tab":"Mirror","icon":"terminal","pages":[{"title":"Mirror","href":"/mirror-overview"}]},{"tab":"Deployment","icon":"server","pages":[{"title":"Deployment","href":"/deployment-overview"}]},{"tab":"Customization","icon":"sliders","groups":[{"group":"Get started","pages":[{"title":"Customize Beam","sidebarTitle":"Overview","href":"/customization-overview"}]},{"group":"Data synthesis","pages":[{"group":"Use cases","root":{"title":"Data synthesis use cases","sidebarTitle":"Use cases","href":"/data-synthesis-use-cases"},"pages":[{"title":"Tool-calling reasoning data with Beam","sidebarTitle":"Tool-calling reasoning data","href":"/tool-calling-reasoning-data"},{"title":"Synthetic SWE environments with Beam","sidebarTitle":"Synthetic SWE environments","href":"/terminal-agent-traces"}]}]},{"group":"Supervised fine-tuning","pages":[{"group":"Integration stacks","root":{"title":"Supervised fine-tuning integration stacks","sidebarTitle":"Integration stacks","href":"/sft-integration-stacks"},"pages":[{"title":"NeMo AutoModel","sidebarTitle":"NeMo AutoModel","href":"/automodel-lora"},{"title":"NeMo Megatron Bridge","sidebarTitle":"NeMo Megatron Bridge","href":"/megatron-bridge-sft"},{"title":"Axolotl","sidebarTitle":"Axolotl","href":"/axolotl-sft"},{"title":"TRL","sidebarTitle":"TRL","href":"/trl-sft"}]},{"group":"Use cases","root":{"title":"Supervised fine-tuning use cases","sidebarTitle":"Use cases","href":"/sft-use-cases"},"pages":[{"title":"Token-efficient tool calling with Beam as the teacher","sidebarTitle":"Token-efficient tool calling","description":"Fine-tune Gemma 4 E4B with TRL and FSDP on tool-calling conversations whose thoughts Beam wrote: 45% fewer output tokens and 3.7 more points on BFCL v4, in a 14 to 19 minute run on one node.","href":"/trl-tool-reasoning"},{"title":"Doubling synthetic env tasks solve rate using Beam","sidebarTitle":"Distil a SWE agent","href":"/distil-swe-agent"},{"title":"Teaching Beam to write better GPU kernels in Triton","sidebarTitle":"Triton GPU kernels","description":"Beam fine-tunes itself on its own verified Triton kernels: no teacher model, no human-written kernels","href":"/self-distil-triton"}]}]},{"group":"Reinforcement learning","pages":[{"group":"Integration stacks","root":{"title":"Reinforcement learning integration stacks","sidebarTitle":"Integration stacks","href":"/rl-integration-stacks"},"pages":[{"title":"Miles","sidebarTitle":"Miles","href":"/miles-rl-math"},{"title":"NeMo RL","sidebarTitle":"NeMo RL","href":"/nemo-rl-math"},{"title":"SkyRL","sidebarTitle":"SkyRL","href":"/skyrl-math"}]}]}]},{"tab":"Safety","icon":"shield-check","pages":[{"title":"Safety","href":"/safety-overview"}]},{"tab":"Gallery","icon":"images","pages":[{"title":"Gallery","href":"/gallery"}]}]},"basePath":"","title":"Doubling synthetic env tasks solve rate using Beam - Reflection Developer Docs","deploymentId":"dpl_HZVV42MMRSo9WnNHfTGZvby5jph9","buildId":"dpl_HZVV42MMRSo9WnNHfTGZvby5jph9","dynamics":["10e4515597","a74be98ba7"],"chunks":["BannerMarkdown-CrFSwoa1.js","dist-MIf_HGLZ.js","lib-DMeTj1gb.js","lib-B8HbPgcC.js","katex-Dbtb6Wk7.js","html-void-elements-mCSPHezU.js","marked.esm-CZWythHk.js","zoom-image-lightbox-B9SB_e-W.js","lightbox-handle-r17bVUz3.js"]}