How ameliacmu/ameliatf works
1. What this repo is
- AmeliaTF is the training/evaluation code for an airport-surface trajectory forecasting model, not the raw dataset itself.
- The main external dependency is the Amelia-48 dataset, which is expected to be preprocessed by the companion AmeliaScenes tooling and linked into datasets/.
2. Top-level execution flow
- The two runtime entrypoints are amelia_tf/train.py and amelia_tf/eval.py.
- Both are driven by Hydra configuration, so architecture is assembled from config groups rather than hard-coded scripts.
3. Configuration as the composition layer
- configs/ defines the experiment graph: data splits, model variants, trainer backends, callbacks, loggers, and debug modes.
- The repo is organized around reusable experiment presets such as single-airport, seen-*, joint, marginal, and trajectory-only variants.
- Trainer configs cover CPU/GPU/DDP/MPS paths, which matters because the README notes stable runs are currently multi-GPU-oriented.
4. Data subsystem
- amelia_tf/data/components/ contains the dataset primitives:
- base_dataset.py for shared dataset behavior,
- amelia_dataset.py for Amelia-specific scene samples.
- datamodule.py and datamodule_from_list.py wrap those datasets into PyTorch Lightning DataModules, which are the boundary between raw sample loading and model consumption.
- The data configs under configs/data/ encode airport-specific and multi-airport splits, so the dataset layer is where “seen vs unseen airport” experiment boundaries are enforced.
5. Model subsystem
- amelia_tf/models/trajpred.py appears to be the main Lightning model wrapper for trajectory prediction.
- amelia_tf/models/components/ contains the actual architectural blocks:
- amelia.py and amelia_traj.py for the main model variants,
- context.py for map/context encoding,
- self_attention.py and cross_attention.py for transformer-style scene encoding,
- gmm.py for the probabilistic trajectory decoder,
- common.py for shared layers/utilities.
- The README’s described pipeline is: scene representation/scoring → hierarchical transformer scene encoding → GMM-based future prediction.
6. Model variants and boundaries
- The repository supports both marginal and joint prediction paradigms.
- It also supports context-aware and trajectory-only versions via marginal_traj / joint_traj, which likely bypass the map/context branch while keeping the forecasting stack intact.
- That split is an important diagram boundary: shared forecasting core, optional context encoder.
7. Training loop and experiment management
- Training is built on PyTorch Lightning, with callbacks configured in configs/callbacks/ for checkpointing, early stopping, LR monitoring, model summaries, and progress bars.
- amelia_tf/utils/instantiators.py and related helpers likely glue Hydra-configured objects into Lightning modules, datamodules, loggers, and callbacks.
- This is a config-driven experiment system rather than a bespoke training loop.
8. Evaluation flow
- amelia_tf/eval.py is a standalone inference/evaluation path that loads a checkpoint and computes forecasting metrics.
- The README indicates this is also config-driven and expects an explicit ckpt_path.
- Evaluation is therefore a separate pipeline boundary from training, sharing the same data/model configs but not optimizer state.
9. Metrics, losses, and masking
- amelia_tf/utils/losses.py, metrics.py, and global_masks.py handle the forecasting objective and metric computation.
- The presence of global masks suggests scene-level validity filtering and masked aggregation across agents/timesteps.
- This is likely where ADE/FDE-style reporting is implemented, matching the paper’s metrics.
10. Data quality and preprocessing support
- datasets/error_files.py suggests explicit handling of known problematic samples or preprocessing failures.
- The repo depends on prior dataset post-processing, so the architecture assumes clean, structured scenario files rather than raw sensor feeds.
11. Logging and observability
- configs/logger/ supports multiple experiment tracking backends: TensorBoard, WandB, MLflow, Neptune, Comet, Aim, and CSV.
- This makes logging a plug-in boundary rather than a core dependency.
12. Repository/runtime conventions
- The project follows the lightning-hydra-template pattern, with .hydra/ storing resolved run configs and pyproject.toml defining Python package metadata.
- In architecture terms, this is a packaged research codebase where configuration, not code branching, selects most runtime behavior.
13. Main data path to diagram
- External Amelia dataset → processed scenario files in datasets/ → AmeliaDataset/DataModule → Lightning model (trajpred + component blocks) → loss/metrics → logger/checkpoints.
- Evaluation reuses the same dataset/model path but starts from a saved checkpoint instead of optimizer training.
14. Key diagram boundaries to preserve
- Separate external data preprocessing from this repo’s training code.
- Separate configuration assembly from execution.
- Separate data loading, model computation, and experiment tracking.
- Show optional branches for context vs trajectory-only and marginal vs joint prediction, since those are first-class architectural variations here.
Main entry points: configs Hydra cfg · trajpred.py TrajPred · instantiators.py Instantiators · amelia.py Amelia core
Components 24
External data
Preprocessed Amelia-48 scenarios linked into the repo
- Amelia-48 · Preprocessed airport-surface trajectory data consumed by this repo
- Datasets · Local scenario files and processed dataset inputs
datasets
Configuration
Hydra experiment composition and runtime presets
- Hydra cfg · Top-level config assembly for runs
configs - Data presets · Airport-specific and multi-airport data splits
configs/data - Model presets · Marginal, joint, and trajectory-only model variants
configs/model - Trainer presets · CPU, GPU, DDP, and MPS training backends
configs/trainer - Logger presets · Experiment logging backend selection
configs/logger - Callbacks · Checkpointing, early stopping, progress, and monitoring
configs/callbacks
Execution
Training and evaluation entrypoints
Data subsystem
Dataset and datamodule boundaries
- AmeliaDataset · Amelia-specific scene sample loading and formatting
amelia_tf/data/components/amelia_dataset.py - BaseDataset · Shared dataset behavior
amelia_tf/data/components/base_dataset.py - DataModule · PyTorch Lightning boundary between loading and model input
amelia_tf/data/datamodule.py - List DataModule · DataModule variant built from explicit file lists
amelia_tf/data/datamodule_from_list.py
Model subsystem
Forecasting wrapper and internal components
- TrajPred · Main forecasting wrapper around the Amelia model
amelia_tf/models/trajpred.py - Amelia core · Main marginal/joint prediction model
amelia_tf/models/components/amelia.py - Traj core · Trajectory-only variant without full context branch
amelia_tf/models/components/amelia_traj.py - Context encoder · Map and airport context encoding
amelia_tf/models/components/context.py - Attention blocks · Self-attention and cross-attention scene encoding
amelia_tf/models/components/self_attention.py - GMM decoder · Gaussian mixture future trajectory prediction
amelia_tf/models/components/gmm.py
Utilities
Losses, metrics, logging, and instantiation helpers
- Losses & metrics · Forecasting loss, ADE/FDE-style metrics, and masking
amelia_tf/utils/losses.py - Instantiators · Hydra-to-Lightning object construction helpers
amelia_tf/utils/instantiators.py - Global masks · Scene-level validity filtering and aggregation masks
amelia_tf/utils/global_masks.py - Logging utils · Logger setup and rich logging helpers
amelia_tf/utils/logging_utils.py
Connections 30
- Train → Hydra cfg: loads · Training is assembled from Hydra configs
- Eval → Hydra cfg: loads · Evaluation is assembled from Hydra configs
- Hydra cfg → Data presets: includes · Selects dataset split presets
- Hydra cfg → Model presets: includes · Selects model variant presets
- Hydra cfg → Trainer presets: includes · Selects execution backend preset
- Hydra cfg → Logger presets: includes · Selects experiment tracking backend
- Hydra cfg → Callbacks: includes · Selects training callbacks
- Data presets → Datasets: points to · Experiment splits resolve into linked dataset files
- Datasets → Amelia-48: derived from · Local datasets are processed Amelia-48 scenarios
- Train → Instantiators: wires · Builds runtime objects from config
- Eval → Instantiators: wires · Builds runtime objects from config
- Instantiators → DataModule: creates · Constructs the main Lightning DataModule
- Instantiators → List DataModule: creates · Constructs list-based data loading when needed
- DataModule → AmeliaDataset: wraps · Exposes Amelia samples to the trainer
- List DataModule → AmeliaDataset: wraps · Builds datasets from explicit file lists
- AmeliaDataset → BaseDataset: extends · Shares common dataset behavior
- Instantiators → TrajPred: creates · Constructs the Lightning forecasting module
- TrajPred → Amelia core: uses · Delegates core forecasting to the Amelia model
- TrajPred → Traj core: variant · Switches to trajectory-only forecasting core
- Amelia core → Context encoder: includes · Optional context-aware scene encoding branch
- Amelia core → Attention blocks: includes · Uses self/cross-attention for hierarchical encoding
- Traj core → Attention blocks: includes · Retains forecasting encoder blocks
- Amelia core → GMM decoder: decodes with · Produces probabilistic future trajectories
- Traj core → GMM decoder: decodes with · Produces probabilistic future trajectories
- TrajPred → Losses & metrics: optimizes · Training objective and reporting metrics
- TrajPred → Global masks: filters · Applies scene/agent/timestep validity masks
- Train → Logging utils: logs via · Training emits experiment logs and summaries
- Eval → Logging utils: logs via · Evaluation emits metrics and run output
- Logger presets → Logging utils: configures · Selects the active logging backend
- Callbacks → TrajPred: monitors · Callbacks observe checkpoints and metrics during training