guppy_worker

Module Contents

Functions

emulate

Emulate a hugr on a local emulator.

from_circuit

Build a hugr from a pytket circuit.

to_backend_result

Transform a new stack result to a pytket result.

ghz

Build a n-qubit GHZ quantum state as Hugr.

from_str

Build a Hugr from a string representation of a quantum program.

to_str

Convert a Hugr to a string representation of a quantum program.

from_bytes

Build a Hugr from a bytes representation of a quantum program.

to_bytes

Convert a Hugr to a bytes representation of a quantum program.

normalize

Normalize a Hugr package.

apply_pytket_pass

Apply a pytket pass to a Hugr package.

remove_redundancies

Remove redundant operations from a Hugr package.

squash_rz_phased_x

Squash Rz and PhasedX gates in a Hugr package.

to_qir

Convert a Hugr package to a QIR representation.

Data

API

worker = 'Worker(...)'
Result = None
emulate(hugr_package: hugr.package.Package, n_qubits: int, n_shots: int, seed: int | None = None) guppy_worker.Result

Emulate a hugr on a local emulator.

Parameters:
  • hugr_package (Package) – The package to emulate.

  • n_qubits (int) – The number of qubits to emulate.

  • n_shots (int) – The number of shots to take.

  • seed (int | None, optional) – The seed for the random number generator, defaults to None

Returns:

The emulator result state.

Return type:

Result

from_circuit(circuit: pytket.Circuit, name: str, use_arrays: bool = True) hugr.package.Package

Build a hugr from a pytket circuit.

Parameters:
  • circuit (Circuit) – The circuit to build the hugr from.

  • name (str) – The name of the hugr.

  • use_arrays (bool, optional) – Use qubit arrays, defaults to True

Returns:

The compiled hugr.

Return type:

Package

to_backend_result(results: guppy_worker.Result) pytket.backends.backendresult.BackendResult

Transform a new stack result to a pytket result.

Parameters:

results (Result) – The original result.

Returns:

The corresponding pytket result.

Return type:

BackendResult

ghz(size: int) hugr.package.Package

Build a n-qubit GHZ quantum state as Hugr.

Parameters:

size (int) – The size of the state.

Returns:

A Hugr representing the GHZ state.

Return type:

Package

from_str(package_str: str) hugr.package.Package

Build a Hugr from a string representation of a quantum program.

Parameters:

package_str (str) – The string representation of the quantum program.

Returns:

The compiled Hugr.

Return type:

Package

to_str(package: hugr.package.Package) str

Convert a Hugr to a string representation of a quantum program.

Parameters:

package (Package) – The Hugr package to convert.

Returns:

The string representation of the Hugr.

Return type:

str

from_bytes(package_bytes: bytes) hugr.package.Package

Build a Hugr from a bytes representation of a quantum program.

Parameters:

package_bytes (bytes) – The bytes representation of the quantum program.

Returns:

The compiled Hugr.

Return type:

Package

to_bytes(package: hugr.package.Package) bytes

Convert a Hugr to a bytes representation of a quantum program.

Parameters:

package (Package) – The Hugr package to convert.

Returns:

The bytes representation of the Hugr.

Return type:

bytes

normalize(package: hugr.package.Package) hugr.package.Package

Normalize a Hugr package.

Parameters:

package (Package) – The Hugr package to normalize.

Returns:

The normalized Hugr package.

Return type:

Package

apply_pytket_pass(package: hugr.package.Package, pytket_pass: pytket.passes.BasePass) hugr.package.Package

Apply a pytket pass to a Hugr package.

Parameters:
  • package (Package) – The Hugr package to apply the pass to.

  • pytket_pass (BasePass) – The pytket pass to apply.

Returns:

The Hugr package after applying the pass.

Return type:

Package

remove_redundancies(package: hugr.package.Package) hugr.package.Package

Remove redundant operations from a Hugr package.

Parameters:

package (Package) – The Hugr package to optimize.

Returns:

The optimized Hugr package.

Return type:

Package

squash_rz_phased_x(package: hugr.package.Package) hugr.package.Package

Squash Rz and PhasedX gates in a Hugr package.

Parameters:

package (Package) – The Hugr package to optimize.

Returns:

The optimized Hugr package.

Return type:

Package

to_qir(package: hugr.package.Package, format: str) bytes | str

Convert a Hugr package to a QIR representation.

Parameters:
  • package (Package) – The Hugr package to convert.

  • format (str) – The format of the QIR.

Returns:

The QIR representation of the Hugr package.

Return type:

bytes | str