horde_sdk.generation_parameters.image.constraints_document¶
The wire shape of the sampler constraints document an AI Horde API publishes.
The facts themselves live in
constraints. A python client can import that
module directly; every other client reads them over HTTP from the API's sampler constraints endpoint.
This module is the type of that response, so both ends describe the same document rather than agreeing
by convention: the API builds one of these and serialises it, and a python client parses the response
back into the same type.
Critical public members:
- The whole served document, and the entry point for parsing a response:
SamplerConstraintsDocument - One sampler's knobs, cost, tier and vocabulary as they are served:
PublishedSamplerRecord - One discoverable worker conformance profile:
PublishedSamplerExecutionContract - The sections mirroring the API's rejections, which a client honouring them cannot construct against:
PublishedHardConstraints
The models here are deliberately separate from the dataclasses in constraints. Those describe the
rules; these describe how one API chose to publish them, including keys named after that API's own
request fields. Field names match the served JSON keys exactly, so renaming one is a wire change.
__all__
module-attribute
¶
__all__ = [
"AUTHORITATIVE_WORK_FIELD",
"SAMPLER_CONSTRAINTS_DOCUMENT_SCHEMA_VERSION",
"PublishedAdaptiveIterationCeiling",
"PublishedAdaptiveWorkProfile",
"PublishedAdvisories",
"PublishedBoundedAdaptiveSamplerExecutionGuarantee",
"PublishedFixedRateWorkProfile",
"PublishedHardConstraints",
"PublishedKnobRange",
"PublishedPresentationTiers",
"PublishedRecommendation",
"PublishedRejectedPairing",
"PublishedSamplerExecutionContract",
"PublishedSamplerExecutionGuarantee",
"PublishedSamplerRecord",
"PublishedSamplerWorkProfile",
"PublishedWorkAccounting",
"SamplerConstraintsDocument",
]
AUTHORITATIVE_WORK_FIELD
module-attribute
¶
The sampler-record field carrying operational work-accounting semantics.
Published alongside measured cost ratios so clients cannot mistake one-card timing evidence for the portable work quantity used by operational policy.
SAMPLER_CONSTRAINTS_DOCUMENT_SCHEMA_VERSION
module-attribute
¶
Identify the initial public JSON shape of the sampler constraints document.
PublishedSamplerWorkProfile
module-attribute
¶
PublishedSamplerWorkProfile = Annotated[
PublishedFixedRateWorkProfile
| PublishedAdaptiveWorkProfile,
Field(discriminator="kind"),
]
The discriminated wire representation of fixed and adaptive sampler work.
PublishedSamplerExecutionGuarantee
module-attribute
¶
PublishedSamplerExecutionGuarantee = Annotated[
PublishedBoundedAdaptiveSamplerExecutionGuarantee,
Field(discriminator="name"),
]
The discriminated wire representation of atomic sampler execution guarantees.
PublishedKnobRange ¶
Bases: BaseModel
Represents the accepted range of one numeric solver knob, as it is served.
JSON has no literal for infinity, so an unbounded maximum, and a default meaning "the solver applies no limit unless you set one", are both served as null rather than as a number.
Source code in horde_sdk/generation_parameters/image/constraints_document.py
PublishedFixedRateWorkProfile ¶
Bases: BaseModel
A published sampler whose marginal work scales with requested trajectory length.
Source code in horde_sdk/generation_parameters/image/constraints_document.py
PublishedAdaptiveWorkProfile ¶
Bases: BaseModel
A published adaptive sampler and the serving API's request-level estimate for it.
Source code in horde_sdk/generation_parameters/image/constraints_document.py
model_config
class-attribute
instance-attribute
¶
kind
class-attribute
instance-attribute
¶
The discriminator for solver-chosen iteration counts.
estimated_work_units_per_request
class-attribute
instance-attribute
¶
The serving API's stable accounting estimate, independent of requested trajectory steps.
finite_ceiling_contract_versions
instance-attribute
¶
Execution contracts that make this adaptive sampler's maximum work finite.
PublishedAdaptiveIterationCeiling ¶
Bases: BaseModel
Represents an adaptive solver's exact trajectory-derived iteration ceiling.
Source code in horde_sdk/generation_parameters/image/constraints_document.py
model_config
class-attribute
instance-attribute
¶
trajectory_multiplier_numerator
class-attribute
instance-attribute
¶
Numerator of the exact multiplier applied to requested trajectory steps.
trajectory_multiplier_denominator
class-attribute
instance-attribute
¶
Denominator of the exact multiplier applied to requested trajectory steps.
rounding
class-attribute
instance-attribute
¶
Require fractional iteration ceilings to round upward.
PublishedBoundedAdaptiveSamplerExecutionGuarantee ¶
Bases: BaseModel
Represents the atomic finite-iteration guarantee for the adaptive sampler.
Source code in horde_sdk/generation_parameters/image/constraints_document.py
model_config
class-attribute
instance-attribute
¶
name
class-attribute
instance-attribute
¶
Stable SDK identifier for the atomic execution behavior.
sampler
instance-attribute
¶
Sampler whose runtime behavior this guarantee constrains.
maximum_solver_iterations
instance-attribute
¶
Exact formula for the maximum solver iterations the backend permits.
work_units_per_solver_iteration_source
class-attribute
instance-attribute
¶
Request setting that determines work units consumed by each solver iteration.
PublishedSamplerExecutionContract ¶
Bases: BaseModel
Represents a cumulative execution behavior profile a worker can claim to implement.
Source code in horde_sdk/generation_parameters/image/constraints_document.py
PublishedSamplerRecord ¶
Bases: BaseModel
Represents one sampler's knobs, cost, tier and vocabulary as they are served.
Source code in horde_sdk/generation_parameters/image/constraints_document.py
model_config
class-attribute
instance-attribute
¶
name
instance-attribute
¶
The sampler this record describes, repeated here so an entry stands alone once read out of the map.
work_profile
instance-attribute
¶
How operational work relates—or does not relate—to requested trajectory steps.
measured_cost_ratio_sd15
instance-attribute
¶
Per-step wall-clock cost relative to k_euler on a stable_diffusion_1 model, or null where a ratio
is meaningless because the sampler chooses its own step count.
measured_cost_ratio_sdxl
instance-attribute
¶
The same ratio on a stable_diffusion_xl model, or null for the same reason.
presentation_tier
instance-attribute
¶
How prominently the sampler is worth offering. A presentation hint that restricts nothing.
solver_type_choices
instance-attribute
¶
The solver_type values this sampler accepts, empty when it takes none.
accepted_settings
instance-attribute
¶
The numeric knobs this sampler accepts, keyed by the request field name a client sends them under.
The keys are the serving API's own request field names rather than the knob names the backend's solvers use, because a client reads this to build a request.
applies_cfg_pp
instance-attribute
¶
Whether the sampler applies the CFG++ correction, which expects a much lower cfg_scale.
PublishedRejectedPairing ¶
Bases: BaseModel
Represents one sampler and scheduler pairing the API refuses outright.
Source code in horde_sdk/generation_parameters/image/constraints_document.py
PublishedHardConstraints ¶
Bases: BaseModel
Represents the sections that mirror the API's rejections exactly.
A request honouring everything here cannot be one the API refuses on constraint grounds, which is what separates these from the advisory sections.
Source code in horde_sdk/generation_parameters/image/constraints_document.py
model_config
class-attribute
instance-attribute
¶
rejected_sampler_scheduler_pairings
instance-attribute
¶
Pairings that produce no usable image and are refused rather than substituted.
scheduler_baseline_applicability
instance-attribute
¶
scheduler_baseline_applicability: dict[
KNOWN_IMAGE_SCHEDULERS,
list[KNOWN_IMAGE_GENERATION_BASELINE],
]
Baselines each restricted scheduler is defined for. A scheduler absent here works on every baseline.
PublishedRecommendation ¶
Bases: BaseModel
Represents one advisory statement, with the provenance that qualifies it.
Recommendations never block a request. The provenance is served because these range from statements by the image backend's own author to third-party folklore, and a client cannot weigh them otherwise.
Source code in horde_sdk/generation_parameters/image/constraints_document.py
PublishedAdvisories ¶
Bases: BaseModel
Represents the quality expectations the API warns about rather than enforcing.
Source code in horde_sdk/generation_parameters/image/constraints_document.py
PublishedWorkAccounting ¶
Bases: BaseModel
Explains operational work figures without claiming they are the learned Kudos price.
Served as bare numbers, measured ratios would read like portable costs. They are one card's evidence about marginal work. The API's learned Kudos model remains a separate sampler-plus-step calculation.
Source code in horde_sdk/generation_parameters/image/constraints_document.py
model_config
class-attribute
instance-attribute
¶
authoritative_field
class-attribute
instance-attribute
¶
Names the sampler-record field operational accounting and time budgeting consume.
authoritative_note
instance-attribute
¶
What that field counts, and where it is read from.
measured_cost_ratio_provenance
instance-attribute
¶
The provenance both measured ratio columns carry.
measured_cost_ratio_source
instance-attribute
¶
Filename of the measurement artifact both ratio columns were read from.
measured_cost_ratio_note
instance-attribute
¶
How the ratios were derived, and why they corroborate the authoritative field rather than replace it.
measured_cost_ratio_sdxl_note
instance-attribute
¶
The model and resolution the stable_diffusion_xl column was taken on, and how to read it.
measured_cost_ratio_sd15_note
instance-attribute
¶
The model and resolution the stable_diffusion_1 column was taken on, and the bias it carries.
PublishedPresentationTiers ¶
Bases: BaseModel
Represents the default-offer set, and the note saying the split restricts nothing.
Source code in horde_sdk/generation_parameters/image/constraints_document.py
SamplerConstraintsDocument ¶
Bases: BaseModel
Represents the whole sampler constraints document an API serves.
Only samplers and schedulers the serving API accepts appear, so a client reading this never offers a name that API's request models would reject as unknown.
Examples:
Parsing a response from the sampler constraints endpoint:
document = SamplerConstraintsDocument.model_validate(response.json())
euler = document.samplers[KNOWN_IMAGE_SAMPLERS.k_euler]
Source code in horde_sdk/generation_parameters/image/constraints_document.py
model_config
class-attribute
instance-attribute
¶
schema_version
class-attribute
instance-attribute
¶
Version of this document's JSON shape, independent of execution conformance versions.
execution_contracts
instance-attribute
¶
Discoverable execution profiles workers can claim to implement.
samplers
instance-attribute
¶
Every sampler the serving API accepts, keyed by name.
hard_constraints
instance-attribute
¶
The sections that mirror the API's rejections. Honouring these avoids a refusal.
recommendations
instance-attribute
¶
Advisory pairings and settings, each carrying the provenance of the claim.
advisories
instance-attribute
¶
Quality expectations the API warns about rather than enforcing.
work_accounting
instance-attribute
¶
What work units, estimates, ceilings, and measured ratios mean.
presentation_tiers
instance-attribute
¶
Which samplers are worth offering by default, and the note saying the split restricts nothing.