Skip to content
Sudhanshu ShuklaAI Lab · GenAI Engineering
Menu
HLD · v1.0Updated 2 December 2026

CodeMind high-level design

How CodeMind is built, trained and run: a fill-in-the-middle coding model trained in the cloud and served entirely on the developer's laptop. For implementation details, see the low-level design.

1. Goals and constraints

2. Architecture overview

CodeMind high-level architecture Three layers. Cloud training on Cloud TPU v6e-8: training data, supervised fine-tuning, then Test-based DPO. Artifacts and evaluation: checkpoints in Cloud Storage, the evaluation harness, then a 16-bit release build. Inference on the developer's laptop, offline: the editor sends the code around the cursor to the local CodeMind runtime, which returns the filled middle; nothing leaves the laptop. 1 · CLOUD TRAINING — CLOUD TPU V6E-8 2 · ARTIFACTS AND EVALUATION 3 · INFERENCE — DEVELOPER LAPTOP, OFFLINE Training dataSupervised fine-tuningTest-based DPO Cloud StorageEvaluation harnessRelease build CodeMind runtimeEditor Privacy boundary 2M FIM examples (SFT)HumanEval+ and MultiPL-Eproblems with unit tests All 1.54B weights31,250 steps, 512 tokensabout 4.6 hours Sample, run unit tests402 preference pairs381 train / 21 held out SFT and DPO checkpointspairs, configs, logsin one bucket HumanEval(+), MBPP(+)FIM, held-out preferenceaccuracy Convert to 16-bitabout 3.5 GB of weightsdownloaded once 16-bit weights on aconsumer-grade GPUfills the middle span Sends code before andafter the cursor; showsthe suggestion inline No network calls atinference: code and keysstay on the laptop
  1. Training data2M FIM examples for SFT; HumanEval+ and MultiPL-E problems with unit tests for preference training.
  2. Supervised fine-tuningAll 1.54B weights, 31,250 steps, 512-token context, about 4.6 hours.
  3. Test-based DPOSample completions, run the unit tests, update the dense weights in FP32 on 381 pairs and evaluate on 21 held-out pairs.
  4. Cloud StorageSFT and DPO checkpoints, pairs, configs and logs in one bucket.
  5. Evaluation harnessHumanEval(+), MBPP(+), FIM and held-out preference accuracy.
  6. Release buildConverted to 16-bit, about 3.5 GB, downloaded once.
  7. Editor and runtimeThe editor sends the code around the cursor to the local runtime, which returns the filled middle. Nothing leaves the laptop.
Training runs in the cloud once; every completion afterwards runs on the laptop.

3. Components

ComponentResponsibilityRuns on
Base modelQwen2.5-Coder-1.5B Base, extended with hybrid attention and a sparse mixture of adapter experts—
SFT trainerFull fine-tuning on 2M fill-in-the-middle examplesCloud TPU v6e-8
Candidate samplerGenerates 8 completions per problem, one process per TPU chipCloud TPU v6e-8
Execution rewardRuns each completion against its unit tests (Python, Node.js, tsc, javac)TPU host CPUs
Pair builderTurns pass/fail results into chosen/rejected preference pairsTPU host CPUs
DPO trainerAligns the model to prefer passing code, against a frozen SFT referenceOne TPU v6e chip
Evaluation harnessBenchmarks and held-out metrics for every checkpointGPU or TPU
Artifact storeCheckpoints, datasets, pairs, configs and logsGoogle Cloud Storage
Local runtimeLoads the 16-bit release and serves completions to the editorDeveloper laptop

4. Data flow

Cloud training (once per release)

Fill-in-the-middle examples train the base model with supervised fine-tuning. The SFT model then samples several completions for coding problems that ship with unit tests; the tests decide which completions pass. Passing and failing completions of the same problem become preference pairs, and DPO trains the model to prefer the passing ones. Checkpoints go to Cloud Storage, are evaluated, and the release is converted to 16-bit.

Inference path (every keystroke pause)

The editor captures the code before and after the cursor, wraps it in the FIM prompt format, and sends it to the local runtime. The model generates the middle span until a stop token, and the editor shows it inline. There is no server round trip.

5. Key design decisions

DecisionWhy
Fill-in-the-middleInline completion needs both sides of the cursor, not only the code above it (Bavarian et al., 2022).
1.5B base modelLarge enough for useful code, small enough for a laptop GPU with low latency.
Hybrid attentionA 96-token sliding window in three of every four layers keeps long files fast; full attention every fourth layer keeps global context.
Sparse adapter expertsTop-2 of 4 low-rank adapters in the final two layers add capacity at little inference cost.
Unit tests as the rewardPass or fail is objective and cheap to compute; no learned reward model or human labeling is needed. DPO uses these test results as preference labels.
DPO rather than PPODPO learns directly from preference pairs, with no reward model or online rollouts, so it fits a single accelerator.
32-bit DPO weightsDPO learning rates are tiny (5e-6); in 16-bit most updates would round away. The release is converted to 16-bit afterwards.
Sampling on 8 chipsSampling is the expensive step; one process per TPU chip divides it eight ways.

6. Current status