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

Store time of tagging #114

Merged
merged 36 commits into from
May 21, 2024
Merged

Store time of tagging #114

merged 36 commits into from
May 21, 2024

Conversation

ba2tro
Copy link
Member

@ba2tro ba2tro commented Apr 15, 2024

Resolves #111

@ba2tro ba2tro added the Skip-Changelog label for control of CI: skips the changelog check label Apr 15, 2024
Copy link

codecov bot commented May 3, 2024

Codecov Report

Attention: Patch coverage is 94.64286% with 3 lines in your changes are missing coverage. Please review.

Project coverage is 71.40%. Comparing base (a3969d7) to head (0540e90).

Current head 0540e90 differs from pull request most recent head 48f6240

Please upload reports for the commit 48f6240 to get more accurate results.

Files Patch % Lines
src/queries.jl 93.47% 3 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #114      +/-   ##
==========================================
+ Coverage   71.34%   71.40%   +0.05%     
==========================================
  Files          37       37              
  Lines        1525     1528       +3     
==========================================
+ Hits         1088     1091       +3     
  Misses        437      437              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@ba2tro
Copy link
Member Author

ba2tro commented May 3, 2024

@Krastanov , any idea what the xvfb startup issue is from(the documentation ci failure)? https://github.com/QuantumSavory/QuantumSavory.jl/actions/runs/8932976512/job/24537665495?pr=114#step:7:564

@ba2tro ba2tro marked this pull request as ready for review May 3, 2024 02:06
Copy link
Member

@Krastanov Krastanov left a comment

Choose a reason for hiding this comment

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

I left some comments in. This seems to introduce an API change that breaks current code and requires the user to run a lot of extra boilerplate (carrying around the guid() calls). guid should not be a user-visible thing.

Not sure about why the documentation build fails. Do not worry about it for now.

src/ProtocolZoo/ProtocolZoo.jl Outdated Show resolved Hide resolved
src/networks.jl Outdated
@@ -14,6 +14,7 @@ struct RegisterNet
end

function RegisterNet(graph::SimpleGraph, registers, vertex_metadata, edge_metadata, directed_edge_metadata)
glcnt[] = 0 # set the global counter of `guid`s to zero whenever a new network is initialized
Copy link
Member

Choose a reason for hiding this comment

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

someone might be modeling multiple networks. No need to set it to zero, to avoid clashes

Copy link
Member

Choose a reason for hiding this comment

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

On the other hand, this seems pretty useful when it comes to tests... So maybe we should not have a global counter, rather a counter per network?

Copy link
Member Author

Choose a reason for hiding this comment

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

Its straight forward to make the counter local to each network, but then taking in to account the previous comment about adding id and time automatically inside the tag!, the local id now would be a field of the network and we would need to pass the network to tag! in order to access it

Copy link
Member

Choose a reason for hiding this comment

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

A new private field in the network makes sense, but having to pass around additional arguments is definitely not workable. The goal is not just to make something possible, equally important is for the interface to be something usable and logical.

Most of the objects that are being tagged carry a reference to the more centralized objects, e.g. the way get_time_tracker works. Maybe the best solution is to have get_time_tracker provide the object tracking the ids (e.g. by having a new simulation type).

Or you can just stick to a global non-zeroed counter, while fixing the rest of the things. That is fairly straightforward to solve separately.

Copy link
Member Author

Choose a reason for hiding this comment

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

I think making net a field of our own Simulation type would be the best way about it then, as you suggested above. For now lets work with a the non-zeroed global counter, I'll open an issue for it

src/queries.jl Outdated Show resolved Hide resolved
test/test_entanglement_consumer.jl Outdated Show resolved Hide resolved
@Krastanov
Copy link
Member

is this ready for review?

@ba2tro
Copy link
Member Author

ba2tro commented May 15, 2024

Yes, sorry my bad, I should've re-requested for review

@Krastanov
Copy link
Member

no worries! You might have said so in person, but it helps to have it mentioned here as well in case I forget

Copy link
Member

@Krastanov Krastanov left a comment

Choose a reason for hiding this comment

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

This seems nearly ready.

I think we are still missing tests for the new functionality, though. Tests that previously would have failed, like requesting filo or fifo for a whole register where we have various slots of the register tagged in arbitrary order. Could you add such tests?

src/queries.jl Outdated Show resolved Hide resolved
src/queries.jl Outdated Show resolved Hide resolved
src/queries.jl Outdated
tags = ref.reg.tags[ref.idx]
i = findfirst(==(tag), tags)
isnothing(i) ? throw(KeyError(tag)) : deleteat!(tags, i) # TODO make sure there is a clear error message
function untag!(ref::RegRef, id::Int128) # TODO rather slow implementation. See issue #74
Copy link
Member

Choose a reason for hiding this comment

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

Is the TODO comment still valid? What is necessary to fix it?

Copy link
Member Author

@ba2tro ba2tro May 16, 2024

Choose a reason for hiding this comment

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

I would consider it resolved, considering we're using a dictionary instead of a vector of tags, so deleting a tag just need the key to be dropped(deleted) rather than iterating and comparing for equality through each element of a vector of tags. If you agree I'll remove the TODO. This would also mean we could close #74

test/test_tags_and_queries.jl Show resolved Hide resolved

@test queryall(reg, EntanglementCounterpart, 1, ❓) == [(slot = reg[i], depth = d, tag = Tag(EntanglementCounterpart,1,j+i)) for i in 2:4 for (d,j) in ((8,310),(5,110),(1,10))]
@test queryall(reg, EntanglementCounterpart, 1, ❓; filo=true) == [(slot = reg[i], depth = d, tag = Tag(EntanglementCounterpart,1,j+i)) for i in 2:4 for (d,j) in ((8,310),(5,110),(1,10))]
@test queryall(reg, EntanglementCounterpart, 1, ❓; filo=false) == [(slot = reg[i], depth = d, tag = Tag(EntanglementCounterpart,1,j+i)) for i in 2:4 for (d,j) in reverse(((8,310),(5,110),(1,10)))]
Copy link
Member

Choose a reason for hiding this comment

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

This test is very difficult to read. Tests should be obviously correct, not copy-pasting things that we generate by the code we are testing. This test is also fragile -- it will have to be modified if we switch how the id is represented.

I would suggest making a helper function in this file along the lines of strip_id so that you can do strip_id(querryall(...)) == ... in order to keep the test easy to read.

Copy link
Member

Choose a reason for hiding this comment

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

It will be even easier to read than previously becaise we will not need the depth tag anywhere either.

Basically, remove id from these tests so that the tests are not fragile.

Copy link
Member

Choose a reason for hiding this comment

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

these tests still look much more complicated than they used to

@ba2tro
Copy link
Member Author

ba2tro commented May 16, 2024

This seems nearly ready.

I think we are still missing tests for the new functionality, though. Tests that previously would have failed, like requesting filo or fifo for a whole register where we have various slots of the register tagged in arbitrary order. Could you add such tests?

It looks to me like these tests that we already have are what you described? Let me know if I missed something here
https://github.com/Abhishek-1Bhatt/QuantumSavory.jl/blob/f606f1baa76236d48bcbdc1065f208ff6628e2df/test/test_tags_and_queries.jl#L74-L100

@Krastanov
Copy link
Member

I made some changes and polish. Please check each of the commits I have submitted in case something is off. Most of them have a clear description for why I added them. Those marked fixup are just there to fix silly mistakes I have made as I was working on this.

@Krastanov Krastanov merged commit 242f852 into QuantumSavory:master May 21, 2024
7 of 11 checks passed
@Krastanov
Copy link
Member

woohoo, this is in!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Skip-Changelog label for control of CI: skips the changelog check
Projects
None yet
Development

Successfully merging this pull request may close these issues.

save time of tagging and use it in FILO/FIFO considerations
2 participants