isqtools package

Subpackages

Submodules

isqtools.isqc_path module

get_isqc_path()

Get the current default isqc path.

Returns:

The current default isqc path.

Return type:

str

set_isqc_path(isqc_path)

Set the default isqc path.

Parameters:

isqc_path (str) – The path to set as the default isqc path.

Return type:

None

isqtools.utils module

This file provides some utility functions for calling the isqc compiler from python.

class CompileTarget(*values)

Bases: Enum

OPEN_QASM3 = 'open-qasm3'
QCIS = 'qcis'
QIR = 'qir'
classmethod from_string(value)

Convert a string to the corresponding CompileTarget enum value.

Parameters:

value (str)

Return type:

CompileTarget

class FindSimulator

Bases: object

To build a SIMULATOR BIN for isqc.

static get_dir_name_of_simulator(isqcDIR)
static get_isQ_dir()
classmethod get_simulator_bin_path()
classmethod make_simulator_bin()

Automatically find the directory of isqc, create a SIMULATOR file with appropriate content, and set file permissions.

static set_simulator_file_name()
exception IsqcError

Bases: Exception

IsQ compiler Error.

gen_qcis_from_so(file, int_param=None, double_param=None, additional_args='')

According to the compilation plan of isQ compiler, this function is not open to users.

Parameters:
  • file (str | Path)

  • int_param (Sequence[int] | int | None)

  • double_param (Sequence[float] | float | None)

  • additional_args (str)

Return type:

None

isqc_compile(file, target=CompileTarget.QIR, int_param=None, double_param=None, additional_args='')

This function encapsulates the compile of isQ compiler.

Parameters:
  • file (str) – The path to the file that needs to be compiled.

  • target (CompileTarget | str) – The compiled target output form (either a CompileTarget enum or a string).

  • int_param (Sequence[int] | int | None) – An integer variable (array) passed in when compiling.

  • double_param (Sequence[float] | float | None) – An double variable (array) passed in when compiling.

  • additional_args (str) – Other arguments passed in when compiling, see more: https://www.arclightquantum.com/isq-docs/latest/

Return type:

None

isqc_run(file, target=CompileTarget.QIR, shots=100, int_param=None, double_param=None)

This method executes compile and simulate in sequence.

Parameters:
  • file (str)

  • target (CompileTarget)

  • shots (int)

  • int_param (Sequence[int] | int | None)

  • double_param (Sequence[float] | float | None)

Return type:

tuple[dict[str, int], str, int] | tuple[str, str, int]

isqc_simulate(file, shots=100, int_param=None, double_param=None, debug=False, additional_args='')

This function encapsulates the simulate of isQ compiler.

Parameters:
  • file (str | Path) – The path to the file that needs to be compiled.

  • shots (int) – Shots number of quantum simulation.

  • int_param (Sequence[int] | int | None) – An integer variable (array) passed in when compiling.

  • double_param (Sequence[float] | float | None) – An double variable (array) passed in when compiling.

  • additional_args (str) – Other arguments passed in when compiling, see more: https://www.arclightquantum.com/isq-docs/latest/

  • debug (bool)

Return type:

tuple[dict[str, int], str, int] | tuple[str, str, int]

Returns:

A dictionary with simulation results if successful, otherwise a tuple containing stdout, stderr, and the return code.

Raises:
  • IsqcError – If the file format is unsupported or the file does not exist.

  • subprocess.CalledProcessError – If the simulation command fails.

Module contents