Skip to content
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

Add subcommand to convert to/from various result formats #600

Merged
merged 11 commits into from
Aug 22, 2023

Conversation

justinledford
Copy link
Contributor

This can be very useful when comparing results from experiments when the outputs were stored in different formats.

Also updated run_captured_stim_main to take std::string instead of
cstrings, so that a sequence of bytes containing a null byte doesn't
get interpreted as a null terminator effectively truncating the
sequence.
After updating run_captured_stim_main to take std::string for stdin
instead of a cstring, main.help_modes started failing. For cases where
an empty string was passed instead of nullptr, run_captured_stim_main
created a tmp file and passed it with `--in`. This caused some test
cases in help_modes to behave differently than expected.

This commit simply updates the output on a single test case to reflect
the real output of this command (`stim --help --sample`).
Copy link
Collaborator

@Strilanc Strilanc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a good start, but there are several more use cases that I think need to be covered. Extend this to include the following use cases:

  • I have the DEM, not the circuit, and want to convert detection event data.
  • I have neither the DEM nor the circuit but I know all the values that would be derived from them like the bits per shot
  • I know how many bits per shot, but I don't know if it's detection event data or measurement data (and I'm not using the DETS format which is the only one where that distinction matters)
  • The input file has observable data appended to the detector data, and I want to split the observable data out into a separate file

These use cases all kind of differ in what information they need. In general the command should infer everything it can from whatever the user provides, and if it can't infer a needed quantity it should raise an error identifying that quantity and saying various ways it can be provided.

src/stim/cmd/command_convert.test.cc Outdated Show resolved Hide resolved
src/stim/cmd/command_convert.test.cc Outdated Show resolved Hide resolved
src/stim/main_namespaced.test.cc Show resolved Hide resolved
@justinledford
Copy link
Contributor Author

This is a good start, but there are several more use cases that I think need to be covered. Extend this to include the following use cases:

  • I have the DEM, not the circuit, and want to convert detection event data.
  • I have neither the DEM nor the circuit but I know all the values that would be derived from them like the bits per shot
  • I know how many bits per shot, but I don't know if it's detection event data or measurement data (and I'm not using the DETS format which is the only one where that distinction matters)
  • The input file has observable data appended to the detector data, and I want to split the observable data out into a separate file

These use cases all kind of differ in what information they need. In general the command should infer everything it can from whatever the user provides, and if it can't infer a needed quantity it should raise an error identifying that quantity and saying various ways it can be provided.

Thanks, that is a very good point. I naively assumed the user would always have the circuit on hand. I added support for all of these cases, but there is another I'm wondering if we should add. For DETS files we can also attempt to parse the text looking for the value prefixes, but this may not be reliable as the file would need to include the max index of each type, which may not always occur. What do you think?

@Strilanc
Copy link
Collaborator

Strilanc commented Aug 7, 2023

Because it's not reliable to infer sizes or types from a det file, I would not attempt to do so.

Copy link
Collaborator

@Strilanc Strilanc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Look pretty good, just a few things left I think

src/stim/cmd/command_convert.cc Show resolved Hide resolved
src/stim/cmd/command_convert.cc Show resolved Hide resolved
src/stim/cmd/command_help.cc Show resolved Hide resolved
@Strilanc Strilanc merged commit 4b14127 into quantumlib:main Aug 22, 2023
50 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants