From 167ef8670189978cacb1f0403cace32630ce987c Mon Sep 17 00:00:00 2001 From: Cong Luo <c.luo@fz-juelich.de> Date: Wed, 19 Jun 2024 13:19:29 +0200 Subject: [PATCH 1/2] Allow users to leave seed unspecified. --- juqcs/backend.py | 2 +- juqcs/job.py | 12 ++++++++---- juqcs/runtime.py | 2 +- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/juqcs/backend.py b/juqcs/backend.py index b52855e..a065d7c 100644 --- a/juqcs/backend.py +++ b/juqcs/backend.py @@ -94,7 +94,7 @@ class JuqcsBackend(Backend): return False else: return True - + def status(self): '''Return backend status.''' if self._allocation_is_valid(): diff --git a/juqcs/job.py b/juqcs/job.py index 70344b9..684ba91 100644 --- a/juqcs/job.py +++ b/juqcs/job.py @@ -25,6 +25,7 @@ class JuqcsJob(Job): self._status = JobStatus.INITIALIZING self._result = None self._storage = None + self._circuit_files = [] def _validate(self, run_input): ''' @@ -60,9 +61,9 @@ class JuqcsJob(Job): args = ['--amplitudes'] elif self._backend._result_type == 'counts': args = ['--repetitions', str(int(self._options['shots']))] +\ - ['--seed', str(int(self._options['seed']))] if self._options['seed'] else [] # non-string cause error - circuit_id = uuid4() - circuit_file = f'{str(circuit_id)}.qasm' + ['--seed', str(int(self._options['seed'])) if 'seed' in self._options else '-1'] + # either '-1' or user specified seed value + circuit_file = f'{self._circuit_files[-1]}.qasm' run_arguments = [str(self._backend._allocation_id), circuit_file, str(self._backend._project), str(self._backend._device)] + args run_description = { 'Project': self._backend._project, 'ApplicationName': 'RUN', @@ -84,14 +85,16 @@ class JuqcsJob(Job): start = time() self._time_submit = str(datetime.now().strftime("%Y-%m-%d %H:%M:%S")) self._storage = create_storage(self.job_id()) - self.serialize_job() for circuit in self._inputs: + self._circuit_files.append(str(uuid4())) + self.serialize_job() job = self._submit(circuit) self._unicore_jobs.append(job) # add to unicore_jobs self._time_taken = time() - start self._status = JobStatus.DONE self._result = self.result() self.serialize_job() + self._circuit_files = [] return self def result(self, partial=False): @@ -220,6 +223,7 @@ class JuqcsJob(Job): job_data = { 'job_id' : self.job_id(), 'job_backend' : self._backend.name, + 'job_circuits': self._circuit_files, 'job_submit_time' : self._time_submit, 'job_status' : f'{self.status().name}:{self.status().value}', 'job_done' : self.done(), diff --git a/juqcs/runtime.py b/juqcs/runtime.py index 8219d76..94de790 100644 --- a/juqcs/runtime.py +++ b/juqcs/runtime.py @@ -58,7 +58,7 @@ class JobRet: self._submit_time = job_info["job_submit_time"] self._status = job_info["job_status"] self._done = job_info["job_done"] - self._result = job_info["job_result"] + self._result = job_info["job_result"] def backend(self): return self._backend -- GitLab From e0a623937c1c83c399959ac036ca091a6e0003bc Mon Sep 17 00:00:00 2001 From: Cong Luo <c.luo@fz-juelich.de> Date: Wed, 19 Jun 2024 13:31:52 +0200 Subject: [PATCH 2/2] Update README. --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 18d57dd..dd4c1ad 100644 --- a/README.md +++ b/README.md @@ -147,6 +147,8 @@ This section shows how to submit a circuit for simulation to JUQCS. --- ## Release History +* 0.9.3 + - The `seed` option can be unspecified (JUQCS will run with a random seed). * 0.9.2 - Added runtime service and job retrieval feature. * 0.9.1 -- GitLab