{"id":37081256,"url":"https://github.com/quantastica/qps-api","last_synced_at":"2026-01-14T09:52:34.394Z","repository":{"id":57459241,"uuid":"337093547","full_name":"quantastica/qps-api","owner":"quantastica","description":"Python wrapper for Quantum Programming Studio HTTP API","archived":false,"fork":false,"pushed_at":"2025-09-29T14:58:01.000Z","size":89,"stargazers_count":4,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-11-08T04:17:32.525Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/quantastica.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2021-02-08T13:58:09.000Z","updated_at":"2025-09-29T14:58:05.000Z","dependencies_parsed_at":"2024-05-02T01:28:38.412Z","dependency_job_id":"98661aee-cea4-4905-9701-b2070f7c4c67","html_url":"https://github.com/quantastica/qps-api","commit_stats":{"total_commits":13,"total_committers":1,"mean_commits":13.0,"dds":0.0,"last_synced_commit":"6649310bdb101b7473b84e81bd16d4175a123c8f"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/quantastica/qps-api","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/quantastica%2Fqps-api","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/quantastica%2Fqps-api/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/quantastica%2Fqps-api/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/quantastica%2Fqps-api/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/quantastica","download_url":"https://codeload.github.com/quantastica/qps-api/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/quantastica%2Fqps-api/sbom","scorecard":{"id":755091,"data":{"date":"2025-08-11","repo":{"name":"github.com/quantastica/qps-api","commit":"d5acf9278245a538d4573d861f58c263d8c85d39"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":3,"checks":[{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"SAST","score":0,"reason":"no SAST tool detected","details":["Warn: no pull requests merged into dev branch"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}},{"name":"Code-Review","score":0,"reason":"Found 0/18 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Dangerous-Workflow","score":-1,"reason":"no workflows found","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Pinned-Dependencies","score":-1,"reason":"no dependencies found","details":null,"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Token-Permissions","score":-1,"reason":"No tokens found","details":null,"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Vulnerabilities","score":10,"reason":"0 existing vulnerabilities detected","details":null,"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: Apache License 2.0: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'master'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}}]},"last_synced_at":"2025-08-22T21:26:22.544Z","repository_id":57459241,"created_at":"2025-08-22T21:26:22.544Z","updated_at":"2025-08-22T21:26:22.544Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28416120,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-14T08:38:59.149Z","status":"ssl_error","status_checked_at":"2026-01-14T08:38:43.588Z","response_time":107,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2026-01-14T09:52:33.601Z","updated_at":"2026-01-14T09:52:34.386Z","avatar_url":"https://github.com/quantastica.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Quantum Programming Studio API\n\nPython wrapper for [Quantum Programming Studio](https://quantum-circuit.com/) HTTP API.\n\n\n## Install and configure\n\n**1. Install QPS API package:**\n\n```bash\npip install quantastica-qps-api\n```\n\n**2. Find your QPS API token:**\n\n[Login](https://quantum-circuit.com/login) to Quantum Programming Studio, go to [Profile -\u003e API Access](https://quantum-circuit.com/user_settings/api) and copy your API token.\n\n**3. Configure QPS API package with your API token:**\n\nMake sure that environment variable `QPS_API_KEY` contains your API token.\n\n**Now you are ready to use QPS API.**\n\n\nAlternativelly, you can temporary set your API token:\n\n```python\nfrom quantastica.qps_api import QPS\n\nQPS.use_account(\"YOUR_API_TOKEN\")\n```\n\n\nYou can also save your API token to local configuration file for future use:\n\n```python\nfrom quantastica.qps_api import QPS\n\nQPS.save_account(\"YOUR_API_TOKEN\")\n```\n\n*Note: saving API token in local configuration file is not recommented and we advise you to use environment variable instead.*\n\n\n## Account management\n\n**QPS.use_account(api_token, api_url=None)**\n\nMethod will temporary set provided API token to be used. This will not store your token.\n\n*Note: it is not recommended to expose your API token in source code. Please use environment variable instead*\n\n\n**QPS.save_account(api_token, api_url=None)**\n\nMethod will create configuration file and your api token will be stored there for future use.\n\nIf needed, you can clear your token by running `QPS.save_account(\"\")` (or by deleting a configuration file).\n\n*Note: it is not recommended to store your API token in configuration file. Please use environment variable instead*\n\n\n**QPS.load_account()**\n\nMethod will load previously stored API token from local configuration file.\n\n*Note: it is not recommended to keep your API token in configuration file. Please use environment variable instead*\n\n\n**QPS.config_path()**\n\nYou can get config file path by running `QPS.config_path()`.\n\nDefault configuration file path:\n\n- On Unix, directory is obtained from environment variable HOME if it is set; otherwise the current user’s home directory is looked up in the password directory through the built-in module pwd.\n\n- On Windows, USERPROFILE will be used if set, otherwise a combination of HOMEPATH and HOMEDRIVE will be used.\n\n\n\n## Synthesis and transpilation API\n\nSynthesis and transpilation tool can be used to:\n\n- create quantum circuit from state vectors\n\n- create quantum circuit from truth table\n\n- create quantum circuit from unitary matrix (decompose unitary matrix)\n\n- transpile circuits (change instruction set)\n\n\n### Circuit from vectors\n\nFind quantum circuit from pairs of initial \u0026 final state vectors (wave functions).\n\n**QPS.synth.circuit_from_vectors(vector_pairs, endianness = \"little\", job_name=None, settings = {}, start_job=True)**\n\n- `vector_pairs` is list containing vector pairs. Each vector pair is list with 2 elements: initial vector and final vector. All vectors in all pairs must be of same length (same number of qubits).\n\n- `endianness` string. Orientation of bits in state vector (most significant bit/first qubit or least significant bit/first qubit). Can be `little` (like Qiskit) or `big`. Default is `little`.\n\n- `job_name` string is optional. You can give it a human readable name.\n\n- `start_job` if this argument is `True` (default) the job will be immediatelly sent to execution queue. If `start_job` is `False` then it will stay in `draft` state and you will be able to start it later by calling `start_job()` method.\n\n- `settings` object is optional. Default is:\n\n```python\n{\n\t\"strategy\": \"strategy_a\",\n\t\"pre_processing\": \"\",\n\t\"allowed_gates\": \"u3,cx\",\n\t\"min_gates\": 0,\n\t\"max_gates\": 0,\n\t\"max_diff\": 0.001,\n\t\"diff_method\": \"ignorephase\",\n\t\"max_duration\": 0,\n\t\"single_solution\": True\n}\n```\n\n**Settings**\n\n- `strategy` string. Can be one of: `strategy_a` (brute force or heuristics) and `strategy_b` OptigenQ+QSD (OptigenQ is Quantastica's method to find unitary matrix from pairs of vectors, and QSD is used to decompose matrix and return circuit). Default is `strategy_a`.\n\n- `pre_processing` string. Used only with `strategy_a` (brute force or heuristics). Can be one of: `stable`, `experimental_1`, `experimental_2`, `experimental_3`, `experimental_5`. Default is empty string (Empty string means \"use default\" which is currently `stable`).\n\n- `allowed_gates` string. Used only with `strategy_a` (brute force or heuristics). Comma delimited gate names (instruction set) to use. Default is `u3,cx`. With `strategy_b` instruction set is fixed to `u3,cx` (you can transpile returned circuit later using `QPS.synth.transpile()` method.\n\n- `min_gates` and `max_gates` integer. Used only with `strategy_a` (brute force or heuristics). Default is `0` (no limits).\n\n- `max_diff` float. Used only with `strategy_a` (brute force or heuristics). Default is `0.001` (1e-3).\n\n- `diff_method` string. Used only with `strategy_a` (brute force or heuristics). Can be one of: `distance` (exact match), `ignorephase` (match up to a global phase) and `abs` (match absolute values). Default is `ignorephase`.\n\n- `max_duration` integer. Timeout in seconds. Solver will stop after specified number of seconds and error will be returned. Useful with brute force algorithm which has high computational complexity and can run for a very long time. You can decide when to stop (and for example proceed with the next job which is using different method and is waiting in a queue - if you prepared it). Default is `0` which means \"maximum allowed by your subscription plan\". Free plan has limit of a few seconds (subject to change).\n\n- `single_solution` boolean. Used only with `strategy_a` (brute force or heuristics). When `True`, solver will stop when first solution was found. When `False` solver will return all possible configurations of a circuit.\n\nNote: if `settings` argument is provided, it will overwrite default settings, but only provided keys will be overwritten - not entire default settings object.\n\n\n**Example:**\n\n```python\nfrom quantastica.qps_api import QPS\n\nvector_pairs = [\n[ [1, 0, 0, 0], [ 0.5+0j,  0.5+0j,  0.5+0j,  0.5+0j ] ],\n[ [0, 1, 0, 0], [ 0.5+0j,  0+0.5j, -0.5+0j,  0-0.5j ] ],\n[ [0, 0, 1, 0], [ 0.5+0j, -0.5+0j,  0.5+0j, -0.5+0j ] ],\n[ [0, 0, 0, 1], [ 0.5+0j,  0-0.5j, -0.5+0j,  0+0.5j ] ]\n]\n\njob_id = QPS.synth.circuit_from_vectors(vector_pairs, settings = { \"instruction_set\": [\"h\", \"cu1\", \"swap\"], \"single_solution\": False })\n\njob = QPS.synth.get_job(job_id, wait=True)\n\njob_status = job[\"status\"]\njob_output = job[\"output\"]\n\nif(job_status == \"error\"):\n\tprint(job_output[\"message\"])\nelse:\n\tfor circuit in job_output[\"circuits\"]:\n\t\tprint(circuit[\"qasm\"])\n\n```\n\nExample output:\n\n```\nOPENQASM 2.0;\ninclude \"qelib1.inc\";\nqreg q[2];\nh q[1];\nswap q[0], q[1];\ncu1 (2.356194496154785) q[0], q[1];\nh q[1];\n\nOPENQASM 2.0;\ninclude \"qelib1.inc\";\nqreg q[2];\nh q[1];\ncu1 (2.356194496154785) q[0], q[1];\nh q[0];\nswap q[0], q[1];\n\nOPENQASM 2.0;\ninclude \"qelib1.inc\";\nqreg q[2];\nh q[1];\ncu1 (2.356194496154785) q[0], q[1];\nswap q[0], q[1];\nh q[1];\n\nOPENQASM 2.0;\ninclude \"qelib1.inc\";\nqreg q[2];\nswap q[0], q[1];\nh q[0];\ncu1 (2.356194496154785) q[0], q[1];\nh q[1];\n```\n\n### State preparation\n\nGet circuit which prepares provided state.\n\n**QPS.synth.state_preparation(final_vector, endianness = \"little\", job_name=None, settings = {}, start_job=True)**\n\n- `final_vector` is target vector.\n\n- `endianness` string. Orientation of bits in state vector (most significant bit/first qubit or least significant bit/first qubit). Can be `little` (like Qiskit) or `big`. Default is `little`.\n\n- `job_name` string is optional. You can give it a human readable name.\n\n- `start_job` if this argument is `True` (default) the job will be immediatelly sent to execution queue. If `start_job` is `False` then it will stay in `draft` state and you will be able to start it later by calling `start_job()` method.\n\n- `settings` object is optional. Default is:\n\n```python\n{\n\t\"strategy\": \"strategy_a\",\n\t\"pre_processing\": \"\",\n\t\"allowed_gates\": \"u3,cx\",\n\t\"min_gates\": 0,\n\t\"max_gates\": 0,\n\t\"max_diff\": 0.001,\n\t\"diff_method\": \"ignorephase\",\n\t\"max_duration\": 0,\n\t\"single_solution\": True\n}\n\n```\n\n**Settings**\n\n- `strategy` string. Can be one of: `strategy_a` (brute force or heuristics) and `strategy_b` OptigenQ+QSD (OptigenQ is Quantastica's method to find unitary matrix from pairs of vectors, after which QSD is used to decompose matrix and return circuit). Default is `strategy_a`.\n\n- `pre_processing` string. Used only with `strategy_a` (brute force or heuristics). Can be one of: `stable`, `experimental_1`, `experimental_2`, `experimental_3`, `experimental_5`. Default is empty string (Empty string means \"use default\" which is currently `stable`).\n\n- `allowed_gates` string. Used only with `strategy_a` (brute force or heuristics). Comma delimited gate names (instruction set) to use. Default is `u3,cx`. With `strategy_b` instruction set is fixed to `u3,cx` (you can transpile returned circuit later using `QPS.synth.transpile()` method.\n\n- `min_gates` and `max_gates` integer. Used only with `strategy_a` (brute force or heuristics). Default is `0` (no limits).\n\n- `max_diff` float. Used only with `strategy_a` (brute force or heuristics). Default is `0.001` (1e-3).\n\n- `diff_method` string. Used only with `strategy_a` (brute force or heuristics). Can be one of: `distance` (exact match), `ignorephase` (match up to a global phase) and `abs` (match absolute values). Default is `ignorephase`.\n\n- `max_duration` integer. Timeout in seconds. Solver will stop after specified number of seconds and error will be returned. Useful with brute force algorithm which has high computational complexity and can run for a very long time. You can decide when to stop (and for example proceed with the next job which is using different method and is waiting in a queue - if you prepared it). Default is `0` which means \"maximum allowed by your subscription plan\". Free plan has limit of a few seconds (subject to change).\n\n- `single_solution` boolean. Used only with `strategy_a` (brute force or heuristics). When `True`, solver will stop when first solution was found. When `False` solver will return all possible configurations of a circuit.\n\nNote: if `settings` argument is provided, it will overwrite default settings, but only provided keys will be overwritten - not entire default settings object.\n\n\n**Example:**\n\n```python\nfrom quantastica.qps_api import QPS\n\ndesired_state = [0.5, 0.5, 0.5, 0.5]\n\njob_id = QPS.synth.state_preparation(desired_state, settings = { \"instruction_set\": [\"u3\", \"cx\"] })\n\njob = QPS.synth.get_job(job_id, wait=True)\n\njob_status = job[\"status\"]\njob_output = job[\"output\"]\n\nif(job_status == \"error\"):\n\tprint(job_output[\"message\"])\nelse:\n\tfor circuit in job_output[\"circuits\"]:\n\t\tprint(circuit[\"qasm\"])\n\n```\n\nExample output:\n\n```\nOPENQASM 2.0;\ninclude \"qelib1.inc\";\nqreg q[2];\nu3 (1.570796370506287, 0, 1.217840194702148) q[0];\nu3 (1.570796370506287, 0, 0.621559917926788) q[1];\n```\n\n\n### Transpile\n\nTranspile circuit (change instruction set).\n\n**QPS.synth.transpile(input_qasm, method=\"replace_blocks\", method_options={}, job_name=None, settings = {}, start_job=True)**\n\n- `input_qasm` is string containing OpenQASM 2.0 code.\n\n- `method` is method name string. Can be one of: \"replace_circuit\", \"replace_blocks\", \"replace_gates\". Default: \"replace_blocks\".\n\n- `method_options` dict with following structure:\n\n\t- If method is `replace_blocks` then: `{ \"block_size\": 2, \"two_pass\": False }` (maximum block size is 4).\n\n\t- For other methods: no options (`method_options` is ignored)\n\n- `job_name` string is optional. You can give it a human readable name.\n\n- `start_job` if this argument is `True` (default) the job will be immediatelly sent to execution queue. If `start_job` is `False` then it will stay in `draft` state and you will be able to start it later by calling `start_job()` method.\n\n- `settings` object is optional. Default is:\n\n```python\n{\n\t\"pre_processing\": \"experimental1\",\n\t\"allowed_gates\": \"u3,cx\",\n\t\"max_diff\": 0.001,\n\t\"diff_method\": \"ignorephase\",\n\t\"max_duration\": 0\n}\n\n```\n\n**Settings**\n\n- `pre_processing` string. Can be one of: `stable`, `experimental_1`, `experimental_2`, `experimental_3`, `experimental_5`. Default is empty string (Empty string means \"use default\" which is currently `stable`).\n\n- `allowed_gates` string. Comma delimited gate names (instruction set) to use. Default is `u3,cx`.\n\n- `max_diff` float. Default is `0.001` (1e-3).\n\n- `diff_method` string. Can be one of: `distance` (exact match), `ignorephase` (match up to a global phase) and `abs` (match absolute values). Default is `ignorephase`.\n\n- `max_duration` integer. Timeout in seconds. Solver will stop after specified number of seconds and error will be returned. Default is `0` which means \"maximum allowed by your subscription plan\". Free plan has limit of a few seconds (subject to change).\n\nNote: if `settings` argument is provided, it will overwrite default settings, but only provided keys will be overwritten - not entire default settings object.\n\n\n**Example:**\n\n```python\nfrom quantastica.qps_api import QPS\n\ninput_qasm = \"\"\"\nOPENQASM 2.0;\ninclude \"qelib1.inc\";\nqreg q[2];\nh q[0];\ncx q[0], q[1];\n\"\"\"\n\njob_id = QPS.synth.transpile(input_qasm, settings = { \"instruction_set\": [\"id\", \"x\", \"sx\", \"rz\", \"cx\"], \"diff_method\": \"ignorephase\" })\n\njob = QPS.synth.get_job(job_id, wait=True)\n\njob_status = job[\"status\"]\njob_output = job[\"output\"]\n\nif(job_status == \"error\"):\n\tprint(job_output[\"message\"])\nelse:\n\tfor circuit in job_output[\"circuits\"]:\n\t\tprint(circuit[\"qasm\"])\n\n```\n\nExample output:\n\n```\nOPENQASM 2.0;\ninclude \"qelib1.inc\";\nqreg q[2];\nsx q[0];\nrz (1.570796370506287) q[0];\nsx q[0];\ncx q[0], q[1];\n```\n\n### Decompose matrix\n\nDecompose unitary matrix (find circuit from matrix).\n\n**QPS.synth.decompose_unitary(unitary, endianness=\"big\", job_name=None, settings = {}, start_job=True)**\n\n- `unitary` matrix operator.\n\n- `endianness` - orientation of the matrix. Can be `little` endian (like Qiskit) or `big` endian. Default is `big`. Note that default endianness of the matrix differs from default endianness of vectors in other methods. That's to be aligned with QPS. In Qiskit, both matrices and vectors are `little` endian. So, if you are solving unitary from Qiskit then provide `endianness = \"little\"` argument.\n\n- `job_name` string is optional. You can give it a human readable name.\n\n- `start_job` if this argument is `True` (default) the job will be immediatelly sent to execution queue. If `start_job` is `False` then it will stay in `draft` state and you will be able to start it later by calling `start_job()` method.\n\n- `settings` object is optional. Default is:\n\n```python\n{\n\t\"strategy\": \"strategy_a\",\n\t\"pre_processing\": \"\",\n\t\"allowed_gates\": \"u3,cx\",\n\t\"coupling_map\": [],\n\t\"min_gates\": 0,\n\t\"max_gates\": 0,\n\t\"max_diff\": 0.001,\n\t\"diff_method\": \"ignorephase\",\n\t\"max_duration\": 0,\n\t\"single_solution\": True\n}\n\n```\n\n**Settings**\n\n- `strategy` string. Can be one of: `strategy_a` (brute force or heuristics) and `strategy_b` QSD. Default is `strategy_a`. Note that `strategy_a` (brute force or heuristics) returns circuit with optimal or near optimal depth, but this method has very high computational complexity and can run for a very long time (depending on number of qubits and total number of gates in the resulting circuit).\n\n- `pre_processing` string. Used only with `strategy_a` (brute force or heuristics). Can be one of: `stable`, `experimental_1` and `experimental_5`. Default is empty string (Empty string means \"use default\" which is currently `stable`). Experimental methods have lower computational complexity and should finish sooner, but that depends on many factors, so you should try all methods and see what works best for your particular problem.\n\n- `allowed_gates` string. Used only with `strategy_a` (brute force or heuristics). Comma delimited gate names (instruction set) to use. Default is `u3,cx`. With `strategy_b` instruction set is fixed to `u3,cx` (you can transpile returned circuit later using `QPS.synth.transpile()` method.\n\n- `min_gates` and `max_gates` integer. Used only with `strategy_a` (brute force or heuristics). Default is `0` (no limits).\n\n- `max_diff` float. Used only with `strategy_a` (brute force or heuristics). Default is `0.001` (1e-3).\n\n- `diff_method` string. Used only with `strategy_a` (brute force or heuristics). Can be one of: `distance` (exact match), `ignorephase` (match up to a global phase) `hs` (match up to a global phase using faster method) and `abs` (match absolute values). Default is `ignorephase`.\n\n- `max_duration` integer. Timeout in seconds. Solver will stop after specified number of seconds and error will be returned. Useful with brute force algorithm which has high computational complexity and can run for a very long time. You can decide when to stop (and for example proceed with the next job which is using different method and is waiting in a queue - if you prepared it). Default is `0` which means \"maximum allowed by your subscription plan\". Free plan has limit of a few seconds (subject to change).\n\n- `single_solution` boolean. Used only with `strategy_a` (brute force or heuristics). When `True`, solver will stop when first solution was found. When `False` solver will return all possible configurations of a circuit.\n\nNote: if `settings` argument is provided, it will overwrite default settings, but only provided keys will be overwritten - not entire default settings object.\n\n\n**Example:**\n\n```python\nfrom quantastica.qps_api import QPS\n\nunitary = [\n[ 0.5+0.0j,  0.5+0.0j,  0.5+0.0j,  0.5+0.0j],\n[ 0.5+0.0j,  0.5+0.0j, -0.5+0.0j, -0.5+0.0j],\n[ 0.5+0.0j, -0.5+0.0j,  0.0+0.5j,  0.0-0.5j],\n[ 0.5+0.0j, -0.5+0.0j,  0.0-0.5j,  0.0+0.5j]\n]\n\njob_id = QPS.synth.decompose_unitary(unitary, settings = { \"instruction_set\": [\"h\", \"cu1\", \"swap\"], \"single_solution\": False })\n\njob = QPS.synth.get_job(job_id, wait=True)\n\njob_status = job[\"status\"]\njob_output = job[\"output\"]\n\nif(job_status == \"error\"):\n\tprint(job_output[\"message\"])\nelse:\n\tfor circuit in job_output[\"circuits\"]:\n\t\tprint(circuit[\"qasm\"])\n\n```\n\nExample output:\n\n```\nOPENQASM 2.0;\ninclude \"qelib1.inc\";\nqreg q[2];\nh q[1];\nswap q[0], q[1];\ncu1 (1.570796370506287) q[0], q[1];\nh q[1];\n\nOPENQASM 2.0;\ninclude \"qelib1.inc\";\nqreg q[2];\nh q[1];\ncu1 (1.570796370506287) q[0], q[1];\nh q[0];\nswap q[0], q[1];\n\nOPENQASM 2.0;\ninclude \"qelib1.inc\";\nqreg q[2];\nh q[1];\ncu1 (1.570796370506287) q[0], q[1];\nswap q[0], q[1];\nh q[1];\n\nOPENQASM 2.0;\ninclude \"qelib1.inc\";\nqreg q[2];\nswap q[0], q[1];\nh q[0];\ncu1 (1.570796370506287) q[0], q[1];\nh q[1];\n```\n\n\n### Create circuit from truth table\n\nCreate circuit which implements logical expression whose truth table is given.\n\n**QPS.synth.circuit_from_truth_table(truth_table_csv, column_defs, csv_delimiter=None, additional_qubits=1, job_name=None, settings={}, start_job=True)**\n\n- `truth_table_csv` is string containing truth table in CSV format\n\n- `column_defs` list of strings describing each column from truth table: `\"input\"`, `\"output\"` or `\"ignore\"`\n\n- `csv_delimiter` CSV column delimiter char: `None`, `\",\"` (comma) or `\"\\t\"` (tab). If delimiter is `None` (default) it will be automatically detected.\n\n- `additional_qubits` number of qubits to add (to displace input and output qubits).\n\n- `job_name` string is optional. You can give it a human readable name.\n\n- `settings` object is optional. Default is:\n\n```python\n{\n\t\"pre_processing\": \"\",\n\t\"allowed_gates\": \"x,cx,ccx,swap\",\n\t\"coupling_map\": [],\n\t\"min_gates\": 0,\n\t\"max_gates\": 0,\n\t\"max_diff\": 0.001,\n\t\"diff_method\": \"ignorephase\",\n\t\"max_duration\": 0,\n\t\"single_solution\": True\n}\n\n```\n\n**Settings**\n\n- `pre_processing` string. Can be one of: `stable`, `experimental_1` and `experimental_5`. Default is empty string (Empty string means \"use default\" which is currently `stable`).\n\n- `allowed_gates` string. Comma delimited gate names (instruction set) to use. Default is `x,cx,ccx,swap`.\n\n- `min_gates` and `max_gates` integer. Default is `0` (no limits).\n\n- `max_diff` float. Used only with `strategy_a` (brute force or heuristics). Default is `0.001` (1e-3).\n\n- `diff_method` string. Used only with `strategy_a` (brute force or heuristics). Can be one of: `distance` (exact match), `ignorephase` (match up to a global phase) and `abs` (match absolute values). Default is `ignorephase`.\n\n- `max_duration` integer. Timeout in seconds. Solver will stop after specified number of seconds and error will be returned. Useful with brute force algorithm which has high computational complexity and can run for a very long time. You can decide when to stop (and for example proceed with the next job which is using different method and is waiting in a queue - if you prepared it). Default is `0` which means \"maximum allowed by your subscription plan\". Free plan has limit of a few seconds (subject to change).\n\n- `single_solution` boolean. Used only with `strategy_a` (brute force or heuristics). When `True`, solver will stop when first solution was found. When `False` solver will return all possible configurations of a circuit.\n\nNote: if `settings` argument is provided, it will overwrite default settings, but only provided keys will be overwritten - not entire default settings object.\n\n\n**Example:**\n\n```python\nfrom quantastica.qps_api import QPS\n\ntruth_table = \"\"\"\nA,B,A_NAND_B\n0,0,1\n0,1,1\n1,0,1\n1,1,0\n\"\"\"\n\njob_id = QPS.synth.circuit_from_truth_table(truth_table, [\"input\", \"input\", \"output\"])\n\njob = QPS.synth.get_job(job_id, wait=True)\n\njob_status = job[\"status\"]\njob_output = job[\"output\"]\n\nif(job_status == \"error\"):\n\traise Exception(job_output[\"message\"])\nelse:\n\tif(len(job_output[\"circuits\"]) == 0):\n\t\traise Exception(\"No results.\")\n\telse:\n\t\tfor circuit in job_output[\"circuits\"]:\n\t\t\tprint(circuit[\"qasm\"])\n\n```\n\nExample output:\n\n```\nOPENQASM 2.0;\ninclude \"qelib1.inc\";\nqreg q[3];\nx q[2];\nccx q[0], q[1], q[2];\n```\n\n\n### Run synthesizer or transpiler job defined in JSON file\n\nSolve problem provided in JSON format used by synthesizer and transpiler.\n\n**QPS.synth.solve(problem, settings = {}, start_job=True)**\n\n- `problem` object (e.g. job exported to json from Quantum Programming studio).\n\n- `settings` argument is optional. If provided, it will overwrite keys in `problem.settings`. Note that only provided keys will be overwritten - not entire `problem.settings` object.\n\n- `start_job` if this argument is `True` (default) the job will be immediatelly sent to execution queue. If `start_job` is `False` then it will stay in `draft` state and you will be able to start it later by calling `start_job()` method.\n\n\n**Example:**\n\n```python\nfrom quantastica.qps_api import QPS\n\nproblem = {\n\t\"name\": \"Bell\",\n\t\"type\": \"vectors\",\n\t\"source\": {\n\t\t\"vectors\": {\n\t\t\t\"text1\": \"[ 1, 0, 0, 0 ]\",\n\t\t\t\"text2\": \"[ 1/sqrt(2), 0, 0, 1/sqrt(2) ]\",\n\t\t\t\"endianness1\": \"little\",\n\t\t\t\"endianness2\": \"little\"\n\t\t}\n\t},\n\t\"problem\": [\n\t\t{\n\t\t\t\"input\": [\n\t\t\t\t1,\n\t\t\t\t0,\n\t\t\t\t0,\n\t\t\t\t0\n\t\t\t],\n\t\t\t\"output\": [\n\t\t\t\t0.7071067811865475,\n\t\t\t\t0,\n\t\t\t\t0,\n\t\t\t\t0.7071067811865475\n\t\t\t]\n\t\t}\n\t],\n\t\"settings\": {\n\t\t\"strategy\": \"strategy_a\",\n\t\t\"pre_processing\": \"\",\n\t\t\"allowed_gates\": \"u3,cx\",\n\t\t\"coupling_map\": [],\n\t\t\"min_gates\": 0,\n\t\t\"max_gates\": 0,\n\t\t\"max_diff\": 0.001,\n\t\t\"diff_method\": \"distance\",\n\t\t\"max_duration\": 0,\n\t\t\"single_solution\": False\n\t}\n}\n\njob_id = QPS.synth.solve(problem)\n\njob = QPS.synth.get_job(job_id, wait=True)\n\njob_status = job[\"status\"]\njob_output = job[\"output\"]\n\nif(job_status == \"error\"):\n\tprint(job_output[\"message\"])\nelse:\n\tfor circuit in job_output[\"circuits\"]:\n\t\tprint(circuit[\"qasm\"])\n\n```\n\nExample output:\n\n```\nOPENQASM 2.0;\ninclude \"qelib1.inc\";\nqreg q[2];\nu3 (-1.570796370506287, -3.141592741012573, -2.675650835037231) q[0];\ncx q[0], q[1];\n\nOPENQASM 2.0;\ninclude \"qelib1.inc\";\nqreg q[2];\nu3 (-1.570796370506287, -3.141592741012573, -2.675650835037231) q[1];\ncx q[1], q[0];\n```\n\n\n### Synthesizer/transpiler output format\n\nFinished job object has following structure:\n\n```javascript\n{\n\t\"name\"       : String,\n\t\"type\"       : String,\n\t\"source\"     : Object,\n\t\"problem\"    : Array,\n\t\"settings\"   : Object,\n\t\"status\"     : String,\n\t\"output\"     : Object,\n\t\"queuedAt\"   : String,\n\t\"startedAt\"  : String,\n\t\"finishedAt\" : String\n}\n```\n\nKeys important to user are:\n\n- `name` String: name of the job\n\n- `status` String: can be `draft`, `queued`, `running`, `error`, `done`.\n\n- `output` Object with following structure:\n\n```javascript\n{\n\t\"error_code\" : Integer,\n\t\"message\"    : String,\n\t\"time_taken\" : Float,\n\t\"version\"    : String,\n\t\"circuits\"   : Array of Object\n}\n```\n\n- `error_code` Integer: 0 on success, non-zero on error\n\n- `message` String: error message if error code is non-zero\n\n- `time_taken` Float: number of seconds\n\n- `version` String: solver version\n\n- `circuits` Array: resulting circuits. Each is object with following structure:\n\n```javascript\n{\n\t\"qubits\"  : Integer,\n\t\"cregs\"   : Array,\n\t\"program\" : Array,\n\t\"diff\"    : Float,\n\t\"index\"   : Integer,\n\t\"qasm\"    : String,\n\t\"qasmExt\" : String\n}\n```\n\nKeys important to user are:\n\n- `qasm` OpenQASM 2.0 source code of the resulting circuit.\n\n- `qasmExt` OpenQASM 2.0 with extended instruction set (all gates supported by Quantum Programming Studio).\n\nDifference between `qasm` and `qasmExt`: if circuit contains gate supported by QPS but not directly supported by OpenQASM 2.0 then `qasm` will contain equivalent circuit transpiled to OpenQASM 2.0 instruction set, but `qasmExt` will contain gates as is.\n\nFor example if circuit contains IONQ native gate `gpi2(2.51678906856393)` on first qubit:\n\n`qasm` will be:\n\n```\nOPENQASM 2.0;\ninclude \"qelib1.inc\";\nqreg q[1];\nu3 (1.5707963267948966, 0.9459927417690333, -0.9459927417690333) q[0];\n```\n\n`qasmExt` will contain:\n```\nOPENQASM 2.0;\ninclude \"qelib1.inc\";\nqreg q[1];\ngpi2 (2.51678906856393) q[0];\n```\n\n\n**Example job object with output:**\n\n```python\n{\n\t\"_id\": \"r9LskFoLPQW5w7HTp\",\n\t\"name\": \"Bell\",\n\t\"type\": \"vectors\",\n\t\"source\": {\n\t\t\"vectors\": {\n\t\t\t\"text1\": \"[ 1, 0, 0, 0 ]\",\n\t\t\t\"text2\": \"[ 1/sqrt(2), 0, 0, 1/sqrt(2) ]\",\n\t\t\t\"endianness1\": \"little\",\n\t\t\t\"endianness2\": \"little\"\n\t\t}\n\t},\n\t\"problem\": [\n\t\t{\n\t\t\t\"input\": [\n\t\t\t\t1,\n\t\t\t\t0,\n\t\t\t\t0,\n\t\t\t\t0\n\t\t\t],\n\t\t\t\"output\": [\n\t\t\t\t0.7071067811865475,\n\t\t\t\t0,\n\t\t\t\t0,\n\t\t\t\t0.7071067811865475\n\t\t\t]\n\t\t}\n\t],\n\t\"settings\": {\n\t\t\"strategy\": \"strategy_a\",\n\t\t\"pre_processing\": \"\",\n\t\t\"allowed_gates\": \"u3,cx\",\n\t\t\"coupling_map\": [],\n\t\t\"min_gates\": 0,\n\t\t\"max_gates\": 0,\n\t\t\"max_diff\": 0.001,\n\t\t\"diff_method\": \"distance\",\n\t\t\"max_duration\": 0,\n\t\t\"single_solution\": False\n\t},\n\t\"output\": {\n\t\t\"circuits\": [\n\t\t\t{\n\t\t\t\t\"qubits\": 2,\n\t\t\t\t\"cregs\": [],\n\t\t\t\t\"diff\": 0,\n\t\t\t\t\"program\": [\n\t\t\t\t\t{\n\t\t\t\t\t\t\"name\": \"u3\",\n\t\t\t\t\t\t\"wires\": [\n\t\t\t\t\t\t\t0\n\t\t\t\t\t\t],\n\t\t\t\t\t\t\"options\": {\n\t\t\t\t\t\t\t\"params\": {\n\t\t\t\t\t\t\t\t\"theta\": 1.570796326794896,\n\t\t\t\t\t\t\t\t\"phi\": 0,\n\t\t\t\t\t\t\t\t\"lambda\": 1.456034103897321\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\t\"name\": \"cx\",\n\t\t\t\t\t\t\"wires\": [\n\t\t\t\t\t\t\t0,\n\t\t\t\t\t\t\t1\n\t\t\t\t\t\t],\n\t\t\t\t\t\t\"options\": {}\n\t\t\t\t\t}\n\t\t\t\t],\n\t\t\t\t\"index\": 0\n\t\t\t},\n\t\t\t{\n\t\t\t\t\"qubits\": 2,\n\t\t\t\t\"cregs\": [],\n\t\t\t\t\"diff\": 0,\n\t\t\t\t\"program\": [\n\t\t\t\t\t{\n\t\t\t\t\t\t\"name\": \"u3\",\n\t\t\t\t\t\t\"wires\": [\n\t\t\t\t\t\t\t1\n\t\t\t\t\t\t],\n\t\t\t\t\t\t\"options\": {\n\t\t\t\t\t\t\t\"params\": {\n\t\t\t\t\t\t\t\t\"theta\": 1.570796326794896,\n\t\t\t\t\t\t\t\t\"phi\": 0,\n\t\t\t\t\t\t\t\t\"lambda\": 1.456034103897321\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\t\"name\": \"cx\",\n\t\t\t\t\t\t\"wires\": [\n\t\t\t\t\t\t\t1,\n\t\t\t\t\t\t\t0\n\t\t\t\t\t\t],\n\t\t\t\t\t\t\"options\": {}\n\t\t\t\t\t}\n\t\t\t\t],\n\t\t\t\t\"index\": 1\n\t\t\t}\n\t\t],\n\t\t\"error_code\": 0,\n\t\t\"message\": \"\",\n\t\t\"time_taken\": 0.008,\n\t\t\"version\": \"0.1.0\",\n\t\t\"stats\": {\n\t\t\t\"result_count\": 2\n\t\t}\n\t},\n\t\"createdAt\": \"2021-02-06T23:39:29.108Z\",\n\t\"modifiedAt\": \"2021-02-06T23:39:30.383Z\",\n\t\"queuedAt\": \"2021-02-06T23:39:29.676Z\",\n\t\"startedAt\": \"2021-02-06T23:39:29.926Z\",\n\t\"finishedAt\": \"2021-02-06T23:39:30.383Z\",\n\t\"status\": \"done\"\n}\n\n```\n\n\n### Using synthesizer and transpiler with Qiskit\n\nFormat used for input and output is OpenQASM 2.0, so integration with Qiskit (and other frameworks that support OpenQASM) is easy.\n\n**Example** transpile Qiskit circuit:\n\n```python\nfrom qiskit import QuantumCircuit\nfrom qiskit.circuit.random import random_circuit\nfrom qiskit.quantum_info import Operator\n\nfrom quantastica.qps_api import QPS\n\n# Generate random Qiskit circuit\nqc = random_circuit(5, 5, measure=False)\n\n# Get QASM code\ninput_qasm = qc.qasm()\n\n# Transpile with QPS\njob_id = QPS.synth.transpile(input_qasm, settings = { \"instruction_set\": [\"id\", \"u3\", \"cx\"], \"diff_method\": \"ignorephase\" })\njob = QPS.synth.get_job(job_id, wait=True)\njob_status = job[\"status\"]\njob_output = job[\"output\"]\nif(job_status == \"error\"):\n    raise Exception(job_output[\"message\"])\n\ntranspiled_circuit = job_output[\"circuits\"][0]\n\n# Get QASM code\ntranspiled_qasm = transpiled_circuit[\"qasm\"]\n\n# Create Qiskit circuit\ntranspiled_qc = QuantumCircuit.from_qasm_str(transpiled_qasm)\n\n# Show circuit\nprint(\"Depth:\", transpiled_qc.depth())\nprint(\"Ops:\", sum(j for i, j in transpiled_qc.count_ops().items()))\ndisplay(transpiled_qc.draw(output=\"mpl\"))\n\n```\n\n\n### Job management\n\nProblem sent to solver (synthesizer or transpiler) is called a \"job\". Each job has unique ID. Solver is resource intensive tool, so it is configured to execute only one job at a time. While solver is processing a job, other jobs are queued. When solver finishes a job, it takes the next one from the queue.\n\nAPI provides functions for job manipulation: you can list all jobs (filtered by status), stop running job, cancel queued jobs, stop/cancel all jobs, start previously canceled (draft) job, etc.\n\n**QPS.synth.list_jobs(status_filter=None)**\n\nList all jobs, optionally filtered by status.\n\n- `status_filter` String, optional. Can be: `draft`, `queued`, `running`, `error`, `done`.\n\n\n**Example 1** - list all (unfiltered) jobs:\n\n```python\nfrom quantastica.qps_api import QPS\n\njobs = QPS.synth.list_jobs()\n\nprint(jobs)\n\n```\n\nExample output:\n\n```python\n{\n\t\"list\": [\n\t\t{ \"_id\": \"r9LskFoLPQW5w7HTp\", \"name\": \"Bell state\", \"type\": \"vectors\", \"status\": \"done\" },\n\t\t{ \"_id\": \"R8tJH7XoZ233oTREy\", \"name\": \"4Q Gauss\", \"type\": \"vectors\", \"status\": \"queued\" },\n\t\t{ \"_id\": \"h7fzYbFz8MJvkNhiX\", \"name\": \"Challenge\", \"type\": \"unitary\", \"status\": \"draft\" },\n\t\t{ \"_id\": \"PC5PNXiGqhh2HmkX8\", \"name\": \"Experiment\", \"type\": \"vectors\", \"status\": \"error\"},\n\t\t{ \"_id\": \"SNhiCqSCT2WwRWKCd\", \"name\": \"Decompose\", \"type\": \"unitary\", \"status\": \"running\" }\n\t]\n}\n```\n\n**Example 2** - list `running` jobs:\n\n```python\nfrom quantastica.qps_api import QPS\n\njobs = QPS.synth.list_jobs(status_filter=\"running\")\n\nprint(jobs)\n\n```\n\nExample output:\n\n```python\n{\n\t\"list\": [\n\t\t{ \"_id\": \"SNhiCqSCT2WwRWKCd\", \"name\": \"Decompose\", \"type\": \"unitary\", \"status\": \"running\" }\n\t]\n}\n```\n\n\n**QPS.synth.job_status(job_id)**\n\nGet job status.\n\n**Example:**\n\n```python\nfrom quantastica.qps_api import QPS\n\nstatus = QPS.synth.job_status(\"PC5PNXiGqhh2HmkX8\")\n\nprint(status)\n\n```\n\nExample output:\n\n```python\n{ \"_id\": \"PC5PNXiGqhh2HmkX8\", \"name\": \"Experiment\", \"type\": \"vectors\", \"status\": \"error\", \"message\": \"connect ECONNREFUSED\" }\n```\n\n\n**QPS.synth.get_job(job_id, wait=True)**\n\nGet job referenced by ID. If `wait` argument is `True` (default), then function will wait for a job to finish (or fail) before returning. If `wait` is `False`, then job will be immediatelly returned even if it is still running (in which case it will not contain a solution).\n\n**Example:**\n\n```python\nfrom quantastica.qps_api import QPS\n\njob = QPS.synth.get_job(\"r9LskFoLPQW5w7HTp\")\n\nprint(job)\n\n```\n\nExample output:\n\n```python\n{\n\t\"_id\": \"r9LskFoLPQW5w7HTp\",\n\t\"name\": \"Bell\",\n\t\"type\": \"vectors\",\n\t\"source\": {\n\t\t\"vectors\": {\n\t\t\t\"text1\": \"[ 1, 0, 0, 0 ]\",\n\t\t\t\"text2\": \"[ 1/sqrt(2), 0, 0, 1/sqrt(2) ]\",\n\t\t\t\"endianness1\": \"little\",\n\t\t\t\"endianness2\": \"little\"\n\t\t}\n\t},\n\t\"problem\": [\n\t\t{\n\t\t\t\"input\": [ 1, 0, 0, 0 ],\n\t\t\t\"output\": [ 0.7071067811865475, 0, 0, 0.7071067811865475 ]\n\t\t}\n\t],\n\t\"settings\": {\n\t\t\"max_duration\": 0,\n\t\t\"allowed_gates\": \"u3,cx\",\n\t\t\"coupling_map\": [],\n\t\t\"min_gates\": 0,\n\t\t\"max_gates\": 0,\n\t\t\"pre_processing\": \"\",\n\t\t\"strategy\": \"strategy_a\",\n\t\t\"max_diff\": 0.001,\n\t\t\"diff_method\": \"distance\",\n\t\t\"single_solution\": False\n\t},\n\t\"status\": \"done\",\n\t\"output\": {\n\t\t\"circuits\": [\n\t\t\t{\n\t\t\t\t\"qubits\": 2,\n\t\t\t\t\"cregs\": [],\n\t\t\t\t\"diff\": 0,\n\t\t\t\t\"program\": [\n\t\t\t\t\t{\n\t\t\t\t\t\t\"name\": \"u3\",\n\t\t\t\t\t\t\"wires\": [ 0 ],\n\t\t\t\t\t\t\"options\": {\n\t\t\t\t\t\t\t\"params\": {\n\t\t\t\t\t\t\t\t\"theta\": -1.570796370506287,\n\t\t\t\t\t\t\t\t\"phi\": -3.141592741012573,\n\t\t\t\t\t\t\t\t\"lambda\": -5.327113628387451\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\t\"name\": \"cx\",\n\t\t\t\t\t\t\"wires\": [ 0, 1 ],\n\t\t\t\t\t\t\"options\": {}\n\t\t\t\t\t}\n\t\t\t\t],\n\t\t\t\t\"index\": 0,\n\t\t\t\t\"qasm\": \"OPENQASM 2.0;\\ninclude \\\"qelib1.inc\\\";\\nqreg q[2];\\nu3 (-1.570796370506287, -3.141592741012573, -5.327113628387451) q[0];\\ncx q[0], q[1];\\n\",\n\t\t\t\t\"qasmExt\": \"OPENQASM 2.0;\\ninclude \\\"qelib1.inc\\\";\\nqreg q[2];\\nu3 (-1.570796370506287, -3.141592741012573, -5.327113628387451) q[0];\\ncx q[0], q[1];\\n\"\n\t\t\t},\n\t\t\t{\n\t\t\t\t\"qubits\": 2,\n\t\t\t\t\"cregs\": [],\n\t\t\t\t\"diff\": 0,\n\t\t\t\t\"program\": [\n\t\t\t\t\t{\n\t\t\t\t\t\t\"name\": \"u3\",\n\t\t\t\t\t\t\"wires\": [ 1 ],\n\t\t\t\t\t\t\"options\": {\n\t\t\t\t\t\t\t\"params\": {\n\t\t\t\t\t\t\t\t\"theta\": -1.570796370506287,\n\t\t\t\t\t\t\t\t\"phi\": -3.141592741012573,\n\t\t\t\t\t\t\t\t\"lambda\": -5.327113628387451\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\t\"name\": \"cx\",\n\t\t\t\t\t\t\"wires\": [ 1, 0 ],\n\t\t\t\t\t\t\"options\": {}\n\t\t\t\t\t}\n\t\t\t\t],\n\t\t\t\t\"index\": 1,\n\t\t\t\t\"qasm\": \"OPENQASM 2.0;\\ninclude \\\"qelib1.inc\\\";\\nqreg q[2];\\nu3 (-1.570796370506287, -3.141592741012573, -5.327113628387451) q[1];\\ncx q[1], q[0];\\n\",\n\t\t\t\t\"qasmExt\": \"OPENQASM 2.0;\\ninclude \\\"qelib1.inc\\\";\\nqreg q[2];\\nu3 (-1.570796370506287, -3.141592741012573, -5.327113628387451) q[1];\\ncx q[1], q[0];\\n\"\t\t\t\t\n\t\t\t}\n\t\t],\n\t\t\"error_code\": 0,\n\t\t\"message\": \"\",\n\t\t\"time_taken\": 0.002,\n\t\t\"version\": \"0.1.0\"\n\t},\n\t\"queuedAt\": \"2021-02-06T23:39:29.676Z\",\n\t\"startedAt\": \"2021-02-06T23:39:29.926Z\",\n\t\"finishedAt\": \"2021-02-06T23:39:30.383Z\"\n}\n```\n\n**QPS.synth.stop_job(job_id)**\n\nStop running or cancel queued job. Job will be put into `draft` state, and you can start it again later by calling `start_job()`.\n\n**Example:**\n\n```python\nfrom quantastica.qps_api import QPS\n\nresponse = QPS.synth.stop_job(\"SNhiCqSCT2WwRWKCd\")\n\nprint(response)\n\n```\n\nExample output:\n\n```python\n{ \"_id\": \"SNhiCqSCT2WwRWKCd\", \"message\": \"OK\" }\n```\n\n\n**QPS.synth.stop_all_jobs(status_filter=None)**\n\nStop running job / cancel all queued jobs.\n\n- `status_filter` - you can stop only a running job by providing `status_filter=\"running\"` (after this, next job from the queue will be executed). Or, you can cancel all queued jobs by providing `status_filter=\"queued\"` (running job will not be affected - it will continue running).\n\n**Example 1** - stop running job and remove all jobs from queue:\n\n```python\nfrom quantastica.qps_api import QPS\n\nstopped = QPS.synth.stop_all_jobs()\n\nprint(stopped)\n\n```\n\nExample output:\n\n```python\n{\n\t\"stopped\": [ \n\t\t{ \"_id\": \"SNhiCqSCT2WwRWKCd\", \"name\": \"Decompose\", \"type\": \"unitary\" },\n\t\t{ \"_id\": \"R8tJH7XoZ233oTREy\", \"name\": \"4Q Gauss\", \"type\": \"vectors\" }\n\t]\n}\n```\n\n**Example 2** - stop only a running job. Next job from queue, if any, will start:\n\n```python\nfrom quantastica.qps_api import QPS\n\nstopped = QPS.synth.stop_all_jobs(status_filter=\"running\")\n\nprint(stopped)\n\n```\n\nExample output:\n\n```python\n{\n\t\"stopped\": [\n\t\t{ \"_id\": \"SNhiCqSCT2WwRWKCd\", \"name\": \"Decompose\", \"type\": \"unitary\" }\n\t]\n}\n```\n\n**Example 3** - cancel all queued jobs. Running job will not be affected:\n\n```python\nfrom quantastica.qps_api import QPS\n\nstopped = QPS.synth.stop_all_jobs(status_filter=\"queued\")\n\nprint(stopped)\n\n```\n\nExample output:\n\n```python\n{\n\t\"stopped\": [\n\t\t{ \"_id\": \"R8tJH7XoZ233oTREy\", \"name\": \"4Q Gauss\", \"type\": \"vectors\" }\n\t]\n}\n```\n\n\n**QPS.synth.start_job(job_id)**\n\nStart previously stopped/canceled job (can be any job with status `draft`).\n\n**Example:**\n\n```python\nfrom quantastica.qps_api import QPS\n\nresponse = QPS.synth.start_job(\"SNhiCqSCT2WwRWKCd\")\n\nprint(response)\n\n```\n\nExample output:\n\n```python\n{ \"_id\": \"SNhiCqSCT2WwRWKCd\", \"message\": \"OK\" }\n```\n\n\n## Quantum Language Converter API\n\n[Quantum Language Converter](https://quantastica.com/#converters) is a tool which converts quantum program between different quantum programming languages and frameworks. It is also available as a [q-convert](https://www.npmjs.com/package/q-convert) command line tool and as a web UI at [https://quantum-circuit.com/qconvert](https://quantum-circuit.com/qconvert).\n\nQPS has integrated quantum language converter API which you can access directly from python code:\n\n\n**QPS.converter.convert(input, source, dest)**\n\nConverts `input` quantum program given as string from `source` format into `dest` format.\n\n- `input` String. Program source code\n\n- `source` String. Input format:\n\n\t- `qasm` [OpenQASM 2.0](https://github.com/Qiskit/openqasm) source code\n\t- `quil` [Quil](https://arxiv.org/abs/1608.03355) source code\n\t- `qobj` [QObj](https://arxiv.org/abs/1809.03452)\n\t- `ionq` [IONQ](https://docs.ionq.com/) (json)\n\t- `quantum-circuit` [quantum-circuit](https://www.npmjs.com/package/quantum-circuit) object (json)\n\t- `toaster` [Qubit Toaster](https://quantastica.com/#toaster) object (json)\n\n- `dest` String. Output format:\n\n\t- `qiskit` [Qiskit](https://qiskit.org/documentation/)\n\t- `qasm` [OpenQASM 2.0](https://github.com/Qiskit/openqasm)\n\t- `qasm-ext` OpenQASM 2.0 with complete instruction set supported by QPS (and other Quantastica tools)\n\t- `qobj` [QObj](https://arxiv.org/abs/1809.03452)\n\t- `quil` [Quil](https://arxiv.org/abs/1608.03355)\n\t- `pyquil` [pyQuil](http://docs.rigetti.com/en/latest/index.html)\n\t- `cudaq` [CudaQ](https://nvidia.github.io/cuda-quantum/latest/index.html)\n\t- `braket` [Braket](https://docs.aws.amazon.com/braket/)\n\t- `cirq` [Cirq](https://github.com/quantumlib/Cirq)\n\t- `tfq` [TensorFlow Quantum](https://www.tensorflow.org/quantum)\n\t- `qsharp` [QSharp](https://docs.microsoft.com/en-us/quantum/language/index?view=qsharp-preview)\n\t- `quest` [QuEST](https://quest.qtechtheory.org/)\n\t- `js` [quantum-circuit](https://www.npmjs.com/package/quantum-circuit) (javascript)\n\t- `quantum-circuit` [quantum-circuit](https://www.npmjs.com/package/quantum-circuit) (json)\n\t- `toaster` [Qubit Toaster](https://quantastica.com/toaster/)\n\t- `svg` [SVG (standalone)](https://www.w3.org/Graphics/SVG/)\n\t- `svg-inline` [SVG (inline)](https://www.w3.org/Graphics/SVG/)\n\n\n\n**Example 1** - convert QASM 2.0 program to QUIL:\n\n```python\nfrom quantastica.qps_api import QPS\n\ninput_program = \"\"\"\nOPENQASM 2.0;\ninclude \"qelib1.inc\";\nqreg q[2];\ncreg c[2];\nh q[0];\ncx q[0], q[1];\nmeasure q[0] -\u003e c[0];\nmeasure q[1] -\u003e c[1];\n\"\"\"\n\noutput_program = QPS.converter.convert(input_program, \"qasm\", \"quil\")\n\nprint(output_program)\n\n```\n\nOutput:\n\n```\nDECLARE ro BIT[2]\nH 0\nCNOT 0 1\nMEASURE 0 ro[0]\nMEASURE 1 ro[1]\n```\n\n\n**Example 2** - convert QASM 2.0 program to circuit drawing (vector image):\n\n```python\nfrom quantastica.qps_api import QPS\n\ninput_program = \"\"\"\nOPENQASM 2.0;\ninclude \"qelib1.inc\";\nqreg q[2];\ncreg c[2];\nh q[0];\ncx q[0], q[1];\nmeasure q[0] -\u003e c[0];\nmeasure q[1] -\u003e c[1];\n\"\"\"\n\noutput_svg = QPS.converter.convert(input_program, \"qasm\", \"svg\")\n\n# Do something with returned vector image...\nopen(\"output.svg\", \"w\").write(output_svg)\n\n```\n\n\n## Utils API\n\n**QPS.utils.random_circuit(num_qubits=5, output_format=\"quantum-circuit\", options=None)**\n\nReturns random quantum circuit.\n\n- `num_qubits` Integer. Number of qubits. Default: `5`.\n\n- `format` String. Output format. The same as `QPS.converter.convert()` function's `dest` argument. Example: `\"qasm\"`. Default: `\"quantum-circuit\"`.\n\n- `options` Dict. Optional. Can contain following keys:\n\n\t- `instruction_set` List of gates to use. Example: `[\"u3\", \"cx\"]`. Default: `[ \"u3\", \"rx\", \"ry\", \"rz\", \"cx\", \"cz\" ]`.\n\t- `num_gates` Integer. Number of gates in the circuit. Default is `num_qubits * 8`.\n\t- `mid_circuit_measurement` Bool. Default: `False`.\n\t- `mid_circuit_reset` Bool. Default: `False`.\n\t- `classic_control` Bool. Default: `False`.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fquantastica%2Fqps-api","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fquantastica%2Fqps-api","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fquantastica%2Fqps-api/lists"}