Skip to content

Conversation

david-pl
Copy link
Collaborator

Closes #479 .

As expected, this makes the implementation of the NSitesAnalysis a bit more tricky and also leads to situations where you can't infer the number of sites of an identity.

@david-pl david-pl requested review from kaihsin and weinbe58 August 25, 2025 09:38
@david-pl david-pl added breaking breaking changes or proposed changes that would break existing APIs squin squin related issues labels Aug 25, 2025
Copy link

codecov bot commented Aug 25, 2025

Codecov Report

❌ Patch coverage is 87.50000% with 3 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/bloqade/cirq_utils/lowering.py 60.00% 2 Missing ⚠️
src/bloqade/squin/analysis/nsites/impls.py 90.00% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

Copy link
Contributor

github-actions bot commented Aug 25, 2025

☂️ Python Coverage

current status: ✅

Overall Coverage

Lines Covered Coverage Threshold Status
10400 9156 88% 0% 🟢

New Files

No new covered files...

Modified Files

File Coverage Status
src/bloqade/cirq_utils/emit/op.py 98% 🟢
src/bloqade/cirq_utils/lowering.py 95% 🟢
src/bloqade/pyqrack/squin/op.py 100% 🟢
src/bloqade/squin/analysis/nsites/analysis.py 84% 🟢
src/bloqade/squin/analysis/nsites/impls.py 90% 🟢
src/bloqade/squin/op/_wrapper.py 100% 🟢
src/bloqade/squin/op/stmts.py 99% 🟢
src/bloqade/squin/rewrite/U3_to_clifford.py 87% 🟢
TOTAL 94% 🟢

updated for commit: 14fdc40 by action🐍

Comment on lines 97 to 104
if not isinstance(sites, ir.ResultValue):
return (interp.lattice.top(),)

if not isinstance(site_stmt := sites.stmt, py.Constant):
return (interp.lattice.top(),)

if not isinstance(value := site_stmt.value, ir.PyAttr):
return (interp.lattice.top(),)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should return bottom instead of top tho

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also this does not deal with alias, so double check if the analysis are run before alias inline pass

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

or, assuming wrap const and cont prop is done before this analysis, then you can get the constant it from hint["const"]

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, it's not run, which is why there were no hints. But I'll just include it in the run then.

this should return bottom instead of top tho

Can you explain why? I thought since there is no error, but you just can't know how many sites there are since sites is not a constant that top would be the way to go as it's AnySites.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah right... nvm

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just change the get constant as @weinbe58 mentioned below then

Copy link
Member

@weinbe58 weinbe58 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm good so long as you implement the method table using the hints, if there is no hint return unknown

@weinbe58
Copy link
Member

if you want an example of how to use the hints look at the implementation here:

def get_const_value(self, typ: type[T], value: ir.SSAValue) -> T:

@david-pl david-pl requested review from kaihsin and weinbe58 August 27, 2025 10:51
Copy link
Member

@weinbe58 weinbe58 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just some minor comments

@david-pl
Copy link
Collaborator Author

@kaihsin pinging for another round of review. I think we should be good to go!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

breaking breaking changes or proposed changes that would break existing APIs squin squin related issues

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Squin identity sites should be an argument instead of an attribute

3 participants