Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions docs/contracts.md

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
---
date: 2026-11-13
title: "Spell the sd.cpp argv for the installed build"
---

# 2026-11-13 — Spell the sd.cpp argv for the installed build

- **Context:** The engine candidate check of `master-1091-b9d7176` reported five flags core emits as
deprecated by `sd-server`, marked the same way in the pin `master-1088-32d516c`: `--clip-on-cpu` (use `--backend te=cpu`),
`--vae-on-cpu` (`--backend vae=cpu`), `--diffusion-fa` (`--flash-attn off,diffusion=on`),
`--diffusion-conv-direct` (`--conv-direct auto,diffusion=on,controlnet=on`) and `--qwen2vl` (`--llm`).
Nothing is removed yet, but conf's manifest has no `min_core_version`, so every core gets the next build.
The replacements are not equally old. `--backend` module assignments, `--llm` and the `te=cpu` entry that
`--clip-on-cpu` merely prepends are in every build conf has served (849 on). `--flash-attn` and
`--conv-direct` arrived on 2026-10-13 (leejet/stable-diffusion.cpp#2134), first tagged in 982; conf served
849 and 883 before that, those trees stay installed (`selectModelInstall` keeps whatever engine a family
needs no update for), and an older `sd-server` exits on a flag it does not know. Separately, `-M vid_gen`
sat behind `ATOMIC_DIFFUSION_VID_GEN_MODE_FLAG` until a live run said whether `sd-server` wants it (ADR
2026-09-23); `-M` is parsed by `sd-cli` only, and `sd-server` takes its modes from the model.
- **Decision:** `buildServerArgs` spells the argv for the build the install's tag names. The CPU modules go
in one `--backend te=cpu,vae=cpu` and a `qwen2vl` file as `--llm` on every build. Flash attention and
direct convolution are `--flash-attn off,diffusion=on --conv-direct auto,diffusion=on,controlnet=on` from
build 982 (`MODULE_ASSIGNMENT_FLAGS_BUILD`), the old two flags before it and on a tag that names no build.
`-M` and its switch are gone. The engine contract carries the bound per flag (`from_build`,
`below_build`); the candidate check and the live test read only the flags core emits to the build under
test.
- **Consequences:** No candidate from 982 on reports a deprecated flag, and older installs keep working
unchanged. The new spelling means what the old one did: `--diffusion-fa` itself sets `off,diffusion=on`,
and sd.cpp asks about direct convolution only for the diffusion model, the VAE and ControlNet, where
`--diffusion-conv-direct` meant on, auto and on. Only `sd-server`'s upscale route still reads the legacy
boolean, and core never calls it. A repeated `--backend` is joined with commas and a module's entry beats
the bare default, so the CPU recovery's `--backend cpu`, appended last, still runs everything on the CPU;
the launch log line shows the joined value (`backend=te=cpu` on macOS). The legacy spellings leave the
contract once no supported install predates 982.
- **Owner:** team
- **Links:** `src/diffusion/{args,compat}.ts`,
`test/fixtures/sdcpp/{engine-contract.json,required-flags.txt}`,
`test/fixtures/sdcpp/help/sd-server-master-1028-37bc88b.txt`, `scripts/lib/sdcpp-surface.mjs`,
`test/contract/sdcpp-{engine-contract,surface}.test.ts`, `test/e2e/{diffusion-engine,video}.test.ts`,
`test/live/diffusion.test.ts`; upstream `examples/common/common.cpp` (`prepare_backend_assignments`, the
deprecated handlers) at `master-1088-32d516c`; engine-candidate report of `master-1091-b9d7176` (Hatchet
run `350cd60d-91f7-4d77-ac46-5c4c08383cf6`).

<!--
Refines: 2026-09-23-generate-video-through-the-resident-diffusion-session.md (drops the -M switch),
2026-10-21-check-sdcpp-builds-with-the-engine-candidate.md (the deprecated-flag warns it expected)
-->
1 change: 1 addition & 0 deletions docs/decisions/INDEX.md
Original file line number Diff line number Diff line change
Expand Up @@ -257,3 +257,4 @@ add a new one that says which record it supersedes.
- [Browser stack frames keep their served asset path](2026-11-12-keep-browser-asset-paths-in-stack-frames.md)
- [An audio shutdown refusal is not an engine crash](2026-11-12-audio-shutdown-refusal-is-not-a-crash.md)
- [Check MLX builds with the engine candidate workflow](2026-11-12-check-mlx-builds-with-the-engine-candidate.md) — `engine=mlx`: the fork's `vX.Y.Z`, conf's `mlxvlm-macos-arm64-<rev>` mirror; everything on macos-15, watched folders, folder live models
- [Spell the sd.cpp argv for the installed build](2026-11-13-spell-the-sd-cpp-argv-for-the-installed-build.md) — `--backend te=cpu,vae=cpu` and `--llm` everywhere; `--flash-attn`/`--conv-direct` from build 982, the deprecated pair before; no `-M`
4 changes: 2 additions & 2 deletions docs/testing-critical-flows.md

Large diffs are not rendered by default.

24 changes: 22 additions & 2 deletions scripts/lib/sdcpp-surface.d.mts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,16 @@ export interface SdcppContract {
}>
probe?: { bins: string[]; argv: string[]; markers: string[] }
version?: { pattern: string }
flags: Array<{ flag: string; severity?: Severity; source?: string; note?: string }>
flags: Array<{
flag: string
severity?: Severity
source?: string
note?: string
/** Emitted only to builds from this one on. */
from_build?: number
/** Emitted only to builds before this one, and to a tag that names no build. */
below_build?: number
}>
strings?: Array<{
id: string
text: string
Expand Down Expand Up @@ -90,7 +99,18 @@ export declare const SDCPP_CHECKS: ReadonlyArray<{ id: string; title: string }>
export declare const MIN_SD_HELP_OPTIONS: number
export declare function parseSdHelp(text: string): SdHelpOption[]
export declare function findSdOption(options: readonly SdHelpOption[], flag: string): SdHelpOption | undefined
export declare function checkSdHelp(contract: SdcppContract, options: readonly SdHelpOption[]): Finding[]
/** `master-<build>-<rest>` → the build number; any other tag → undefined. */
export declare function sdcppBuildOf(tag: string | undefined): number | undefined
/** The contract's flags core emits to `build` (undefined: older than every bound). */
export declare function sdFlagsForBuild(
contract: SdcppContract,
build: number | undefined
): SdcppContract['flags']
export declare function checkSdHelp(
contract: SdcppContract,
options: readonly SdHelpOption[],
tag?: string
): Finding[]
export declare function diffSdHelp(
pinOptions: readonly SdHelpOption[],
candidateOptions: readonly SdHelpOption[],
Expand Down
34 changes: 28 additions & 6 deletions scripts/lib/sdcpp-surface.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -92,11 +92,33 @@ export function parseSdHelp(text) {
export const findSdOption = (options, flag) => options.find((o) => o.aliases.includes(flag))

/**
* The build's `--help` against the flags core emits (the contract's `flags`): one it does not know
* fails the launch (`break`), or is a `warn` for a flag core emits only when opted in (`-M`); one it
* marks deprecated is a `warn`.
* `master-<build>-<rest>` → the build number, as `sdcppBuildOf` in src/diffusion/compat.ts reads an
* install's tag; any other tag → undefined.
*/
export function checkSdHelp(contract, options) {
export function sdcppBuildOf(tag) {
const match = /^master-(\d+)-./.exec(tag ?? '')
return match ? Number(match[1]) : undefined
}

/**
* The contract's flags core emits to `build`: a flag with `from_build` only from that build on, one
* with `below_build` only before it. `build` is undefined for a tag that names none, which core
* treats as older than every bound (`speedFlags` in src/diffusion/args.ts).
*/
export function sdFlagsForBuild(contract, build) {
return contract.flags.filter(
(f) =>
(f.from_build === undefined || (build !== undefined && build >= f.from_build)) &&
(f.below_build === undefined || build === undefined || build < f.below_build)
)
}

/**
* The build's `--help` against the flags core emits to it (the contract's `flags` for the build `tag`
* names): one it does not know fails the launch (`break`, or the flag's own severity); one it marks
* deprecated is a `warn`.
*/
export function checkSdHelp(contract, options, tag) {
if (options.length < MIN_SD_HELP_OPTIONS)
return [
finding(
Expand All @@ -107,7 +129,7 @@ export function checkSdHelp(contract, options) {
),
]
const findings = []
for (const f of contract.flags) {
for (const f of sdFlagsForBuild(contract, sdcppBuildOf(tag))) {
const option = findSdOption(options, f.flag)
const severity = f.severity ?? 'break'
if (!option)
Expand Down Expand Up @@ -495,7 +517,7 @@ export function buildSdcppReport(contract, inputs, options = {}) {
skipped['help.diff'] = 'the candidate was not run'
} else {
const options = parseSdHelp(candidate.help_text ?? '')
findings.push(...checkSdHelp(contract, options))
findings.push(...checkSdHelp(contract, options, candidate.tag))
const pinOptions = pin?.help_text === undefined ? undefined : parseSdHelp(pin.help_text)
if (!pin) skipped['help.diff'] = 'no pin'
else if (pin.capture_error)
Expand Down
Loading
Loading