agony5757 / qpanda-lite Goto Github PK
View Code? Open in Web Editor NEWA python-native version for pyqpanda. Simple, easy, and transparent.
License: Apache License 2.0
A python-native version for pyqpanda. Simple, easy, and transparent.
License: Apache License 2.0
The desired matrix form of RZ is supposed to be,
But the current implementation is,
Although there is only a global phase for the single-qubit case, there will be issues if we add control to it due to the extra phase.
if (!control_enable(i, global_controller))
continue;
do nothing at all. It will need something like
bool control_active = true;
for (size_t q : global_controller) {
if (!((i >> q) & 1)) {
control_active = false;
break;
}
}
to collect the boolean value regarding the global_controller string.
The current version of NoisySimulator::execute_once()
does not care global control part. It would be better to add,
case (uint32_t)SupportOperationType::CNOT:
if (!opcode.global_controller.empty())
{
// If there are global controllers, use the cnot_cont method
simulator.cnot_cont(opcode.qubits[0], opcode.qubits[1], opcode.global_controller);
}
else
{
// If there are no global controllers, use the regular cnot method
simulator.cnot(opcode.qubits[0], opcode.qubits[1]);
}
break;
to temporarily solve the issue.
The two code blocks are able to temporarily solve the problem, but the final version may end up with better solutions :)
Traceback (most recent call last):
File "c:\Users\Administrator\Desktop\watchdog\watchdog_20240107_222310\Lorantz.py", line 464, in
val_model("val",rho = 24.8,train_set=600)
File "c:\Users\Administrator\Desktop\watchdog\watchdog_20240107_222310\Lorantz.py", line 440, in val_model
pre_label=model(batch_text)
File "pyvqnet\nn\module.py", line 613, in pyvqnet.nn.module.Module.call
File "c:\Users\Administrator\Desktop\watchdog\watchdog_20240107_222310\models.py", line 353, in forward
output, (h_n, _) = self.rnn(x)
File "pyvqnet\nn\module.py", line 613, in pyvqnet.nn.module.Module.call
File "c:\Users\Administrator\Desktop\watchdog\watchdog_20240107_222310\models.py", line 211, in forward
i_t = self.sigmoid(self.vqc_input(encoding_input[:, :hs]))
File "pyvqnet\nn\module.py", line 613, in pyvqnet.nn.module.Module.call
File "c:\Users\Administrator\Desktop\watchdog\watchdog_20240107_222310\QLayer.py", line 313, in forward
outputs = [
File "c:\Users\Administrator\Desktop\watchdog\watchdog_20240107_222310\QLayer.py", line 314, in
calculate_expectation(output, self.hamiltonian)
File "C:\ProgramData\Anaconda3\envs\kynb310\lib\site-packages\qpandalite\analyzer\expectation.py", line 59, in calculate_expectation
return [calculate_expectation(measured_result, h) for h in hamiltonian]
ate_expectation
return _calculate_expectation_dict(measured_result, hamiltonian, nqubit)
File "C:\ProgramData\Anaconda3\envs\kynb310\lib\site-packages\qpandalite\analyzer\expectation.py", line 15, in _calculate_expectation_dict
task.py 240行 key.append(hex(i))
When inputting mapping dict like {0:100, 1:100} (duplicate qubit mapped to the same qubit), it should raise an exception.
QINIT 1
CREG 1
RX q[0], (-1.57)
RZ q[0], (1.57)
H q[0]
MEASURE q[0],c[0]
这个线路应该和
QINIT 1
CREG 1
X q[0]
MEASURE q[0],c[0]
结果一致,pyqpanda模拟结果分别为{'0': 3.170681151136739e-07, '1': 0.9999996829318852},{'0': 0.0, '1': 1.0},与理论预期一致; 但qpandalite分别为[0.9999996829318849, 3.170681151136738e-07]和[0.0, 1.0],排除了顺序问题确实有误。将H q[0]替换为RY q[0], (-1.57)时同样有问题。
Modify analyze_circuit
under the standard OriginIR_base_parser
Following Q1: For the operations that are not affected by the dagger, do we need to keep the "_dg"?
For example: {'H': 3, 'CNOT': 3, 'CCCNOT': 1, 'X_dg': 2, 'Z_dg': 3, 'X': 1, 'Z': 1, 'CCNOT': 1, 'CCCCNOT': 1, 'CCCNOT_dg': 1, 'CNOT_dg': 1, 'CZ_dg': 1, 'CCNOT_dg': 1},
Following Q2: At what level we do not need to care about them anymore? circuit <-> OriginIR ->simulator
A2: We might name the operation in the OriginIR_base_parser, given its status of control and dagger_not
Modify qasm
under the standard OriginIR_line_parser
Add dagger/ barrier support when converting OriginIR to QASM
There is no specific flag in QASM, RXGate(-0.4).inverse()
->rx(0.4) q[?]
. Others follow a similar rule, all of the QE primitives have their own inverse() method to deal with the dagger issue.
Add dagger/ barrier support when converting QASM to OriginIR
Based on the point above, I guess the transition from QASM to OriginIR would be easier.
Circuit.remapping does not support partial-remapping currently, might need a discussion about it.
Dagger not done
Will close it after finish all of them. :^)
remap = {0:1, 1:0}
c.remapping(remap) will not be correctly supported.
qpandalite/originir/originir_line_parser.py line 103
qubit_indices = [int(q[0]) for q in qubits] --> qubit_indices = [int(q) for q in qubits]
My design is:
It has one at the table of content "qpandalite.task package" with "IBM, Quafu, OriginQ, OriginQ,_dummy" four subpackages instead of three table of content items :^(
When auto_mapping
is true, the results
will be lost. The referred code should be unindented.
The memory consumption is increasing continuously because the dummy_cache is never cleared.
Potential solution:
The output of the noisy simulator under the same circuit will return the same sampling output.
It should return another similar output. @YunJ1e
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.