You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
PECOS has fifteen Python-facing builders and they disagree on all three parts of the
builder contract: how setters are named, how the builder is entered, and how it is
terminated. The split is close to even, so a reader cannot infer any of it.
Setter naming: 8 versus 7
with_*
bare
general_noise() (47 methods)
sim(...)
depolarizing_noise() (7)
DetectorErrorModel.builder() (14)
biased_depolarizing_noise() (7)
BpOsdBuilder (5)
DemBuilder (6)
BpLsdBuilder (4)
DemSamplerBuilder (4)
RelayBpBuilder (8)
InfluenceBuilder (4)
MinSumBpBuilder (3)
SurfacePatchBuilder (3)
UnionFindBuilder (1)
ColorCode488Builder (1)
Two plausible dividing lines both fail:
user-facing versus low-level — the noise builders are user-facing and use with_*,
while sim() is user-facing and bare.
Rust-backed versus Python — BpOsdBuilder is Rust-backed and bare, DemBuilder is
Rust-backed and with_*.
Terminal method
.build() — most builders
.run() — sim(...)
none — the noise builders, which are passed directly into .noise(...)
direct construction with required positional arguments: BpOsdBuilder(pcm, error_rate)
Why now
PR #420 added DetectorErrorModel.builder() and chose bare setters partly on the
strength of a "user-facing builders use bare setters" reading of the codebase. That
rule does not hold — see the counterexamples above. The choice is defensible on other
grounds (it is scalar configuration on a Python surface, and the Rust API Guidelines
leave builder naming explicitly open, reserving with_ for constructors such as Vec::with_capacity), but it was made against a pattern that turned out to be imaginary.
Rather than let that stand as an accidental precedent, the project should decide.
Proposal
Pick one setter convention and write it down where it will be found — a short
section in the contributing or API-conventions docs, not just an issue comment.
Standardize the terminal..build() everywhere, with sim(...).run() as a
deliberate, documented exception because it also executes.
Decide whether noise builders should have a terminal at all, or remain
builder-shaped objects consumed directly by .noise(...).
Converge entries on one shape, or state the rule that selects between them.
Any convention chosen should be applied to the new DetectorErrorModel.builder() too;
it is new enough to change cheaply and has no external callers yet.
Problem
PECOS has fifteen Python-facing builders and they disagree on all three parts of the
builder contract: how setters are named, how the builder is entered, and how it is
terminated. The split is close to even, so a reader cannot infer any of it.
Setter naming: 8 versus 7
with_*general_noise()(47 methods)sim(...)depolarizing_noise()(7)DetectorErrorModel.builder()(14)biased_depolarizing_noise()(7)BpOsdBuilder(5)DemBuilder(6)BpLsdBuilder(4)DemSamplerBuilder(4)RelayBpBuilder(8)InfluenceBuilder(4)MinSumBpBuilder(3)SurfacePatchBuilder(3)UnionFindBuilder(1)ColorCode488Builder(1)Two plausible dividing lines both fail:
with_*,while
sim()is user-facing and bare.BpOsdBuilderis Rust-backed and bare,DemBuilderisRust-backed and
with_*.Terminal method
.build()— most builders.run()—sim(...).noise(...)Entry
sim(...),general_noise(),depolarizing_noise()DetectorErrorModel.builder()BpOsdBuilder(pcm, error_rate)Why now
PR #420 added
DetectorErrorModel.builder()and chose bare setters partly on thestrength of a "user-facing builders use bare setters" reading of the codebase. That
rule does not hold — see the counterexamples above. The choice is defensible on other
grounds (it is scalar configuration on a Python surface, and the Rust API Guidelines
leave builder naming explicitly open, reserving
with_for constructors such asVec::with_capacity), but it was made against a pattern that turned out to be imaginary.Rather than let that stand as an accidental precedent, the project should decide.
Proposal
section in the contributing or API-conventions docs, not just an issue comment.
.build()everywhere, withsim(...).run()as adeliberate, documented exception because it also executes.
builder-shaped objects consumed directly by
.noise(...).and widely used.
Notes
DetectorErrorModel.builder()too;it is new enough to change cheaply and has no external callers yet.
NoiseModelnaming), Deprecation ramp: align pecos-engines GeneralNoiseModel idle-noise API with the structured vocabulary #424/Align the non-idle GeneralNoiseModel surfaces (gate/emission/leakage/measurement/crosstalk) with the structured noise vocabulary #425(the engines-side vocabulary ramp, where a deprecation pattern is already planned).