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

Remove bit_tools and replace with QDType features #1041

Merged
merged 10 commits into from
Jun 11, 2024

Conversation

charlesyuan314
Copy link
Contributor

@charlesyuan314 charlesyuan314 commented May 31, 2024

Replace references to iter_bits, iter_bits_twos_complement, and iter_bits_fixed_point from qualtran.cirq_interop.bit_tools as they are largely duplicated by functionality in QUInt, QInt, and QFxp respectively.

Move functionality of float_as_fixed_width_int to QFxp.to_fixed_width_int.

Modify QFxp.to_bits to enable the exactly-representable check to be bypassed and to enable overriding the twos-complement representation of negative binary fractions used by fxpmath. Previous users of iter_bits_fixed_point instead require sign-magnitude representation.

Remove bit_tools and move its tests to data_types.

Towards #811. Updates to users of classical_sim.ints_to_bits should follow in another PR.

@charlesyuan314
Copy link
Contributor Author

@mpharrigan PTAL.

As far as I can tell, classical_sim.ints_to_bits and classical_sim.bits_to_ints are currently only used in relation to classical simulation. They also use np.uint64 for what I assume to be performance reasons. So I haven't touched those at this point.

@mpharrigan mpharrigan enabled auto-merge (squash) June 11, 2024 22:13
@mpharrigan mpharrigan merged commit c501651 into quantumlib:main Jun 11, 2024
7 checks passed
@charlesyuan314 charlesyuan314 deleted the bits branch June 12, 2024 01:16
Comment on lines +72 to +74
output_bits = QFxp(arctan_bitsize, arctan_bitsize).to_bits(
np.abs(output_val), require_exact=False
)
Copy link
Collaborator

Choose a reason for hiding this comment

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

This got way slower and now this is one of the slowest unit tests

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