Skip to content

Class All/ optimize #42

@xleonplayz

Description

@xleonplayz

Class: All

Method: optimize

In this method, various classes and methods are executed to orchestrate the optimization process of the training matrix.

Overview

The optimization process involves iterating through all optimizers and activation matrices specified in data.json. For each combination, a training loop is executed multiple times to refine the training matrix. Finally, a cross-training phase is conducted to reinforce the phases across all scenarios.


Process Details

1. Optimizer Loop

This loop iterates through all optimizers stored in data.json.

  • For Each Optimizer:
    • Proceed to the Activation Matrices Loop.

2. Activation Matrices Loop

In this loop, we iterate through all activation matrices.

  • For Each Activation Matrix:
    • Evaluate Activation Matrix State:

      • Execute the get_state method to evaluate the state of the current activation matrix.
    • Initialize Optimizer:

      • Call the start method of the Optimizer class with the target state and the current optimizer.
    • Training Loop (Iteration Loop):

      This loop runs for a number of iterations specified by the Iteration value, which defines how many times we iterate with an activation matrix.

      • For Each Iteration:
        • Circuit Creation:
          • Insert the activation matrix and the training matrix into a circuit.
        • Measurement:
          • Measure the circuit to obtain measurement values.
        • Optimization:
          • Pass the measurement values to the optimizer.
          • Execute the optimize method of the Optimizer class.
          • With the newly generated matrix from the optimizer:
            • Regenerate the circuit.
            • Measure it again.
            • Pass the new measurements back to the optimizer.
    • Cross-Training Phase:

      • At the very end, execute the crosstraining(Optimizer) method to reinforce the phases for all scenarios.

Documentation and Logging

Rules for the Training Matrices

  • Saving Training Matrices:
    • Every state at the end of the training loop is saved in train.json.
      • Each matrix returned at the end of the loop is written into train.json.
  • Initial Training Matrix:
    • The initial matrix in train.json is never manipulated.
      • Every optimizer starts with this initial matrix.
      • In train.json, each optimizer gets a matrix under the initial_matrix key, which is the starting matrix from data.json.
      • All permutations through the optimizer in the iteration loop are stored as separate matrices in the optimizer's section, along with the iteration number.
  • Final Training Matrix:
    • The last training matrix is saved under final_ombc (Final Optimized Matrix Before Cross-Training).

Logging Rules

  • Logging Optimizer Usage:
    • Log every time a new optimizer is used.
  • Logging Activation Matrix Completion:
    • Log every time an activation matrix has been completed.
      • Include how many entries were made in train.json per activation matrix.

Additional Notes

  • Target States:
    • Target states are saved in train.json under:
      • The respective optimizer section.
      • The respective activation matrix section.
      • Stored as target_state.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions