Skip to main content

One post tagged with "python-optimization"

View All Tags

Air Combat Mission Replanning #1: Overcoming CPython Latency & VRAM OOM

· 13 min read
Jaybee
AI & Robotics Engineer

Air Combat Mission Replanning #1 Cover

💡 Executive Summary (TL;DR)

  • The Target: Designing an end-to-end mission-critical software architecture for in-flight dynamic mission replanning (F-16 and F-15E air combat operations), generating and verifying tactical delta packages within 5.0 seconds over tactical data links (Link 16).
  • Real Engineering Pitfalls Encountered:
    1. The 31.4s CPython Search Latency Wall: Pure Python A* graph search over a 100 km × 100 km Digital Elevation Model (10^7 nodes) consumed up to 31.42 seconds (48.0s in ridge lines) due to dynamic object boxing, heap fragmentation, and runtime ray-casting, failing quality standard Q_3(<= 5.0 s).
    2. 8GB VRAM Dual-LLM CUDA OOM Trap: Loading two generative 7B/8B language models simultaneously demanded 11.44 GB VRAM (weights + KV-cache + CUDA overhead), immediately triggering torch.cuda.OutOfMemoryError on single-GPU developer workstations.
    3. Ground-Truth Circularity in Fuel Metrics: Stating a "\pm 1\% calculation accuracy" without access to classified military aerodynamic polar tables created an untestable circular definition.
  • Clean Production Fixes:
    1. Pre-baked Viewshed Maps & 2D Manifold A*: Pre-computed radar lines-of-sight into a contiguous 2D float NumPy matrix during scenario loading, combining 2D horizontal A* exploration with analytical altitude clamping to slash search latency to 0.259 seconds (1/20th of the 5.0s budget).
    2. KV-Cache Elimination & 4D Cost-Weight Vectorization: Discarded generative autoregressive text generation in favor of a 0.28 GB encoder (DeBERTa-v3-small) and an MLP predicting a 4D cost vector w ∈ [0, 1]^4, reducing required VRAM to 0.80 GB (90% headroom on 8GB GPU) with zero coordinate hallucination.
    3. RK4 Numerical Ground Truth: Formulated an independent Runge-Kutta 4th Order numerical integration engine calibrated via publicly released Breguet range equations (c_0 = 0.131227 hr^{-1), achieving a maximum relative error of 3.31 × 10^{-5 to mathematically verify Q_2.