Skip to content

Optimize LM pipelines by combining and splitting calls - #139

Open
arthurianresolve wants to merge 148 commits into
krypticmouse:mainfrom
arthurianresolve:fix-llm-compiler
Open

arthurianresolve wants to merge 148 commits into
krypticmouse:mainfrom
arthurianresolve:fix-llm-compiler

Conversation

@arthurianresolve

Copy link
Copy Markdown

Summary of Fix

Add an optimizer that changes how a pipeline groups its LM calls, then checks whether the changed pipeline produces acceptable results faster.

For example, a pipeline may ask for a country's capital and continent in two separate calls. This PR can combine those into one call that returns both fields.

  • Combine compatible, independent prediction calls, or split a call with several output fields into separate calls.
  • Update later steps and exported outputs so they still refer to the correct fields after a change.
  • Evaluate each candidate on the same validation cases. Keep it only when the supplied quality and latency measurements meet the configured limits.
  • Let the existing Structural optimizer select these operations from textual feedback about a program's results.
  • Return a revised, runnable pipeline definition and a report explaining which changes were accepted or rejected.

Fixes #26
Fixes #28

Why

A pipeline definition records its processing steps and which earlier results each step needs. This dependency map is called a directed acyclic graph, or DAG: arrows point from a step to the steps that use its results, and there is no circular chain of dependencies.

In this PR, a “DAG compiler” is an optimizer for that pipeline definition. It reads the dependency map, tries supported ways to combine or split calls, runs validation, and saves the selected pipeline. The resulting program runs in the existing interpreter.

The graph-editing foundations already existed, but the complete workflow for making these transformations, measuring their effects and selecting a runnable result was missing.

By default, the optimizer permits no quality decrease on any supplied validation case and requires at least a 1% reduction in mean pipeline latency. Failed evaluation or a rejected change leaves the current pipeline unchanged. These checks apply to the supplied validation workload; model behavior can differ on other inputs.

Related work

Testing

  • All 12 focused compiler tests passed, including conflicting output names and aliases, executing the transformed programs, saving/loading them, evaluation budgets, and quality/latency acceptance rules.
  • The integrated cache-enabled release suite passed 61 tests, with three live tests excluded from that offline run.
  • The integrated minimal-feature suite passed 68 release tests covering transformations, Structural selection, persistent storage, typed special fields and trace/history behavior.
  • The mock-provider example reduced eight requests to four after combining calls, while producing the same four checked outputs. Its report and source/executable manifest are retained under benchmarks/compiler/evidence/2026-11-11-mock.
  • That example uses a simulated 10 ms provider delay. It verifies the optimizer's measurement and selection workflow; live-provider speed improvements have not been established by this example.
  • Targeted rustfmt and git diff --check passed.

AI Disclosure

  • OpenAI Codex assisted with implementation, tests, and PR drafting.
  • all fixes and drafts have been human-architected, human-directed and human-reviewed before publication of PR requests.

…-structured-output

# Conflicts:
#	crates/dspy-rs/src/core/lm/mod.rs
#	crates/dspy-rs/src/trace/span.rs
@mintlify

mintlify Bot commented Nov 11, 2026 •

Copy link
Copy Markdown

Preview approval required

This pull request comes from a fork, so Mintlify won't build a preview until someone with write access approves commit 1d1561c.

Approve preview

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Building a Fusion and Split Ops Building a True LLM Compiler

1 participant