Tutorials and examples for building AI agents, ML pipelines, and data workflows with Flyte 2.
An ML engineer agent runs the model factory: evaluate, fine-tune, promote, deploy, and retrain when the data drifts. LangGraph for the agent, Flyte 2 for everything it touches.
A support agent in production routes tickets with an API call. An ML engineer agent gets the request to replace that call with a model we own: it evaluates open candidates in parallel, fine-tunes the ones worth it, promotes the winner, deploys it, and tests the live app. Then the data drifts and the loop turns again. Every tool call is a durable Flyte task, so a run that dies halfway resumes without retraining anything, and every eval and fine-tune leaves a report you can open.
Three ways to run it (Setup has the details):
- A Flyte devbox on your own machine (recommended: the full workshop). Docker Desktop,
Python 3.10+,
uv;flyte start devbox --apple-siliconon an Apple Silicon Mac, plainflyte start devboxwith an NVIDIA GPU or on CPU. - The workshop's Union cluster (
tryv2), from any laptop. Oneflyte create configcommand and a browser sign-in; the cluster's GPUs do the work. - The notebook on Google Colab (no GPU, nothing to install). Click the badge. Slightly pared down: the core loop end to end, without the live app and kill-and-resume steps.
Bring a laptop. The devbox and Colab paths need a Claude or OpenAI API key; the cluster already has one.
git clone https://github.com/unionai/workshops
cd workshops/tutorials/langgraph-model-factory-agent
uv venv .venv --python 3.11 && source .venv/bin/activate
uv pip install -r requirements.txt
flyte start devbox --apple-silicon && flyte create config --devbox # a Mac: the devbox path
# or, the cluster path:
# flyte create config --endpoint tryv2.hosted.unionai.cloud --project factorysea --domain development --builder remote
flyte run model_factory.py model_factory --fine_tune_too # step 1: the factory, you at the controls| Example | Description |
|---|---|
| Apple Silicon: fine-tune on your Mac's GPU | flyte start devbox --apple-silicon, gpu="AppleSilicon": LoRA on mps for text-to-SQL (5% → 62% exact match, 14 s of training), live loss chart, the adapter served on the same GPU; one env var moves it to a T4 |
| Apple Silicon: serve an LLM on your Mac | Qwen3-1.7B behind an OpenAI-compatible Flyte app on the Metal GPU (streaming, tool calls), benchmarked from a task, torch on mps vs MLX native (79 vs 277 tok/s), a chat UI that finds the app by name |
| Apple Silicon: an agent whose model and tools run on your Mac | A LangGraph SQL agent with Qwen3-4B served on the Mac's GPU as its brain and Flyte tasks as its tools: every query is a durable child action, 16 questions fanned out and scored (81%), swap the brain for Claude with one env var |
| Model Factory Agent | Tonight's workshop. A LangGraph agent plays ML engineer on Flyte 2: parallel evals, fine-tunes, promotion, a deployed router app it tests, drift and the retrain; runs on a Union cluster, on a Flyte devbox on your Mac, or in Colab with no cluster at all |
| Model Factory Agent + Grafana | A LangGraph agent plays ML engineer: evaluates five candidates on T4s in parallel, fine-tunes the right ones (and discovers a 149M encoder beats the chat models), promotes it as a Union artifact, deploys it, tests the live app, and turns the factory again when the data changes; Grafana Agent Observability watches every turn |
| SkyRL SQL Agent | Multi-turn RL against a real database — write one SkyRL-Gym environment, then drive it with no model, with a 0.5B, with Claude, or with SkyRL's distributed trainer; GRPO rollouts fan out as durable Flyte tasks |
| RAG and Agentic Memory | One vector store, pointed two directions — build a RAG index, watch retrieval work with no model involved, visualize the embedding space, then let an agent write its own memories back into it |
| Code Mode — NYC Taxi analyst | Claude writes one program, the Monty sandbox runs it, and its loops fan out into durable parallel tasks over real NYC taxi data |
| LangGraph Research Pipeline | Research agent pipeline — LangGraph orchestrates planning and quality gates, Flyte fans out parallel researcher tasks |
| LangGraph ReAct Agent | Build a ReAct agent with LangGraph + OpenAI on Flyte |
| Stable Diffusion | Generate images from text prompts with SDXL Turbo on GPU |
| DuckDB ETL | Extract and transform data with DuckDB SQL |
| Fraud Detection with Feast | Real-time fraud scoring with Feast feature store + XGBoost |
| Tutorial | What you'll learn |
|---|---|
| Flyte Basics | Flyte 2 fundamentals — tasks, pipelines, error handling, TaskEnvironment, ReusePolicy, map() |
| LangGraph ReAct Agent | Build a ReAct agent with tools in a single file |
| Stable Diffusion | GPU inference with Flyte reports |
| Image Classifier | Fine-tune ResNet18 on HuggingFace dataset with PyTorch |
| DuckDB ETL | Data pipeline with DuckDB SQL and Flyte reports |
| Snowflake ETL | ETL pipeline with the Snowflake connector |
| Flyte Local Dev | Local dev features — TUI, caching, reports, tracing, serving (no cluster needed) |
| Fraud Detection with Feast | Fraud scoring pipeline with Feast feature store, XGBoost, and real-time serving |
| Tutorial | Description |
|---|---|
| Apple Silicon SQL Agent | LangGraph ReAct agent on a model served from your Mac's GPU, tools as Flyte tasks, no API key; 16 scored questions, brain swappable to Claude or a cluster GPU |
| Model Factory Agent + Grafana | The agent runs the model factory: parallel T4 evals, fine-tunes, artifact promotion, a deployed router app it tests and can roll back, an artifact trigger that validates every promotion, a human approval gate, and a day-two retrain; observed in Grafana Agent Observability, with a crash-and-resume that trains nothing twice |
| Code Mode — NYC Taxi analyst | The agent writes a program instead of calling tools one at a time. It runs in the Monty sandbox, and a loop in the generated code becomes a fan-out of durable, parallel query tasks over 3M+ real taxi trips |
| RAG and Agentic Memory | One Chroma store, pointed two directions — build a document index, search it with no model, answer from it with citations, see the embedding space in 2D, then let an agent write its own memories back into it |
| LangGraph Research Pipeline | Research agent pipeline — LangGraph orchestrates planning and quality gates, Flyte fans out parallel researcher tasks via Tavily web search |
| LangGraph ReAct Agent | Single-file ReAct agent with LangGraph |
| Planner Multi-Agent System | Scalable planner multi-agent system |
| ReAct Multi-Agent System | Adaptive ReAct multi-agent system |
| Debate Multi-Agent System | Multi-agent debate pattern |
| Manager Multi-Agent System | Manager-worker agent delegation |
| Sequential Multi-Agent System | Sequential agent pipeline |
| Autoresearch | Autoresearch-style self-healing agent on Flyte |
| Tutorial | Description |
|---|---|
| MCP Recipe Assistant | Build and deploy a recipe assistant MCP server on Union |
| Tutorial | Description |
|---|---|
Apple Silicon: LoRA on mps |
Fine-tune Qwen2.5-0.5B for text-to-SQL on your Mac's GPU from a Flyte devbox task, then serve the adapter; the same pipeline runs on a T4 with ACCELERATOR=T4 |
| LoRA / QLoRA / Full | Fine-tune an LLM on text-to-SQL with LoRA, QLoRA, or full fine-tuning — live training reports, FastAPI serving, Gradio UI |
| Nemotron 3 Nano — LoRA / QLoRA | Fine-tune NVIDIA's Nemotron 3 Nano 4B for tool calling — LoRA on an L40S or QLoRA on a T4 from the same pipeline, discovered LoRA targets for the Mamba hybrid, adapter serving |
| Nemotron 3 Nano — GRPO | Reinforcement learning on Nemotron 3 Nano 4B — Countdown puzzles with a verifier as the only reward, thinking off, live solve-rate charts |
| Nemotron — Healthcare: clinical notes | Fine-tune Nemotron 3 Nano 4B to turn clinical case notes into fixed-schema JSON records — field-level scoring, LoRA on an L40S or QLoRA on a T4 |
| Nemotron — Finance: XBRL tagging | Fine-tune Nemotron 3 Nano 4B to tag amounts in SEC filings with US-GAAP XBRL concepts (FiNER-139) — exact tag-set and pair-F1 scoring, LoRA on an L40S or QLoRA on a T4 |
| Nemotron — Legal: contract clauses | QLoRA an 8B model on a T4 — Llama-3.1-Nemotron-Nano-8B classifies contract clauses into the 100-way LEDGAR taxonomy, reasoning switched off via system prompt |
| Nemotron — Biomed: chemical-protein relations | Fine-tune Nemotron 3 Nano 4B to classify chemical-protein relations in PubMed abstracts (ChemProt) — the extraction step behind drug-target knowledge bases, LoRA on an L40S or QLoRA on a T4 |
| GRPO — Code Generation | Teach a model to write Python with GRPO — reward = sandboxed test execution, MBPP dataset, live reward/pass-rate charts |
| GRPO — Distributed | Scale GRPO across the cluster — fan out sandboxed verification to a reusable pool, then disaggregate rollouts onto vLLM workers with LoRA weight sync |
| GRPO | GRPO fine-tuning on math/reasoning tasks |
| DPO | Direct Preference Optimization for alignment |
| PPO | Proximal Policy Optimization for RLHF |
| Tutorial | Description |
|---|---|
| Fraud Detection with Feast | Fraud scoring pipeline with Feast feature store, XGBoost, and real-time serving |
| Stable Diffusion | Image generation with SDXL Turbo |
| Image Classifier | Fine-tune ResNet18 on Beans dataset |
| DETR Object Detection | Fine-tune DETR for object detection with live mAP charts |
| Tutorial | Description |
|---|---|
| Genomic Variant Effect Prediction | Score DNA mutations with HuggingFace Carbon genomic foundation model — zero-shot pathogenicity prediction on BRCA2, TP53, KRAS, and more |
| DNA Sequence Generation & Analysis | Generate DNA with Carbon and compare to real genes — GC content, codon usage, ORFs, dinucleotide frequencies |
| Gene Comparison Across Species | Compare homologous genes across 6 species with Carbon scoring, phylogenetic trees, and ESMFold 3D structure comparison |
| Protein Sequence Analysis | Analyze protein properties, compute sequence similarity, run ESM-2 embeddings, and predict 3D structures with ESMFold |
| Drug Molecule Screening | Virtual drug screening — compute physicochemical properties, apply Lipinski's Rule of Five, rank candidates by drug-likeness |
| Cell Microscopy Classification | Fine-tune a Vision Transformer (ViT) to classify blood cell types from microscopy images |
| Tutorial | Description |
|---|---|
| DuckDB ETL | SQL-based data pipeline with DuckDB |
| Snowflake ETL | ETL with Snowflake connector |
| Lance Streaming for Vision | Convert a swarm of tiny per-sample image files (real CPPE-5 detection data) into one Lance dataset, benchmark per-file vs Lance streaming against real object storage, then train / evaluate / explore a Faster R-CNN streamed straight from S3 on a T4 |
# Clone the repository
git clone https://github.com/unionai/workshops
cd workshops
# Navigate to any tutorial
cd tutorials/langgraph_agent_research
# Create virtual environment and install dependencies
uv venv .venv --python 3.11
source .venv/bin/activate
uv pip install -r requirements.txtflyte create config \
--endpoint <your-endpoint> \
--auth-type headless \
--builder remote \
--domain development \
--project flytesnacksDon't have a cluster? Request access at flyte.org.
Remote:
uv run flyte run workflow.py research_pipeline --query "Compare quantum computing approaches"Local:
uv run flyte run --local workflow.py research_pipeline --query "Compare quantum computing approaches"Local with TUI:
uv run flyte run --local --tui workflow.py research_pipeline --query "Compare quantum computing approaches"Start TUI dashboard:
uv run flyte start tui