Minimal Core Demo#

Example 01 – Minimal Core Demo#

Minimal flow of a hyper-causal model:

x_t → Backend (encode/run) → HCNode (project + policy) → Ŝ_{t+1} → ConsistencyLoss

Modules exercised#

  • qmlhc.core: contracts, BackendConfig, QuantumBackend (base), HCModel

  • qmlhc.hc: HCNode, MeanPolicy

  • qmlhc.loss: ConsistencyLoss

class qmlhc.examples.ex_minimal_core_demo.ToyBackend(config)[source]

Bases: QuantumBackend

Demonstrative backend, deterministic and numerically stable.

This backend defines the minimal deterministic behavior for demonstration purposes. It applies a smooth nonlinear transformation to the encoded input and generates future projections through uniform perturbations.

run(params=None)[source]

Applies a tanh-based transformation to the encoded input.

project_future(s_t, branches=2)[source]

Generates K possible future states.

project_future(s_t, branches=2)[source]

Generate K future states around the current state.

Parameters:
  • s_t (np.ndarray) – Current state vector.

  • branches (int, optional) – Number of future branches (K). Default is 2.

Returns:

Future states matrix with shape (K, D).

Return type:

np.ndarray

run(params=None)[source]

Apply a smooth nonlinear transformation to the last encoded input.

Parameters:

params (dict or None, optional) – Optional parameters (not used in this minimal demo).

Returns:

The transformed state vector s_t.

Return type:

np.ndarray

qmlhc.examples.ex_minimal_core_demo.minimal_core_demo()[source]

Run a minimal demonstration of the hyper-causal model.

This function performs a full pass through a minimal hyper-causal pipeline: it initializes a backend, defines a node with mean policy, executes the forward step, and computes the triadic consistency loss. The results are printed to the console for inspection.

Returns:

Prints the results directly to the console.

Return type:

None