How ailabstw/flavor works
Project Overview & Purpose
• The project is a Federated Learning and Validation Framework that enables multiple parties to collaboratively build and evaluate AI models while maintaining data privacy.
• It supports not only federated training (with both client and server examples) but also model validation and inference services. It’s designed to integrate with user-provided training code (even if not in Python) by invoking it as a subprocess.
• The README shows distinct sections and examples focused on FL clients (using various ML libraries like PyTorch, Tensorflow, SVM, XGBoost), FL servers, validation (FV), and model inference.
Analyzing the File Structure & Components
• Top-Level Example Directories:
• “examples/fl-client”: Contains several subdirectories (pytorch, svm, tensorflow, xgboost) that showcase how a federated learning client can be implemented with different frameworks.
• “examples/fl-server”: Provides an example of a federated learning server, including Dockerfiles and a README.
• “examples/fv”: Focuses on Federated Validation.
• “examples/inference”: Contains notebooks, Dockerfiles, and documentation that explain how to deploy inference models.
• Core Package (flavor directory):
• “flavor/cli”: Implements command-line utilities and checkers (e.g., for FL, FV, and aggregated FL tasks).
• “flavor/cook” and “flavor/taste”: Likely handle model “cooking” (preparing models) and possibly evaluation or further orchestration.
• “flavor/serve”: Contains the inference and serving logic. It is well segmented into:
∙ “inference” submodule with data models (both API and functional), inference models (including base classes for different inference strategies, such as Triton), and strategies (like AICoCO and Gradio).
∙ “invocations”: Handling the process by which code is invoked for inference.
• “flavor/gadget”: Contains specific integrations (for example, an xgboost module).
• Supporting Files:
• Dockerfiles in example directories indicate that containerized execution is a factor, meaning the system design should highlight container boundaries and how FLaVor interacts with external training/inference environments.
• Configuration and linting files (.flake8, .gitignore, .pre-commit-config.yaml, pyproject.toml) indicate a well-standardized project setup.
a. Main Components to Include:
• Federated Learning Client: Show components handling multiple frameworks (PyTorch, TensorFlow, SVM, XGBoost) with Docker-contained examples that run user training code.
• Federated Learning Server: Central orchestration service to coordinate client interactions, model aggregation, and communications.
• Federated Validation Component: Illustrate how validation jobs are set up (referencing the FV example) and interact with training and inference components.
• Inference Service: Represented by the “flavor/serve” module (with nested inference data models, inference models, strategies, and invocation mechanisms).
• Command-line/Utility Layer: Represent the CLI tools available under “flavor/cli” which act as entry points for various operations (checking, aggregating, serving, etc.).
• Auxiliary Components: “flavor/cook” and “flavor/taste” function as processing or preparation layers before deployment or during model assembly.
b. Relationships and Interactions:
• That the FL Server may trigger subprocesses to run user code within isolated Docker containers.
• That the CLI layer interacts with both the server and local modules (cooking/tasting) to facilitate workflow management.
• For inference, illustrate data flow from user requests (or from aggregated training outputs) to the “flavor/serve” subsystem which then leverages specific inference strategies (e.g., Triton, Gradio).
c. Key Architectural Patterns and Principles:
• Modularization: The project is divided into specialized modules (client, server, validation, inference) for separation of concerns.
• Containerization: Use of Docker in examples points to encapsulating user code execution to prevent environment conflicts.
• Extensibility: Through a well-structured CLI and plugin-like modules (in “cook”, “taste”, and “gadget”), the architecture promotes easy extensions—especially for integrating non-Python code.
• Subprocess Isolation: The design’s emphasis on calling external code using subprocess indicates a safeguard against dependency conflicts.
d. Technologies & Frameworks:
• The examples indicate popular ML frameworks (PyTorch, TensorFlow, SVM libraries, XGBoost).
• Docker for containerization.
• REST/HTTP (and legacy gRPC) for communication (as noted in changelog regarding Inference service and FL via HTTP).
• Use of Python’s packaging and CLI tools (as indicated by pyproject.toml, flavor/cli).