# birla-ai-labs/yug architecture

> Architecture diagram of the GitHub repository birla-ai-labs/yug, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-17). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/birla-ai-labs/yug
- Repository: https://github.com/birla-ai-labs/yug

## Overview

Yug is a pretrained time-series foundation model for zero-shot probabilistic forecasting. Users load a local or Hub checkpoint through the pipeline, provide one or more series (optionally with covariates), and receive horizon-length quantile forecasts. The pipeline handles rollout and sampling; lower layers prepare inference batches and execute the patch-based model. The README also documents a GluonTS benchmark adapter and optional pandas output. Several internal links are explicit in excerpts or the README; unsampled adapter wiring is shown only as documented.

Main entry points: [`src/yug/pipeline.py`](https://github.com/birla-ai-labs/yug/blob/main/src/yug/pipeline.py) (Forecast pipeline), [`src/yug/model.py`](https://github.com/birla-ai-labs/yug/blob/main/src/yug/model.py) (Patch transformer), [`src/yug/base.py`](https://github.com/birla-ai-labs/yug/blob/main/src/yug/base.py) (Quantile result), [`src/yug/forecaster.py`](https://github.com/birla-ai-labs/yug/blob/main/src/yug/forecaster.py) (Batch forecaster)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["Forecast API"]
  node_pipeline["Forecast pipeline<br/>[pipeline.py]"]
  node_forecast["Quantile result<br/>[base.py]"]
end

subgraph group_inference["Inference Runtime"]
  node_forecaster["Batch forecaster<br/>[forecaster.py]"]
  node_engine["Cached rollout engine<br/>[engine.py]"]
  node_utils["Frequency and sampling<br/>[utils.py]"]
  node_config["Model configuration<br/>[configs.py]"]
  node_checkpoint["Model checkpoint"]
end

subgraph group_network["Forecast Model"]
  node_model["Patch transformer<br/>[model.py]"]
end

subgraph group_integrations["Integrations"]
  node_gluonts["GluonTS adapter<br/>[gluonts_adapter.py]"]
  node_pandas["DataFrame output<br/>[base.py]"]
end

node_user(("Forecast caller"))
node_hub["Hugging Face Hub"]
node_benchmark(("Benchmark harness"))

node_user -->|"calls"| node_pipeline
node_pipeline -->|"loads"| node_checkpoint
node_pipeline -->|"downloads from"| node_hub
node_pipeline -->|"uses"| node_config
node_pipeline -->|"delegates to"| node_forecaster
node_pipeline -->|"rolls out with"| node_engine
node_pipeline -->|"samples via"| node_utils
node_forecaster -->|"runs"| node_model
node_engine -->|"decodes with"| node_model
node_pipeline -->|"returns forecast"| node_model
node_pipeline -->|"produces"| node_forecast
node_forecast -->|"converts to"| node_pandas
node_user -->|"uses"| node_gluonts
node_gluonts -->|"predicts for"| node_benchmark

click node_pipeline "https://github.com/birla-ai-labs/yug/blob/main/src/yug/pipeline.py"
click node_forecast "https://github.com/birla-ai-labs/yug/blob/main/src/yug/base.py"
click node_forecaster "https://github.com/birla-ai-labs/yug/blob/main/src/yug/forecaster.py"
click node_engine "https://github.com/birla-ai-labs/yug/blob/main/src/yug/engine.py"
click node_utils "https://github.com/birla-ai-labs/yug/blob/main/src/yug/utils.py"
click node_config "https://github.com/birla-ai-labs/yug/blob/main/src/yug/configs.py"
click node_model "https://github.com/birla-ai-labs/yug/blob/main/src/yug/model.py"
click node_gluonts "https://github.com/birla-ai-labs/yug/blob/main/src/yug/gluonts_adapter.py"
click node_pandas "https://github.com/birla-ai-labs/yug/blob/main/src/yug/base.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_pipeline,node_forecast toneBlue
class node_forecaster,node_engine,node_utils,node_config,node_checkpoint toneAmber
class node_model toneMint
class node_gluonts,node_pandas toneRose
class node_user,node_hub,node_benchmark toneIndigo
```

## Components

### Forecast API

- [Forecast pipeline](https://github.com/birla-ai-labs/yug/blob/main/src/yug/pipeline.py): `src/yug/pipeline.py`
- [Quantile result](https://github.com/birla-ai-labs/yug/blob/main/src/yug/base.py): `src/yug/base.py`

### Inference Runtime

- [Batch forecaster](https://github.com/birla-ai-labs/yug/blob/main/src/yug/forecaster.py): `src/yug/forecaster.py`
- [Cached rollout engine](https://github.com/birla-ai-labs/yug/blob/main/src/yug/engine.py): `src/yug/engine.py`
- [Frequency and sampling](https://github.com/birla-ai-labs/yug/blob/main/src/yug/utils.py): `src/yug/utils.py`
- [Model configuration](https://github.com/birla-ai-labs/yug/blob/main/src/yug/configs.py): `src/yug/configs.py`
- **Model checkpoint**

### Forecast Model

- [Patch transformer](https://github.com/birla-ai-labs/yug/blob/main/src/yug/model.py): `src/yug/model.py`

### Integrations

- [GluonTS adapter](https://github.com/birla-ai-labs/yug/blob/main/src/yug/gluonts_adapter.py): `src/yug/gluonts_adapter.py`
- [DataFrame output](https://github.com/birla-ai-labs/yug/blob/main/src/yug/base.py): `src/yug/base.py`

### Other components

- **Forecast caller**
- **Hugging Face Hub**
- **Benchmark harness**

## Connections

- Forecast caller → Forecast pipeline: calls (evidence: `README.md`)
- Forecast pipeline → Model checkpoint: loads (evidence: `src/yug/pipeline.py`)
- Forecast pipeline → Hugging Face Hub: downloads from (evidence: `src/yug/pipeline.py`)
- Forecast pipeline → Model configuration: uses (evidence: `src/yug/pipeline.py`)
- Forecast pipeline → Batch forecaster: delegates to (evidence: `src/yug/pipeline.py`)
- Forecast pipeline → Cached rollout engine: rolls out with (evidence: `src/yug/pipeline.py`)
- Forecast pipeline → Frequency and sampling: samples via (evidence: `src/yug/pipeline.py`)
- Batch forecaster → Patch transformer: runs (evidence: `src/yug/forecaster.py`)
- Cached rollout engine → Patch transformer: decodes with (evidence: `src/yug/engine.py`)
- Forecast pipeline → Patch transformer: returns forecast (evidence: `README.md`)
- Forecast pipeline → Quantile result: produces (evidence: `README.md`)
- Quantile result → DataFrame output: converts to (evidence: `src/yug/base.py`)
- Forecast caller → GluonTS adapter: uses (evidence: `README.md`)
- GluonTS adapter → Benchmark harness: predicts for (evidence: `README.md`)
