Skip to content

Model Management

In progress · updated 2026-10-30 · embodied-ai-architect/docs/plan/model-management.md

Three Architectures for Model Management

Architecture 1: Model Registry with Static Analysis

Approach: Analyze models at registration time, store metadata in a local database.

┌─────────────────────────────────────────────────────────────────┐ │ Model Registry │ ├─────────────────────────────────────────────────────────────────┤ │ branes model register model.pt —name “perception_v1” │ │ │ │ │ ▼ │ │ ┌─────────────────────────────────────────────────────────┐ │ │ │ Model Analyzer (static) │ │ │ │ - torch.jit.script() or trace for structure │ │ │ │ - Count params, layers, ops (FLOPs) │ │ │ │ - Detect architecture patterns (CNN, Transformer, etc) │ │ │ │ - Extract input/output shapes │ │ │ └─────────────────────────────────────────────────────────┘ │ │ │ │ │ ▼ │ │ ┌─────────────────────────────────────────────────────────┐ │ │ │ SQLite/JSON Knowledge Base │ │ │ │ { │ │ │ │ “name”: “perception_v1”, │ │ │ │ “path”: “/models/yolo.pt”, │ │ │ │ “params”: 7_200_000, │ │ │ │ “flops”: 8.9e9, │ │ │ │ “architecture”: “yolov8”, │ │ │ │ “input_shape”: [1, 3, 640, 640], │ │ │ │ “layers”: {“Conv2d”: 53, “BatchNorm2d”: 53, …} │ │ │ │ } │ │ │ └─────────────────────────────────────────────────────────┘ │ └─────────────────────────────────────────────────────────────────┘

Pros:

  • Simple, no runtime overhead
  • Works offline
  • Easy to query and filter

Cons:

  • Static analysis can miss dynamic behavior
  • Requires explicit registration
  • Limited reasoning capability

Implementation: ~500 LOC, extends existing ModelAnalyzer agent


Architecture 2: LLM-Augmented Model Understanding

Approach: Use LLM to interpret model structure and generate semantic descriptions.

┌─────────────────────────────────────────────────────────────────┐ │ LLM Model Intelligence │ ├─────────────────────────────────────────────────────────────────┤ │ │ │ ┌──────────────┐ ┌──────────────┐ ┌──────────────┐ │ │ │ Model Loader │───▶│ Introspector │───▶│ LLM Analyst │ │ │ │ │ │ │ │ │ │ │ │ - state_dict │ │ - Graph trace│ │ - Interpret │ │ │ │ - JIT load │ │ - Shape infer│ │ - Classify │ │ │ │ - ONNX load │ │ - Op census │ │ - Recommend │ │ │ └──────────────┘ └──────────────┘ └──────────────┘ │ │ │ │ │ ▼ │ │ ┌─────────────────────────────────────────────────────────┐ │ │ │ Semantic Model Card │ │ │ │ │ │ │ │ “This is a YOLOv8-small object detection model. │ │ │ │ It uses a CSPDarknet backbone with 53 convolutional │ │ │ │ layers and a PANet neck. Suitable for real-time │ │ │ │ detection on edge devices with >2 TOPS compute. │ │ │ │ │ │ │ │ Recommended hardware: Jetson Orin Nano, Hailo-8 │ │ │ │ Expected latency: 15-25ms @ 640x640 input” │ │ │ └─────────────────────────────────────────────────────────┘ │ │ │ │ │ ▼ │ │ ┌─────────────────────────────────────────────────────────┐ │ │ │ Tool: model_query │ │ │ │ User: “What models can run under 20ms on Jetson?” │ │ │ │ LLM: Queries registry, reasons about constraints │ │ │ └─────────────────────────────────────────────────────────┘ │ └─────────────────────────────────────────────────────────────────┘

Pros:

  • Rich semantic understanding
  • Natural language queries
  • Can reason about tradeoffs

Cons:

  • Requires LLM calls (cost, latency)
  • Hallucination risk for unfamiliar architectures
  • Needs good prompts

Implementation: ~800 LOC, integrates with existing ArchitectAgent


Architecture 3: Federated Model Graph with Roofline Integration

Approach: Build a graph database linking models ↔ hardware ↔ benchmarks, with roofline analysis.

┌─────────────────────────────────────────────────────────────────┐ │ Federated Model-Hardware Graph │ ├─────────────────────────────────────────────────────────────────┤ │ │ │ ┌─────────┐ ┌─────────┐ ┌─────────┐ │ │ │ Model │────────▶│ Roofline │◀────────│Hardware │ │ │ │ Node │ │ Edge │ │ Node │ │ │ └─────────┘ └─────────┘ └─────────┘ │ │ │ │ │ │ │ │ ┌──────────────┴──────────────┐ │ │ │ │ │ │ │ │ │ ▼ ▼ ▼ ▼ │ │ ┌─────────────────────────────────────────────────┐ │ │ │ Model-Hardware Fit │ │ │ │ │ │ │ │ model: yolov8s │ │ │ │ hardware: jetson_orin_nano │ │ │ │ arithmetic_intensity: 45.2 ops/byte │ │ │ │ peak_throughput: 2.1 TOPS (INT8) │ │ │ │ memory_bandwidth: 68 GB/s │ │ │ │ roofline_bound: compute │ │ │ │ predicted_latency_ms: 18.3 │ │ │ │ measured_latency_ms: 21.7 (benchmark) │ │ │ └─────────────────────────────────────────────────┘ │ │ │ │ │ ▼ │ │ ┌─────────────────────────────────────────────────┐ │ │ │ Graph Queries (Cypher-like) │ │ │ │ │ │ │ │ MATCH (m:Model)-[r:RUNS_ON]->(h:Hardware) │ │ │ │ WHERE r.latency_ms < 30 AND h.power_w < 15 │ │ │ │ RETURN m.name, h.name, r.latency_ms │ │ │ └─────────────────────────────────────────────────┘ │ └─────────────────────────────────────────────────────────────────┘

Integration with existing repos: - embodied-schemas: HardwareEntry, ModelEntry definitions - graphs: roofline model, ops_per_clock calibration data

Pros:

  • Rich relational queries
  • Integrates theory (roofline) with empirical (benchmarks)
  • Supports multi-repo architecture you already have

Cons:

  • Complex to implement
  • Requires graph DB or custom indexing
  • More infrastructure

Implementation: ~1,500 LOC, spans embodied-schemas + graphs + this repo


Comparison Matrix

AspectStatic RegistryLLM-AugmentedFederated Graph
ComplexityLowMediumHigh
Query PowerFilter/sortNatural languageGraph traversal
ReasoningNoneLLM-drivenRoofline + LLM
OfflineYesNoPartial
Multi-repoNoNoYes
LOC estimate~500~800~1,500

My Recommendation

Start with Architecture 1 (Static Registry), then layer on Architecture 2 (LLM) for reasoning:

Phase 1: Model Registry (~500 LOC) - branes model register/list/show/remove - Static analysis: params, FLOPs, shapes, layer census - JSON/SQLite storage

Phase 2: LLM Integration (~300 LOC additional) - Add model_query tool to ArchitectAgent - LLM interprets registry data for recommendations - Natural language queries

Phase 3: Graph Integration (future) - Connect to embodied-schemas Registry - Add roofline edges from graphs repo

This gives you immediate value (fix the current error, build knowledge base) while preserving the path to richer reasoning.