Skip to content

Commit

Permalink
XIR converter (#643)
Browse files Browse the repository at this point in the history
* add converters

* update io

* add and refactor io tests

* add xir to requirements

* use quantum-xir

* run format

* add tdm converters

* minor updates

* refactor io

* fix tdm

* fix other workaround

* fix tests

* make format

* switch to use constants

* install correct xir branch for tests to pass

* make format

* test updating setup

* revert to released xir

* update tests

* Apply suggestions from code review

Co-authored-by: Mikhail Andrenkov <Mandrenkov@users.noreply.github.com>
Co-authored-by: Tom Bromley <49409390+trbromley@users.noreply.github.com>

* suggestions from code review

* Apply suggestions from code review

Co-authored-by: Mikhail Andrenkov <Mandrenkov@users.noreply.github.com>

* fixes to tests

* move generate_code to utils

* fixes from code review

* Update setup.py

Co-authored-by: Tom Bromley <49409390+trbromley@users.noreply.github.com>

* update name to _name_

* Apply suggestions from code review

Co-authored-by: Mikhail Andrenkov <Mandrenkov@users.noreply.github.com>

* add aubergine

* make format

* fix typing for docs

* fix listr

* add test

* remove type hint to test

* add changelog

* Apply suggestions from code review

Co-authored-by: Mikhail Andrenkov <Mandrenkov@users.noreply.github.com>

* update test

* add default eng in generate_code

* fix tests

* add to tests

Co-authored-by: Mikhail Andrenkov <Mandrenkov@users.noreply.github.com>
Co-authored-by: Tom Bromley <49409390+trbromley@users.noreply.github.com>
  • Loading branch information
3 people committed Dec 13, 2021
1 parent 4161918 commit ac38063
Show file tree
Hide file tree
Showing 12 changed files with 2,133 additions and 753 deletions.
28 changes: 28 additions & 0 deletions .github/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,34 @@
has not previously been set.
[(#663)](https://github.com/XanaduAI/strawberryfields/pull/663)

* Functions are now available to convert between XIR and Strawberry Fields programs.
[(#643)](https://github.com/XanaduAI/strawberryfields/pull/643)

For example,

```python
prog = sf.Program(3)
eng = sf.Engine("gaussian")

with prog.context as q:
ops.Sgate(0, 0) | q[0]
ops.Sgate(1, 0) | q[1]
ops.BSgate(0.45, 0.0) | (q[0], q[2])
ops.MeasureFock() | q[0]

xir_prog = sf.io.to_xir(prog)
```

resulting in the following XIR script

```pycon
>>> print(xir_prog.serialize())
Sgate(0, 0) | [0];
Sgate(1, 0) | [1];
BSgate(0.45, 0.0) | [0, 2];
MeasureFock | [0];
```

<h3>Breaking Changes</h3>

<h3>Bug fixes</h3>
Expand Down
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,5 @@ thewalrus==0.17.0
toml==0.10.2
typing-extensions==3.7.4
urllib3==1.25.8
quantum-xir==0.1.1
xanadu-cloud-client==0.1.1
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
"thewalrus>=0.17.0",
"toml",
"urllib3>=1.25.3",
"quantum-xir>=0.1.1",
"xanadu-cloud-client>=0.1.1",
]

Expand Down

0 comments on commit ac38063

Please sign in to comment.