Skip to content

Conversation

@tanujkhattar
Copy link
Collaborator

@tanujkhattar tanujkhattar commented Jun 5, 2024

Low hanging fruits towards #1052. Achieves a ~15% improvement.

Before:

image

After:

image

"""
return self._total_bits

@cached_property
Copy link
Collaborator

Choose a reason for hiding this comment

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

just use cached method on the original method?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

functools doesn't seem to have a cached_method and I didn't want to add another dependency. using just cache would require computing hash of the class itself which would again be slow.

)
yield multi_controlled_and
yield self._load_nth_data(zero_indx, lambda q: CNOT().on(and_target, q), **target_regs)
yield self._load_nth_data(zero_indx, lambda q: cirq.CNOT(and_target, q), **target_regs)
Copy link
Collaborator

Choose a reason for hiding this comment

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

use qualtran CNOT so that it can immediately unwrap from CirqGateAsBloq without doing any logic?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Using qualtran CNOT is slower because CNOT in Qualtran is not a GateWithRegisters. So the cirq construction wraps it in a BloqAsCirqGate; which ends up being slow. See the first profiling picture in my linked comment.

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.

2 participants