Personal R&D · open/synthetic data

GPO - Generative Process Optimizer

TL;DR. GPO turns known process physics into a head start for the optimizer: on an open injection-molding benchmark (564 cycles, n=20), the Gaussian Process surrogate reaches the 90% convergence threshold in 14.8 evaluations versus 35.1 for random search, and a physics-informed prior reduces that to 8.8. Built solo, end-to-end — BO core, four physics-prior modules, a FastAPI + Celery backend, and a React dashboard, shipped as an 8-service Docker stack. A personal R&D project validated only on open and synthetic datasets, not deployed in production.
2.38x fewer experiments vs random search, injection-molding
+40.7% fewer with prior physics-informed prior
8 Docker services full stack
4 physics priors injection/CNC/laser/3D-print
GPO system architecture: 8-service Docker Compose stack showing Browser, nginx web, FastAPI, Postgres+TimescaleDB, Redis, Celery GPU worker, and Prometheus/Alertmanager/Grafana observability
System architecture -- 8-service Docker Compose deployment. FastAPI is the synchronous control plane; long-running BO iterations run asynchronously on a GPU-enabled Celery worker. Redis handles the Celery job queue and a pub/sub channel that streams per-iteration progress to the React client over WebSocket. PostgreSQL + TimescaleDB persists experiment state, per-iteration GP checkpoints, and time-series metrics (Alembic migrations). Prometheus scrapes API metrics, Alertmanager routes alerts, Grafana surfaces live ops dashboards.

Problem

Setting up and tuning a manufacturing process (injection molding, CNC milling, laser welding, 3D printing) requires finding optimal process parameters, but the conventional approaches -- Design of Experiments (DoE) and random search -- are expensive: each physical experiment consumes material, machine time, and labor, and the number of runs needed grows quickly with the parameter space. GPO attacks this by minimizing the number of experiments needed to reach an optimum, reaching it in only 10-50 experiments on the datasets tested. Domain physics is available for many processes but is hard to exploit in a generic optimizer; conversely, a purely data-driven optimizer ignores known physical relationships. As a personal R&D project the goal was also to support a bilingual KO/EN UI and consume existing MES/ERP-style data exports rather than requiring new sensors or factory hardware, and to validate the whole approach on open and synthetic process datasets rather than any client production system.

What I built

  • BO core engine, built solo: the Gaussian Process surrogate (Matérn 5/2 + ARD, warm-start, RFF and Deep GP variants), three acquisition functions (Expected Improvement, Upper Confidence Bound, Knowledge Gradient) on BoTorch / GPyTorch, the sequential optimizer loop with convergence detection, and qEHVI / qNEHVI multi-objective optimization (ModelListGP) for 3D-printing Pareto fronts.
  • Physics priors and transfer learning: an abstract prior interface plus four domain priors (injection-molding glass-transition / shrinkage, CNC Taylor-type tool-wear, laser-welding penetration-depth, 3D-printing multi-output), each auto-weighted by Empirical-Bayes; and a GP-to-GP residual transfer module that warm-starts hyperparameters across materials (PP -> ABS).
  • Full-stack delivery: a FastAPI + Celery + PostgreSQL/TimescaleDB backend (Redis pub/sub progress, GP checkpoint recovery) and a React + Plotly dashboard (live convergence, GP surface, uncertainty map), shipped as an 8-service Docker Compose stack with Prometheus / Grafana monitoring and a unit / integration / E2E / benchmark test suite.

Design decisions

  1. Generic BO engine + per-process physics prior (plug-in)

    Context: Physical dynamics differ across processes (injection molding vs. CNC vs. laser welding vs. 3D print) but the optimization mathematics is shared. Options: a single monolithic domain-specific optimizer, or a generic optimizer with pluggable domain modules. Rationale: an abstract PhysicsPrior interface lets new processes ship as a single new module (mean function + constraints + empirical weighting), without touching the surrogate, acquisition, or API layers.

    Plug-in physics priors: four interchangeable PhysicsPrior modules (injection / CNC / laser / 3D-print) socket into one fixed Bayesian Optimization core.
    An abstract PhysicsPrior interface lets each process plug into one fixed BO core, so a new process ships as a single module while the surrogate, acquisition, and API layers stay untouched.
  2. Celery async execution with WebSocket progress

    Context: BO runs are long (minutes to hours) and must survive browser disconnects and server restarts. Options: synchronous HTTP request, background thread in the API process, or a dedicated task queue. Rationale: Celery workers isolate GPU workload from the API, Redis pub/sub streams per-iteration progress to the React client over WebSocket, and periodic GP checkpoints to Postgres let a restarted worker resume exactly where it left off.

  3. BoTorch / GPyTorch over scikit-learn GP

    Context: need GPU-accelerated GP fits, batch acquisition (q>=1), and multi-objective support (qEHVI). Options: scikit-learn GaussianProcessRegressor, GPy (CPU), or BoTorch on PyTorch. Rationale: BoTorch provides native CUDA GP inference, analytic and Monte-Carlo acquisition variants, and first-class multi-objective support, which the other libraries would have required custom work to match.

  4. Physics-informed mean function biases the GP posterior

    Bayesian Optimization treats the unknown process response as a random function and maintains a GP posterior over it; each iteration the acquisition function balances exploration (high-uncertainty regions) against exploitation (high predicted value) to choose the next experiment. In GPO the GP posterior is additionally biased by a physics-informed mean function (e.g. a Taylor tool-wear relation for CNC or a glass-transition constraint for injection molding) so the optimizer starts from a physically plausible region rather than an uninformed prior, and the prior's influence shrinks automatically as more data accumulates via the Empirical-Bayes weighting term.

    Two GP panels — an uninformed flat prior versus a physics-informed mean that biases the posterior toward a plausible region; an inset shows the Empirical-Bayes weight decaying as data accumulates.
    A physics-informed mean function biases the GP toward a physically-plausible region, and Empirical-Bayes weighting shrinks the prior's influence as data accumulates.
  5. Async pipeline: upload -> define space -> launch -> review live -> record observation

    End-to-end loop: (1) upload process data (CSV of historical runs, or an MES/ERP-style export) with client-side schema validation in the DataUpload component; (2) define the parameter space and constraints (per-variable bounds; continuous/integer/categorical types; physical constraints such as glass-transition temperature) and optionally attach a physics prior or run purely data-driven; (3) launch a BO run that the API enqueues as a Celery task on the GPU worker, fitting the GP and optimizing the acquisition function each iteration; (4) review recommendations live via Plotly convergence curves, GP posterior surface, and uncertainty map, accepting/overriding/stopping; (5) record the new observation back through the API, retrain the GP, and continue until convergence or the experiment budget is exhausted.

Engineering foothold

ClaimEvidence
BO converges in 2.38x fewer iterations than random search on the open injection-molding benchmarkOpen B2SHARE/EUDAT injection-molding dataset (564 cycles, 4-D process space; an oracle GP fit to all 564 points provides ground truth), 20 independent repeats: vanilla BO with Expected Improvement reaches the 90% convergence threshold in 14.8 iterations vs. 35.1 for random search -- a 2.38x reduction. results/gate_benchmark_report.md Gate 1 and results/gate_report.txt (90%-threshold ratio 2.38x, Random=35.1, BO=14.8). On the synthetic Branin function (50 repeats, 95% CI) BO-EI reaches a final best of 0.3975 vs. 0.4285 for random search (f*=0.397887), confirming correct convergence behavior.
Physics-informed prior cuts iterations to 90% convergence by ~41% on the open injection-molding benchmarkOpen injection-molding dataset (564 cycles, 4-D process space), n=20 repeats: a prior encoding the glass-transition temperature constraint and a shrinkage-packing-pressure relation reduces iterations to the 90% convergence threshold from vanilla BO ~14.8 iter to BO+Prior ~8.8 iter. results/gate_benchmark_report.md Gate 3 reports +40.7% (1 - 8.8/14.8), and results/summary.csv confirms the BO+Prior run.
Transfer learning (PP -> ABS) reduces simple regret at iteration 15 by ~66% vs cold-start BO on the open benchmarkOn the open injection-molding benchmark, warm-starting the optimizer for a new ABS polymer with knowledge transferred from a previously optimized PP polymer drops simple regret at iteration 15 by ~66% relative to cold-start vanilla BO, n=20 repeats; the transfer module reuses GP hyperparameters and a residual mean function and degrades gracefully to an independent GP if source and target disagree. results/gate_benchmark_report.md Gate 4 reports +65.7% regret reduction at iter 15; gpo_core/transfer/gp_transfer.py implements residual-mean transfer + hyperparameter warm-start. (Reported honestly: on the iteration-threshold metric transfer was slightly slower than vanilla BO, indicating some negative transfer across the PP/ABS domain gap.)
The engine generalizes cross-domain to CNC tool wear on a public datasetPublic Kaggle CNC milling tool-wear dataset (University of Michigan SMART Lab, 18 machining experiments, 2-D parameter space: feedrate_norm, clamp_pressure_norm): the CNC prior -- a Taylor-type wear law V_B proportional to f^alpha v^beta combined with a feed-rate/surface-roughness relation -- identifies feed-rate and spindle-speed combinations balancing tool life against machining time, demonstrating the engine + plug-in prior design transfers to a different process family. scripts/validate_real_cnc_bo.py; gpo_core/prior/cnc_milling.py implements the Taylor-type wear law; data/processed/cnc_mill/metadata.json (Kaggle shasun/tool-wear-detection-in-cnc-mill, 18 experiments).
GP surrogate behaves correctly on Branin (low uncertainty near observations, high in unexplored regions)GP posterior on the synthetic Branin function fit on n=20 observations with BoTorch SingleTaskGP (same surrogate as the convergence benchmark): posterior mean and uncertainty/std maps show the three true global optima, with uncertainty low near observed points and high in unexplored regions -- exactly what Expected Improvement exploits. gpo_core/surrogate/gp_model.py uses MaternKernel(nu=2.5, ard_num_dims); SingleTaskGP used in scripts/_branin_analysis.py.
Validated on standard synthetic functions and open manufacturing datasetsDatasets validated: synthetic Branin and Hartmann-6 functions; an open B2SHARE/EUDAT injection-molding dataset (564 cycles, PP+ABS); a public Kaggle CNC tool-wear dataset (18 experiments); and a public Kaggle 3D-printer dataset (50 samples, 3-objective MOBO). scripts/run_benchmarks.py supports branin/hartmann6/injection-molding; scripts/validate_real_cnc_bo.py (18 exp); scripts/validate_real_3dprint_mobo.py (qEHVI MOBO, 3 objectives); dataset metadata.json files cite the B2SHARE/EUDAT and Kaggle sources. Developed solo on a single workstation (i9-9900K, 32 GB RAM, RTX 2080 Super 8 GB) with no custom sensors or factory hardware required.
Bar comparison: iterations to 90% convergence on the open injection-molding benchmark — Random search 35.1, vanilla BO 14.8, BO + physics-prior 8.8 (fewer is better), with gains of 2.38x vs random, +40.7% with the prior, and a 65.7% transfer-regret cut at iteration 15.
Headline result on the open injection-molding benchmark (n=20): Bayesian Optimization reaches 90% convergence in 2.38x fewer experiments than random search, and a physics-informed prior cuts ~41% more on top; transfer (PP -> ABS) drops simple regret at iteration 15 by ~66%.
CNC tool wear optimization insights
Cross-Domain Validation (CNC Tool Wear). On a public CNC milling tool-wear dataset (18 experiments), the CNC prior -- a Taylor-type wear law V_B proportional to f^alpha v^beta combined with a feed-rate / surface-roughness relation -- identifies feed-rate and spindle-speed combinations balancing tool life against machining time, demonstrating that the engine + plug-in prior design transfers cleanly to a different process family.
GP posterior on Branin: posterior mean heatmap (left) with observed points and true global optima, and posterior uncertainty standard deviation (right)
GP posterior on Branin -- posterior mean (left) and uncertainty / std (right), fit on n=20 observations with BoTorch SingleTaskGP, the same surrogate used in the Gate 1 convergence benchmark. The three true global optima are marked with stars; uncertainty is low near observed points and high in unexplored regions, which is exactly what the Expected Improvement acquisition exploits.
Branin benchmark convergence plot: BO vs Random Search
Benchmark: BO vs. Random Search (Branin). 50 independent repeats, 95% confidence intervals. BO with Expected Improvement reaches the 90% convergence threshold in ~2.1x fewer evaluations than random search (BO ~9 vs. Random ~20 evaluations).

Tech stack

Optimization / BO Stack
PyTorch 2.6 (CUDA 12.4), BoTorch 0.17, GPyTorch, Gaussian Process surrogate (Matérn 5/2 + ARD), Variational / RFF / Deep GP variants, Acquisition: Expected Improvement, Upper Confidence Bound (beta=2.0), Knowledge Gradient, Multi-objective: qEHVI / qNEHVI with ModelListGP
Physics Priors & Transfer
AbstractPhysicsPrior interface with Empirical-Bayes auto-weighting, Injection Molding prior (glass-transition constraint + shrinkage model), CNC Milling prior (Taylor-type tool-wear + surface-roughness law), Laser Welding prior (penetration-depth relations), 3D Printing prior (multi-output constraints), GP-to-GP residual transfer with hyperparameter warm-start (PP -> ABS)
Backend
FastAPI (9 routers: auth, oauth, experiments, data, metrics, billing, usage, webhooks, websocket), Celery + Redis (async BO execution, pub/sub progress streaming), PostgreSQL + TimescaleDB, Alembic migrations, GP checkpoint recovery, JWT auth, WebSocket progress
Frontend
React + Vite, Plotly (convergence curves, GP response surface, uncertainty map), react-router, AuthContext (JWT), DataUpload component (client-side schema validation), Bilingual KO / EN UI toggle (react-i18next)
Infrastructure & Observability
Docker Compose -- 8 services, nginx web, GPU-enabled Celery worker, Prometheus, Alertmanager, Grafana, Test suite: unit / integration / E2E / benchmark layers
Hardware (development)
Single workstation: Intel i9-9900K, 32 GB RAM, NVIDIA RTX 2080 Super 8 GB, No custom sensors or factory hardware -- consumes existing MES / ERP-style data exports

Gallery

← All projects