feat(qsystem)!: multiple platform extensions#1567
Conversation
65b0cdd to
24f9794
Compare
Disambiguate helios and sol during rebasing, rename N2PhasedX -> TwinPhasedX Correct descriptions after the reintroduction of the rz gate Format + rust test fixups Rebase + document QSystemCodegenExtension::new Rename python testing of unimplemented sol features and change from pytest.raises to xfail Ruff format Remove redundant variable setting in xfail test Add unimplemented two-qubit operations for sol gateset (#1377) [decompositions.py](https://github.com/user-attachments/files/24907896/decompositions.py) Constructions should be as in attached python. --------- Co-authored-by: Jake Arkinstall <65358059+jake-arkinstall@users.noreply.github.com> Add missing maximally entangling XXPhase Update ZZPhase and ZZMax Correct output wire indexing for 2q sol gates, correct some typos in gate rebasing, add QFT test Correct add_phased_xx Apply requested changes, add addition test
- include deprecated tket.qsystem alias for helios - regenerate extensions - comment out sol ops in pytket and llvm for now
Parametrise qis-compiler snapshot tests over both 'helios' and 'sol' platforms
(previously only helios was exercised).
Changes:
- Expose 'platform' and 'target_triple' kwargs in the Python .pyi stubs for
compile_to_llvm_ir / compile_to_bitcode (the Rust signatures already had them).
- Add 'platforms = ["helios", "sol"]' and @parametrize("platform", platforms)
to test_basic_generation.py::test_llvm; snapshot keys gain a platform suffix
({hugr_file}_{target_triple}_{platform}).
- Old platform-less snapshot files deleted.
- Remove residual '# type: ignore[call-arg]' comments from both test files now
that the stubs are correct.
Expected diff between helios and sol snapshots
-----------------------------------------------
All differences are mechanical consequences of each platform's native gate set:
1. Single-qubit gate name: PhasedX maps to ___rxy on Helios and ___rp on Sol.
2. Two-qubit gate rewriting (rus.hugr, postselect_*.hugr, measure_qb_array.hugr):
The QSystemPass rewrites tket.quantum gates (cx, h, t, ...) into platform-native
qsystem gates before LLVM codegen.
- Helios: cx -> ZZPhase + PhasedX -> calls to @___rzz + @___rxy
- Sol: cx -> PhasedXX -> calls to @___rpp + @___rp
The control-flow structure is identical; only the runtime-function names and
the platform string embedded in hugr-llvm's mangled inner-function labels
('__tk2_helios_' vs '__tk2_sol_') differ.
3. No differences in discard_qb_array, print_current_shot, rng — these circuits
contain no 2Q gates and no PhasedX, so codegen is platform-independent.
24f9794 to
08fb061
Compare
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1567 +/- ##
==========================================
- Coverage 85.52% 85.49% -0.03%
==========================================
Files 184 190 +6
Lines 29077 30070 +993
Branches 27876 28729 +853
==========================================
+ Hits 24868 25709 +841
- Misses 3075 3238 +163
+ Partials 1134 1123 -11
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
This PR contains breaking changes to the public Rust API. cargo-semver-checks summary |
08fb061 to
2e85308
Compare
aborgna-q
left a comment
There was a problem hiding this comment.
Nice. Just a few comments.
| target_triple: str = "native", | ||
| platform: str = "helios", |
There was a problem hiding this comment.
Could use Literals here for the options, rather than a general str?
| .reassemble_inplace(&mut program.hugr, Some(Arc::new(qsystem_decoder_config()))) | ||
| .reassemble_inplace( | ||
| &mut program.hugr, | ||
| Some(Arc::new(qsystem_decoder_config(QSystemPlatform::Helios))), |
There was a problem hiding this comment.
It's OK to default to Helios for now, but we'll want to do something configurable in the future.
Opened an issue about it. This is something that we already discussed with Callum.
| Some(Arc::new(qsystem_decoder_config(QSystemPlatform::Helios))), | |
| // TODO: Make the decoder set configurable. | |
| // <https://github.com/Quantinuum/tket2/issues/1619> | |
| Some(Arc::new(qsystem_decoder_config(QSystemPlatform::Helios))), |
| "QSystemRandomExtension", | ||
| "QSystemSolExtension", | ||
| "QSystemUtilsExtension", | ||
| "QSystemGenericExtension", |
| tket.qsystem.QSystemHeliosExtension(), | ||
| tket.qsystem.QSystemSolExtension(), |
There was a problem hiding this comment.
We should keep the old extension in this set for now, otherwise we'll fail to load hugrs using tket.qsystem.
| tket.qsystem.QSystemHeliosExtension(), | |
| tket.qsystem.QSystemSolExtension(), | |
| tket.qsystem.QSystemHeliosExtension(), | |
| tket.qsystem.QSystemSolExtension(), | |
| tket.qsystem.QSystemExtension(), |
| ) -> Result<Vec<Node>, LowerTk2Error> { | ||
| let scope = scope.into(); | ||
| let mut funcs: BTreeMap<TketOp, NodeTemplate> = BTreeMap::new(); | ||
| let mut lowerer = ReplaceTypes::new_empty().with_scope(scope.clone()); | ||
| let mut barrier_funcs = BarrierInserter::new(); | ||
| register_legacy_qsystem_replacements(&mut lowerer); |
There was a problem hiding this comment.
We're lowering tket.quantum ops to the target platform here, but any tket.qsystem op gets mapped to tket.quantum.helios.
Should we use the chosen platform for the legacy replacements too?
Creates new platform specific qsystem extensions. Each extension is self-contained and complete but code is deduplicated to a reasonable degree.
SharedOpenum for shared definitionstket.qsystemextension and some utilities kept in deprecated form for backwards compatibilityBREAKING CHANGE: tket-qsystem conversion, lowering and codegen methods take additional
QSystemPlatformparameter to choose target platform.