Hybrid Inference Architecture
Skill Profile
(Select at least one profile to enable specific modules)
Overview
Hybrid Inference Architecture enables intelligent coordination between cloud and edge inference systems, dynamically routing inference requests based on latency requirements, model complexity, resource availability, and cost considerations. This architecture is essential for enterprises deploying AI at scale across heterogeneous environments while optimizing for performance, cost, and accuracy.
Why This Matters
- Cost Optimization: Reduces cloud infrastructure costs by 70-90% through intelligent edge offloading
- Performance: Achieves 80-95% latency reduction compared to cloud-only inference
- Reliability: Enables 99.9%+ uptime with automatic fallback mechanisms
- Scalability: Handles 10K+ concurrent requests across distributed infrastructure
- Flexibility: Supports diverse use cases from real-time IoT to batch analytics
Core Concepts & Rules
1. Core Principles
- Follow established patterns and conventions
- Maintain consistency across codebase
- Document decisions and trade-offs
2. Implementation Guidelines
- Start with the simplest viable solution
- Iterate based on feedback and requirements
- Test thoroughly before deployment
Inputs / Outputs / Contracts
- Inputs:
- Inference request (model_name, input_data, latency_requirement, model_complexity, priority)
- Resource status (edge availability, edge load, cloud availability, cloud cost)
- Model registry (model variants, accuracy, size, latency)
- Routing configuration (cost thresholds, edge preference)
- Entry Conditions:
- Edge inference endpoints deployed and accessible
- Cloud inference endpoints deployed and accessible
- Model registry populated with model variants
- Resource monitoring configured and running
- Router service deployed and healthy
- Outputs:
- Inference result (predictions, latency, cost, target used)
- Routing decision (target selected, fallback chain used)
- Metrics (latency, cost, success rate, fallback rate)
- Resource utilization (edge load, cloud usage)
- Artifacts Required (Deliverables):
- Inference router service
- Edge inference clients (MCU, GPU)
- Cloud inference client
- Fallback cache implementation
- Metrics and monitoring setup
- Acceptance Evidence:
- P95 latency < 100ms
- Routing accuracy > 95%
- Cost per inference < $0.01
- Fallback rate < 5%
- Edge utilization > 70%
- Success Criteria:
- Latency targets met (P95 < 100ms)
- Cost reduction > 70% vs cloud-only
- Reliability > 99.9% with fallback
- Routing accuracy > 95%
- Edge utilization > 70%
Skill Composition
Quick Start / Implementation Example
- Review requirements and constraints
- Set up development environment
- Implement core functionality following patterns
- Write tests for critical paths
- Run tests and fix issues
- Document any deviations or decisions
# Example implementation following best practices
def example_function():
# Your implementation here
pass
Assumptions / Constraints / Non-goals
- Assumptions:
- Development environment is properly configured
- Required dependencies are available
- Team has basic understanding of domain
- Constraints:
- Must follow existing codebase conventions
- Time and resource limitations
- Compatibility requirements
- Non-goals:
- This skill does not cover edge cases outside scope
- Not a replacement for formal training
Compatibility & Prerequisites
- Supported Versions:
- Python 3.8+
- Node.js 16+
- Modern browsers (Chrome, Firefox, Safari, Edge)
- Required AI Tools:
- Code editor (VS Code recommended)
- Testing framework appropriate for language
- Version control (Git)
- Dependencies:
- Language-specific package manager
- Build tools
- Testing libraries
- Environment Setup:
.env.example keys: API_KEY, DATABASE_URL (no values)
Test Scenario Matrix (QA Strategy)
| Type |
Focus Area |
Required Scenarios / Mocks |
| Unit |
Core Logic |
Must cover primary logic and at least 3 edge/error cases. Target minimum 80% coverage |
| Integration |
DB / API |
All external API calls or database connections must be mocked during unit tests |
| E2E |
User Journey |
Critical user flows to test |
| Performance |
Latency / Load |
Benchmark requirements |
| Security |
Vuln / Auth |
SAST/DAST or dependency audit |
| Frontend |
UX / A11y |
Accessibility checklist (WCAG), Performance Budget (Lighthouse score) |
Technical Guardrails & Security Threat Model
1. Security & Privacy (Threat Model)
- Top Threats: Injection attacks, authentication bypass, data exposure
2. Performance & Resources
3. Architecture & Scalability
4. Observability & Reliability
Agent Directives & Error Recovery
(ข้อกำหนดสำหรับ AI Agent ในการคิดและแก้ปัญหาเมื่อเกิดข้อผิดพลาด)
- Thinking Process: Analyze root cause before fixing. Do not brute-force.
- Fallback Strategy: Stop after 3 failed test attempts. Output root cause and ask for human intervention/clarification.
- Self-Review: Check against Guardrails & Anti-patterns before finalizing.
- Output Constraints: Output ONLY the modified code block. Do not explain unless asked.
Definition of Done (DoD) Checklist
Anti-patterns / Pitfalls
- ⛔ Don't: Log PII, catch-all exception, N+1 queries
- ⚠️ Watch out for: Common symptoms and quick fixes
- 💡 Instead: Use proper error handling, pagination, and logging
Reference Links & Examples
- Internal documentation and examples
- Official documentation and best practices
- Community resources and discussions
Versioning & Changelog
- Version: 1.0.0
- Changelog:
- 2026-02-22: Initial version with complete template structure
Converted and distributed by TomeVault — claim your Tome and manage your conversions.
1---2name: hybrid-inference-architecture3description: Hybrid Inference Architecture enables intelligent coordination between Use when this capability is needed.4---56# Hybrid Inference Architecture78## Skill Profile9*(Select at least one profile to enable specific modules)*10- [ ] **DevOps**11- [x] **Backend**12- [ ] **Frontend**13- [ ] **AI-RAG**14- [ ] **Security Critical**1516## Overview17Hybrid Inference Architecture enables intelligent coordination between cloud and edge inference systems, dynamically routing inference requests based on latency requirements, model complexity, resource availability, and cost considerations. This architecture is essential for enterprises deploying AI at scale across heterogeneous environments while optimizing for performance, cost, and accuracy.1819## Why This Matters20- **Cost Optimization**: Reduces cloud infrastructure costs by 70-90% through intelligent edge offloading21- **Performance**: Achieves 80-95% latency reduction compared to cloud-only inference22- **Reliability**: Enables 99.9%+ uptime with automatic fallback mechanisms23- **Scalability**: Handles 10K+ concurrent requests across distributed infrastructure24- **Flexibility**: Supports diverse use cases from real-time IoT to batch analytics2526---2728## Core Concepts & Rules2930### 1. Core Principles31- Follow established patterns and conventions32- Maintain consistency across codebase33- Document decisions and trade-offs3435### 2. Implementation Guidelines36- Start with the simplest viable solution37- Iterate based on feedback and requirements38- Test thoroughly before deployment394041## Inputs / Outputs / Contracts42* **Inputs**:43 - Inference request (model_name, input_data, latency_requirement, model_complexity, priority)44 - Resource status (edge availability, edge load, cloud availability, cloud cost)45 - Model registry (model variants, accuracy, size, latency)46 - Routing configuration (cost thresholds, edge preference)47* **Entry Conditions**:48 - Edge inference endpoints deployed and accessible49 - Cloud inference endpoints deployed and accessible50 - Model registry populated with model variants51 - Resource monitoring configured and running52 - Router service deployed and healthy53* **Outputs**:54 - Inference result (predictions, latency, cost, target used)55 - Routing decision (target selected, fallback chain used)56 - Metrics (latency, cost, success rate, fallback rate)57 - Resource utilization (edge load, cloud usage)58* **Artifacts Required (Deliverables)**:59 - Inference router service60 - Edge inference clients (MCU, GPU)61 - Cloud inference client62 - Fallback cache implementation63 - Metrics and monitoring setup64* **Acceptance Evidence**:65 - P95 latency < 100ms66 - Routing accuracy > 95%67 - Cost per inference < $0.0168 - Fallback rate < 5%69 - Edge utilization > 70%70* **Success Criteria**:71 - Latency targets met (P95 < 100ms)72 - Cost reduction > 70% vs cloud-only73 - Reliability > 99.9% with fallback74 - Routing accuracy > 95%75 - Edge utilization > 70%7677## Skill Composition78* **Depends on**: [tinyml-microcontroller-ai](../tinyml-microcontroller-ai/SKILL.md) (Edge MCU inference), [edge-model-compression](../edge-model-compression/SKILL.md) (Model optimization)79* **Compatible with**: [on-device-model-training](../on-device-model-training/SKILL.md), [edge-ai-development-workflow](../edge-ai-development-workflow/SKILL.md)80* **Conflicts with**: None81* **Related Skills**: [high-performance-inference](../../78-inference-model-serving/high-performance-inference/SKILL.md), [serverless-inference](../../78-inference-model-serving/serverless-inference/SKILL.md)8283---8485## Quick Start / Implementation Example86871. Review requirements and constraints882. Set up development environment893. Implement core functionality following patterns904. Write tests for critical paths915. Run tests and fix issues926. Document any deviations or decisions9394```python95# Example implementation following best practices96def example_function():97 # Your implementation here98 pass99```100101102## Assumptions / Constraints / Non-goals103104* **Assumptions**:105 - Development environment is properly configured106 - Required dependencies are available107 - Team has basic understanding of domain108* **Constraints**:109 - Must follow existing codebase conventions110 - Time and resource limitations111 - Compatibility requirements112* **Non-goals**:113 - This skill does not cover edge cases outside scope114 - Not a replacement for formal training115116117## Compatibility & Prerequisites118119* **Supported Versions**:120 - Python 3.8+121 - Node.js 16+122 - Modern browsers (Chrome, Firefox, Safari, Edge)123* **Required AI Tools**:124 - Code editor (VS Code recommended)125 - Testing framework appropriate for language126 - Version control (Git)127* **Dependencies**:128 - Language-specific package manager129 - Build tools130 - Testing libraries131* **Environment Setup**:132 - `.env.example` keys: `API_KEY`, `DATABASE_URL` (no values)133134135## Test Scenario Matrix (QA Strategy)136137| Type | Focus Area | Required Scenarios / Mocks |138| :--- | :--- | :--- |139| **Unit** | Core Logic | Must cover primary logic and at least 3 edge/error cases. Target minimum 80% coverage |140| **Integration** | DB / API | All external API calls or database connections must be mocked during unit tests |141| **E2E** | User Journey | Critical user flows to test |142| **Performance** | Latency / Load | Benchmark requirements |143| **Security** | Vuln / Auth | SAST/DAST or dependency audit |144| **Frontend** | UX / A11y | Accessibility checklist (WCAG), Performance Budget (Lighthouse score) |145146147## Technical Guardrails & Security Threat Model148149### 1. Security & Privacy (Threat Model)150* **Top Threats**: Injection attacks, authentication bypass, data exposure151- [ ] **Data Handling**: Sanitize all user inputs to prevent Injection attacks. Never log raw PII152- [ ] **Secrets Management**: No hardcoded API keys. Use Env Vars/Secrets Manager153- [ ] **Authorization**: Validate user permissions before state changes154155### 2. Performance & Resources156- [ ] **Execution Efficiency**: Consider time complexity for algorithms157- [ ] **Memory Management**: Use streams/pagination for large data158- [ ] **Resource Cleanup**: Close DB connections/file handlers in finally blocks159160### 3. Architecture & Scalability161- [ ] **Design Pattern**: Follow SOLID principles, use Dependency Injection162- [ ] **Modularity**: Decouple logic from UI/Frameworks163164### 4. Observability & Reliability165- [ ] **Logging Standards**: Structured JSON, include trace IDs `request_id`166- [ ] **Metrics**: Track `error_rate`, `latency`, `queue_depth`167- [ ] **Error Handling**: Standardized error codes, no bare except168- [ ] **Observability Artifacts**:169 - **Log Fields**: timestamp, level, message, request_id170 - **Metrics**: request_count, error_count, response_time171 - **Dashboards/Alerts**: High Error Rate > 5%172173174## Agent Directives & Error Recovery175*(ข้อกำหนดสำหรับ AI Agent ในการคิดและแก้ปัญหาเมื่อเกิดข้อผิดพลาด)*176177- **Thinking Process**: Analyze root cause before fixing. Do not brute-force.178- **Fallback Strategy**: Stop after 3 failed test attempts. Output root cause and ask for human intervention/clarification.179- **Self-Review**: Check against Guardrails & Anti-patterns before finalizing.180- **Output Constraints**: Output ONLY the modified code block. Do not explain unless asked.181182183## Definition of Done (DoD) Checklist184185- [ ] Tests passed + coverage met186- [ ] Lint/Typecheck passed187- [ ] Logging/Metrics/Trace implemented188- [ ] Security checks passed189- [ ] Documentation/Changelog updated190- [ ] Accessibility/Performance requirements met (if frontend)191192193## Anti-patterns / Pitfalls194195* ⛔ **Don't**: Log PII, catch-all exception, N+1 queries196* ⚠️ **Watch out for**: Common symptoms and quick fixes197* 💡 **Instead**: Use proper error handling, pagination, and logging198199200## Reference Links & Examples201202* Internal documentation and examples203* Official documentation and best practices204* Community resources and discussions205206207## Versioning & Changelog208209* **Version**: 1.0.0210* **Changelog**:211 - 2026-02-22: Initial version with complete template structure212213---214> Converted and distributed by [TomeVault](https://tomevault.io/claim/amnadtaowsoam) — claim your Tome and manage your conversions.215<!-- tomevault:4.0:skill_md:2026-04-13 -->