Skip to content

feat: Add primitives for the toy_k2 architecture - #315

Merged
PabloAndresCQ merged 14 commits into
mainfrom
feat/toyk2_primitives
Nov 4, 2026
Merged

PabloAndresCQ merged 14 commits into
mainfrom
feat/toyk2_primitives

Conversation

@PabloAndresCQ

@PabloAndresCQ PabloAndresCQ commented Sep 7, 2026 •

Copy link
Copy Markdown
Collaborator

Closes #241
Closes #242

@PabloAndresCQ
PabloAndresCQ requested review from a team, CalMacCQ and hsemenenko and removed request for a team and CalMacCQ September 7, 2026 11:34
Comment thread src/guppyft/code/toy_k2/primitives.py Resolved
Comment thread src/guppyft/code/toy_k2/primitives.py Resolved
Comment thread src/guppyft/code/toy_k2/primitives.py Resolved

@hsemenenko hsemenenko left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thanks Pablo, this looks great. Most comments are about naming.

Comment thread src/guppyft/code/toy_k2/primitives.py Resolved
Comment thread src/guppyft/code/toy_k2/primitives.py Resolved
Comment thread src/guppyft/code/toy_k2/primitives.py Resolved
Comment thread src/guppyft/code/toy_k2/primitives.py Resolved
Comment thread src/guppyft/code/toy_k2/primitives.py Resolved
Comment thread src/guppyft/code/toy_k2/primitives.py Resolved
Comment thread src/guppyft/code/toy_k2/primitives.py Resolved
@PabloAndresCQ PabloAndresCQ changed the title feat: Add toy_k2 architecture primitives and their tests feat: Add primitives and their tests for the toy_k2 architecture Sep 7, 2026
Comment thread src/guppyft/code/toy_k2/primitives.py Resolved
Comment thread src/guppyft/code/toy_k2/primitives.py Resolved
@PabloAndresCQ
PabloAndresCQ requested a review from a team as a code owner September 15, 2026 13:19
Comment thread src/guppyft/code/toy_k2/primitives.py Resolved
@PabloAndresCQ
PabloAndresCQ force-pushed the feat/toyk2_primitives branch 6 times, most recently from b195f19 to 342b3e4 Compare October 12, 2026 12:46

@hsemenenko hsemenenko left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I think one bug needs addressing. I'll look at the rest of the stack which should give me a better idea of whether replacing the array with tuple is worthwhile.

Comment thread src/guppyft/code/toy_k2/primitives.py Resolved
Comment thread src/guppyft/code/toy_k2/primitives.py Resolved

@hsemenenko hsemenenko left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Looks good to me!

@maximilianruesch
maximilianruesch self-requested a review October 20, 2026 10:06
@guppy
@no_type_check
def impl_func(arr: array[qubit, 4]) -> None:
block = LogicalBlock(array(arr.take(i) for i in range(4)))

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

The verifier has been updated to support LogicalBlock directly, so these helpers are no longer necessary.

See: #199

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

done

Comment thread src/guppyft/code/toy_k2/primitives.py Outdated
Comment on lines +34 to +35
if idx != 0 and idx != 1:
exit("Invalid logical qubit index. Must be 0 or 1.")

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

These statements could be extracted into a function call.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

done


@guppy
@no_type_check
def x(blk: LogicalBlock[4], idx: int) -> None:

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This is kind of why I do not like use of LogicalBlock in its current form. The generic parameter 4 suggests to me that there are 4 logical qubits stored in the block, which afaik is not the case here. Instead, it is 4 physical qubits.

I think it should either be renamed or removed. But currently its just confusing. Not something to do in this PR though.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This is a fair criticism. We could include all code parameters in the struct i.e. LogicalBlock[n,k,d]. This is quite verbose but would at least be explicit.

Alternatively, I wonder if using type-level arithmetic would allow us to just have LogicalBlock[k] and then compute n and d.

Comment thread src/guppyft/code/toy_k2/primitives.py Resolved
@maximilianruesch maximilianruesch changed the title feat: Add primitives and their tests for the toy_k2 architecture feat: Add primitives for the toy_k2 architecture Nov 4, 2026
@PabloAndresCQ
PabloAndresCQ removed this pull request from stack #322 November 4, 2026 17:31
@PabloAndresCQ
PabloAndresCQ merged commit b679062 into main Nov 4, 2026
24 checks passed
@PabloAndresCQ
PabloAndresCQ deleted the feat/toyk2_primitives branch November 4, 2026 17:44
@hugrbot hugrbot mentioned this pull request Nov 4, 2026
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.

[Feature]: Use logical verifier tool to test "Toy k2" primitives [Feature]: Add implementation of "Toy k2" primitives

4 participants