{"id":20131259,"url":"https://github.com/glassnotes/graycode-qubitencoding","last_synced_at":"2025-04-09T16:40:42.362Z","repository":{"id":54222049,"uuid":"286295194","full_name":"glassnotes/GrayCode-QubitEncoding","owner":"glassnotes","description":null,"archived":false,"fork":false,"pushed_at":"2021-03-27T17:57:16.000Z","size":11537,"stargazers_count":6,"open_issues_count":0,"forks_count":6,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-23T18:52:10.924Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Jupyter Notebook","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/glassnotes.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}},"created_at":"2020-08-09T18:34:38.000Z","updated_at":"2024-12-10T08:40:11.000Z","dependencies_parsed_at":"2022-08-13T09:30:57.223Z","dependency_job_id":null,"html_url":"https://github.com/glassnotes/GrayCode-QubitEncoding","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/glassnotes%2FGrayCode-QubitEncoding","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/glassnotes%2FGrayCode-QubitEncoding/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/glassnotes%2FGrayCode-QubitEncoding/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/glassnotes%2FGrayCode-QubitEncoding/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/glassnotes","download_url":"https://codeload.github.com/glassnotes/GrayCode-QubitEncoding/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248068887,"owners_count":21042574,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":"2024-11-13T20:47:08.984Z","updated_at":"2025-04-09T16:40:42.335Z","avatar_url":"https://github.com/glassnotes.png","language":"Jupyter Notebook","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Improving Hamiltonian encodings with the Gray code\n\nObtain energies for deuteron Hamiltonian defined in [https://arxiv.org/abs/2008.05012](https://arxiv.org/abs/2008.05012) using a variational quantum eigensolver. Code was written jointly by Olivia Di Matteo ([@glassnotes](https://github.com/glassnotes/)), Anna McCoy ([@aemccoy](https://github.com/aemccoy/)), Peter Gysbers ([@pgysbers](https://github.com/pgysbers)) and Takayuki Miyagi ([@Takayuki-Miyagi](https://github.com/Takayuki-Miyagi)). \n\n## Installation\n\nWe have provided the specifications of an Anaconda environment in the file `environment.yml`. To reproduce the environment, install Anaconda and run\n```\nconda env create --file environment.yml\n```\n\nThe results of the paper are obtained with qiskit version 0.19.2, this specified in the environment file.\nTo double-check, run `python`: \n```\nPython 3.7.5 (default, Oct 25 2019, 15:51:11) \n[GCC 7.3.0] :: Anaconda, Inc. on linux\nType \"help\", \"copyright\", \"credits\" or \"license\" for more information.\n\u003e\u003e\u003e import qiskit\n\u003e\u003e\u003e qiskit.__version__\n'0.14.1'\n\u003e\u003e\u003e qiskit.__qiskit_version__\n{'qiskit-terra': '0.14.1', 'qiskit-aer': '0.5.1', 'qiskit-ignis': '0.3.0', 'qiskit-ibmq-provider': '0.7.1', 'qiskit-aqua': '0.7.1', 'qiskit': '0.19.2'}\n```\n\n## Instructions\n\nTo compute energies run the program in this director called `run_qiskit_experiments.py`.  This program takes a yaml input file which specifies the necessary parameters for the calculation.  An example of the input file is given by `params.yml`.  Set the parameters in the yaml file, and then run\n```\npython run_qiskit_experiments.py params.yml\n```\nBy default, this will create a directory called `outputs` to store the output, unless you set `output_dir` in `params.yml`. If the directory doesn't exist, the directory will be created.\n\nThe program outputs three .npy files: \n```\n\u003cbasename\u003e-energies.npy : Ground state energy for each trial\n\u003cbasename\u003e-theta0.npy : Initial guess for deuteron wavefunction parameterization\n\u003cbasename\u003e-theta.npy : Wavefunction parameterization obtained using VQE. \n```\nThe `\u003cbasename\u003e` is generated internally from input parameters.  \n\nIf optional boolean `save_to_textfile` at start of main is set to `True`, text versions of the above files will also be output. \n\n## Input file\n```\n    Mandatory parameters:\n        N_states (int) -- number of deuteron basis states (N\u003e=2).  \n     \n        Optional parameters:\n        encoding (string) -- specifies encoding of deuteron Hamiltonian.  See paper [XREF]\n            Supported encodings are:\n               'gray_code'  (default)\n               'one_hot'\n     \n        N_trials (int) -- number of independent trials to run.  (Default value : 1). \n     \n        backend (string) -- name of qiskit backend.  Supported backend are \n            'statevector_simulator'     (default)\n            'qasm_simulator'\n     \n        N_shots (int) -- number of repetitions of each circuit.  Default value : 10000). \n     \n        device_name (string) -- Handle for noise model used in qasm simulations based on IBMQ machines.  \n            If handle is 'None' or no handle is given then no noise model is used.  Files containing data \n            used to create noise models are found in the directory \"devices\".  \n            Valid handles are:\n                'None'              (default)\n                'ibmq_16_melbourne'\n                'ibmq_5_yorktown'\n                'ibmq_burlington'\n                'ibmq_essex'\n                'ibmq_london'\n                'ibmq_vigo'\n\n        layout (list) -- Specification of which physical qubits on a device to use and the initial qubit ordering (the ordering may be changed by SWAPs during circuit execution, this corresponds to using the \"initial_layout\" argument for qiskit.execute()). The length of the list must correspond to 'N_qubits' (i.e. N_states with one_hot encoding, ceil(log_2(N_states)) with gray_code)\n            None (default)\n            Examples with 3 qubits on a 5 qubit device:\n            [0, 1, 2]\n            [4, 3, 2]\n     \n        mitigate_meas_error (boolean) -- Apply readout error mitigation (Default value : False). \n     \n        optimizer (string) -- Optimizer used for variation quantum eigensolver.\n            'SPSA' (default)\n            'Nelder-Mead' \n     \n             For additional optimizers which can be used, see documentation for scipy.optimizer.minimize.\n             Supported functions include ‘Powell’, ‘CG’, ‘BFGS’, 'L-BFGS-B’, ‘TNC’, ‘COBYLA’, ‘SLSQP’, ‘trust-constr’\n             For iminuit optimizer use 'MIGRAD' option (this should be used only with statevector_simulator) and\n                 N_cpus = 1\n     \n             Additional parameters only used with SPSA optimizer         \n                spsa_a : scaling parameter for step size.  (Default value : 0.628)\n                spsa_c : scaling parameter for evolution.  (Default value : 0.1)\n     \n        N_iter : Number of iterations after which to terminate optimizer algorithm. (Default value : 1000)\n     \n        N_cpus (int) -- Number of processes over which trials are distributed. (Default value : 1)\n     \n        output_dir (string) -- Directory for results files.  (Default value : \"outputs\"). \n                               Directory created at runtime if it doesn't exist.\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fglassnotes%2Fgraycode-qubitencoding","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fglassnotes%2Fgraycode-qubitencoding","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fglassnotes%2Fgraycode-qubitencoding/lists"}