Skip to content

About

ArchitectAI is a next-generation framework for the automated discovery and optimization of neural network architectures. Unlike traditional NAS (Neural Architecture Search), SDNN leverages evolutionary algorithms combined with logic-based reasoning to "design" architectures that are optimized for specific hardware constraints and tasks.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

Β 

History

42 Commits

Folders and files

Repository files navigation

🧠 ArchitectAI

Self-Designing Neural Networks (SDNN)

Python Tests Lint Python 3.9+ License: MIT PyTorch Code style: black

A next-generation framework for automated discovery and optimization of neural network architectures.

Unlike traditional NAS (Neural Architecture Search), SDNN combines evolutionary algorithms with logic-based reasoning to design architectures optimized for specific hardware constraints and tasks.

Getting Started Β· Examples Β· Documentation Β· Contributing


✨ Key Features

Feature Description
Graph-Based DSL Define and compose neural architectures using a fluent, chainable API built on DAG primitives
Evolutionary Search Multi-objective optimization balancing accuracy, latency, and energy efficiency
Hardware-Aware Constrain search by parameter count, memory budget, and target device (CPU/GPU/edge)
Reasoning Engine Logic-based pruning to eliminate invalid architectures and guide the search process
PyTorch Code Generation Automatically compile discovered architectures into runnable PyTorch modules
REST API Serve architecture discovery as a service via FastAPI
CLI Full command-line interface for running discovery pipelines
Visualization Plot evolution progress, architecture graphs, and Pareto fronts

πŸ—οΈ Architecture Overview

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                     ArchitectAI                          β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚   Core   β”‚ Evolution β”‚ Reasoning  β”‚  CodeGen  β”‚ Hardware β”‚
β”‚  ──────  β”‚  ───────  β”‚  ────────  β”‚  ──────── β”‚ ──────── β”‚
β”‚  DSL     β”‚ Search    β”‚ Engine     β”‚ Compiler  β”‚ Profiler β”‚
β”‚  Graph   β”‚ Space     β”‚ Rules      β”‚ PyTorch   β”‚ Constr.  β”‚
β”‚  Prims   β”‚ Populat.  β”‚ Knowl.Base β”‚ Optimizer β”‚ Evaluatorβ”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚              CLI  Β·  REST API  Β·  Visualization          β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

The framework is built around a DAG-based architecture graph where nodes represent neural network operations (Conv2D, ReLU, Linear, BatchNorm, etc.) and edges represent data flow. The evolutionary engine samples candidate architectures from a configurable search space, evaluates them against hardware constraints, and iteratively refines the population toward optimal designs.


πŸš€ Getting Started

Prerequisites

  • Python 3.9 or higher
  • PyTorch 2.0+

Installation

# Clone the repository
git clone https://github.com/ZitouniNidhal/Self-Designing-Neural-Networks--SDNN-.git
cd Self-Designing-Neural-Networks--SDNN-

# Install in editable mode
pip install -e .

# Install dev dependencies (for testing & linting)
pip install -r requirements-dev.txt

Quick Start

from architectai import Architect
from architectai.hardware.constraints import HardwareConstraints

# Initialize the architect
architect = Architect()

# Define hardware constraints
constraints = HardwareConstraints(
    max_params=500_000,
    max_memory_mb=256,
    target_device="cpu",
)

# Run architecture discovery
best_architecture = architect.discover(
    task="image_classification",
    iterations=50,
    constraints=constraints,
)

# Export to PyTorch code
architect.export(best_architecture, "my_model.py")

πŸ”§ Usage

Python API

Building Architectures with the DSL

The fluent DSL API lets you define architectures as chained operations:

from architectai.core.dsl import ArchitectureDSL

# Build a simple CNN
model = (
    ArchitectureDSL("my_cnn")
    .input([3, 32, 32])
    .conv2d(32, kernel_size=3, stride=1)
    .relu()
    .conv2d(64)
    .relu()
    .linear(10)
    .build()
)

# Inspect the architecture graph
print(model.to_dict())

Exploring the Search Space

from architectai.evolution.search_space import SearchSpace

space = SearchSpace()
# Sample a random architecture with depth 6
candidate = space.sample_random_architecture(depth=6)

CLI

The architect CLI is installed as a console script:

# Run architecture discovery
architect discover --task image_classification --iterations 100 --output model.py

# Show help
architect --help
Option Default Description
--task image_classification Discovery task type
--iterations 10 Number of search iterations
--output output_architecture.py Path to save the exported architecture

REST API

Start the API server to expose discovery as a service:

uvicorn architectai.api.server:app --reload

Docker

cd docker
docker-compose up --build

πŸ“‚ Project Structure

Self-Designing-Neural-Networks--SDNN-/
β”œβ”€β”€ src/architectai/
β”‚   β”œβ”€β”€ __init__.py              # Package exports
β”‚   β”œβ”€β”€ core/                    # Foundation layer
β”‚   β”‚   β”œβ”€β”€ primitives.py        #   Operation types, NodeConfig, Primitive
β”‚   β”‚   β”œβ”€β”€ graph.py             #   ArchitectureGraph (NetworkX DAG)
β”‚   β”‚   └── dsl.py               #   Fluent DSL for building architectures
β”‚   β”œβ”€β”€ evolution/               # Evolutionary search
β”‚   β”‚   β”œβ”€β”€ search_space.py      #   Defines available ops & sampling
β”‚   β”‚   └── population.py        #   Population management
β”‚   β”œβ”€β”€ reasoning/               # Logic-based guidance
β”‚   β”‚   β”œβ”€β”€ engine.py            #   Reasoning engine
β”‚   β”‚   β”œβ”€β”€ rules.py             #   Architecture validity rules
β”‚   β”‚   β”œβ”€β”€ knowledge_base.py    #   Domain knowledge store
β”‚   β”‚   └── explainer.py         #   Decision explanations
β”‚   β”œβ”€β”€ codegen/                 # Code generation
β”‚   β”‚   β”œβ”€β”€ compiler.py          #   Graph β†’ file export (JSON / Python)
β”‚   β”‚   β”œβ”€β”€ pytorch_generator.py #   Graph β†’ PyTorch nn.Module source
β”‚   β”‚   └── optimizer.py         #   Graph-level optimizations
β”‚   β”œβ”€β”€ hardware/                # Hardware awareness
β”‚   β”‚   β”œβ”€β”€ constraints.py       #   HardwareConstraints & evaluator
β”‚   β”‚   └── profiler.py          #   Runtime profiling
β”‚   β”œβ”€β”€ evaluation/              # Model evaluation
β”‚   β”œβ”€β”€ viz/                     # Visualization utilities
β”‚   β”‚   β”œβ”€β”€ graph_viz.py         #   Architecture graph plots
β”‚   β”‚   β”œβ”€β”€ evolution_viz.py     #   Evolution progress charts
β”‚   β”‚   β”œβ”€β”€ pareto_viz.py        #   Multi-objective Pareto fronts
β”‚   β”‚   └── report_generator.py  #   HTML/PDF report generation
β”‚   β”œβ”€β”€ cli/                     # Command-line interface
β”‚   β”‚   β”œβ”€β”€ main.py              #   Click CLI entry point
β”‚   β”‚   β”œβ”€β”€ commands.py          #   CLI commands (discover)
β”‚   β”‚   └── args.py              #   Default arguments
β”‚   β”œβ”€β”€ api/                     # REST API
β”‚   β”‚   β”œβ”€β”€ server.py            #   FastAPI application
β”‚   β”‚   β”œβ”€β”€ endpoints.py         #   API routes
β”‚   β”‚   └── schemas.py           #   Request/response models
β”‚   β”œβ”€β”€ system/                  # System coordination
β”‚   β”‚   β”œβ”€β”€ architectai.py       #   Architect (main entry class)
β”‚   β”‚   β”œβ”€β”€ config.py            #   ArchitectConfig (pydantic-settings)
β”‚   β”‚   └── logger.py            #   Rich-powered logging
β”‚   └── utils/                   # Shared utilities
β”œβ”€β”€ examples/
β”‚   β”œβ”€β”€ image_classification/    # CIFAR-10, ImageNet examples
β”‚   β”œβ”€β”€ nlp/                     # NLP task examples
β”‚   β”œβ”€β”€ multimodal/              # Vision-language examples
β”‚   └── edge/                    # Edge deployment examples
β”œβ”€β”€ tests/                       # Pytest test suite
β”œβ”€β”€ docs/                        # Documentation
β”œβ”€β”€ docker/                      # Docker & Compose config
β”œβ”€β”€ experiments/                 # Experiment outputs
β”œβ”€β”€ models/                      # Saved models
β”œβ”€β”€ .github/workflows/           # CI: lint, test, publish
β”œβ”€β”€ pyproject.toml               # Build config & tool settings
β”œβ”€β”€ requirements.txt             # Runtime dependencies
└── requirements-dev.txt         # Dev/test dependencies

πŸ“š Examples

Ready-to-run examples are provided for multiple domains:

Example Path Description
CIFAR-10 Classification examples/image_classification/discover_cifar10.py Discover a CNN for CIFAR-10 with parameter & memory constraints
ImageNet Discovery examples/image_classification/discover_imagenet.py Large-scale image classification architecture search
Vision-Language examples/multimodal/discover_vision_language.py Multimodal architecture discovery
Edge Deployment examples/edge/ Hardware-constrained search for edge devices
# Run the CIFAR-10 example
python examples/image_classification/discover_cifar10.py

πŸ§ͺ Testing

# Run all tests
pytest

# Run with coverage
pytest --cov=architectai

# Run a specific test file
pytest tests/test_graph.py -v

Linting & Type Checking

# Linting
flake8 src tests

# Type checking
mypy src

# Formatting
black src tests
isort src tests

πŸ› οΈ Configuration

ArchitectAI uses pydantic-settings for configuration. You can configure the framework via environment variables or by passing an ArchitectConfig object:

from architectai import Architect, ArchitectConfig

config = ArchitectConfig(
    project_name="my_experiment",
    debug=True,
)
architect = Architect(config_override=config)
Environment Variable Default Description
ARCHITECTAI_PROJECT_NAME sdnn_project Name of the project/experiment
ARCHITECTAI_DEBUG false Enable debug logging

πŸ—ΊοΈ Roadmap

  • Core DSL and graph representation
  • Evolutionary search with random sampling
  • Hardware-aware constraint evaluation
  • PyTorch code generation
  • CLI and REST API
  • CI/CD pipeline (lint, test, publish)
  • NSGA-II multi-objective evolution
  • Full reasoning engine with architecture validity rules
  • Training loop integration with real accuracy evaluation
  • Latency and memory profiling on real hardware
  • Visualization dashboards (graph, evolution, Pareto)
  • ONNX and TensorFlow export backends
  • Distributed search across multiple GPUs/nodes

🀝 Contributing

Contributions are welcome! Please follow these steps:

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Ensure all checks pass:
    flake8 src tests && mypy src && pytest
  4. Commit your changes (git commit -m 'Add amazing feature')
  5. Push to the branch (git push origin feature/amazing-feature)
  6. Open a Pull Request

πŸ“„ License

This project is licensed under the MIT License β€” see the LICENSE file for details.


Built with ❀️ by ZitouniNidhal

About

ArchitectAI is a next-generation framework for the automated discovery and optimization of neural network architectures. Unlike traditional NAS (Neural Architecture Search), SDNN leverages evolutionary algorithms combined with logic-based reasoning to "design" architectures that are optimized for specific hardware constraints and tasks.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages