Depth Control Callback#

Depth Scheduling Callback#

Adaptive control of circuit or model depth across epochs or iterations.

This callback linearly interpolates an integer-valued depth attribute from a starting value to an ending value over a given number of epochs. It updates either a backend or a model object, depending on which one is provided in the callback context.

class qmlhc.callbacks.depth_control.DepthScheduler(target_attr='depth', start=1, end=6, epochs=10)[source]#

Bases: Callback

Gradually adjust a depth-like attribute during training.

The scheduler linearly interpolates the target attribute (default: "depth") from start to end over epochs steps. At the beginning of each epoch, it writes the new integer depth into the object passed via the callback context (context["model"] or context["backend"]).

Parameters:
  • target_attr (str, optional) – Name of the attribute to update, by default "depth".

  • start (int, optional) – Starting depth value, by default 1.

  • end (int, optional) – Final depth value reached at or before the last epoch, by default 6.

  • epochs (int, optional) – Number of epochs over which to interpolate (minimum 1), by default 10.

on_epoch_begin(epoch, context)[source]#

Update the target object’s depth attribute at the start of each epoch.

The method looks for a "model" or "backend" entry in context. If present and the object exposes the target attribute, it is updated with the interpolated integer value.

Parameters:
  • epoch (int) – Current epoch index (0-based).

  • context (Mapping[str, Any]) – Callback context, expected to include "model" or "backend".

Return type:

None

on_epoch_end(epoch, context)[source]#

No-op: provided for interface completeness.

Return type:

None

on_error(error, context)[source]#

No-op: provided for interface completeness.

Return type:

None

on_step_begin(step, context)[source]#

No-op: provided for interface completeness.

Return type:

None

on_step_end(step, context)[source]#

No-op: provided for interface completeness.

Return type:

None