# LightGCN vs GraphSAGE Recommender

A stripped graph convolution against a sampled one.

**GraphSAGE Recommender has 70M fewer parameters than LightGCN: 8 layers added, 12 removed, 1 changed.**

Source: https://neurarch.com/diff/lightgcn-vs-graph-sage-rec.html

## Sides

| | LightGCN | GraphSAGE Recommender |
|---|---|---|
| Layers | 11 | 8 |
| Parameters | 70M | 263K |
| Input | 1 | 128 |
| Output | 64 | 128 × 64 |
| Forward-passes | yes | yes |
| Est. train cost | $0.065 | $0.042 |
| T4 16GB | fits | fits |
| A100 40GB | fits | fits |
| H100 80GB | fits | fits |

## Deltas (GraphSAGE Recommender relative to LightGCN)

- Parameters: -70M (-99.6%)
- Layers: -3
- Added 8, removed 12, changed 1, unchanged 1

## Layer by layer

| # | Status | LightGCN | Params | Output | GraphSAGE Recommender | Params | Output |
|---|---|---|---|---|---|---|---|
| 1 | removed | User ID (Input) |  | 1 |  | |  |
| 2 | changed (shape) | Item ID (Input) |  | 1 | Node Features (Input) |  | 128 |
| 3 | removed | E_user(0) (Embedding) | 6.4M | 1 × 64 |  | |  |
| 4 | removed | E_item(0) (Embedding) | 64M | 1 × 64 |  | |  |
| 5 | removed | GraphConv(1) (Graph Conv) | 4.2K | 1 × 64 |  | |  |
| 6 | removed | GraphConv(1) (Graph Conv) | 4.2K | 1 × 64 |  | |  |
| 7 | removed | GraphConv(2) (Graph Conv) | 4.2K | 1 × 64 |  | |  |
| 8 | removed | GraphConv(2) (Graph Conv) | 4.2K | 1 × 64 |  | |  |
| 9 | removed | GraphConv(3) (Graph Conv) | 4.2K | 1 × 64 |  | |  |
| 10 | removed | GraphConv(3) (Graph Conv) | 4.2K | 1 × 64 |  | |  |
| 11 | removed | Layer Combine (mean) (Mean) |  | 64 |  | |  |
| 12 | removed | Layer Combine (mean) (Mean) |  | 64 |  | |  |
| 13 | removed | Dot Score (Matmul) |  | 64 |  | |  |
| 14 | added |  | |  | SAGE Layer 1 (Graph SAGE) | 66K | 128 × 64 |
| 15 | added |  | |  | ReLU (Relu) |  | 128 × 64 |
| 16 | added |  | |  | Dropout (Dropout) |  | 128 × 64 |
| 17 | added |  | |  | SAGE Layer 2 (Graph SAGE) | 131K | 128 × 64 |
| 18 | added |  | |  | ReLU (Relu) |  | 128 × 64 |
| 19 | added |  | |  | Dropout (Dropout) |  | 128 × 64 |
| 20 | added |  | |  | SAGE Layer 3 (Graph SAGE) | 66K | 128 × 64 |
| 21 | added |  | |  | LayerNorm (Layer Norm) | 256 | 128 × 64 |
| 22 | same | Score (Output) |  | 64 | Node Embedding (Output) |  | 128 × 64 |

## What this is not

- The two are priced at different declared inputs (1 against 128), so memory, cost and GPU fit are each right about their own model and are not a comparison between them. The layer and parameter deltas are unaffected.
- Parameter counts are derived from the graph, not read from a checkpoint. They are exact for a graph that is fully specified and approximate for one that is not.
- Cost and GPU fit are estimates from the graph under one set of assumptions, not measurements of a run.

## Graphs

- LightGCN: https://neurarch.com/templates/lightgcn/model.json
- GraphSAGE Recommender: https://neurarch.com/templates/graph-sage-rec/model.json
- Check a graph of your own: `POST https://www.neurarch.com/api/v1/plan`
