Skip to content

Semantic-Infrastructure-Lab/morphogen

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

36 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
project type status beth_topics tags
morphogen
software
active
morphogen
creative-computation
dsl
mlir
audio-synthesis
agent-simulation
field-operations
compiler
simulation
generative
deterministic

Morphogen

License

Where computation becomes composition

Morphogen is a universal, deterministic computation platform that unifies domains that have never talked to each other before: audio synthesis meets physics simulation meets circuit design meets geometry meets optimization β€” all in one type system, one scheduler, one language.

Why Morphogen Exists

Current tools force you to:

  • Export CAD β†’ import to FEA β†’ export mesh β†’ import to CFD β†’ manually couple results
  • Write audio DSP in C++ β†’ physics in Python β†’ visualization in JavaScript
  • Bridge domains with brittle scripts and incompatible data formats

Morphogen eliminates this fragmentation. Model a guitar string's physics, synthesize its sound, optimize its geometry, and visualize the result β€” all in the same deterministic execution environment.


Part of the Semantic Infrastructure Lab

Morphogen is a production component of the Semantic Infrastructure Lab (SIL) β€” building the semantic substrate for intelligent systems.

Role in the Semantic OS:

  • Layer 2: Domain Module (audio, physics, circuits, geometry)
  • Layer 4: Deterministic Engine (MLIR compilation, reproducible execution)

SIL Principles Applied:

  • βœ… Clarity β€” Explicit domain semantics (audio, field, agent, geometry)
  • βœ… Simplicity β€” Four core operations unify all domains
  • βœ… Composability β€” Domains compose via typed connections
  • βœ… Correctness β€” Type system enforces units, rates, constraints
  • βœ… Verifiability β€” Deterministic execution enables reproducibility

Quick Links: SIL Manifesto β€’ Unified Architecture β€’ Project Index


Two Surfaces, One Kernel

Morphogen presents two human-friendly faces powered by a single semantic kernel:

  • Morphogen.Audio β€” Declarative language for compositional audio, physics, and multi-domain scenes
  • RiffStack β€” Live performance environment for real-time interaction and improvisation

Both compile to the same Graph IR, share the same operator registry, and guarantee deterministic, reproducible results.

πŸ“ Deep Dive: See docs/architecture/ for the complete stack design (kernel, frontends, Graph IR, MLIR compilation)

What Makes Morphogen Different

Cross-Domain Composition

  • Audio synthesis + fluid dynamics + circuit simulation in the same program
  • Type-safe connections between domains (e.g., field β†’ agent force, geometry β†’ audio impulse response)
  • Single execution model handles multiple rates (audio @ 48kHz, control @ 60Hz, physics @ 240Hz)

Deterministic by Design

  • Bitwise-identical results across runs, platforms, and GPU vendors
  • Explicit RNG seeding, sample-accurate event scheduling
  • Three profiles: strict (bit-exact), repro (deterministic FP), live (low-latency)

Transform-First Thinking

  • FFT, STFT, wavelets, DCT as first-class operations
  • Domain changes (time ↔ frequency, space ↔ k-space) are core primitives
  • Uniform transform API across all domains

Production-Grade Compilation

  • MLIR-based compiler with 6 custom dialects
  • Lowers to optimized CPU/GPU code via LLVM
  • Field operations, agents, audio DSP, temporal execution all compile to native code

Sister Project: Philbrick

Morphogen (software) and Philbrick (hardware) are two halves of one vision β€” modular computation in different substrates.

Aspect Morphogen (Digital) Philbrick (Analog/Hybrid)
Purpose Digital simulation of continuous phenomena Physical embodiment of continuous dynamics
Primitives Streams, fields, transforms Sum, integrate, nonlinearity, events
Safety Type system (domain/rate/units) Pin contracts (voltage/impedance/latency)
Execution Multirate deterministic scheduler Latency-aware routing fabric
Philosophy Computation = composition Computation = composition

The Bridge

  • Design in Morphogen β†’ Simulate and optimize continuous-time systems
  • Build in Philbrick β†’ Physical modules implementing the same primitives
  • Validate Together β†’ Software and hardware mirror each other

Both platforms share the same four core operations (sum, integrate, nonlinearity, events) and the same compositional philosophy. They will eventually compile to each other.

πŸ”§ Learn More: Philbrick - Modular analog/digital hybrid computing platform


Cross-Domain in Action

Here's what sets Morphogen apart β€” domains working together seamlessly:

# Couple fluid dynamics β†’ acoustics β†’ audio synthesis
use fluid, acoustics, audio

# Simulate airflow in a 2-stroke engine exhaust
@state flow : FluidNetwork1D = engine_exhaust(length=2.5m, diameter=50mm)
@state acoustic : AcousticField1D = waveguide_from_flow(flow)

flow(dt=0.1ms) {
    # Fluid dynamics: pressure pulses from engine
    flow = flow.advance(engine_pulse(t), method="lax_wendroff")

    # Couple to acoustics: flow β†’ sound propagation
    acoustic = acoustic.couple_from_fluid(flow, impedance_match=true)

    # Synthesize audio from acoustic field
    let exhaust_sound = acoustic.to_audio(mic_position=1.5m)

    # Real-time output
    audio.play(exhaust_sound)
}

One program. Three domains. Zero glue code.

See docs/use-cases/2-stroke-muffler-modeling.md for the complete example.


Quick Start

Installation

git clone https://github.com/scottsen/morphogen.git
cd morphogen
pip install -e .

Your First Program

Create hello.kairo (Morphogen source files use .kairo extension):

# hello.kairo - Heat diffusion

use field, visual

@state temp : Field2D<f32 [K]> = random_normal(
    seed=42,
    shape=(128, 128),
    mean=300.0,
    std=50.0
)

const KAPPA : f32 [mΒ²/s] = 0.1

flow(dt=0.01, steps=500) {
    temp = diffuse(temp, rate=KAPPA, dt, iterations=20)
    output colorize(temp, palette="fire", min=250.0, max=350.0)
}

Run it:

morphogen run hello.kairo

Next steps:


πŸš€ Project Status & v1.0 Roadmap

Current Status (v0.11.0):

  • βœ… 25 active computational domains (fully integrated with use statement)
  • βœ… 15 legacy domains (implemented, migration to new system in progress)
  • βœ… 386 operators accessible from Morphogen language
  • βœ… 1,381 tests passing (251 MLIR tests skipped)
  • βœ… MLIR compilation pipeline complete (6 phases)
  • βœ… Python runtime with NumPy backend

v1.0 Release Plan (24 weeks):

Morphogen is on an aggressive path to v1.0 with a three-track strategy:

  1. Track 1 - Language Evolution (13 weeks)

    • Symbolic + numeric execution (SymPy integration)
    • Transform space tracking with functorial translations
    • Algebraic composition (∘ operator) + category theory optimization
    • Domain plugin system for user extensibility
  2. Track 2 - Critical Domains (12 weeks)

    • Circuit domain with audio coupling ⭐ Unique differentiator
    • Fluid dynamics (Navier-Stokes)
    • Chemistry Phase 2 expansion
    • Target: 50+ domains
  3. Track 3 - Adoption & Polish (ongoing)

    • PyPI release (alpha in week 4)
    • 5 showcase examples with videos
    • 7 progressive tutorials
    • Complete API documentation
    • Active community infrastructure

Read the full plan: Morphogen Roadmap

What makes v1.0 special:

  • πŸ”¬ Symbolic + numeric execution (first platform to combine both)
  • 🎡 Circuit β†’ Audio coupling (design pedal circuits, hear sound instantly)
  • πŸ“ Category theory optimization (verified composition, automatic fusion)
  • πŸ”Œ User extensibility (plugin system for custom domains)
  • 🎯 50+ integrated domains (audio, physics, chemistry, graphics, AI)

Timeline: Current v0.11.0 β†’ v1.0 release in 2026-Q2


Language Overview

Temporal Model

Morphogen programs describe time-evolving systems through flow blocks:

flow(dt=0.01, steps=1000) {
    # Execute this block 1000 times with timestep 0.01
    temp = diffuse(temp, rate=0.1, dt)
    output colorize(temp, palette="fire")
}

State Management

Persistent variables are declared with @state:

@state vel : Field2D<Vec2<f32>> = zeros((256, 256))
@state agents : Agents<Particle> = alloc(count=1000)

flow(dt=0.01) {
    vel = advect(vel, vel, dt)      # Updates vel for next step
    agents = integrate(agents, dt)   # Updates agents for next step
}

Deterministic Randomness

All randomness is explicit via RNG objects:

@state agents : Agents<Particle> = alloc(count=100, init=spawn_random)

fn spawn_random(id: u32, rng: RNG) -> Particle {
    return Particle {
        pos: rng.uniform_vec2(min=(0, 0), max=(100, 100)),
        vel: rng.normal_vec2(mean=(0, 0), std=(1, 1))
    }
}

Physical Units

Types can carry dimensional information:

temp : Field2D<f32 [K]>           # Temperature in Kelvin
pos : Vec2<f32 [m]>               # Position in meters
vel : Vec2<f32 [m/s]>             # Velocity in m/s
force : Vec2<f32 [N]>             # Force in Newtons

# Unit checking at compile time
dist : f32 [m] = 10.0
time : f32 [s] = 2.0
speed = dist / time               # OK: f32 [m/s]

# ERROR: cannot mix incompatible units
x = dist + time                   # ERROR: m + s is invalid

25 Active Computational Domains

Morphogen provides 25 fully-integrated domains accessible via the use statement, with 15 additional legacy domains in migration. Each domain offers specialized operators optimized for its computational model.

Core Domains (Fully Integrated βœ…)

Field Operations (19 ops) - PDE solvers, diffusion, advection, stencils Agent Systems (13 ops) - Particle simulations, flocking, N-body forces Audio Synthesis (60 ops) - Oscillators, filters, effects, physical modeling RigidBody Physics (12 ops) - 2D dynamics, collisions, constraints

Active Domains (Fully Integrated βœ…)

Physics & Simulation - field, agent, rigidbody, integrators, acoustics Audio & Signal - audio, signal, temporal Graphics & Visual - visual, color, image, noise, palette, terrain, vision AI & Optimization - neural, optimization, genetic, cellular, statemachine Data & Infrastructure - graph, sparse_linalg, io_storage, geometry Circuit - circuit (Phase 1: DC/AC/transient analysis)

Legacy Domains (Migration Pending ⏳)

Chemistry Suite (9 domains) - molecular, qchem, thermo, kinetics, electrochem, catalysis, transport, multiphase, combustion Specialized Physics (4 domains) - thermal_ode, fluid_network, fluid_jet Audio Extensions (2 domains) - audio_analysis, instrument_model

Complete Domain Catalog

πŸ“‹ View Full Domain Catalog - Detailed descriptions, code examples, and feature lists

Status Analysis: See DOMAIN_STATUS_ANALYSIS.md for detailed breakdown of active vs. legacy domains

Migration Plan: Legacy domains will be integrated in v0.12.0 - see Migration Guide


Examples

Fluid Simulation (Navier-Stokes)

use field, visual

@state vel : Field2D<Vec2<f32 [m/s]>> = zeros((256, 256))
@state density : Field2D<f32> = zeros((256, 256))

const VISCOSITY : f32 = 0.001
const DIFFUSION : f32 = 0.0001

flow(dt=0.01, steps=1000) {
    # Advect velocity
    vel = advect(vel, vel, dt, method="maccormack")

    # Diffuse velocity (viscosity)
    vel = diffuse(vel, rate=VISCOSITY, dt, iterations=20)

    # Project (incompressibility)
    vel = project(vel, method="cg", max_iterations=50)

    # Advect and diffuse density
    density = advect(density, vel, dt)
    density = diffuse(density, rate=DIFFUSION, dt)

    # Dissipation
    density = density * 0.995

    # Visualize
    output colorize(density, palette="viridis")
}

Reaction-Diffusion (Gray-Scott)

use field, visual

@state u : Field2D<f32> = ones((256, 256))
@state v : Field2D<f32> = zeros((256, 256))

const Du : f32 = 0.16
const Dv : f32 = 0.08
const F : f32 = 0.060
const K : f32 = 0.062

flow(dt=1.0, steps=10000) {
    # Gray-Scott reaction
    let uvv = u * v * v
    let du_dt = Du * laplacian(u) - uvv + F * (1.0 - u)
    let dv_dt = Dv * laplacian(v) + uvv - (F + K) * v

    u = u + du_dt * dt
    v = v + dv_dt * dt

    # Visualize
    output colorize(v, palette="viridis")
}

πŸ“‚ More Examples: See the examples/ directory for 24 working programs demonstrating all major domains!


Documentation

Getting Started

Technical Documentation

Implementation Resources


The Ecosystem Vision

Morphogen is building toward a future where professional domains seamlessly compose:

Professional Applications

Education & Academia - Multi-physics simulations, interactive visualizations, reproducible research

Digital Twins & Enterprise - Real-time system simulation, predictive maintenance, optimization workflows

Audio Production & Lutherie - Physical modeling synthesis, instrument design, timbre extraction

Scientific Computing - Coupled PDE systems, reaction-diffusion, quantum chemistry

Creative Coding & Generative Art - Procedural generation, audio-reactive visuals, deterministic creativity


Evolution from Creative Computation DSL

Morphogen v0.3.1 is the evolution of Creative Computation DSL v0.2.2, incorporating:

  • Better semantics: flow(dt) blocks, @state declarations, explicit RNG
  • Clearer branding: "Morphogen" is unique and memorable
  • Same foundation: Frontend work carries forward, comprehensive stdlib preserved

Related Projects

RiffStack - Live performance shell for Morphogen.Audio

RiffStack is a stack-based, YAML-driven performance environment that serves as the live interface to Morphogen.Audio. While Morphogen.Audio provides the compositional language layer, RiffStack offers real-time interaction and performance capabilities. Together they form a complete audio synthesis and performance ecosystem built on Morphogen's deterministic execution kernel.


Contributing

Morphogen is building toward something transformative: a universal platform where professional domains that have never talked before can seamlessly compose. Contributions welcome at all levels!

See CONTRIBUTING.md for:

  • Development setup
  • High-impact contribution areas
  • Code style guidelines
  • Pull request process

Quick links:


License

Apache 2.0 - see LICENSE for details

Copyright 2025 Semantic Infrastructure Lab Contributors


Contact


Status: v0.11.0 β†’ v1.0 Release Plan Active | Current Version: 0.11.0 | Target: v1.0 (2026-Q2) | Last Updated: 2025-11-21

πŸš€ View Roadmap - Unified roadmap to v1.0 (Q2 2026)

About

Universal deterministic computation platform unifying audio, physics, circuits, and optimization

Resources

License

Code of conduct

Contributing

Security policy

Stars

Watchers

Forks

Packages

No packages published

Languages