dspy-wsp adds weight-space optimization to DSPy’s optimizer interface
dspy-wsp exposes weight-space optimization through DSPy’s optimizer interface, supporting MLX, PyTorch and vLLM. Its authors report improving every tested decision model with roughly $5–10 of Astra usage.

TL;DR
- DSPy programs can now be optimized through direct model-weight edits using the separate dspy-wsp prototype.
- Astra improved every decision model tested for roughly $5–10 per model, according to the launch announcement.
- MLX, PyTorch and vLLM are supported, per the backend follow-up, but the author's release follow-up flags many untested configurations.
Disabling in-kernel decision-head simulation cut one model's accuracy gain from 16.1 to 2.8 points. A saved patch includes hashes of the original and edited tensors, allowing an edit to be reconstructed bit for bit from the public base model.
WeightSpace's writer loop
Weight editing gets a pleasantly boring API: WeightSpace accepts a DSPy module and metric, and compile() returns a module running on edited local weights. The November 13 announcement specifies compatibility with DSPy 3.5.
The writer LLM explains its next step, then submits exactly one block:
- Python: inspect or edit the student's weights in a persistent sandboxed kernel, with gradients disabled.
- Forward: run the DSPy program on practice examples and receive metric feedback.
When the forward-pass budget runs out, the writer's selected edit becomes the patch. Cmpnd CEO Drew Breunig also describes swapping decision models and LLMs behind DSPy signatures in the DSPy discussion.
Typed Decisions gains
Cmpnd tested five open decision models spanning 0.6B to 9B parameters. Each run used GPT-6-Astra at maximum reasoning effort, one conversation and 25 forward passes, followed by evaluation on 400 unseen cases.
Cmpnd's Typed Decisions comparison on 400 held-out test cases.
Across all five models, WeightSpace alone added 1.9–16.1 accuracy points; combining it with ReAnchor added 6.5–20.0 points, according to the full results. The paired gains have standard errors of 0.7–1.4 points, reported in the chart's fine print.
ReAnchor
The neat trick is composability: ReAnchor changes how probabilities become answers without modifying model weights. The repository describes three mappings:
- Noul: decision thresholds.
- Score: cut points between ordered scores.
- Choice: option weights.
Two results expose how much that decoding layer contributes:
- Strands Decider 2B: ReAnchor alone gained 13.7 points, versus 10.4 from weight edits. Together they gained 20.0 points, the largest combined improvement.
- Clef-Flash: weight edits gained 1.9 points on returned answers but 5.8 on the most likely option. Combining the edit with ReAnchor gained 6.5 points on returned answers.
Head simulation and test boundaries
The README's methodology notes qualify the headline scores:
- Head simulation: the reported decision-model runs allowed the writer to recompute and fit the decision head inside its Python kernel. The original paper restricted network execution to the forward-pass tool. With
simulate_head=False, d1-omni-600M gained 2.8 ± 0.7 points instead of 16.1, and added nothing over ReAnchor. - Writer choice: replacing Astra with GPT-6.1-Sol changed d1-2B's weight-edit gain from +13.4 points to −0.6 points.
- Data separation:
holdout=0.25reserves a quarter of the training examples for validation scoring without revealing those examples to the writer. The separatevalsetis evaluated once at the end, comparing original and edited weights on identical examples and seeds. - Leaderboard comparisons: Cmpnd uses DSPy-generated requests and scores returned answers, while the public leaderboard uses each case's original request and scores the most likely option. Edited models have also practiced on the benchmark's training split, placing them alongside fitted models rather than zero-shot entries.
Backends and checkpoints
The repository's runtime documentation puts the tested 25-pass decision-model runs at 68–167 minutes and $5.42–$10.78 in writer calls. The 2B models used about 6 GB of memory; Clef-Flash needs about 20 GB.
Support differs by model family:
- MLX: all five tested decision-model families on Apple silicon.
- PyTorch: d1-omni, NanoJev and d1-2B. Clef and Strands currently require MLX.
- vLLM: text-generating LLMs on NVIDIA GPUs through the
dspy-wsp[vllm]extra.
Outputs can be saved as a small patch requiring the base model, or as a complete checkpoint. A written checkpoint loads without the writer or its API key; text-generating checkpoints can be served through vLLM.
Sandbox and API exposure
The default sandbox uses sandbox-exec on macOS and bubblewrap on Linux. Its allowlist permits:
- Reads: system libraries, Python and its packages, the package itself, and model files.
- Writes: the run's work directory and a scratch directory.
- Network: none.
Everything the kernel prints goes to the writer's API, so its provider sees weights and practice examples as the writer reads them. If no sandbox is available, initialization fails before loading the model; sandbox="none" instead gives the writer's code the user's permissions and network access.