Skip to main content

Strangeworks-Wolfram

The strangeworks-wolfram package allows Wolfram Mathematica users to comunicate with the strangeworks platform. This allows users to submit jobs to gate based quantum hardware as well to a wider range of alternative compute providers, see full catalogue.

Installation

A user must go through the following steps to be able to run jobs

  • Download and authenticate Wolfram, free trials available. Skip this if you already have a license.
  • Sign up for free to our platform
  • Add the free IBMQ resource
  • Put in your apiKey from the homepage and resource id from the resource page and run the example below

🥳 Success! You may view your job in the portal.

😅 Something went wrong? Find us in Slack!

Usage

IBMQ

Here's a simple example of creating a Bell state with IBMQ.

Before running follow the installation steps above:

IBM: Hello World

(* Install QuantumFramework *)
PacletInstall["Wolfram/QuantumFramework", ForceVersionInstall -> True]
<< Wolfram`QuantumFramework`;

(* Install Strangeworks Extension *)
PacletInstall["Strangeworks/Strangeworks", ForceVersionInstall -> True]
<< Strangeworks`Strangeworks`;

(* Define quantum circuit using the QuantumFrameworks *)
ops = {QuantumOperator["H", {1}],
QuantumOperator["CX", {1, 2}], {1}, {2}};
qc = QuantumCircuitOperator[ops]; qc["Diagram"]

(* User must input their own apikey and resourceslug, see installation instructions above *)
apikey = "";
resourceslug = "";
productslug = "ibm-quantum";

authstatus = AuthenticateSW[apikey]
resourcestatus = GetResourceSW[resourceslug, productslug]

(* Display backends available to the user *)
backends = BackendsSW[]

(* Run on the simulator *)
backend = "ibmq_qasm_simulator";
shots = 100;
swjob = RunSW[qc, backend, shots]
jobslug = Part[swjob, 2]

(* Check on the status of the job *)
status = StatusSW[jobslug]

(* Get the results *)
result = ResultSW[jobslug];

(* Plot the results *)
histogramSW[Part[result, 2]]

🥳 Success! You may view your job in the portal.

😅 Something went wrong? Find us in Slack!

AWS Braket

Here's a simple example of creating a Bell state with AWS Braket.

Before running follow the installation steps above, but you will also need to add the AWS Braket resource on the platform. To do that complete the billing account details on the paltform page and also contact hello@strangeworks.com to begin the process.

AWS: Hello World

(* Install QuantumFramework *)
PacletInstall["Wolfram/QuantumFramework", ForceVersionInstall -> True]
<< Wolfram`QuantumFramework`;

(* Install Strangeworks Extension *)
PacletInstall["Strangeworks/Strangeworks", ForceVersionInstall -> True]
<< Strangeworks`Strangeworks`;

(* Define quantum circuit using the QuantumFrameworks *)
ops = {QuantumOperator["H", {1}],
QuantumOperator["CX", {1, 2}], {1}, {2}};
qc = QuantumCircuitOperator[ops]; qc["Diagram"]

(* User must input their own apikey and resourceslug, see installation instructions above *)
apikey = "";
resourceslug = "";
productslug = "amazon-braket";

authstatus = AuthenticateSW[apikey]
resourcestatus = GetResourceSW[resourceslug, productslug]

(* Display backends available to the user *)
backends = BackendsSW[]

(* Run on the simulator *)
backend = "arn:aws:braket:::device/quantum-simulator/amazon/sv1";
shots = 100;
swjob = RunSW[qc, backend, shots]
jobslug = Part[swjob, 2]

(* Check on the status of the job *)
status = StatusSW[jobslug]

(* Get the results *)
result = ResultSW[jobslug];

(* Plot the results *)
histogramSW[Part[result, 2]]

🥳 Success! You may view your job in the portal.

😅 Something went wrong? Find us in Slack!