Skip to content

Commit

Permalink
[DOC] Update changelog and readme
Browse files Browse the repository at this point in the history
  • Loading branch information
MatthieuMoreau0 committed Feb 5, 2024
1 parent 1f38b57 commit 9169b5f
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 1 deletion.
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,17 @@

All notable changes to this project will be documented in this file.


## [0.5.0] - 2024-02-05

### Added

- Added feature to create an "open" batch.
- To create an open batch, set the `complete` argument to `True` in the `create_batch` method of the SDK
- To add jobs to an open batch, use the `add_jobs` method
- Updated documentation to add examples to create open batches.


## [0.4.3] - 2024-12-08

### Added
Expand Down
21 changes: 20 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ See `Auth0TokenProvider` implementation for an example.
The package main component is a python object called `SDK` which can be used to create a `Batch`.

A `Batch` is a group of jobs with the same sequence that will run on the same QPU. For each job of a given batch, you must set a value for each variable, if any, defined in your sequence.
Once the QPU starts running a batch, only the jobs from that batch will be executed until they all end up in a termination status (`DONE`, `ERROR`, `CANCELED`).
The batch sequence can be generated using [Pulser](https://github.com/pasqal-io/Pulser). See their [documentation](https://pulser.readthedocs.io/en/stable/),
for more information on how to install the library and create your own sequence.

Expand All @@ -102,12 +103,30 @@ job1 = {"runs": 20, "variables": {"omega_max": 6}}
job2 = {"runs": 50, "variables": {"omega_max": 10.5}}
```

Then, send the batch of jobs to the QPU and wait for the results:
Batches can either be "open" or "closed" (also called "complete").
Open batch may be used to schedule variational algorithm where the next job parameter are derived from the results of the previous jobs, without losing access to the QPU.


You can create a batch of jobs using the `create_batch` method of the SDK.
By default, this will create a closed batch, so all jobs should be passed as arguments right away.
You may set the `wait` argument to `True` to wait for the batch to end up in a termination status before proceeding to the next statement.

```python
# Create a closed batch with 2 jobs and wait for its termination
batch = sdk.create_batch(serialized_sequence, [job1,job2], wait=True)
```

To create an open batch, set the `complete` argument to `False`, you can then add jobs to your batch.
Don't forget to mark your batch as closed/complete when you are done adding new jobs to it.

```python
# Create an open batch with 1 job
batch = sdk.create_batch(serialized_sequence, [job1], complete=False)
# Add some jobs to it and wait for the jobs to be terminated
job3 = {"runs": 50, "variables": {"omega_max": 10.5}}
batch.add_jobs([job2, job3], wait=True)
```

You can also choose to run your batch on an emulator using the optional argument `emulator`.
For using a basic single-threaded QPU emulator that can go up to 10 qubits, you can specify the "EMU_FREE" emulator:

Expand Down
4 changes: 4 additions & 0 deletions pasqal_cloud/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,10 @@ def create_batch(
DeprecationWarning,
stacklevel=2,
)
wait = wait or fetch_results

if wait and not complete:
raise ValueError("Cannot wait for an open batch.")

req = {
"sequence_builder": serialized_sequence,
Expand Down

0 comments on commit 9169b5f

Please sign in to comment.