-
Notifications
You must be signed in to change notification settings - Fork 0
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
Hamiltonians #28
Comments
Similarly to the channels' case, #27, we can represent Hamiltonians as lists of However, both because they are not entering execution, and additional complications (see below) I'd not mix the definition with the current list of gates, also used to implement the queue, and instead do something like: struct Circuit {
gates: Vec<Gate>,
...,
hamiltonians: Vec<Hamiltonian>,
observable: Option<usize>,
}
struct Hamiltonian {
coefficients: Vec<f64>,
components: Vec<Circuit>
} where the Apart from being optimal or not, notice that the types above are mutually recursive, though they're size is known at compile time, since the recursion is kepts behind references ( |
Ok, I checked: mutual recursion on types is actually possible (provided the guaranteed compile-time size) #[derive(Debug)]
struct A {
pub b: Vec<B>,
}
#[derive(Debug)]
struct B {
pub a: Vec<A>,
}
fn main() {
let a = A {
b: vec![B { a: vec![] }],
};
println!("{a:#?}");
} Finished dev [unoptimized + debuginfo] target(s) in 0.58s
Running `/Users/alessandro/Projects/quantum/qibo-core/target/debug/ciao`
A {
b: [
B {
a: [],
},
],
} |
Hamiltonians do not need to be included or accounted for in qibo-core, as they generally do not participate in circuit execution.
We have only found one case were a
Hamiltonian
is involved during circuit execution: when theEnergy
callback is used. In that case, it is sufficient to represent theHamiltonian
as a matrix (array) for the case of dense Hamiltonians, or a list of circuits forSymbolicHamiltonian
s.The matrix representation of a Hamiltonian is not always unitary. This can be accommodated by having a general
Matrix
gate in qibo-core which is mapped to an arbitrary (potentially non-unitary) matrix. The currentUnitary
gate in qibo can also use thisMatrix
gate with the additional check of being unitary. (this check does not happen currently, meaning thatUnitary
gates may in fact be non-unitary)The text was updated successfully, but these errors were encountered: