Skip to content

feat: quantum-inspired error correction for sensor robustness (Priority 3.3)#37

Merged
InauguralPhysicist merged 1 commit into
mainfrom
claude/test-latest-commit-01QSQV3zRfFfVNk4XFGV8WQv
Nov 14, 2025
Merged

feat: quantum-inspired error correction for sensor robustness (Priority 3.3)#37
InauguralPhysicist merged 1 commit into
mainfrom
claude/test-latest-commit-01QSQV3zRfFfVNk4XFGV8WQv

Conversation

@InauguralPhysicist

Copy link
Copy Markdown
Owner

No description provided.

…ty 3.3)

Implements redundant sensor encoding with parity checks (inspired by quantum
error correction) for robust state estimation despite sensor failures.

**Core Innovation:**
Uses quantum error correction principles (redundancy + syndrome extraction)
to detect and correct measurement errors from faulty sensors, enabling
reliable control despite individual sensor failures.

**New Module: src/eigen_qec.py (460 lines)**

Functions:
- encode_state_redundant(): Create n redundant copies (like quantum repetition code)
- apply_measurement_errors(): Simulate sensor failures and noise
- compute_parity_checks(): Compute syndromes to detect errors
  For 3 sensors: checks (0 vs 1), (1 vs 2), (0 vs 2)
- detect_error_location(): Identify faulty sensor from syndrome pattern
  Syndrome [1,0,1] → sensor 0 faulty (differs from 1 and 2)
  Syndrome [1,1,0] → sensor 1 faulty (differs from 0 and 2)
  Syndrome [0,1,1] → sensor 2 faulty (differs from 0 and 1)
- correct_measurement_errors(): Majority voting excluding faulty sensor
- qec_control_step(): Control step with error-corrected measurements
- simulate_sensor_array(): Simulate redundant sensors with failures

**Quantum Error Correction Principles:**

Classical Repetition Code:
- Encode: |ψ⟩ → |ψψψ⟩ (redundant copies)
- Parity checks detect which copy differs
- Majority vote corrects single errors

Applied to Robotics:
- Encode state across 3+ redundant sensors
- Parity checks: compare all sensor pairs
- Syndrome pattern identifies faulty sensor
- Exclude faulty sensor, average remaining ones

**Algorithm:**

1. Encode: Create redundant sensor measurements
2. Parity Checks:
   - syndromes[i] = ||sensor[i] - sensor[i+1]||
   - Large syndrome → inconsistency detected
3. Error Detection:
   - Pattern [0,0,0] → no error
   - Pattern [1,0,1] → sensor 0 has error
   - Pattern [1,1,0] → sensor 1 has error
   - Pattern [0,1,1] → sensor 2 has error
4. Correction:
   - If error detected: exclude faulty sensor
   - Average remaining good sensors
5. Control:
   - Use corrected measurement
   - Move toward target

**Important Design Choice:**

2-sensor case: Cannot determine which sensor is wrong → average both
3+ sensors: Can identify and exclude faulty sensor via syndrome pattern

**Tests: tests/test_qec.py (31 tests, 82.54% coverage)**

Test suites:
- TestEncodeStateRedundant: Copy creation, independence
- TestApplyMeasurementErrors: Error simulation at different rates
- TestComputeParityChecks: Syndrome computation, length validation
- TestDetectErrorLocation: Syndrome pattern decoding for 3-sensor system
- TestCorrectMeasurementErrors: Error detection and majority voting
- TestQECControlStep: Control robustness to measurement errors
- TestSimulateSensorArray: Sensor failure simulation
- TestQECBenefits: QEC vs naive averaging comparison

**Benchmark Results:**

benchmark_qec.py tests across 3 failure rate scenarios:
- Low: 10% sensor failure rate per step
- Medium: 30% sensor failure rate
- High: 50% sensor failure rate

Performance vs naive averaging (no error correction):
- Average Error Improvement: +60.5%
- Average Success Improvement: +3.3%

Breakdown:
- 10% failures: +100% error reduction (0.198 → 0.000), perfect convergence
- 30% failures: +66.7% error reduction (0.560 → 0.186), +5% success
- 50% failures: +14.7% error reduction (0.780 → 0.665), +5% success

**Key Achievement:**
Perfect goal reaching (zero error) in low-failure scenarios. QEC correctly
detects and excludes faulty sensors (~9-36 errors detected per 100 steps),
while naive averaging gets corrupted by outliers.

At 10% failure rate: QEC achieves zero error vs 0.198 for naive
At 30% failure rate: QEC reduces error by 67%
At 50% failure rate: Still provides 15% benefit despite half sensors failing

**Updated Exports:**
- src/__init__.py: Added 7 new functions to public API

**Implementation Fix:**
Fixed 2-sensor case in detect_error_location():
- Changed from returning sensor 0 as default to returning None
- Reason: With only 2 sensors, cannot determine which is faulty
- Better to average both than to arbitrarily exclude one

Priority 3.3 complete. Framework now features robust sensor fusion via
quantum-inspired error correction.
@InauguralPhysicist InauguralPhysicist merged commit 9f875e7 into main Nov 14, 2025
14 of 15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants