feat: quantum-inspired error correction for sensor robustness (Priority 3.3)#37
Merged
InauguralPhysicist merged 1 commit intoNov 14, 2025
Conversation
…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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.