From 74b984eba66eada052d5cbc47980970d120d166f Mon Sep 17 00:00:00 2001 From: jwoehr Date: Mon, 4 Jul 2022 08:34:43 -0600 Subject: [PATCH] Remove max_credits --- CHANGES.txt | 3 +- README.md | 139 ++++++++++++++++++++++++----------- qisjob/qisjob.pyx | 26 ------- scripts/qisjob | 5 +- share/doc/qisjob/qisjob.html | 9 +-- 5 files changed, 101 insertions(+), 81 deletions(-) diff --git a/CHANGES.txt b/CHANGES.txt index e4165d2..a470de5 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -13,7 +13,8 @@ CHANGES by revision to QisJob v4.1.1 This is an intermediate release as the Qiskit BaseBackend, BaseJob, and BaseProvider classes have all been removed in favor of BackendV2, JobV1, and -ProviderV1. +ProviderV1. The max_credits option has also been deprecated in Qiskit and is +removed from QisJob v4.1 Note: Version 4.1 is the last version before changing Aer simulator support to the new `AerSimulator` backend. diff --git a/README.md b/README.md index a96be5a..d5b5137 100644 --- a/README.md +++ b/README.md @@ -113,93 +113,148 @@ The `qisjob` script has helpful help. ``` $ qisjob -h -usage: qisjob [-h] [-i | -s | -a | -b BACKEND] [--qasm_simulator | --unitary_simulator] [--statevector_gpu | --unitary_gpu | --density_matrix_gpu] [--version] - [--api_provider API_PROVIDER] [--hub HUB] [--group GROUP] [--project PROJECT] [--providers] [--noisy_sim] [--qvm] [--qvm_as] [--backends] [-1] [-c CREDITS] [-d DATETIME] - [-g] [-j] [--jobs JOBS] [--job_id JOB_ID] [--job_result JOB_RESULT] [-m] [-n NUQASM2] [-o OUTFILE] [-p] [-q QUBITS] [--qiskit_version] [-r] [-t SHOTS] [-v] [-x] - [--showsched] [--circuit_layout] [--optimization_level OPTIMIZATION_LEVEL] [--histogram] [--plot_state_city PLOT_STATE_CITY] [--figure_basename FIGURE_BASENAME] [--qasm] - [--qc QC] [--status] [--token TOKEN] [--url URL] [--use_job_monitor] [--job_monitor_line JOB_MONITOR_LINE] [--job_monitor_filepath JOB_MONITOR_FILEPATH] [-w] - [filepath [filepath ...]] - -Qisjob loads from one or more OpenQASM source files or from a file containing a Qiskit QuantumCircuit definition in Python and runs as experiments with reporting in CSV form. Can -graph results as histogram or state-city plot. Also can give info on backend properties, qiskit version, show circuit transpilation, etc. Can run as multiple jobs or all as one job. -Exits 0 on success, 1 on argument error, 100 on runtime error, 200 on QiskitError. Copyright 2019 Jack Woehr jwoehr@softwoehr.com PO Box 51, Golden, CO 80402-0051. Apache License, -Version 2.0 -- See LICENSE which you should have received with this code. Unless required by applicable law or agreed to in writing, software distributed under the License is -distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and +usage: qisjob [-h] [-i | -s | -a | -b BACKEND] + [--qasm_simulator | --unitary_simulator] + [--statevector_gpu | --unitary_gpu | --density_matrix_gpu] + [--version] [--api_provider API_PROVIDER] [--hub HUB] + [--group GROUP] [--project PROJECT] [--providers] [--noisy_sim] + [--qvm] [--qvm_as] [--backends] [-1] [-c CREDITS] [-d DATETIME] + [-g] [-j] [--jobs JOBS] [--job_id JOB_ID] + [--job_result JOB_RESULT] [-m] [-n NUQASM2] [-o OUTFILE] [-p] + [-q QUBITS] [--qiskit_version] [-r] [-t SHOTS] [-v] [-x] + [--showsched] [--circuit_layout] + [--optimization_level OPTIMIZATION_LEVEL] [--histogram] + [--plot_state_city PLOT_STATE_CITY] + [--figure_basename FIGURE_BASENAME] [--qasm] [--qc QC] + [--status] [--token TOKEN] [--url URL] [--use_job_monitor] + [--job_monitor_line JOB_MONITOR_LINE] + [--job_monitor_filepath JOB_MONITOR_FILEPATH] [-w] + [filepath ...] + +Qisjob loads from one or more OpenQASM source files or from a file containing +a Qiskit QuantumCircuit definition in Python and runs as experiments with +reporting in CSV form. Can graph results as histogram or state-city plot. Also +can give info on backend properties, qiskit version, show circuit +transpilation, etc. Can run as multiple jobs or all as one job. Exits 0 on +success, 1 on argument error, 100 on runtime error, 200 on QiskitError. +Copyright 2019 Jack Woehr jwoehr@softwoehr.com PO Box 51, Golden, CO +80402-0051. Apache License, Version 2.0 -- See LICENSE which you should have +received with this code. Unless required by applicable law or agreed to in +writing, software distributed under the License is distributed on an "AS IS" +BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or +implied. See the License for the specific language governing permissions and limitations under the License. positional arguments: filepath Filepath(s) to 0 or more .qasm files, default is stdin -optional arguments: +options: -h, --help show this help message and exit -i, --ibmq Use best genuine IBMQ processor (default) -s, --sim Use IBMQ qasm simulator - -a, --aer Use QISKit Aer simulator. Default is Aer statevector simulator. Use -a --qasm-simulator to get Aer qasm simulator. Use -a --unitary-simulator to get Aer + -a, --aer Use QISKit Aer simulator. Default is Aer statevector + simulator. Use -a --qasm-simulator to get Aer qasm + simulator. Use -a --unitary-simulator to get Aer unitary simulator. -b BACKEND, --backend BACKEND Use specified IBMQ backend - --qasm_simulator With -a use qasm simulator instead of statevector simulator - --unitary_simulator With -a use unitary simulator instead of statevector simulator - --statevector_gpu With -a and --qasm_simulator use gpu statevector simulator + --qasm_simulator With -a use qasm simulator instead of statevector + simulator + --unitary_simulator With -a use unitary simulator instead of statevector + simulator + --statevector_gpu With -a and --qasm_simulator use gpu statevector + simulator --unitary_gpu With -a and --qasm_simulator use gpu unitary simulator - --density_matrix_gpu With -a and --qasm_simulator use gpu density matrix simulator + --density_matrix_gpu With -a and --qasm_simulator use gpu density matrix + simulator --version Announce QisJob version --api_provider API_PROVIDER - Backend remote api provider, currently supported are [IBMQ | QI | Forest | JKU]. Default is IBMQ. + Backend remote api provider, currently supported are + [IBMQ | QI | Forest | JKU]. Default is IBMQ. --hub HUB Provider hub, default is 'ibm-q' --group GROUP Provider group, default is 'open' --project PROJECT Provider project, default is 'main' --providers List hub/group/project providers for IBMQ - --noisy_sim Perform circuit(s) as Aer simulation using the designated backend (see --backend) as the model backend. - --qvm Use Forest local qvm simulator described by -b backend, generally one of qasm_simulator or statevector_simulator. Use --qvm_as to instruct the simulator to - emulate a specific Rigetti QPU - --qvm_as Use Forest local qvm simulator to emulate the specific Rigetti QPU described by -b backend. Use --qvm to run the Forest local qvm simulator described by -b + --noisy_sim Perform circuit(s) as Aer simulation using the + designated backend (see --backend) as the model + backend. + --qvm Use Forest local qvm simulator described by -b + backend, generally one of qasm_simulator or + statevector_simulator. Use --qvm_as to instruct the + simulator to emulate a specific Rigetti QPU + --qvm_as Use Forest local qvm simulator to emulate the specific + Rigetti QPU described by -b backend. Use --qvm to run + the Forest local qvm simulator described by -b backend. --backends Print list of backends to stdout and exit 0 -1, --one_job Run all experiments as one job -c CREDITS, --credits CREDITS Max credits to expend on each job, default is 3 -d DATETIME, --datetime DATETIME - Datetime 'year,month,day[,hour,min,sec]' for -p,--properties - -g, --configuration Print configuration for backend specified by -b to stdout and exit 0 + Datetime 'year,month,day[,hour,min,sec]' for -p,-- + properties + -g, --configuration Print configuration for backend specified by -b to + stdout and exit 0 -j, --job Print your job's dictionary - --jobs JOBS Print JOBS number of jobs and status for -b backend and exit 0 + --jobs JOBS Print JOBS number of jobs and status for -b backend + and exit 0 --job_id JOB_ID Print job number JOB_ID for -b backend and exit 0 --job_result JOB_RESULT - Print result of job number JOB_RESULT for -b backend and exit 0 + Print result of job number JOB_RESULT for -b backend + and exit 0 -m, --memory Print individual results of multishot experiment -n NUQASM2, --nuqasm2 NUQASM2 - Use nuqasm2 to translate OPENQASM2 source, providing include path for any include directives + Use nuqasm2 to translate OPENQASM2 source, providing + include path for any include directives -o OUTFILE, --outfile OUTFILE Write appending CSV to outfile, default is stdout - -p, --properties Print properties for backend specified by -b to stdout and exit 0 + -p, --properties Print properties for backend specified by -b to stdout + and exit 0 -q QUBITS, --qubits QUBITS Number of qubits for the experiment, default is 5 --qiskit_version Print Qiskit version and exit 0 -r, --result Print job result -t SHOTS, --shots SHOTS - Number of shots for the experiment, default 1024, max 8192 - -v, --verbose Increase runtime verbosity each -v up to 3. If precisely 4, prettyprint QisJob's data dictionary and return (good for debugging script arguments) - -x, --transpile Print circuit transpiled for chosen backend to stdout before running job - --showsched In conjuction with -x, show schedule for transpiled circuit for chosen backend to stdout before running job - --circuit_layout With -x, write image file of circuit layout after transpile (see --figure_basename) + Number of shots for the experiment, default 1024, max + 8192 + -v, --verbose Increase runtime verbosity each -v up to 3. If + precisely 4, prettyprint QisJob's data dictionary and + return (good for debugging script arguments) + -x, --transpile Print circuit transpiled for chosen backend to stdout + before running job + --showsched In conjuction with -x, show schedule for transpiled + circuit for chosen backend to stdout before running + job + --circuit_layout With -x, write image file of circuit layout after + transpile (see --figure_basename) --optimization_level OPTIMIZATION_LEVEL - Set optimization level for transpilation before run, valid values 0-3, default is 1 - --histogram Write image file of histogram of experiment results (see --figure_basename) + Set optimization level for transpilation before run, + valid values 0-3, default is 1 + --histogram Write image file of histogram of experiment results + (see --figure_basename) --plot_state_city PLOT_STATE_CITY - Write image file of state city plot of statevector to PLOT_STATE_CITY decimal points (see --figure_basename) + Write image file of state city plot of statevector to + PLOT_STATE_CITY decimal points (see --figure_basename) --figure_basename FIGURE_BASENAME - basename including path (if any) for figure output, default='figout', backend name, figure type, and timestamp will be appended + basename including path (if any) for figure output, + default='figout', backend name, figure type, and + timestamp will be appended --qasm Print qasm file to stdout before running job --qc QC Indicate variable name of Python-coded QuantumCircuit - --status Print status of chosen --backend to stdout (default all backends) of --api_provider (default IBMQ) and exit 0 + --status Print status of chosen --backend to stdout (default + all backends) of --api_provider (default IBMQ) and + exit 0 --token TOKEN Use this token --url URL Use this url - --use_job_monitor Display job monitor instead of just waiting for job result + --use_job_monitor Display job monitor instead of just waiting for job + result --job_monitor_line JOB_MONITOR_LINE - Comma-separated list of hex values for character(s) to emit at the head of each line of job monitor output, default is '0x0d' + Comma-separated list of hex values for character(s) to + emit at the head of each line of job monitor output, + default is '0x0d' --job_monitor_filepath JOB_MONITOR_FILEPATH - Filepath for Job Monitor output if Job Monitor requested by --use_job_monitor, default is sys.stdout + Filepath for Job Monitor output if Job Monitor + requested by --use_job_monitor, default is sys.stdout -w, --warnings Don't print warnings on missing optional modules ``` diff --git a/qisjob/qisjob.pyx b/qisjob/qisjob.pyx index b617e55..65e7ccb 100644 --- a/qisjob/qisjob.pyx +++ b/qisjob/qisjob.pyx @@ -109,7 +109,6 @@ class QisJob: # pylint: disable-msg=too-many-instance-attributes, too-many-publ nuqasm2=None, num_qubits=5, shots=1024, - max_credits=3, outfile_path=None, one_job=False, qasm=False, @@ -297,14 +296,6 @@ class QisJob: # pylint: disable-msg=too-many-instance-attributes, too-many-publ Number of shots performed for any and all experiment(s). Subject to limitation of the provider backend. - max_credits : int - The default is 3. - - _Corresponding `qisjob` script argument_: `-c, --credits` - - Max credits to expend on each job, default is 3. If provider - has no credit scheme enabled, `max_credits` has no effect. - outfile_path : str The default is stdout. @@ -682,7 +673,6 @@ class QisJob: # pylint: disable-msg=too-many-instance-attributes, too-many-publ self.nuqasm2 = nuqasm2 self.num_qubits = num_qubits self.shots = shots - self.max_credits = max_credits self.outfile_path = outfile_path self.one_job = one_job self.qasm = qasm @@ -1502,7 +1492,6 @@ class QisJob: # pylint: disable-msg=too-many-instance-attributes, too-many-publ backend_options=backend_options, optimization_level=self.optimization_level, shots=self.shots, - max_credits=self.max_credits, memory=self.memory, ) else: @@ -1511,7 +1500,6 @@ class QisJob: # pylint: disable-msg=too-many-instance-attributes, too-many-publ backend=self.backend, optimization_level=self.optimization_level, shots=self.shots, - max_credits=self.max_credits, memory=self.memory, ) @@ -1704,7 +1692,6 @@ class QisJob: # pylint: disable-msg=too-many-instance-attributes, too-many-publ optimization_level=self.optimization_level, backend_options=backend_options, shots=self.shots, - max_credits=self.max_credits, memory=self.memory, ) else: @@ -1713,7 +1700,6 @@ class QisJob: # pylint: disable-msg=too-many-instance-attributes, too-many-publ backend=self.backend, optimization_level=self.optimization_level, shots=self.shots, - max_credits=self.max_credits, memory=self.memory, ) @@ -1875,7 +1861,6 @@ class QisJob: # pylint: disable-msg=too-many-instance-attributes, too-many-publ optimization_level=self.optimization_level, backend_options=backend_options, shots=self.shots, - max_credits=self.max_credits, memory=self.memory, ) else: @@ -1884,7 +1869,6 @@ class QisJob: # pylint: disable-msg=too-many-instance-attributes, too-many-publ backend=self.backend, optimization_level=self.optimization_level, shots=self.shots, - max_credits=self.max_credits, memory=self.memory, ) @@ -2333,14 +2317,6 @@ if __name__ == "__main__": PARSER.add_argument( "-1", "--one_job", action="store_true", help="Run all experiments as one job" ) - PARSER.add_argument( - "-c", - "--credits", - type=int, - action="store", - default=3, - help="Max credits to expend on each job, default is 3", - ) PARSER.add_argument( "-d", "--datetime", @@ -2565,7 +2541,6 @@ if __name__ == "__main__": ) JOB_RESULT = ARGS.job_result JOBS = ARGS.jobs - MAX_CREDITS = ARGS.credits MEMORY = ARGS.memory NOISY_SIM = ARGS.noisy_sim NUQASM2 = ARGS.nuqasm2 @@ -2610,7 +2585,6 @@ if __name__ == "__main__": nuqasm2=NUQASM2, num_qubits=QUBITS, shots=SHOTS, - max_credits=MAX_CREDITS, outfile_path=OUTFILE, one_job=ONE_JOB, qasm=QASM, diff --git a/scripts/qisjob b/scripts/qisjob index c7a5654..916ad8b 100644 --- a/scripts/qisjob +++ b/scripts/qisjob @@ -104,8 +104,6 @@ PARSER.add_argument("--backends", action="store_true", help="Print list of backends to stdout and exit 0") PARSER.add_argument("-1", "--one_job", action="store_true", help="Run all experiments as one job") -PARSER.add_argument("-c", "--credits", type=int, action="store", default=3, - help="Max credits to expend on each job, default is 3") PARSER.add_argument("-d", "--datetime", type=str, action="store", help="""Datetime 'year,month,day[,hour,min,sec]' for -p,--properties""") @@ -226,7 +224,6 @@ JOB_MONITOR_LINE = ''.join(chr(int(lstr, 16)) for lstr in ARGS.job_monitor_line.split(',')) JOB_RESULT = ARGS.job_result JOBS = ARGS.jobs -MAX_CREDITS = ARGS.credits MEMORY = ARGS.memory NOISY_SIM = ARGS.noisy_sim NUQASM2 = ARGS.nuqasm2 @@ -264,7 +261,7 @@ QJ = QisJob(filepaths=FILEPATH, providers=PROVIDERS, token=TOKEN, url=URL, nuqasm2=NUQASM2, - num_qubits=QUBITS, shots=SHOTS, max_credits=MAX_CREDITS, + num_qubits=QUBITS, shots=SHOTS, outfile_path=OUTFILE, one_job=ONE_JOB, qasm=QASM, use_aer=AER, use_qasm_simulator=QASM_SIMULATOR, diff --git a/share/doc/qisjob/qisjob.html b/share/doc/qisjob/qisjob.html index 2dc4e4b..8b8a044 100644 --- a/share/doc/qisjob/qisjob.html +++ b/share/doc/qisjob/qisjob.html @@ -63,7 +63,7 @@

Classes

class QisJob -(filepaths=None, qasm_src=None, provider_name='IBMQ', hub='ibm-q', group='open', project='main', providers=False, backend_name=None, token=None, url=None, nuqasm2=None, num_qubits=5, shots=1024, max_credits=3, outfile_path=None, one_job=False, qasm=False, use_aer=False, use_qasm_simulator=False, use_unitary_simulator=False, use_statevector_gpu=False, use_unitary_gpu=False, use_density_matrix_gpu=False, use_sim=False, qvm=False, qvm_as=False, qc_name=None, xpile=False, showsched=False, circuit_layout=False, optimization_level=1, print_job=False, memory=False, show_result=False, jobs_status=None, job_id=None, job_result=None, show_backends=False, show_configuration=False, show_properties=False, show_statuses=False, date_time=None, print_histogram=False, print_state_city=0, figure_basename='figout', show_q_version=False, verbose=0, show_qisjob_version=False, use_job_monitor=False, job_monitor_filepath=None, job_monitor_line='\r', noisy_sim=False) +(filepaths=None, qasm_src=None, provider_name='IBMQ', hub='ibm-q', group='open', project='main', providers=False, backend_name=None, token=None, url=None, nuqasm2=None, num_qubits=5, shots=1024, outfile_path=None, one_job=False, qasm=False, use_aer=False, use_qasm_simulator=False, use_unitary_simulator=False, use_statevector_gpu=False, use_unitary_gpu=False, use_density_matrix_gpu=False, use_sim=False, qvm=False, qvm_as=False, qc_name=None, xpile=False, showsched=False, circuit_layout=False, optimization_level=1, print_job=False, memory=False, show_result=False, jobs_status=None, job_id=None, job_result=None, show_backends=False, show_configuration=False, show_properties=False, show_statuses=False, date_time=None, print_histogram=False, print_state_city=0, figure_basename='figout', show_q_version=False, verbose=0, show_qisjob_version=False, use_job_monitor=False, job_monitor_filepath=None, job_monitor_line='\r', noisy_sim=False)

Embody preparation, execution, display, and management of Qiskit job or jobs.

@@ -192,13 +192,6 @@

Parameters

Number of shots performed for any and all experiment(s). Subject to limitation of the provider backend.

-
max_credits : int
-
-

The default is 3.

-

Corresponding qisjob script argument: -c, --credits

-

Max credits to expend on each job, default is 3. If provider -has no credit scheme enabled, max_credits has no effect.

-
outfile_path : str

The default is stdout.