Soft Algebra Optimizer for Quantum & Complex Optimization
Project description
Mobiu-Q v2.8.1
Mobiu-Q wraps your existing optimizer with Soft Algebra to filter noise and improve convergence. Same API, better results.
⚡ Quick Start
from mobiu_q import MobiuOptimizer
# PyTorch (RL, LLM, Deep Learning)
base_opt = torch.optim.Adam(model.parameters(), lr=0.0003)
opt = MobiuOptimizer(base_opt, license_key="YOUR_KEY", method="adaptive")
# Quantum (VQE, QAOA) - pass params instead of optimizer
params = np.random.randn(10)
opt = MobiuOptimizer(params, license_key="YOUR_KEY", method="standard", mode="simulation")
Note:
MobiuOptimizerauto-detects PyTorch optimizers vs numpy arrays and uses the appropriate backend.
🔧 Configuration
Methods
| Method | Best For | Default LR |
|---|---|---|
standard |
VQE, Chemistry, smooth landscapes | 0.01 (sim) / 0.02 (hw) |
deep |
QAOA, combinatorial, rugged landscapes | 0.1 |
adaptive |
RL, LLM, high-variance problems | 0.0003 |
Modes (Quantum only)
| Mode | When to Use | Gradient Method |
|---|---|---|
simulation |
Clean simulator (Qiskit Aer, PennyLane default) | Finite Difference (2N evals) |
hardware |
Real quantum hardware, FakeFez, noisy backends | SPSA (2 evals, noise-resilient) |
Rule of thumb: If your backend has noise → use hardware. If it's a perfect simulator → use simulation.
Base Optimizers (MobiuQCore only)
Available: Adam (default), AdamW, NAdam, AMSGrad, SGD, Momentum, LAMB
Note: Optimizer names are case-sensitive!
A/B Testing Parameter
# For fair comparisons, toggle Soft Algebra:
opt = MobiuOptimizer(base_opt, use_soft_algebra=True) # Default - SA enabled
opt = MobiuOptimizer(base_opt, use_soft_algebra=False) # Baseline - SA disabled
📦 Installation
pip install mobiu-q
🎯 Usage Examples
PyTorch (RL / LLM / Deep Learning)
Use MobiuOptimizer - wraps your PyTorch optimizer:
import torch
from mobiu_q import MobiuOptimizer
LICENSE_KEY = "your-license-key"
model = MyModel()
base_opt = torch.optim.Adam(model.parameters(), lr=0.0003)
opt = MobiuOptimizer(
base_opt, # Your PyTorch optimizer
license_key=LICENSE_KEY,
method="adaptive", # Best for RL/LLM
use_soft_algebra=True, # Enable Soft Algebra (default)
sync_interval=50, # Sync with cloud every N steps (default: 50)
verbose=True
)
for epoch in range(100):
loss = criterion(model(x), y)
loss.backward()
opt.step(loss.item()) # Pass loss value for Soft Algebra
opt.zero_grad()
opt.end()
Quantum VQE (Simulation)
from mobiu_q import MobiuOptimizer
import numpy as np
LICENSE_KEY = "your-license-key"
params = np.random.randn(10)
opt = MobiuOptimizer(
params, # Numpy array - auto-detects quantum mode
license_key=LICENSE_KEY,
method="standard",
mode="simulation", # Clean simulator
use_soft_algebra=True
)
for step in range(100):
params = opt.step(params, energy_fn) # Auto-computes gradient
opt.end()
Quantum VQE (Real Hardware / FakeFez)
from mobiu_q import MobiuOptimizer
opt = MobiuOptimizer(
params,
license_key=LICENSE_KEY,
method="standard",
mode="hardware", # Noisy hardware - uses SPSA
)
for step in range(100):
params = opt.step(params, energy_fn)
opt.end()
QAOA (Combinatorial Optimization)
from mobiu_q import MobiuOptimizer
opt = MobiuOptimizer(
params,
license_key=LICENSE_KEY,
method="deep", # Best for rugged landscapes
mode="hardware",
)
for step in range(150):
params = opt.step(params, maxcut_cost_fn)
opt.end()
Manual Gradient (Quantum)
from mobiu_q import MobiuOptimizer, Demeasurement
opt = MobiuOptimizer(params, license_key=LICENSE_KEY, method="standard")
for step in range(100):
energy = energy_fn(params)
gradient = Demeasurement.finite_difference(energy_fn, params)
params = opt.step(params, gradient, energy)
opt.end()
🔑 License Key
Get your key at app.mobiu.ai
# Option 1: Pass directly
opt = MobiuOptimizer(base_opt, license_key="your-key")
# Option 2: Environment variable
export MOBIU_Q_LICENSE_KEY="your-key"
# Option 3: Save to file (one time)
from mobiu_q import save_license_key
save_license_key("your-key")
🏆 Verified Benchmark Results
All benchmarks use fair A/B testing: Soft Algebra ON vs OFF, same seeds, same conditions.
🧪 Fair Testing Methodology
# PyTorch A/B test:
opt_baseline = MobiuOptimizer(base_opt, license_key=KEY, use_soft_algebra=False)
opt_mobiu = MobiuOptimizer(base_opt, license_key=KEY, use_soft_algebra=True)
# Quantum A/B test:
opt_baseline = MobiuOptimizer(params, license_key=KEY, use_soft_algebra=False)
opt_mobiu = MobiuOptimizer(params, license_key=KEY, use_soft_algebra=True)
# Same seed, same problem, same everything - only SA differs
⚛️ Quantum VQE on IBM FakeFez
| Molecule | Qubits | Improvement | Win Rate |
|---|---|---|---|
| H₂ | 2 | +52.5% | 100% |
| BeH₂ | 6 | +55.1% | 100% |
| LiH | 4 | +34.5% | 100% |
🎯 QAOA on IBM FakeFez
| Problem | Improvement | p-value |
|---|---|---|
| MaxCut | +45.1% | 0.0003 |
🎮 Reinforcement Learning
| Environment | Improvement | Win Rate |
|---|---|---|
| LunarLander-v3 | +127.8% | 96.7% |
| MuJoCo InvertedPendulum | +111% | 100% |
| MuJoCo Hopper | +41% | 80% |
💰 Finance
| Problem | Improvement |
|---|---|
| Credit Risk | +52.3% |
| Portfolio Optimization | +51.7% |
🛠️ Troubleshooting
Not Improving?
- Switch optimizer: Try
NAdamorMomentum(Quantum mode) - Switch method:
standard↔adaptive↔deep - Adjust LR: Diverging → lower by 2-5x, stuck → raise by 2x
- Reduce sync_interval: Try
sync_interval=1for more frequent updates (PyTorch)
Quantum Specific
- Noisy results? Use
mode="hardware"(enables SPSA) - Clean simulator? Use
mode="simulation"(uses finite difference)
PyTorch Specific
- High latency? Increase
sync_interval(default: 50) - Not learning? Decrease
sync_intervalto 1
📖 API Reference
MobiuOptimizer (Universal)
MobiuOptimizer(
optimizer_or_params, # torch.optim.Optimizer OR np.ndarray
license_key: str,
method: str = "adaptive", # "standard", "deep", "adaptive"
mode: str = "simulation", # "simulation", "hardware"
use_soft_algebra: bool = True,
sync_interval: int = 50, # Cloud sync frequency (PyTorch only)
verbose: bool = True
)
Auto-detection:
- If
optimizer_or_paramshas.step(),.param_groups,.zero_grad()→ PyTorch mode - Otherwise → Quantum mode (delegates to MobiuQCore)
MobiuQCore (Quantum - Low-level)
For advanced quantum use cases:
from mobiu_q import MobiuQCore
MobiuQCore(
license_key: str,
method: str = "standard",
mode: str = "simulation",
base_optimizer: str = "Adam", # Optimizer name (string!)
base_lr: float = None, # Auto-computed if None
use_soft_algebra: bool = True,
verbose: bool = True
)
🔬 How It Works
Mobiu-Q is based on Soft Algebra from Klein/Maimon theory:
SoftNumber multiplication (ε²=0):
(a, b) × (c, d) = (ad + bc, bd)
The Super-Equation Δ† detects emergence moments for adaptive scaling.
💰 Pricing
| Tier | Price | Runs |
|---|---|---|
| Free | $0 | 20 runs/month |
| Pro | $19/month | Unlimited |
Get your key at app.mobiu.ai
🧑🔬 Scientific Foundation
Based on Soft Numbers theory developed by Dr. Moshe Klein and Prof. Oded Maimon (Tel Aviv University), as presented in their book on Soft Logic and Soft Numbers.
📚 Links
- Website: mobiu.ai
- App: app.mobiu.ai
- PyPI: pypi.org/project/mobiu-q
© 2025 Mobiu Technologies. All rights reserved.
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-2.8.1.tar.gz.
File metadata
- Download URL: mobiu_q-2.8.1.tar.gz
- Upload date:
- Size: 19.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 |
a7c54ce276c6f2642fb8d60a4a53fa22cff432f563f8d5cd217c89146ad7f0ff
|
|
| MD5 |
ebb7d83ec509b2b14961cc028353203f
|
|
| BLAKE2b-256 |
db3b10a808c169ed94b7b4b452861b6a5f8546e632ff4de43873cd8b6d3ecb0c
|
File details
Details for the file mobiu_q-2.8.1-py3-none-any.whl.
File metadata
- Download URL: mobiu_q-2.8.1-py3-none-any.whl
- Upload date:
- Size: 16.7 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 |
c5af5b476400a3f11a0faf6ec1b31b4ed9440223b4528b89ad258d9ff4e65f44
|
|
| MD5 |
c4fc7439d5ab9f6bcca80d80329c9483
|
|
| BLAKE2b-256 |
fe8e7f8c9a84bfba1da8cbb00cef8ab168f502819528221a4a26e918ef234224
|