QComputeSDK-TypeScript is the TypeScript version of QCompute, the quantum development kit of Quantum Leaf. QComputeSDK-TypeScript can be used to design quantum experiments: build quantum circuits, manipulate quantum modules, and run quantum computing tasks on Quantum Leaf (https://quantum-hub.baidu.com). The user, via QComputeSDK-TypeScript, can use all quantum-ends on the cloud, including QPUs and cloud simulators.
QComputeSDK-TypeScript is suitable for the circumstances when:
- The targeted platform does not support Python;
- The targeted platform depends on TypeScript, JavaScript packages, or other languages.
- The user needs to use QComputeSDK on front-ends such as Web or ReactNative.
Otherwise, we highly suggest the developer use QComputeSDK-Python, which is more fully featured, reference functional comparison. (https://github.com/baidu/QCompute).
The source code can run on any platform that supports Node.js.
- Node.js
>=19.4.0
- TypeScript
>=4.9.4
-
Install Node.js environment. https://nodejs.org
-
Install TypeScript compiler.
npm install -g typescript
npm install -g ts-node
Method 1 - Install via NPM
npm install qcomputesdk-ts
Method 2 - Install via source code
- Download QComputeSDK-TypeScript source code.
git clone https://github.com/baidu/QComputeSDK-TS.git
- Install NPM requirements.
cd QComputeSDK-TS
npm i
Running the example code QComputeSDK-TS\Example\GHZ_Cloud.ts
.
- Input your Token into
GHZ_Cloud.ts
. Token is an authorization credential for using cloud quantum computing resources, which can be obtained from the Quantum-hub website.
// Your token:
Define.hubToken = '';
- Run the example code.
ts-node Example/Level_1/GHZ_Cloud.ts
- The results would be displayed as follows.
Circuit upload successful, circuitId => 165538 taskId => 162654
Task 162654 is running, please wait...
status changed waiting => success
Download origin success /home/user/QComputeSDK-TS/Output/remote.162654.origin.json size = 779
Download measure success /home/user/QComputeSDK-TS/Output/remote.162654.measure.json size = 24
{"counts":{"000":518,"111":506},"moduleList":[{"arguments":null,"module":"UnrollProcedureModule"},{"arguments":null,"module":"CompositeGateModule"},{"arguments":null,"module":"UnrollCircuitModule"},{"arguments":null,"module":"CompressGateModule"}],"origin":"/home/user/QComputeSDK-TS/Output/remote.162654.origin.json","status":"success","taskId":162654}
done
- Developer can use
GHZ_Cloud.ts
as source code framework. Modify and apply this file can significantly mitigate the learning task. - API usage can reference “Manual/MANUAL.md”.
Coding requirements:
-
Be familiar with quantum circuit model. Any pull should be tested first and then submitted. Be careful about the order of qubits.
-
Please comply with development specifications of relevant programming languages.
-
If any questions/advices/suggestions, please contact us via Email: quantum@baidu.com ;
-
Or, you can use feedback table in Quantum-hub to provide any feedbacks;
-
Or, you are also welcomed to join our discussion QQ group. Scan the QR code below or search by QQ group number 1147781135.
Institute for Quantum Computing, Baidu.
This project is licensed under the Apache License 2.0 - see the LICENSE file for details.