Comments (5)
Yes, this definitely is a memory issue. The sudoku puzzle in this example has 8 missing digits, with 2 bits per digit the algorithm will need 16 qubits to represent the search space alone. With the extra qubits allocated during the execution to check the constraints, one per constraint, the number of qubits used in the oracle implementation is over 50, which is a lot more than the simulator can handle. The hardcoded examples used with the quantum solution have fewer missing digits and fewer constraints, so they don't run in a similar memory issue.
It would make sense to update this example to add some checks on the total number of qubits that will be used, and to fail early with a cleaner error message when the number of qubits is over 30. @cgranade, what do you think?
from quantum.
Thanks @tcNickolas. this is what i suspected too. I wonder if there is an additional way to address some of these kinds of situations. It occurs to me that the number of starting constraints + number of possible values = size (e.g., 4 for a 4x4, 9 for a 9x9 puzzle) * empty vertices. So, in the case I outlined above, there are 8 vertices which equate to 32 values all in all; 22 starting number constraints are known...leaving a total of ten possible values left for the 8 vertices (6 have 1 possible value and 2 have 2 each). In the case where starting constraints is greater than 1/2 * empty vertices * size, could the puzzle be solved with possible values instead of starting constraints? In this case, it would use 10 instead of 22..
I've played around with this and I think it would need something similar to the ConstrainByEdgeAndStartingColors function but for PossibleValues instead of constraints. Instead of checking if the numbers are the same, it would check to see if the value is one of the possible values; like an == (1 OR 3). I think it would replace these lines of code
for ((cell, value), conflictQubit) in Zipped(startingColorConstraints, startingColorConflictQubits) {
// Check that cell does not clash with starting colors.
ControlledOnInt(value, X)(
colorsRegister[cell * bitsPerColor .. (cell + 1) * bitsPerColor - 1],
conflictQubit
);
But I am still coming up to speed with Quantum and not sure what the code would look like (or if its even possible) to change the conflictQubit based on whether the value is equal to a set of possible values.
thanks again for your help
from quantum.
I finally had the time to dig into this question, and this optimization alone, while reducing the number of qubits necessary to evaluate the same constraints, doesn't bring it down enough to solve your puzzle. I had to do something cleverer, incorporate this type of constraints into the search space construction (prep of the initial state and the reflection about the mean step) so as to avoid checking them as constraints at all. I even wrote a blog post about this!
@msoeken, @cgranade - does it make sense to bring those optimizations into our official sample, so that it could solve larger and more interesting puzzles?
from quantum.
yes, i tried it out and you are correct - it doesnt bring it down enough. I have other ideas (intersections of rows, columns, blocks) but got pulled into other work and havent been able to look at this in a bit. i plan to try some other thoughts when i get time again
BTW, i didnt know about this blog post. I love it! Thank you for writing it!!
from quantum.
You couldn't have known about the blog post, I've published it less than 12 hours ago :-)
from quantum.
Related Issues (20)
- H2 Broombridge file seems incorrect
- Q# installation issue through dotnet , VS code. HOT 4
- Resource estimator for factorization of 2048-bit semi prime integers HOT 12
- Latest LLVM version for qir/oracle-generator is 14.0. Need to update CMakefile.txt if just following instructions
- Typo in samples / interoperability / python / environment.yml HOT 1
- lo
- Using nuget restore from .NET 5.0 no longer requires first updating ca-certificates HOT 1
- Optimization: Remove redundant `list` call in `check_file` in `Build/check_indents.py` HOT 3
- PI
- Add Sparse Simulator Samples HOT 6
- BayesianPEIsCorrect test fails probabilistically HOT 1
- Add sparse simulator sample to main
- mybinder notebook integer-factorization does not work HOT 3
- Quantum Random Number Generator not working HOT 1
- `TimeoutError` but azure still connects? HOT 4
- HalfMoon example on Quantum Hardware HOT 2
- Don't use "failed" in the normal RUS loop logs
- "Prebuild Docker image" Action is broken. HOT 1
- Error in Shor's algorithm HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from quantum.