-
Notifications
You must be signed in to change notification settings - Fork 25
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
Support multiple input/output states. #270
base: master
Are you sure you want to change the base?
Conversation
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.
First pass.
@@ -58,12 +62,33 @@ std::vector<std::vector<std::size_t>> read_grid_layout_from_stream( | |||
* be populated by this method. | |||
* @param output_states vector of output states for the given contraction |
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.
Update comment (output_states
is no longer a parameter)
/** | ||
* Given a grid of 3D tensors, rename indexes of the terminal tensors to | ||
* reflect terminal qubits. | ||
* @param QflexFinalQubits representing the final qubits. |
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 specifying parameters in function comments, please use the format:
* @param <parameter_name> <parameter_description>
Also, it looks like some parameters are missing from this comment.
|
||
/** | ||
* Apply the final delta-tensors to the 3D grid of tensors. | ||
* @param QflexGrid representing the circuit layout. |
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.
See previous comment.
@@ -78,8 +103,8 @@ std::string get_output_states( | |||
* States for qubits with terminal cuts are listed at the end of the state | |||
* bitstring, in the order of their terminal cuts. | |||
*/ | |||
std::vector<std::pair<std::string, std::complex<double>>> EvaluateCircuit( | |||
QflexInput* input); | |||
std::vector<std::tuple<std::string, std::string, std::complex<double>>> |
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.
With this change, the @return
spec is no longer accurate - please update.
@@ -32,8 +32,8 @@ tensor network, CPU-based simulator of large quantum circuits. | |||
qflex::utils::readable_memory_string(qflex::global::memory_limit), R"(]. | |||
-t,--track-memory=<seconds> If <verbosity_level> > 0, track memory usage [default: )", | |||
qflex::global::track_memory_seconds, R"(]. | |||
--initial-conf=<initial_conf> Initial configuration. | |||
--final-conf=<final_conf> Final configuration. | |||
--initial-conf=<initial_conf> Initial configuration [default: 00...00]. |
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.
This help message should indicate that multiple input/output strings are supported, and (briefly) describe how qFlex handles them.
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.
I think I still need to review evaluate_circuit.cpp
, but this should cover the rest.
} | ||
} | ||
|
||
// Delete duplicate initial/final configuration |
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.
I'd actually suggest that we return an error if duplicates are detected. The reasoning is this: if a user manually specifies two input states, they probably meant to provide two different input states. Since a simulation run can take a long time, we should fail early so the user can correct their mistake.
amplitudes.push_back({is, EvaluateCircuit(&input)}); | ||
} | ||
} | ||
// Remove duplicate initial/final states |
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.
Same as above - duplicate states should produce an error.
@@ -320,18 +318,10 @@ void circuit_data_to_tensor_network( | |||
} | |||
|
|||
// Check for the length of initial_conf and final_conf. |
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.
Update comment.
@@ -49,6 +49,15 @@ namespace qflex { | |||
const std::size_t SUPER_CYCLE_DEPTH = 8; | |||
const std::size_t DIM = 2; | |||
|
|||
/** | |||
* Return gate as an array. | |||
* @param name of the gate. |
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.
@param
formatting.
*/ | ||
std::vector<s_type> gate_array(const std::string& gate_name, | ||
const std::vector<double>& params); | ||
|
||
/** | ||
* Read circuit from stream and fill in a 2D grid of vectors of tensors. | ||
* @param qflex::QflexCircuit containing circuit information. |
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.
Update function comment to reflect parameter changes. (Also looks like the first @param
is missing its parameter name.)
@@ -94,9 +101,13 @@ void circuit_data_to_tensor_network( | |||
* @param scratch pointer to s_type array with enough space for all scratch | |||
* work. | |||
*/ | |||
void flatten_grid_of_tensors( | |||
std::vector<std::vector<Tensor>> flatten_grid_of_tensors( |
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.
Update function comment.
@@ -9,15 +9,18 @@ namespace { | |||
class GetOutputStatesTest : public testing::Test { |
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.
File comment: could you add tests for multiple-(input/output) and the new functions (apply_terminal_cuts
and apply_delta_output
)?
tensor_grid_3D, &tensor_grid_2D, &scratch); | ||
|
||
// Reorder the 2D grid | ||
reorder_grid_of_tensors(&tensor_grid_2D, final_qubits.qubits, |
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.
Would a separate test for reorder_grid_of_tensors
make sense, or does this provide enough coverage as-is?
Improve code to handle multiple initial/final states.