Repository navigation
Reduce inference and I/O overhead with native string output - #138
Open
arthurianresolve wants to merge 137 commits into
Open
arthurianresolve wants to merge 137 commits into
arthurianresolve wants to merge 137 commits into
Conversation
…-structured-output # Conflicts: # crates/dspy-rs/src/core/lm/mod.rs # crates/dspy-rs/src/trace/span.rs
This was referenced Nov 19, 2026
arthurianresolve
added a commit
to arthurianresolve/DSRs
that referenced
this pull request
Nov 19, 2026
Integrate krypticmouse#138 — Reduce inference and I/O overhead with native string output
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary of Fix
Stacked on #137. Merge #137 and its parent PRs before this PR.
LM::with_scalar_output_schema(true)for verified endpoints that accept root JSON strings. Tool-free signatures with one string output can omit the generated object wrapper while preserving typed results, aliases, coercion and constraints.--scalar-outputto the Ollama example, alongside offline--inspect-onlysupport.Fixes #22
Why
Disabling history retention previously left the work of constructing records and serializing prompts in every call. Cache hits also prepared provider request structures that were discarded.
For a single string output, generating an object wrapper adds model output tokens even though the field name is already known. On a verified endpoint, requesting a JSON string lets the adapter restore that field name before running the existing coercion and validation stages.
The scalar capability is disabled by default. Custom endpoints also require
with_custom_output_schema(true). Numeric scalar experiments failed live arithmetic checks, so production eligibility is restricted to string outputs; the final object fallbacks pass those checks.Related work
benchmark-scalar-output-baselinepreserves the object-schema baseline for reproduction and does not need a separate functional PR.Testing
Follow-up native-schema correction: all 29 focused release tests passed without default features (seven schema/typed-chat checks and 22 interpreter checks). Coverage includes compact aliased demonstrations, descriptive nested outputs and the uncached retry path. The cache-specific retry regression is now gated on its feature; it also passes separately with caching enabled on the integrated profiling branch.
Final integrated cache-enabled release checks: 61 tests passed using
--no-default-features --features cache(three live tests excluded from this offline run). This covers invocation history, persistent storage, tool-loop limits, native/scalar output and trace/history parity.The original performance measurements remain tied to the frozen revisions in their retained reports. The new integration commits have functional regression coverage; the earlier speedup ratios have not been remeasured on this head.
Integrate typed tool-field metadata and persistent storage with the scalar response path. A storage scope records calls even when all bounded history capacities are zero.
Focused regression suites: 189 passed with default features and 169 passed without defaults. Three live tests were ignored in each offline run.
Explicit live validation: all nine example workflows and four scalar/fallback cases passed against Ollama 0.40.16 with llama3.2 in WSL Ubuntu 24.04.
Coverage includes aliases, demos, constraints, conversations, config copies, history, cache separation, JSONL trace round trips, strict replay and object fallbacks.
Offline scalar prompt preview passed with an unreachable endpoint.
git diff --check— passed. The complete workspace test suite was not run.Controlled release measurements against DSPy 3.2.1:
Each mode includes eight samples per program in balanced order, with answer and HTTP-count checks. Attempts affected by detected Cargo/rustc activity were rejected and retained.
These results apply to the documented warm QA workload. The live gain requires the single-string opt-in; cold starts and other models or signatures have no general 2× guarantee. Compared with the pre-scalar DSRs baseline, live calls were 1.76× faster, cached calls were approximately unchanged, and offline calls were 1.16× faster.
Full results, provenance and raw evidence
AI Disclosure