Soft Algebra Optimizer for Quantum & Complex Optimization
Project description
Mobiu-Q
Mobiu-Q is a next-generation optimizer built on Soft Algebra and Demeasurement theory, enabling stable and efficient optimization in quantum variational algorithms (VQE, QAOA).
✨ Features
- Soft Algebra update rule for stable convergence
- New: SPSA Demeasurement for noisy hardware
- New: Adaptive "Noisy Mode" presets
📦 Installation
pip install mobiu-q
🚀 Quick Start (Simulation)
Best for clean simulations or statevector backends.
import numpy as np
from mobiu_q import MobiuQCore, Demeasurement
# Initialize in standard mode (aggressive learning)
opt = MobiuQCore(mode="standard")
params = np.random.uniform(-np.pi, np.pi, 4)
for step in range(50):
# 1. Calculate Energy
E = energy_fn(params)
# 2. Exact Gradient (Finite Difference)
grad = Demeasurement.finite_difference(energy_fn, params)
# 3. Step
params = opt.step(params, grad, E)
⚡ Noise Resilience (Real Hardware)
When running on noisy quantum computers (IBM, IonQ) or noisy simulators, use SPSA and noisy mode.
# Initialize in noisy mode (robust learning, lower LR)
opt = MobiuQCore(mode="noisy")
for step in range(100):
# Demeasurement.spsa returns BOTH gradient and estimated energy
# This saves 50% of measurement cost compared to separate calls.
grad, estimated_energy = Demeasurement.spsa(energy_fn, params, c_shift=0.1)
params = opt.step(params, grad, estimated_energy)
📚 Built-in Problems
from mobiu_q import list_problems, get_energy_function
print(list_problems())
# ['h2_molecule', 'lih_molecule', 'transverse_ising', ...]
energy_fn = get_energy_function("lih_molecule")
⚙️ API Reference
MobiuQCore
MobiuQCore(
license_key=None, # Your license key (or use MOBIU_Q_LICENSE_KEY env var)
mode="standard", # 'standard' (0.05 LR) or 'noisy' (0.02 LR)
base_lr=None, # Custom learning rate (overrides mode default)
verbose=True # Print session status messages
)
💡 Choosing the Right Mode
| Mode | Learning Rate | Use When |
|---|---|---|
standard |
0.05 | Simulators (Qiskit Aer, PennyLane, Cirq) |
noisy |
0.02 | Real quantum hardware (IBM, IonQ, Rigetti) |
💡 Important Note on Modes
The mode parameter ("standard" / "noisy") only configures the optimizer's internal stability (Learning Rate, Soft Algebra decay).
- It does not automatically calculate gradients.
- For noisy environments, you must explicitly call
Demeasurement.spsa(...)in your loop to generate robust gradients.
Demeasurement
Demeasurement.finite_difference(fn, params): Accurate, requires 2*N measurements.Demeasurement.spsa(fn, params): Noisy-resistant, requires only 2 measurements total.
🔥 Full Demo: Clean vs. Noisy
See how Mobiu-Q adapts to different environments. This script compares:
- Clean Simulation: Using
mode="standard"and Finite Difference gradients. - Noisy Simulation: Using
mode="noisy"and SPSA (robust against shot noise).
import numpy as np
from mobiu_q import MobiuQCore, Demeasurement, get_energy_function
# Load problem
energy_fn = get_energy_function("h2_molecule")
# --- 1. Clean Run ---
opt_clean = MobiuQCore(mode="standard")
params = np.random.uniform(-0.5, 0.5, 4)
# Run standard optimization loop...
# --- 2. Noisy Run (Simulated) ---
def noisy_fn(p):
return energy_fn(p) + np.random.normal(0, 0.05) # Add noise
opt_noisy = MobiuQCore(mode="noisy") # Auto-tunes LR for noise
for step in range(100):
# Use SPSA for robust gradient estimation (only 2 measurements!)
grad, est_energy = Demeasurement.spsa(noisy_fn, params)
params = opt_noisy.step(params, grad, est_energy)
© Mobiu Technologies, 2025
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file mobiu_q-1.0.2.tar.gz.
File metadata
- Download URL: mobiu_q-1.0.2.tar.gz
- Upload date:
- Size: 12.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
002cdfd7cf0888c59b5916d9beb386b27180637c0508671a26faa5481c115ade
|
|
| MD5 |
c8fe2fd6d5419ffbcd66153ee359b93d
|
|
| BLAKE2b-256 |
581029b722adf8690673ee095de18676faafb0cd7377a9d738043b49d369dba0
|
File details
Details for the file mobiu_q-1.0.2-py3-none-any.whl.
File metadata
- Download URL: mobiu_q-1.0.2-py3-none-any.whl
- Upload date:
- Size: 11.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b11023e139170191ea365712b1a174d2341e482e04d74fce81de41c0d042a2b4
|
|
| MD5 |
ba1e15ed53534108e7299b5a9a61b38c
|
|
| BLAKE2b-256 |
fffee5c87671c3d24cfb1b6c8d45ac88cfbf197809b05e9df05d7a40726fb445
|