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

Improve interface for bloqs with specialized single-qubit-controlled versions #1451

Merged
merged 32 commits into from
Oct 28, 2024
Merged
Show file tree
Hide file tree
Changes from 10 commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
710c3b7
get_ctrl_system for bloqs with custom single-qubit-controlled impleme…
anurudhp Oct 8, 2024
bab48c8
replace uses of old interface
anurudhp Oct 8, 2024
c6bf154
replace uses of old interface
anurudhp Oct 8, 2024
439bf06
specialize when `ctrl_spec.num_qubits == 1`
anurudhp Oct 8, 2024
2be4510
add test example of bloq with a separate controlled bloq
anurudhp Oct 9, 2024
a8819b7
Merge branch 'main' into 2024/10/08-custom-ctrl-system
anurudhp Oct 9, 2024
163b402
Merge branch 'main' into 2024/10/08-custom-ctrl-system
mpharrigan Oct 10, 2024
6bcd466
refactor: pass parameters instead of using protocol
anurudhp Oct 15, 2024
eaf572a
`CtrlSpec.get_single_control_bit` to get the correct control bit in t…
anurudhp Oct 15, 2024
35e396e
cleanup
anurudhp Oct 15, 2024
6aa3189
use new single control bit method
anurudhp Oct 16, 2024
0746161
test ctrl bit
anurudhp Oct 16, 2024
3049d98
`control` -> `ctrl`
anurudhp Oct 16, 2024
36f903e
don't pass `bloq`
anurudhp Oct 16, 2024
e137d3e
use callable
anurudhp Oct 16, 2024
2bac28d
update examples
anurudhp Oct 16, 2024
acfe808
mypy
anurudhp Oct 16, 2024
154083e
add helper method which accepts bloqs instead of a callable
anurudhp Oct 16, 2024
cbe3b19
Merge branch 'main' into 2024/10/08-custom-ctrl-system
anurudhp Oct 16, 2024
a75b245
upgrade more usecases
anurudhp Oct 16, 2024
7ee5c8a
Merge branch 'main' into 2024/10/08-custom-ctrl-system
mpharrigan Oct 17, 2024
1be03d0
Merge branch 'main' into 2024/10/08-custom-ctrl-system
mpharrigan Oct 17, 2024
534f5f1
typo
anurudhp Oct 18, 2024
bef2774
Merge branch 'main' into 2024/10/08-custom-ctrl-system
anurudhp Oct 18, 2024
5213602
fix bug in adder
anurudhp Oct 18, 2024
be71bba
rename file to `specialized_ctrl`
anurudhp Oct 18, 2024
160479b
rename function to `get_ctrl_system_1bit_cv`
anurudhp Oct 18, 2024
2ffa8c1
Merge branch 'main' into 2024/10/08-custom-ctrl-system
anurudhp Oct 20, 2024
4a758a8
mypy
anurudhp Oct 20, 2024
0bd9f27
cleanup design
anurudhp Oct 21, 2024
bdcf674
add exposed helpers with clearer types
anurudhp Oct 21, 2024
982df48
Merge branch 'main' into 2024/10/08-custom-ctrl-system
anurudhp Oct 28, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -191,14 +191,12 @@ def __str__(self):
return s

def get_ctrl_system(self, ctrl_spec: 'CtrlSpec') -> Tuple['Bloq', 'AddControlledT']:
from qualtran.bloqs.mcmt.bloq_with_specialized_single_qubit_control import (
get_ctrl_system_for_bloq_with_specialized_single_qubit_control,
)
from qualtran.bloqs.mcmt.specialized_ctrl import get_ctrl_system_1bit_cv

return get_ctrl_system_for_bloq_with_specialized_single_qubit_control(
return get_ctrl_system_1bit_cv(
self,
ctrl_spec=ctrl_spec,
current_ctrl_bit=self.control_val,
bloq_without_ctrl=attrs.evolve(self, control_val=None),
get_ctrl_bloq_and_ctrl_reg_name=lambda cv: (
attrs.evolve(self, control_val=cv),
'control',
Expand Down
8 changes: 3 additions & 5 deletions qualtran/bloqs/chemistry/sparse/select_bloq.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,14 +170,12 @@ def build_call_graph(self, ssa: 'SympySymbolAllocator') -> 'BloqCountDictT':
return {SGate(): 1, maj_x: 1, c_maj_x: 1, maj_y: 1, c_maj_y: 1}

def get_ctrl_system(self, ctrl_spec: 'CtrlSpec') -> Tuple['Bloq', 'AddControlledT']:
from qualtran.bloqs.mcmt.bloq_with_specialized_single_qubit_control import (
get_ctrl_system_for_bloq_with_specialized_single_qubit_control,
)
from qualtran.bloqs.mcmt.specialized_ctrl import get_ctrl_system_1bit_cv

return get_ctrl_system_for_bloq_with_specialized_single_qubit_control(
return get_ctrl_system_1bit_cv(
self,
ctrl_spec=ctrl_spec,
current_ctrl_bit=self.control_val,
bloq_without_ctrl=attrs.evolve(self, control_val=None),
get_ctrl_bloq_and_ctrl_reg_name=lambda cv: (
attrs.evolve(self, control_val=cv),
'control',
Expand Down
8 changes: 3 additions & 5 deletions qualtran/bloqs/chemistry/thc/select_bloq.py
Original file line number Diff line number Diff line change
Expand Up @@ -315,14 +315,12 @@ def build_composite_bloq(self, bb: 'BloqBuilder', **soqs: 'SoquetT') -> Dict[str
return out_soqs

def get_ctrl_system(self, ctrl_spec: 'CtrlSpec') -> Tuple['Bloq', 'AddControlledT']:
from qualtran.bloqs.mcmt.bloq_with_specialized_single_qubit_control import (
get_ctrl_system_for_bloq_with_specialized_single_qubit_control,
)
from qualtran.bloqs.mcmt.specialized_ctrl import get_ctrl_system_1bit_cv

return get_ctrl_system_for_bloq_with_specialized_single_qubit_control(
return get_ctrl_system_1bit_cv(
self,
ctrl_spec=ctrl_spec,
current_ctrl_bit=self.control_val,
bloq_without_ctrl=evolve(self, control_val=None),
get_ctrl_bloq_and_ctrl_reg_name=lambda cv: (evolve(self, control_val=cv), 'control'),
)

Expand Down
8 changes: 3 additions & 5 deletions qualtran/bloqs/for_testing/random_select_and_prepare.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,14 +150,12 @@ def decompose_from_registers(
yield op

def get_ctrl_system(self, ctrl_spec: 'CtrlSpec') -> Tuple['Bloq', 'AddControlledT']:
from qualtran.bloqs.mcmt.bloq_with_specialized_single_qubit_control import (
get_ctrl_system_for_bloq_with_specialized_single_qubit_control,
)
from qualtran.bloqs.mcmt.specialized_ctrl import get_ctrl_system_1bit_cv

return get_ctrl_system_for_bloq_with_specialized_single_qubit_control(
return get_ctrl_system_1bit_cv(
self,
ctrl_spec=ctrl_spec,
current_ctrl_bit=self.control_val,
bloq_without_ctrl=attrs.evolve(self, control_val=None),
get_ctrl_bloq_and_ctrl_reg_name=lambda cv: (
attrs.evolve(self, control_val=cv),
'control',
Expand Down
149 changes: 0 additions & 149 deletions qualtran/bloqs/mcmt/bloq_with_specialized_single_qubit_control.py

This file was deleted.

Loading
Loading