Comments (16)
Hi, I'm also testing JIT compilation with MPSCircuit with @royess. I use a circuit of the same depth but with geometric locality, and the compile time is faster (since we are not able to finish jit compiling for the non-local circuit, I can't say how much faster). However, I don't understand why locality will cause such a difference. What is the logic of in Tensorcircuit when doing contraction?
from tensorcircuit.
The locality is very important for MPSCircuit. If a non-local two-qubit gate is applied, it will be firstly transformed into a series of local swap gates + local two-qubit gate, and all these gates will be applied to the MPS sequentially. The reason is that only local two-qubit tensor can be safely applied and truncated to merge into the MPS for TEBD like algorithms.
from tensorcircuit.
@refraction-ray Thank you for the discussion. It seems that it is no longer a technical problem. The task we face has a fundamental hardness, which is unsolvable with current classical simulation techniques and reasonable computation resources.
from tensorcircuit.
@refraction-ray I would appreciate your comments or suggestions.
from tensorcircuit.
Indeed, jitting a large MPS circuit would require longer times than a plain Circuit, the jitting time varies significantly for different backend (jax vs. tf) or different hardware (cpu vs. gpu). What is the depth of you test circuit, typically MPSCircuit of 8 qubits wouldn't require that longer jitting time. Besides, you may also try the unjit version to see whether the running time is acceptable?
from tensorcircuit.
Thanks for the quick reply! Currently, I am using jax+cpu.
What is the depth of you test circuit
In total, 188 one- or two-qubit gates. The depth should be around 24, then.
By the way, I also tested a circuit of 320 gates via the snippet you provided in #204 (comment) (but changing the circuit to contain 8 qubits and increase the depth) in the same environment. That takes a jit time of about 120s.
Differences:
- My circuit (the slow one) does not obey the 1D locality, i.e., gates are very non-local.
- There are function calls to append components to build my circuit.
Besides, you may also try the unjit version to see whether the running time is acceptable?
I tried. But the training seems much slower than plain circuit simulator. It's not quite acceptable for my needs.
from tensorcircuit.
However, the compiling time is still prolonged when scaling up the qubit number. It takes about 15 minutes for four qubits and more than 2 hours for 16 qubits (the compilation process is still unfinished). This runs counter to the purpose of using MPSCircuit, which is to optimize the computation resource (both time and memory) when scaling up the qubit number. Is there any way to make this better?
from tensorcircuit.
for unjit version, if AD is not required in your workflow, maybe numpy backend is the fastest
from tensorcircuit.
Another possible workaround is when your circuit has some time periodicity, then a scan wrapper can greatly reduce the jitting time, see an example for Circuit
: https://github.com/tencent-quantum-lab/tensorcircuit/blob/master/examples/hea_scan_jit_acc.py. I believe the example can be transfered to MPSCircuit
, with in and out the stacked MPS tensors.
from tensorcircuit.
Thanks for your advice! But I think we need AD and do not have time periodicity in our circuit.
from tensorcircuit.
Do you think it is doable to speed up the complication for MPSCircuit? We will be happy to help if you have ideas on how to work on that. (We need this feature in our research. And it seems to have no other workaround.)
Naively, I will suppose an MPSCircuit is not much more complicated than a normal one in its structure. And should it come with a reasonable jit time?
from tensorcircuit.
Do you think it is doable to speed up the complication for MPSCircuit?
Firstly, from physics perspective, a TEBD like algorithm applied on non-periodic and very structured circuit often leads to a very large approximation error unless there are some types of theory guarantee, eg. one can show that the intermediate state in the circuit is always area law entangled.
From engineering perspective, accelerating jit time is much harder than accelerating running time, as the former is nearly fixed by the ML framework that we have very less control.
One possible way is to support MPS with grouping qubits as one tensor instead of one qubit for one tensor. In the former case, much fewer QR or SVD is required and the approximation error is more controllable. eg. d qubits as one tensor leg, the mps tensor has dimension (
from tensorcircuit.
And what is the target circuit metric (qubits number, error, circuit depth, gate number etc.) in your case? Also, have you tried tf backend? the jitting time is much shorter
from tensorcircuit.
And what is the target circuit metric (qubits number, error, circuit depth, gate number etc.) in your case?
The target circuit contains about 80 qubits, and about 60 layers of all-to-all connected non-local 2-qubit gates, making it roughly 3000 non-local 2-qubit gates. Do you think it is possible to jit such circuits (with or without MPS)?
Also, have you tried tf backend? the jitting time is much shorter
Yes, we have tried tf backend. Unfortunately, tf backend does not have hittable version of QR decomposition, so jitting MPS is impossible.
from tensorcircuit.
The target circuit contains about 80 qubits, and about 60 layers of all-to-all connected non-local 2-qubit gates, making it roughly 3000 non-local 2-qubit gates.
To me, the scale for the simulation is very challenging, by translating to local 2-qubit gates, I guess roughly 30000 two-qubit gates are required for 80 qubits system. Even if MPSCircuit can simulate this, the accuracy would be bad in general. Actually, the simulation scale is even beyond the quantum supremacy experiments, I don't see this as an easy task to run by calling API with one GPU.
Unfortunately, tf backend does not have hittable version of QR decomposition
What do you mean by this, can you run the circuit with jitted tf backend? I don't think vmap is relevant for your use case since one circuit is challenging enough to simulate after all? There is no need to "stack" multiple circuits together to simulate
from tensorcircuit.
To me, the scale for the simulation is very challenging, by translating to local 2-qubit gates, I guess roughly 30000 two-qubit gates are required for 80 qubits system. Even if MPSCircuit can simulate this, the accuracy would be bad in general. Actually, the simulation scale is even beyond the quantum supremacy experiments, I don't see this as an easy task to run by calling API with one GPU.
I see, thanks a lot.
There is no need to "stack" multiple circuits together to simulate
Yes, I understand this. However, for our task, we need to run many batches. As you have said, if simulating one circuit is challenging enough, then there's no reason to consider stacking them together.
from tensorcircuit.
Related Issues (20)
- Enhance <QAOA portfolio tutorial> HOT 4
- Fermion Gaussian State Simulator HOT 3
- Stabilizer simulator
- Backend agnostic implementation of quantum Hamiltonian generation HOT 2
- Applying gates with jnp index HOT 7
- Support trainable adptive circuit HOT 2
- Implementation of SHVQE with QAS HOT 1
- tensor network representation of a tensor circuit HOT 2
- Allow sparse matrix as circuit input HOT 3
- AttributeError: module 'tensorflow' has no attribute 'sparse' HOT 2
- Bug in qiskit circuit parsing HOT 2
- jit compile circuit with any gate HOT 2
- `copy` operation of DM circuit forgets previous `apply_general_kraus` operations HOT 1
- MPS circuit with JIT compilation HOT 8
- Sampling from circuit does not give proper bitstring HOT 4
- Add Jittor backend HOT 7
- Stabilizer simulation example utilizing stim backend HOT 14
- Add examples benchmarking different contractor settings provided by cotengra HOT 1
- Vmap isn't working when using JAX-based MPSCircuits HOT 3
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 tensorcircuit.