ApiUtility#

class pennylane_calculquebec.utility.api.ApiUtility#

Bases: object

basic_auth(username, password)

create a basic authentication token from a Thunderhead username and access token

convert_circuit(circuit)

converts a pennylane quantum script to a dictionary that can be read by the Thunderhead API

convert_instruction(instruction)

converts a Pennylane operation to a dictionary that can be read by the Thunderhead API

headers(username, password, realm)

the Thunderhead API headers

job_body(circuit, circuit_name, project_id, ...)

the body for the job creation request

static basic_auth(username: str, password: str) str#

create a basic authentication token from a Thunderhead username and access token

Parameters:
  • username (str) – your Thunderhead username

  • password (str) – your Thunderhead access token

Returns:

the basic authentification string that will authenticate you with the API

Return type:

str

static convert_circuit(circuit: QuantumTape) dict[str, any]#

converts a pennylane quantum script to a dictionary that can be read by the Thunderhead API

Parameters:

tape (tape.QuantumScript) – a pennylane quantum script (with informations about the number of wires, the operations and the measurements)

Returns:

a dictionary representation of the circuit that can be read by the API

Return type:

dict[str, any]

static convert_instruction(instruction: Operation) dict[str, any]#

converts a Pennylane operation to a dictionary that can be read by the Thunderhead API

Parameters:

instruction (Operation) – a Pennylane operation (a gate)

Returns:

a dictionary representation of the operation that can be read by the Thunderhead API

Return type:

dict[str, any]

static headers(username: str, password: str, realm: str) dict[str, str]#

the Thunderhead API headers

Parameters:
  • username (str) – your Thunderhead username

  • password (str) – your Thunderhead access token

  • realm (str) – your organization identifier with Thunderhead

Returns:

a dictionary representing the request headers

Return type:

dict[str, any]

static job_body(circuit: dict[str, any], circuit_name: str, project_id: str, machine_name: str, shots) dict[str, any]#

the body for the job creation request

Parameters:
  • circuit (tape.QuantumScript) – the script you want to convert

  • circuit_name (str) – the name of your circuit

  • project_id (str) – the id for the project for which this job will be run

  • machine_name (str) – the name of the machine on which this job will be run

  • shots (int, optional) – the number of shots (-1 will use the circuit’s shot number)

Returns:

the body for the job creation request

Return type:

dict[str, any]