-
Notifications
You must be signed in to change notification settings - Fork 98
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
Durr hoyer library min and max #1936
Conversation
…il fix was implemented, takes advantage of optimized slice pattern matching native to rust
…andomInt(), reference microsoft#1928
@microsoft-github-policy-service agree |
Co-authored-by: Manvi-Agrawal <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Some of the comments from previous file regarding imports apply here.
- Also, could you please extract common logic from RunDHMinUT and RunDHMaxUT?
@@ -247,7 +247,7 @@ fn get_indent(compilation: &Compilation, package_offset: u32) -> String { | |||
.try_into() | |||
.expect("offset can't be converted to uszie"); | |||
let before_offset = &source.contents[..source_offset]; | |||
let mut indent = match before_offset.rfind(|c| c == '{' || c == '\n') { | |||
let mut indent = match before_offset.rfind(&['{', '\n'][..]) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we really need to change this? IMO this PR should focus only on implementing DH library.
I saw your commit message saying that build.py doesnt work for you without this change. I will leave this decision to @sezna.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If there is a way to skip over the error when I run the build.py I am happy to change it. I agree it is out of place, and will be hard to log trace down the line while it is included in this PR. maybe we can create a ticket to address this and I can push a PR for that?
@mertall , Mostly, looks good. Left a couple of nits regarding import and code reuse. Overall you have done a good job writing separating code into functions and using meaningful variable names. Could you please look further into some more places if the code can be reused or a library function can be used. I pointed at a couple of places. |
…ects the expectedMaxaindices variable
let double : Double = IntAsDouble(maxValue + 1); | ||
let log : Double = Log(double) / Log(2.0); | ||
let nQubits = Ceiling(log); | ||
let testLists : Int[][] = [ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some comments on the tests:
- What happens if some/all of the values are negative in a
testList
? - What happens if 0 is passed as input in a
testList
? - Can we please rearrange the values so that expectedMaxIndex is not 0 in all the test cases?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for negatives in ConvertToBinary:
if (value < 0 or value > maxVal) {
fail $"Value {value} cannot be represented with {length} bits.";
}
ConvertToBinary will fail if there are negatives
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added unit test for 0 in input list
… reopening closed suggestions
moved too fast on requested changes, lost 50% accuracy while trying to abstract... I get better debugging as a local Q# project. When working within the Q# repo I forked, I do not get the same debugging... Wondering if you had any suggestions to improve dev experience while in forked repo. Made an assumption earlier the debugging is same and went flying with changes. Once I moved it over to my Q# project to update that repo, I saw so many squiggly red lines :o ... :') . for now solution will be to make changes in my local Q# project as debugging is much easier. Will get back to this maybe tomorrow, more likely Friday. Thank you for the review! |
<cargo.exe_path> test --package library --lib -- tests::durrhoyerlibrary --exact --show-output this should help me. I was running the build and made an assumption the tests I created were included during that build. Thank you! |
my rust test file is improperly created. vs code is not highlighting any code on that file. I am inexperienced in rust so could use help in adjusting that script to meet whatever requirements I am missing. In mean time will make changes on my GitHub repo and copy and paste changes as they work. Thank you of your patience |
… find the DurrHoyerAlgorithm
Testing suite is working, and the test cases are getting hit, but they are not passing due to this error: error: Frontend(Error(Resolve(GlobImportNamespaceNotFound("DurrHoyerLibrary", Span { lo: 283, hi: 303 })))) }) |
Hey @mertall -- this looks like awesome work! I'm not sure this is a good fit for the standard library, though. The standard library is for things that have gone through a process of stabilization, with an API that we're willing to commit to forever. I think this algorithm would be best published as a Q# package (library). If it gets wide adoption, is seen as a "general utility", and we're happy with the API, then we can consider adding it to the standard library. Until then, I would suggest maintaining it as a library that you own. We have a document here describing how to publish libraries for Q#: our repo wiki and another document on learn.microsoft.com. After you create your library, you can add it to our registry. Once #1932 goes in, you can put up a PR that adds your library as a list of known libraries. I hope I'm not taking any wind out of your sails here -- our standard library is not meant to be a good example of a library, as it requires a lot of special casing for testing etc. The other libraries, like |
Thank you for the feedback @sezna. To clarify steps moving forward:
No worries on taking any wind out of my sails. I can't say I was not excited to contribute to Q#! When the time is right it shall happen. Thank you for the support so far! |
This is absolutely a contribution to Q#, we are really excited about third party libraries and would love to help you get that set up! And there's plenty of opportunity to contribute here as well 😄 |
Unit Tests worked standalone with 1000 shots. Above 50% accuracy. 💪🏾 (When running locally in my own GitHub Repo)
Can't seem to get DrawRandomInt to work with
python ./build.py
. I can't find any subitutes other than a QuantumRandomNumberGenerator, but that is not feasible when I read the docs on the implementation of the Operation in Q# docs. I was thinking maybe allowing the random int to come from outside of the Algorithm as an input, to be found in a classical computer via a python script run by a hypothetical user.Let me know what you all think. @sezna @billti @Manvi-Agrawal
Issue #1928