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 stim::ReferenceSampleTree to support loop folded reference sampling #772

Merged
merged 5 commits into from
May 21, 2024

Conversation

Strilanc
Copy link
Collaborator

@Strilanc Strilanc commented May 18, 2024

Get a compressed tree representation of the reference sample by using stim::ReferenceSampleTree::from_circuit_reference_sample(circuit).

The reason for a tree, instead of raw run length encoding, is to support nested loops (e.g. physical surface code rounds repeating within repeated logical operations).

Example test:

    CircuitGenParameters params(10000, 3, "rotated_memory_x");
    auto circuit = generate_surface_code_circuit(params).circuit;
    circuit.blocks[0].append_from_text("X 10 11 12 13");
    auto ref = ReferenceSampleTree::from_circuit_reference_sample(circuit);
    ASSERT_EQ(ref.str(), "1*(''+2*('00000000')+4999*('0110000000110000')+1*('000000000'))");

Example benchmark (25 milliseconds to do a distance 31 surface code with a billion rounds):

    CircuitGenParameters params(1000000000, 31, "rotated_memory_x");
    auto circuit = generate_surface_code_circuit(params).circuit;
    simd_bits<MAX_BITWORD_WIDTH> ref(0);
    auto total = 0;
    benchmark_go([&]() {
        auto result = ReferenceSampleTree::from_circuit_reference_sample(circuit);
        total += result.empty();
    })
        .goal_millis(25);

Part of #768

@Strilanc Strilanc requested a review from qec-pconner May 18, 2024 05:18
Copy link
Contributor

@qec-pconner qec-pconner left a comment

Choose a reason for hiding this comment

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

LGTM with some comments.
Nothing really blocking (thus the LGTM), but things that should probably be considered.

src/stim/util_top/reference_sample_tree.cc Outdated Show resolved Hide resolved
src/stim/util_top/reference_sample_tree.cc Outdated Show resolved Hide resolved
src/stim/util_top/reference_sample_tree.cc Outdated Show resolved Hide resolved
src/stim/util_top/reference_sample_tree.cc Outdated Show resolved Hide resolved
src/stim/util_top/reference_sample_tree.cc Show resolved Hide resolved
src/stim/util_top/reference_sample_tree.inl Show resolved Hide resolved
src/stim/util_top/reference_sample_tree.inl Show resolved Hide resolved
src/stim/util_top/reference_sample_tree.inl Show resolved Hide resolved
src/stim/util_top/reference_sample_tree.inl Outdated Show resolved Hide resolved
Copy link
Contributor

@qec-pconner qec-pconner left a comment

Choose a reason for hiding this comment

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

Ok. This all looks good. I think the only thing left worth updating is the non-RVO stuff (#772 (comment)) and cleaning up the throw away work in tortoise (#772 (comment)). But neither of those are really blocking.
Final LGTM.

@Strilanc Strilanc enabled auto-merge (squash) May 21, 2024 21:13
@Strilanc Strilanc merged commit 9c97029 into main May 21, 2024
53 checks passed
@Strilanc Strilanc deleted the runlengthref branch May 21, 2024 21:37
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