New correlation primitives, solver and image classification demo - #132
Open
toncho11 wants to merge 7 commits into
Open
New correlation primitives, solver and image classification demo#132toncho11 wants to merge 7 commits into
toncho11 wants to merge 7 commits into
Conversation
Added a new solver that can take advantage of these primitives. A new image classification demo.
gcattan
reviewed
Sep 5, 2026
| return m[0] if n_shots == 1 else m | ||
| if n_shots == 1: | ||
| return all_m[:, 0, :], all_E[:, 0], all_scales | ||
| return all_m, all_E, all_scales |
Collaborator
There was a problem hiding this comment.
In CaSuDa and Gibbs solver, it returns all_I, all_m and E.
(the order may be inverted).
Worth checking if this breaks annealing.execute
| for name, scale in scales.items(): | ||
| field += scale * fields[name] | ||
| h += scale * comp_h[name] | ||
| return -0.5 * np.sum(m * field, axis=1) - m @ h |
Collaborator
There was a problem hiding this comment.
The sign convention may differ from the existing solvers. Can you check?
| tau=0.1, component_schedules=None, block_size=None): | ||
| super().__init__(Nt, dt, i0, expected_mean, seed, backend, tau) | ||
| if self.backend.xp is not np: | ||
| raise NotImplementedError("CorrelationAnnealingSolver currently supports NumpyBackend only") |
Collaborator
There was a problem hiding this comment.
ok, I just realise that the Gibbs solver itself is probably not compatible with Torch. Let me open follow-up
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Added new correlation primitives.
Added a new solver that can take advantage of these primitives.
Added a new image classification demo.
The image classification uses p-kit in an elegant way, not just use p-kit in some way! The algorithm uses a PCircuit more than other implementations I tried. It does not give currently the best results compared to some other experiments I did, but it is the right direction and there is space for optimization. The new primitives and solver (used in this image classification demo) can be used by other algorithms and other users/researchers. Calculation speed has been optimized as the first version was impossibly slow. Also note that the training is very fast, but then the inference is slow.