Skip to content

feat(ml): integrate predictive AO sequence completion model and Kaggle training pipeline - #96

Closed
Shlok-Parekh09 wants to merge 8 commits into
PxA-Labs:mainfrom
Shlok-Parekh09:main
Closed

Shlok-Parekh09 wants to merge 8 commits into
PxA-Labs:mainfrom
Shlok-Parekh09:main

Conversation

@Shlok-Parekh09

@Shlok-Parekh09 Shlok-Parekh09 commented Aug 19, 2026

Copy link
Copy Markdown

Description

This Pull Request introduces the Slope-Domain Sequence Completion AI, which acts as a graceful fallback mechanism for the AO system. When the external frame-quality gate detects partial signal loss (e.g., from mild fog, scattering, or occlusion), this model reconstructs the missing or corrupted wavefront slopes ($\Delta x$, $\Delta y$) per sub-aperture based on the temporal consistency of past frames.

Key additions:

  • SlopeCompletionLSTM Model: A mask-conditioned LSTM architecture with a persistence-prior residual head.
  • Kaggle Cloud Training Pipeline: Robust dataset extraction, handling of CUDA architecture mismatches, and execution of a massive 100k-sample synthetic dataset training run.
  • C Integration: Added predictive_ao_complete_slopes() API for ONNX Runtime integration with zero-dependency static builds.
  • Physical Constraints: Integrated Zernike projection and stroke clamping to ensure the model outputs always map into valid actuator space without hardware cross-talk.

Related Issues

Closes #94
(Integrates with the umbrella AI fallback issue #90 and frame-quality gate #93)

Mathematical/Scientific Details

  • Architecture: Latent state-space model analogous to a Kalman filter but optimized for Taylor frozen-flow turbulence.
  • Loss Formulation: Utilizes a three-component masked slope loss:
    1. Masked reconstruction loss (gradients only flow from missing entries).
    2. Zernike-consistency regularizer (projects slopes onto the modal derivative basis to enforce physical plausibility).
    3. Temporal smoothness regularizer (exploits the Taylor frozen-flow assumption).
  • Hardware Constraints: The model output is strictly bounded by a per-spot stroke clamp ($\pm \text{pitch}_{px}/2$) and a Zernike projection that truncates high-order instability via an rcond cutoff.

Verification & Testing Done

Detail the testing performed to verify changes:

  • Compiled with GCC / NVCC on Windows/Linux (via CI)
  • Run test suite (test_slope_completion.py passed 19/19 checks)
  • Check for memory safety (Handled by the existing C static pipeline rules)
  • Performance benchmark status (FPS, Latency):
    - Inference Latency: Median ONNX Runtime CPU inference runs at ~1.1 ms.
    - Accuracy: Achieved an RMSE of 0.5201, reflecting a ~30% reduction in error compared to the baseline spatial interpolation (0.7419).

Checklist

  • My code follows the code style guides of this project (Linux kernel for C/CUDA, PEP 8 for Python).
  • I have updated the documentation (docs/, CONTRIBUTOR.md) and added Doxygen comments to public API functions.
  • I have updated CHANGELOG.md with a summary of my changes.

@Shlok-Parekh09

Copy link
Copy Markdown
Author

What about the review anything else to change

@purvanshjoshi purvanshjoshi left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a fantastic contribution. The implementation of the Slope-Domain Sequence Completion AI and the Kaggle training pipeline is well-engineered and thoroughly documented. The inclusion of physical constraints and the C integration architecture are particularly well thought out. The tests demonstrate solid improvements over the baseline. Approved.

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.

feat: AI slope-completion fallback for degraded SH-WFS frames (LSTM, temporal consistency)

2 participants