QuantumLibraries icon indicating copy to clipboard operation
QuantumLibraries copied to clipboard

Add BigInt variants of all Int methods

Open Strilanc opened this issue 5 years ago • 10 comments

When testing an adder, I noticed that as soon as I went to larger sizes some of the functions I was using did not have BigInt variants.

For example, I needed to write BigInt variants of these three functions:

MeasureInteger
DrawRandomInt
ApplyXorInPlace

(This would all be moot if Q# was big-int-by-default like python!)

Strilanc avatar Nov 16 '20 17:11 Strilanc

@Strilanc Thanks for filing! @cgranade This is something for the libraries API - where do you want to track it and what's the appropriate milestone?

bettinaheim avatar Nov 16 '20 18:11 bettinaheim

@bettinaheim @Strilanc: Let me go on and move this to the libraries repo as a feature request. From there, the process will be to propose a new API including that enhancement and schedule it for one of the monthly API reviews. Thanks for filing this, @Strilanc!

cgranade avatar Nov 16 '20 22:11 cgranade

@msoeken @guenp: Thoughts on including this as part of the changes with https://github.com/microsoft/QuantumLibraries/issues/337?

cgranade avatar Nov 16 '20 22:11 cgranade

@cgranade I agree to include BigInt-variants for all Int methods as part of the changes with #337. In general, I think that having Q# bit-int-by-default as mentioned by @Strilanc is an interesting idea.

msoeken avatar Nov 17 '20 08:11 msoeken

It sounds like there's alignment, then, that #337 is the right place to act on that feedback. Will revise that proposal to incorporate and schedule discussion for the December API review.

@msoeken, @Strilanc: Would either of you be willing to file BigInt-by-default as a suggestion on qsharp-language? I'm happy to capture that in qsharp-language if not.

cgranade avatar Nov 17 '20 18:11 cgranade

@cgranade I am not sure what BigInt by default would mean for Q#? there is no default; we have literals for each data type, and no automatic cast or conversions. Hence the data type is whatever you define it to be when you instantiate the value. This is more of a library ask I believe.

bettinaheim avatar Nov 18 '20 03:11 bettinaheim

It means the literal 1 is a BigInt instead of an Int. And slices would be over big ints instead of over ints. Almost everything would be big ints. Basically you would be renaming Int to Int64 and BigInt to Int, and Int64 would almost never be used. That's what I mean by big-int by default.

Strilanc avatar Nov 18 '20 05:11 Strilanc

The slices or rather support for BigInt ranges is a good point. The concern from my side would be performance and the amount of work to fully support that throughout all our tools.

bettinaheim avatar Nov 18 '20 17:11 bettinaheim

There might be some tricks that one can leverage to address performance issues such as a small integer cache as used in Python's C implementation.

msoeken avatar Nov 19 '20 08:11 msoeken

Tagging this as a Status-ChildIssue of https://github.com/microsoft/QuantumLibraries/issues/337.

guenp avatar Nov 23 '20 18:11 guenp