Skip to content

Basiav/sampleset times extraction#10

Open
basiav wants to merge 38 commits intomainfrom
basiav/sampleset_times_extraction
Open

Basiav/sampleset times extraction#10
basiav wants to merge 38 commits intomainfrom
basiav/sampleset_times_extraction

Conversation

@basiav
Copy link
Copy Markdown
Collaborator

@basiav basiav commented Jul 6, 2025

No description provided.

@basiav basiav requested a review from kacper3615 July 6, 2025 15:11
# List instead of samplesets_data = np.empty((num_runs), dtype=object)
# To prevent jupyter notebook kernel crashes
# as handling big objects is not efficient with numpy dtype=object arrs
samplesets_data = []
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Is it a temporary solution?

Copy link
Copy Markdown
Collaborator Author

@basiav basiav Jul 16, 2025

Choose a reason for hiding this comment

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

Maybe, it may be expanded later with embeddings returning/nicer results interface, so you kind of sensed it right that it might be changed. But a list object for now. Is it ok? I was rather explaining why a list not np.empty like the rest.

chain_strength: float | None = None,
use_clique_embedding: bool = False,
elapse_times: bool = False,
return_sampleset_metadata: bool = True,
Copy link
Copy Markdown
Owner

@kacper3615 kacper3615 Jul 9, 2025

Choose a reason for hiding this comment

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

Rename the variable accordingly to what you did in QHyper. As I suggested earlier, this flag should be in the method, not in the constructor

Copy link
Copy Markdown
Collaborator Author

@basiav basiav Jul 16, 2025

Choose a reason for hiding this comment

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

Yes, but it's connected to the issue I opened qc-lab/QHyper#57
and to the QHyper.Advantage.init method. Please take a look at the analogical comment in QHyper's PR:
qc-lab/QHyper#55 (comment).

self.use_clique_embedding = use_clique_embedding
self._use_weights = use_weights
self.elapse_times = elapse_times
self.return_sampleset_metadata = return_sampleset_metadata
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

rename the variable name accordingly to what you did in QHyper

Copy link
Copy Markdown
Collaborator Author

@basiav basiav Jul 16, 2025

Choose a reason for hiding this comment

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

Done. May I ask what is a good practice, shall I make them private (with underscore _)? HierarchicalSearcher accesses it (self.sampler.return_metadata).


def sample_qubo_to_dict(self) -> dict:
sample = self.advantage.solve()
def sample_qubo_to_dict(self, return_sampleset_metadata: bool | None = None) -> dict:
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

There is no reason to use two flags for the same thing: one as a method argument, second as a constructor argument. Leave this one and remove one from the constructor

Copy link
Copy Markdown
Collaborator Author

@basiav basiav Jul 16, 2025

Choose a reason for hiding this comment

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

This one is related to the issue I opened qc-lab/QHyper#57 and to #10 (comment). Please take a look and read it carefully.

I'd like to ask you for help with this one.
Originally, in the HierarchicalSampler interface .sample_qubo_to_dict(self) has no args, only self:
obraz
So I added this flag "artificially" to the AdvantageSampler and do a check in the HierarchicalSearcher:
obraz.
Is it ok? Wanted to keep it as a bool (True) or None just for safety so that when some other method/class calls Advantage.sample_qubo_to_dict(), the empty brackets would mean a None and would keep the interface safe.

Could you please suggest a better sofware engineering approach to it?

Copy link
Copy Markdown
Owner

@kacper3615 kacper3615 left a comment

Choose a reason for hiding this comment

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

I wrote comments next to the proposed changes

@basiav
Copy link
Copy Markdown
Collaborator Author

basiav commented Jul 16, 2025

  1. I applied changes to the resolved comments. I put comments to the suggestions I haven't resolved yet and explained why not.
  2. I opened a QHyper issue connected to both Qommunity and QHyper changes:

qc-lab/QHyper#57

@basiav basiav requested a review from kacper3615 July 16, 2025 17:21
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