# GTA-UAV Balanced (SOFIA-Tiny backbone): SOFIA v7.1 student trained from scratch
# с двухуровневой text fusion:
#   1. Mid-level: Text-FiLM в SAT и UAV heads (модулирует feature map перед GGeM/CHP).
#   2. Late-level: GatedFusion на дескрипторах (как в DINOv3/StripNet вариантах).
#
# Trainable (~5-7M):
#   - SOFIA backbone (Tiny, ~5M, from scratch — нет pretrained)
#   - SOFIA heads (SatHead GGeM+BN+Linear, UAVHead AltitudeFiLM+CHP+BN+Linear, +Text-FiLM)
#   - DGTRS-CLIP LoRA (rank=4, ~147K)
#   - TextFusionMLP (3*768 -> 1024 -> 1024, ~3.4M, shared)
#   - Gates α_q, α_g + learnable τ
#
# Altitude (drone_height метры) подаётся в UAVHead.AltitudeFiLM из dataset meta CSV.
# Для sat — altitude=None → FiLM passthrough (γ=1, β=0).
#
# Note: SOFIA from scratch — нужно больше эпох или warmup, чем frozen DINOv3/StripNet.
#       Mamba-2 backend (mamba_ssm) даёт 2-8x speedup vs torch fallback.

include 'conf/gtauav_balanced.gin'

# ---- Backbone ----
TrainConfigGTAUAV.backbone = "sofia"
TrainConfigGTAUAV.sofia_preset = "Tiny"
TrainConfigGTAUAV.sofia_d_descriptor = 1024
TrainConfigGTAUAV.sofia_use_text_film_uav = True
TrainConfigGTAUAV.sofia_use_text_film_sat = True
TrainConfigGTAUAV.sofia_lora_rank = 4
# Mamba-1 used for Tiny (Mamba-2 torch fallback has a pre-existing reshape bug
# with channels not divisible by default headdim; switch to "mamba2" for M/L
# presets where channels % 64 == 0 OR install mamba_ssm CUDA kernels).
TrainConfigGTAUAV.sofia_mamba_variant = "mamba1"
TrainConfigGTAUAV.sofia_mamba_backend = "auto"  # mamba_ssm if installed else torch fallback

# ---- Training overrides ----
TrainConfigGTAUAV.gradient_checkpointing = False  # SOFIA from-scratch — keep activations live
TrainConfigGTAUAV.shared_encoder = True  # ignored by SOFIA but kept for logging compat

# ---- Output ----
TrainConfigGTAUAV.output_dir = "out/gtauav/with_text_sofia"
