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

Clean up #55

Merged
merged 11 commits into from
Jun 26, 2024
Merged

Clean up #55

merged 11 commits into from
Jun 26, 2024

Conversation

andrea-pasquale
Copy link
Collaborator

@andrea-pasquale andrea-pasquale commented Jun 25, 2024

As I was reviewing the code I decided to remove some parts that are currently not used (or so I believe).
The script is working also on this branch.
@marekgluza I noticed that when I try to run things using the first order group commutator the code is crashing with the following error:

Traceback (most recent call last):
  File "/home/andreapasquale/boostvqe/compiling.py", line 228, in <module>
    main(args)
  File "/home/andreapasquale/boostvqe/compiling.py", line 97, in main
    _, best_s, _, eo_d = select_recursion_step_gd_circuit(
                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/andreapasquale/boostvqe/src/boostvqe/utils.py", line 320, in select_recursion_step_gd_circuit
    eo_d, s, l, eval_dict, params, best_lr = choose_gd_params(
                                             ^^^^^^^^^^^^^^^^^
  File "/home/andreapasquale/boostvqe/src/boostvqe/models/dbi/utils_gci_optimization.py", line 305, in choose_gd_params
    best_lr, best_loss, _, exit_criterion = adaptive_binary_search(
                                            ^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/andreapasquale/boostvqe/src/boostvqe/models/dbi/utils_scheduling.py", line 231, in adaptive_binary_search
    eval_func_at_points(eval_points)
  File "/home/andreapasquale/boostvqe/src/boostvqe/models/dbi/utils_scheduling.py", line 225, in eval_func_at_points
    val = loss_func(point)
          ^^^^^^^^^^^^^^^^
  File "/home/andreapasquale/boostvqe/src/boostvqe/models/dbi/utils_gci_optimization.py", line 284, in loss_func_lr
    ) = adaptive_binary_search(
        ^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/andreapasquale/boostvqe/src/boostvqe/models/dbi/utils_scheduling.py", line 231, in adaptive_binary_search
    eval_func_at_points(eval_points)
  File "/home/andreapasquale/boostvqe/src/boostvqe/models/dbi/utils_scheduling.py", line 225, in eval_func_at_points
    val = loss_func(point)
          ^^^^^^^^^^^^^^^^
  File "/home/andreapasquale/boostvqe/src/boostvqe/models/dbi/utils_gci_optimization.py", line 285, in <lambda>
    lambda s: gci.loss(s, eo_d) if s > 0 else float("inf"),
              ^^^^^^^^^^^^^^^^^
  File "/home/andreapasquale/boostvqe/src/boostvqe/models/dbi/group_commutator_iteration_transpiler.py", line 241, in loss
    circ = self.recursion_step_circuit(step_duration, eo_d, mode_dbr) + circ
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/andreapasquale/boostvqe/src/boostvqe/models/dbi/group_commutator_iteration_transpiler.py", line 279, in recursion_step_circuit
    return self.group_commutator(
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/home/andreapasquale/boostvqe/src/boostvqe/models/dbi/group_commutator_iteration_transpiler.py", line 218, in group_commutator
    "forwards": reduce(Circuit.__add__, query_list_forward[::-1]),
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/andreapasquale/qibo/src/qibo/models/circuit.py", line 264, in __add__
    raise_error(
  File "/home/andreapasquale/qibo/src/qibo/config.py", line 46, in raise_error
    raise exception(message)
ValueError: Cannot add circuits with different kwargs. nqubits is 9 for first circuit and 10 for the second.

Instead when I run with the third order commutator everything seems fine.

@marekgluza
Copy link
Contributor

(args.path / "boosting_data.json").write_text(json.dumps(metadata))

f"boosting_data_{nqubits}q_{nlayers}l_{seed}s_{epoch}e.json

@andrea-pasquale andrea-pasquale merged commit ed6d4b4 into compiling_no_results Jun 26, 2024
@Edoardo-Pedicillo Edoardo-Pedicillo deleted the refactor branch October 15, 2024 08:59
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.

3 participants