Embodied AI Application Framework - Implementation Plan
Date: 2025-11-02 Architecture: Hybrid (Python Framework + Graph IR + DSL) Target Timeline: 12-16 weeks for core functionality
Executive Summary
Section titled “Executive Summary”This plan details the implementation of a comprehensive Embodied AI Application framework that enables:
- Authoring complete embodied AI applications in Python
- Capturing computational graphs for analysis
- Benchmarking end-to-end performance
- Transpiling to C++/Rust for production deployment
Key Innovation: Extend beyond individual DNN benchmarking to complete control loop applications with heterogeneous operators.
Existing Infrastructure (Leverage)
Section titled “Existing Infrastructure (Leverage)”We have significant infrastructure already available:
| Component | Status | Integration Point |
|---|---|---|
| PyTorch FX | Available | Graph capture for DNNs |
| MLIR/IREE | Available | C++ IR analysis & compilation |
| Python Profiling/Tracing | Available | Execution trace capture |
| Simulators (Functional/Perf/Energy) | Available | Benchmark backends |
| Compiler/Runtime Modeler | Available | Hardware mapping analysis |
| Current Agent System | Implemented | Extend for applications |
Strategy: Build new framework on top of existing infrastructure rather than reinventing.
Phase 1: Foundation - Core Application Framework
Section titled “Phase 1: Foundation - Core Application Framework”Duration: 3-4 weeks Goal: Enable users to write embodied AI applications in Python
Milestone 1.1: Base Framework Classes (Week 1)
Section titled “Milestone 1.1: Base Framework Classes (Week 1)”Tasks:
- Design application base class hierarchy
- Implement
EmbodiedAIAppbase class - Create operator interface (
OperatorABC) - Implement sensor/actuator abstractions
- Design type system for data flow
Deliverables:
src/embodied_ai_architect/app/base.pysrc/embodied_ai_architect/app/operator.pysrc/embodied_ai_architect/app/sensors.pysrc/embodied_ai_architect/app/actuators.pysrc/embodied_ai_architect/app/types.py- Unit tests for base classes
Acceptance Criteria:
# User can write:class MyApp(EmbodiedAIApp): def __init__(self): self.sensor = Sensor("camera", shape=(3, 224, 224)) self.actuator = Actuator("motors", shape=(4,))
def step(self): data = self.sensor.read() output = self.process(data) self.actuator.write(output)Milestone 1.2: Control Loop Framework (Week 2)
Section titled “Milestone 1.2: Control Loop Framework (Week 2)”Tasks:
- Implement
@control_loopdecorator - Create execution scheduler
- Implement timing and frequency control
- Add state management
- Design data bundle classes (SensorBundle, ActuatorBundle)
Deliverables:
src/embodied_ai_architect/app/decorators.pysrc/embodied_ai_architect/app/scheduler.pysrc/embodied_ai_architect/app/bundles.pysrc/embodied_ai_architect/app/runtime.py- Integration tests
Acceptance Criteria:
@embai_application(name="test_app")class TestApp: @control_loop(frequency=30) # 30 Hz def step(self, sensors: SensorBundle) -> ActuatorBundle: # Runs at specified frequency return ActuatorBundle(motors=control)Milestone 1.3: Graph IR Data Structures (Week 3)
Section titled “Milestone 1.3: Graph IR Data Structures (Week 3)”Tasks:
- Design graph IR schema
- Implement node/edge data structures
- Create graph builder API
- Implement graph validation
- Add graph visualization (GraphViz export)
Deliverables:
src/embodied_ai_architect/graph/ir.pysrc/embodied_ai_architect/graph/nodes.pysrc/embodied_ai_architect/graph/edges.pysrc/embodied_ai_architect/graph/builder.pysrc/embodied_ai_architect/graph/validation.pysrc/embodied_ai_architect/graph/visualization.py
Acceptance Criteria:
graph = EmbodiedAIGraph()graph.add_operator("detector", PyTorchOperator(...))graph.add_edge("sensors.camera", "detector.input")graph.validate() # Check data types, cycles, etc.graph.visualize("app_graph.png")Milestone 1.4: Simple Example Application (Week 4)
Section titled “Milestone 1.4: Simple Example Application (Week 4)”Tasks:
- Create reference implementation (e.g., object tracking)
- Write comprehensive documentation
- Add examples directory
- Create tutorial notebook
Deliverables:
examples/simple_tracking_app.pyexamples/notebooks/application_tutorial.ipynbdocs/guides/writing-applications.md- Architecture documentation updates
Acceptance Criteria:
- Example app runs successfully
- Documentation is clear and comprehensive
- Tutorial guides new users through app creation
Phase 2: Operator Library
Section titled “Phase 2: Operator Library”Duration: 2-3 weeks Goal: Provide rich library of operators for common embodied AI tasks
Milestone 2.1: PyTorch Operator Integration (Week 5)
Section titled “Milestone 2.1: PyTorch Operator Integration (Week 5)”Tasks:
- Create PyTorchOperator wrapper
- Integrate with existing ModelAnalyzerAgent
- Handle input/output tensor shapes
- Support for common architectures (CNN, ResNet, YOLO, etc.)
- Add model loading utilities
Deliverables:
src/embodied_ai_architect/operators/pytorch_operator.pysrc/embodied_ai_architect/operators/model_loader.py- Unit tests with real models
- Integration with PyTorch FX
Acceptance Criteria:
detector = PyTorchOperator( model=torch.load("yolov5.pt"), input_shape=(1, 3, 640, 640))detections = detector(image_tensor)Milestone 2.2: Classical Algorithm Operators (Week 6-7)
Section titled “Milestone 2.2: Classical Algorithm Operators (Week 6-7)”Tasks:
- Implement KalmanFilter operator
- Implement PIDController operator
- Implement PathPlanner operators (A*, RRT*)
- Add common preprocessing operators (resize, normalize, etc.)
- Create operator catalog/registry
Deliverables:
src/embodied_ai_architect/operators/kalman_filter.pysrc/embodied_ai_architect/operators/pid_controller.pysrc/embodied_ai_architect/operators/path_planners.pysrc/embodied_ai_architect/operators/preprocessing.pysrc/embodied_ai_architect/operators/registry.py- Comprehensive operator tests
Acceptance Criteria:
kf = KalmanFilter(state_dim=6, measurement_dim=3)state = kf.predict()state = kf.update(measurement)
pid = PIDController(kp=1.0, ki=0.1, kd=0.01)control = pid.compute(current, setpoint)
planner = PathPlanner(algorithm="rrt_star")path = planner.plan(start, goal, obstacles)Milestone 2.3: Operator Type System (Week 7)
Section titled “Milestone 2.3: Operator Type System (Week 7)”Tasks:
- Define operator input/output types
- Implement type checking system
- Add type inference
- Create type validation framework
- Add runtime type assertions
Deliverables:
src/embodied_ai_architect/operators/types.pysrc/embodied_ai_architect/operators/type_checker.py- Type annotation examples
- Documentation on type system
Acceptance Criteria:
# Type errors caught at graph construction:detector.output_type # → Tensor[float32, (N, 5)]kalman.input_type # → Vector[float32, (3,)]# Mismatched types detected before executionPhase 3: Graph Capture & Tracing
Section titled “Phase 3: Graph Capture & Tracing”Duration: 2 weeks Goal: Automatically capture computational graphs from Python execution
Milestone 3.1: PyTorch FX Integration (Week 8)
Section titled “Milestone 3.1: PyTorch FX Integration (Week 8)”Tasks:
- Create tracer using PyTorch FX
- Handle DNN graph capture
- Extract DNN subgraphs
- Integrate with existing graph IR
Deliverables:
src/embodied_ai_architect/graph/tracer_fx.py- FX-based graph capture
- Integration tests with real models
Acceptance Criteria:
app = MyApp()tracer = FXTracer()graph = tracer.trace(app.step)# Graph contains all PyTorch operationsMilestone 3.2: Full Application Tracing (Week 9)
Section titled “Milestone 3.2: Full Application Tracing (Week 9)”Tasks:
- Extend tracing beyond PyTorch operations
- Capture calls to custom operators
- Handle control flow (if/else, loops)
- Build complete application graph
- Add debugging/introspection tools
Deliverables:
src/embodied_ai_architect/graph/tracer.pysrc/embodied_ai_architect/graph/control_flow.py- Full application graph capture
- Debugging utilities
Acceptance Criteria:
app = DroneNav()graph = app.compile()# Graph includes: detector, kalman, planner, controller# All data flow edges captured# Control flow annotatedPhase 4: Benchmarking Framework
Section titled “Phase 4: Benchmarking Framework”Duration: 2-3 weeks Goal: Benchmark complete applications end-to-end
Milestone 4.1: Dataset Infrastructure (Week 10)
Section titled “Milestone 4.1: Dataset Infrastructure (Week 10)”Tasks:
- Design dataset interface
- Implement ROS bag loader
- Create custom dataset format
- Add dataset preprocessing
- Support for ground truth annotations
Deliverables:
src/embodied_ai_architect/datasets/base.pysrc/embodied_ai_architect/datasets/rosbag.pysrc/embodied_ai_architect/datasets/custom.pysrc/embodied_ai_architect/datasets/preprocessing.py- Example datasets
Acceptance Criteria:
dataset = RosbagDataset("flight_001.bag")for sample in dataset: camera_image = sample.sensors["camera"] imu_reading = sample.sensors["imu"] ground_truth = sample.ground_truthMilestone 4.2: Metrics Collection (Week 11)
Section titled “Milestone 4.2: Metrics Collection (Week 11)”Tasks:
- Design metrics framework
- Implement latency metrics (mean, p50, p95, p99)
- Implement accuracy metrics (task-specific)
- Implement energy metrics (via simulators)
- Add per-operator profiling
Deliverables:
src/embodied_ai_architect/benchmark/metrics/base.pysrc/embodied_ai_architect/benchmark/metrics/latency.pysrc/embodied_ai_architect/benchmark/metrics/accuracy.pysrc/embodied_ai_architect/benchmark/metrics/energy.pysrc/embodied_ai_architect/benchmark/profiler.py
Acceptance Criteria:
metrics = [ LatencyMetric(percentiles=[50, 95, 99]), AccuracyMetric(iou_threshold=0.5), EnergyMetric()]results = benchmark.run(metrics=metrics)# Per-operator and end-to-end metrics collectedMilestone 4.3: Application Benchmark Harness (Week 12)
Section titled “Milestone 4.3: Application Benchmark Harness (Week 12)”Tasks:
- Create ApplicationBenchmark class
- Integrate with existing BenchmarkAgent
- Add simulator backend integration
- Implement result aggregation
- Generate comparison reports
Deliverables:
src/embodied_ai_architect/benchmark/application_benchmark.py- Integration with existing infrastructure
src/embodied_ai_architect/benchmark/backends/simulator.py- Report generation for applications
Acceptance Criteria:
benchmark = ApplicationBenchmark( application=app.compile(), dataset=dataset, metrics=metrics)results = benchmark.run(backends=[ LocalCPU(), JetsonAGX(), Simulator(energy_model="nvidia_orin")])report = results.generate_report()Phase 5: MLIR/IREE Integration
Section titled “Phase 5: MLIR/IREE Integration”Duration: 3-4 weeks Goal: Connect to existing MLIR/IREE infrastructure for compilation
Milestone 5.1: MLIR Export (Week 13-14)
Section titled “Milestone 5.1: MLIR Export (Week 13-14)”Tasks:
- Design IR → MLIR mapping
- Implement graph traversal for export
- Handle operator lowering to MLIR
- Map PyTorch ops to MLIR dialects
- Export complete application graphs
Deliverables:
src/embodied_ai_architect/codegen/mlir_exporter.pysrc/embodied_ai_architect/codegen/mlir_dialects.py- MLIR generation from graphs
- Integration tests
Acceptance Criteria:
graph = app.compile()mlir_module = graph.to_mlir()# Valid MLIR module with all operatorsMilestone 5.2: IREE Compilation Pipeline (Week 15)
Section titled “Milestone 5.2: IREE Compilation Pipeline (Week 15)”Tasks:
- Create IREE compiler integration
- Configure compilation targets
- Add optimization passes
- Generate executable artifacts
- Benchmark compiled applications
Deliverables:
src/embodied_ai_architect/codegen/iree_compiler.py- IREE compilation integration
- Hardware-specific optimizations
- Compiled artifact execution
Acceptance Criteria:
compiler = IREECompiler(target="nvidia_orin")binary = compiler.compile(mlir_module)runtime = IREERuntime(binary)results = runtime.execute(inputs)Milestone 5.3: Hardware Mapping Analysis (Week 16)
Section titled “Milestone 5.3: Hardware Mapping Analysis (Week 16)”Tasks:
- Integrate with existing compiler/runtime modeler
- Analyze operator placement
- Evaluate different mapping strategies
- Provide hardware recommendations
- Feed back to HardwareProfileAgent
Deliverables:
src/embodied_ai_architect/analysis/hardware_mapping.py- Integration with compiler modeler
- Mapping strategy evaluation
- Updated hardware recommendations
Acceptance Criteria:
mapper = HardwareMapper(graph, target_hardware)strategies = mapper.evaluate_mappings()best_strategy = mapper.recommend()# Recommendations: place detector on GPU, kalman on CPUPhase 6: DSL Serialization
Section titled “Phase 6: DSL Serialization”Duration: 1-2 weeks Goal: Enable graph serialization and storage
Milestone 6.1: DSL Format Definition (Week 17)
Section titled “Milestone 6.1: DSL Format Definition (Week 17)”Tasks:
- Define JSON schema for applications
- Create DSL specification document
- Add schema validation
- Design versioning strategy
Deliverables:
docs/specifications/application-dsl-v1.md- JSON schema file
- Validation utilities
- Examples in DSL format
Acceptance Criteria:
{ "application": {...}, "operators": [...], "dataflow": [...], "schedule": [...]}Milestone 6.2: Serialization Implementation (Week 18)
Section titled “Milestone 6.2: Serialization Implementation (Week 18)”Tasks:
- Implement IR → DSL serializer
- Implement DSL → IR deserializer
- Add round-trip testing
- Handle versioning and migrations
Deliverables:
src/embodied_ai_architect/dsl/serializer.pysrc/embodied_ai_architect/dsl/deserializer.pysrc/embodied_ai_architect/dsl/validation.py- Round-trip tests
Acceptance Criteria:
# Serializedsl_dict = graph.to_dsl()with open("app.json", "w") as f: json.dump(dsl_dict, f)
# Deserializegraph2 = EmbodiedAIGraph.from_dsl(dsl_dict)assert graph == graph2 # Round-trip successfulPhase 7: C++/Rust Transpilation (Future Work)
Section titled “Phase 7: C++/Rust Transpilation (Future Work)”Duration: 4+ weeks Goal: Generate production-ready C++/Rust code
Milestone 7.1: C++ Code Generation
Section titled “Milestone 7.1: C++ Code Generation”Tasks:
- Design C++ code generation templates
- Implement operator code generators
- Generate runtime library
- Add build system integration (CMake)
- Validate generated code correctness
Milestone 7.2: Runtime Library
Section titled “Milestone 7.2: Runtime Library”Tasks:
- Implement C++ runtime library
- Port operators to C++
- Add scheduling and timing
- Integrate with IREE runtime
Milestone 7.3: Rust Code Generation (Optional)
Section titled “Milestone 7.3: Rust Code Generation (Optional)”Tasks:
- Rust code generation templates
- Memory safety verification
- Cargo build integration
Integration Points with Existing System
Section titled “Integration Points with Existing System”With Current Agents
Section titled “With Current Agents”| Existing Component | Integration |
|---|---|
| ModelAnalyzerAgent | Used by PyTorchOperator for analysis |
| BenchmarkAgent | Extended for application benchmarking |
| HardwareProfileAgent | Receives application-level recommendations |
| ReportSynthesisAgent | Generates application benchmark reports |
With Infrastructure
Section titled “With Infrastructure”| Infrastructure | Integration |
|---|---|
| PyTorch FX | Graph capture for DNNs |
| MLIR/IREE | Compilation backend |
| Simulators | Benchmark backends |
| Compiler Modeler | Hardware mapping analysis |
| CLI | New branes app commands |
CLI Extensions
Section titled “CLI Extensions”Add new command group:
# Application commandsbranes app create <name> # Scaffold new appbranes app validate <app.py> # Validate applicationbranes app compile <app.py> # Compile to graph IRbranes app visualize <app.py> # Visualize graphbranes app benchmark <app.py> # Benchmark applicationbranes app export <app.py> # Export to DSL/MLIR/C++
# Examplesbranes app benchmark drone_nav.py \ --dataset flight_001.bag \ --backend jetson_agx \ --metrics latency,accuracy,energyTesting Strategy
Section titled “Testing Strategy”Unit Tests
Section titled “Unit Tests”- All operator implementations
- Graph IR operations
- Type checking system
- Serialization round-trips
Integration Tests
Section titled “Integration Tests”- Complete application workflows
- Benchmarking pipelines
- MLIR/IREE compilation
- Multi-backend execution
End-to-End Tests
Section titled “End-to-End Tests”- Reference applications (drone nav, robot manipulation)
- Real datasets (ROS bags)
- Hardware deployment (if available)
Performance Tests
Section titled “Performance Tests”- Profiling overhead measurement
- Compilation time benchmarks
- Runtime performance validation
Risk Mitigation
Section titled “Risk Mitigation”| Risk | Mitigation |
|---|---|
| PyTorch FX tracing complexity | Start with simple operators, gradual expansion |
| MLIR integration difficulties | Early prototype, seek IREE community help |
| Operator library incompleteness | Prioritize common operators, extensibility |
| Performance overhead | Profile early, optimize hot paths |
| Control flow handling | Use symbolic execution, limit dynamic behavior |
Success Metrics
Section titled “Success Metrics”Phase 1-2 Success:
Section titled “Phase 1-2 Success:”- ✅ Can write 3+ example applications
- ✅ All operators work correctly
- ✅ Type system catches errors
Phase 3-4 Success:
Section titled “Phase 3-4 Success:”- ✅ Graph capture success rate > 95%
- ✅ Benchmark 5+ applications
- ✅ Per-operator latency breakdown
Phase 5-6 Success:
Section titled “Phase 5-6 Success:”- ✅ MLIR export works for all operators
- ✅ IREE compilation successful
- ✅ DSL round-trip 100% accurate
Overall Success:
Section titled “Overall Success:”- ✅ 10+ reference applications
- ✅ Performance within 10% of hand-written C++
- ✅ Deployment to real hardware
- ✅ External users can write applications
Timeline Summary
Section titled “Timeline Summary”| Phase | Weeks | Key Deliverable |
|---|---|---|
| 1: Foundation | 4 | Application framework |
| 2: Operators | 3 | Operator library |
| 3: Tracing | 2 | Graph capture |
| 4: Benchmarking | 3 | Application benchmarks |
| 5: MLIR/IREE | 4 | Compilation pipeline |
| 6: DSL | 2 | Serialization |
| Total (Core) | 18 | Production-ready framework |
| 7: Transpilation | 4+ | C++/Rust code generation |
Total with transpilation: 22+ weeks (~5-6 months)
Dependencies
Section titled “Dependencies”External:
- PyTorch >= 2.0 (FX support)
- MLIR/IREE (existing)
- ROS (optional, for datasets)
- NumPy/SciPy
- GraphViz (for visualization)
Internal:
- Existing agent system
- Existing benchmark infrastructure
- CLI framework
- Secrets management
Next Steps
Section titled “Next Steps”-
Immediate (This Week):
- Review and approve this plan
- Set up project board with milestones
- Create feature branch:
feature/embodied-ai-applications - Begin Phase 1, Milestone 1.1
-
Short Term (Next 2 Weeks):
- Complete Phase 1, Milestone 1.1-1.2
- Create first simple example
- Document architecture decisions
-
Medium Term (Next 4 Weeks):
- Complete Phase 1
- Begin Phase 2
- Prototype MLIR integration
-
Long Term (3 Months):
- Complete Phases 1-4
- Begin MLIR/IREE integration
- Publish early access to external users
Questions for Discussion
Section titled “Questions for Discussion”- Operator Priority: Which operators are most critical? (Kalman, PID, path planners?)
- Dataset Format: Prioritize ROS bags or custom format?
- MLIR/IREE Timeline: Can we access IREE team for integration help?
- Hardware Access: Which hardware platforms for real deployment tests?
- Resource Allocation: How many developers on this project?
- External Dependencies: Any concerns about PyTorch FX limitations?
Appendix: Reference Applications
Section titled “Appendix: Reference Applications”Planned reference applications to validate framework:
-
Drone Navigation (Phase 1)
- Object detection → Kalman filter → Path planning → PID control
- Dataset: Simulated drone flight
-
Robot Arm Manipulation (Phase 2)
- Object detection → Pose estimation → Inverse kinematics → Trajectory control
- Dataset: Pick-and-place tasks
-
Autonomous Vehicle (Phase 3)
- Lane detection → Vehicle tracking → Path planning → MPC control
- Dataset: KITTI or Waymo Open Dataset
-
Legged Robot Locomotion (Phase 4)
- Terrain classification → Gait planning → Joint control
- Dataset: ANYmal or Spot robot logs
-
Humanoid Balance (Phase 5)
- IMU processing → State estimation → Balance control
- Dataset: Atlas or Digit robot data