cosmiq.export#

Exports to other SDKs’ formats. You take the files there yourself: cosmiq routes no jobs. Pulser and Braket are never imported at module level here, so these functions exist without either installed (they produce plain JSON/dicts).

shots_to_braket_bits

{"pre_sequence": [[...]], "post_sequence": [[...]]} with Braket's meaning (post 1 = ground).

to_braket_ahs

A dict that braket.ir.ahs.Program.parse_obj accepts.

to_pulser

One batch row as a Pulser sequence (Pulser has no batch axis), on a Pulser device built from the schedule's target: spec, or else the schedule's device when it's a bundled one (module docstring).

Functions

cosmiq.export.shots_to_braket_bits(shots: Shots, *, loss: Literal['error', 'fold'] = 'error') → dict[str, Any]#

{“pre_sequence”: [[…]], “post_sequence”: [[…]]} with Braket’s meaning (post 1 = ground). An atom lost mid-sequence can’t be represented, so loss=”error” (the default) raises CapabilityError; “fold” writes it as Rydberg. Empty sites map exactly.

When the shots carry their pre and post images, those are written as they are; otherwise every site counts as filled, and post comes from the labels.

cosmiq.export.to_braket_ahs(schedule: Schedule | ScheduleData, *, batch_index: int = 0, local_detuning: Literal['rewrite', 'direct'] = 'rewrite', spec: DeviceSpec | None = None) → dict[str, Any]#

A dict that braket.ir.ahs.Program.parse_obj accepts. Raises ConstraintError when the rewrite leaves the global detuning limits of spec. Without spec, the schedule’s device is used when it’s a bundled one (cosmiq.devices.get); an untargeted schedule, or one for a device that isn’t bundled, isn’t re-checked: pass its spec. A schedule targeted at one device isn’t exported against another’s spec (its label names the device it was checked for, N-14).

Raises FormatError for a malformed schedule, a batch_index outside it, or a spec for another device than the schedule’s; and TypeError for an argument of the wrong type.

cosmiq.export.to_pulser(schedule: Schedule | ScheduleData, *, batch_index: int = 0, spec: DeviceSpec | None = None) → str#

One batch row as a Pulser sequence (Pulser has no batch axis), on a Pulser device built from the schedule’s target: spec, or else the schedule’s device when it’s a bundled one (module docstring).

Raises CapabilityError when Pulser can’t represent the target or the schedule (a \(C_6\) other than Pulser’s level-70 value, a clock off whole nanoseconds, a local detuning the device lacks, \(\delta > 0\), weights outside \([0, 1]\)); FormatError for a malformed schedule, a batch_index outside it, an untargeted schedule without spec, a device that isn’t bundled without spec, or a spec for another device than the schedule’s; and TypeError for an argument of the wrong type.