Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(phirgen): emit Skip mop instead of error on global phase #138

Merged
merged 2 commits into from
Feb 27, 2024

Conversation

qartik
Copy link
Member

@qartik qartik commented Feb 26, 2024

Description

We currently error out on (global) Phase, which is a problem as global phase is a harmless operation. I propose a no-op mop instruction "Skip" instead to handle this scenario.

Fixes #136

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)

Checklist:

  • I have performed a self-review of my code
  • I have added tests that prove my fix is effective or that my feature works

@qartik qartik linked an issue Feb 26, 2024 that may be closed by this pull request
@qartik qartik force-pushed the 136-errorrootgate-phase05-unsupported-by-phir branch from 3949c6f to b594781 Compare February 26, 2024 22:35
@qartik
Copy link
Member Author

qartik commented Feb 26, 2024

The test failure seems to be related to #108

@qartik qartik marked this pull request as ready for review February 26, 2024 22:58
@qartik qartik requested a review from qciaran February 26, 2024 22:58
@qartik
Copy link
Member Author

qartik commented Feb 26, 2024

@qciaran asking you to review since I introduce an invalid/unknown "Skip" mop here. Happy to hear about alternative ideas.

The issue with just ignoring the phase is that if the branches of the conditional are empty, we get an error during phir validation as phir model requires the branches to be non-empty.

Now the output corresponding to Phase is:

        Comment(c='IF ([z_corr_3[0]] == 1) THEN IF ([z_corr_3[0]] == 1) THEN Phase(0.5);'),
        IfBlock(metadata=None, block='if', condition=COp(metadata=None, cop='==', returns=None, args=[('z_corr_3', 0), 1]), true_branch=[MOp(metadata=None, mop='Skip', duration=None)], false_branch=None),

EDIT: discussed with @qciaran. Will send corresponding PRs for supporting "Skip" mop to pecos and phir tomorrow.

qartik added a commit to CQCL/phir that referenced this pull request Feb 27, 2024
@qartik qartik merged commit 3edc92f into main Feb 27, 2024
6 checks passed
@qartik qartik deleted the 136-errorrootgate-phase05-unsupported-by-phir branch February 27, 2024 16:33
qartik added a commit to CQCL/phir that referenced this pull request Feb 29, 2024
github-merge-queue bot pushed a commit to CQCL/phir that referenced this pull request Feb 29, 2024
* feat(spec): introduce Skip mop

See CQCL/pytket-phir#138

* feat(model): add validation for MOps
qartik added a commit that referenced this pull request Mar 24, 2024
Since conditionals depend on classical bits in their condition,
we should create shards for each of them, instead of completely
ignoring any dependency that may occur on those classical bits.
Fixes: #150

A side effect:
	We were previously emitting a Skip mop (introduced in #138)
	for conditional global phase operations, but not they
	correctly get filtered out by `_is_command_global_phase`
@qartik qartik mentioned this pull request Mar 24, 2024
6 tasks
qartik added a commit that referenced this pull request Mar 24, 2024
Since conditionals depend on classical bits in their condition,
we should create shards for each of them, instead of completely
ignoring any dependency that may occur on those classical bits.
Fixes: #150

A side effect:
	We were previously emitting a Skip mop (introduced in #138)
	for conditional global phase operations, but now they
	correctly get filtered out by `_is_command_global_phase`
qartik added a commit that referenced this pull request Mar 24, 2024
Since conditionals depend on classical bits in their condition,
we should create shards for each of them, instead of completely
ignoring any dependency that may occur on those classical bits.
Fixes: #150

A side effect:
	We were previously emitting a Skip mop (introduced in #138)
	for conditional global phase operations, but now they
	correctly get filtered out by `_is_command_global_phase`
qartik added a commit that referenced this pull request Mar 26, 2024
Since conditionals depend on classical bits in their condition,
we should create shards for each of them, instead of completely
ignoring any dependency that may occur on those classical bits.
Fixes: #150

A side effect:
	We were previously emitting a Skip mop (introduced in #138)
	for conditional global phase operations, but now they
	correctly get filtered out by `_is_command_global_phase`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ERROR:root:Gate Phase(0.5) unsupported by PHIR
3 participants