Csed-dev commited on
Commit
3b9c1bf
·
verified ·
1 Parent(s): 7cbb665

Add ablation v3 notebook (5 seeds, 1000 epochs, GCN vs MPNN)

Browse files
Files changed (1) hide show
  1. ablation_edge_features_v3.ipynb +1358 -0
ablation_edge_features_v3.ipynb ADDED
@@ -0,0 +1,1358 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "nbformat": 4,
3
+ "nbformat_minor": 0,
4
+ "metadata": {
5
+ "colab": {
6
+ "provenance": [],
7
+ "gpuType": "T4"
8
+ },
9
+ "kernelspec": {
10
+ "name": "python3",
11
+ "display_name": "Python 3"
12
+ },
13
+ "language_info": {
14
+ "name": "python"
15
+ },
16
+ "accelerator": "GPU"
17
+ },
18
+ "cells": [
19
+ {
20
+ "cell_type": "markdown",
21
+ "metadata": {
22
+ "id": "GlQt0wJw149J"
23
+ },
24
+ "source": [
25
+ "# Ablation: GCN vs MPNN Edge Features (v3)\n",
26
+ "\n",
27
+ "**Question:** Does explicit edge-feature message passing improve preconditioner quality over implicit GCN convolution?\n",
28
+ "\n",
29
+ "- GCN (`ContextResGCN`) vs MPNN (`ContextResMPNN`) with matched hyperparameters\n",
30
+ "- 5 training seeds for statistical significance\n",
31
+ "- 3 evaluation domains: diffusion, advection (in-distribution), graph Laplacian (OOD domain)\n",
32
+ "- Jacobi baseline for experiment verification\n",
33
+ "- Primary metric: average FGMRES iterations\n",
34
+ "- Incremental save/resume: results saved after each seed"
35
+ ]
36
+ },
37
+ {
38
+ "cell_type": "code",
39
+ "metadata": {
40
+ "colab": {
41
+ "base_uri": "https://localhost:8080/"
42
+ },
43
+ "id": "0mx9uK5u149L",
44
+ "outputId": "08c589c6-981b-4dd2-ed6c-a45c57c156cb"
45
+ },
46
+ "source": [
47
+ "!pip install matrixpfn"
48
+ ],
49
+ "execution_count": 1,
50
+ "outputs": [
51
+ {
52
+ "output_type": "stream",
53
+ "name": "stdout",
54
+ "text": [
55
+ "Collecting matrixpfn\n",
56
+ " Using cached matrixpfn-0.1.12-py3-none-any.whl.metadata (4.5 kB)\n",
57
+ "Collecting huggingface-hub>=1.6.0 (from matrixpfn)\n",
58
+ " Using cached huggingface_hub-1.6.0-py3-none-any.whl.metadata (13 kB)\n",
59
+ "Requirement already satisfied: matplotlib>=3.7 in /usr/local/lib/python3.12/dist-packages (from matrixpfn) (3.10.0)\n",
60
+ "Requirement already satisfied: numpy>=1.26 in /usr/local/lib/python3.12/dist-packages (from matrixpfn) (2.0.2)\n",
61
+ "Collecting pyamg>=5.0 (from matrixpfn)\n",
62
+ " Using cached pyamg-5.3.0-cp312-cp312-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl.metadata (8.1 kB)\n",
63
+ "Collecting pyarrow>=23.0.1 (from matrixpfn)\n",
64
+ " Using cached pyarrow-23.0.1-cp312-cp312-manylinux_2_28_x86_64.whl.metadata (3.1 kB)\n",
65
+ "Collecting python-igraph>=1.0 (from matrixpfn)\n",
66
+ " Using cached python_igraph-1.0.0-py3-none-any.whl.metadata (3.1 kB)\n",
67
+ "Requirement already satisfied: scipy>=1.11 in /usr/local/lib/python3.12/dist-packages (from matrixpfn) (1.16.3)\n",
68
+ "Requirement already satisfied: torch>=2.0 in /usr/local/lib/python3.12/dist-packages (from matrixpfn) (2.10.0+cu128)\n",
69
+ "Requirement already satisfied: tqdm>=4.60 in /usr/local/lib/python3.12/dist-packages (from matrixpfn) (4.67.3)\n",
70
+ "Requirement already satisfied: filelock>=3.10.0 in /usr/local/lib/python3.12/dist-packages (from huggingface-hub>=1.6.0->matrixpfn) (3.24.3)\n",
71
+ "Requirement already satisfied: fsspec>=2023.5.0 in /usr/local/lib/python3.12/dist-packages (from huggingface-hub>=1.6.0->matrixpfn) (2025.3.0)\n",
72
+ "Collecting hf-xet<2.0.0,>=1.3.2 (from huggingface-hub>=1.6.0->matrixpfn)\n",
73
+ " Using cached hf_xet-1.3.2-cp37-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl.metadata (4.9 kB)\n",
74
+ "Requirement already satisfied: httpx<1,>=0.23.0 in /usr/local/lib/python3.12/dist-packages (from huggingface-hub>=1.6.0->matrixpfn) (0.28.1)\n",
75
+ "Requirement already satisfied: packaging>=20.9 in /usr/local/lib/python3.12/dist-packages (from huggingface-hub>=1.6.0->matrixpfn) (26.0)\n",
76
+ "Requirement already satisfied: pyyaml>=5.1 in /usr/local/lib/python3.12/dist-packages (from huggingface-hub>=1.6.0->matrixpfn) (6.0.3)\n",
77
+ "Requirement already satisfied: typer in /usr/local/lib/python3.12/dist-packages (from huggingface-hub>=1.6.0->matrixpfn) (0.24.1)\n",
78
+ "Requirement already satisfied: typing-extensions>=4.1.0 in /usr/local/lib/python3.12/dist-packages (from huggingface-hub>=1.6.0->matrixpfn) (4.15.0)\n",
79
+ "Requirement already satisfied: contourpy>=1.0.1 in /usr/local/lib/python3.12/dist-packages (from matplotlib>=3.7->matrixpfn) (1.3.3)\n",
80
+ "Requirement already satisfied: cycler>=0.10 in /usr/local/lib/python3.12/dist-packages (from matplotlib>=3.7->matrixpfn) (0.12.1)\n",
81
+ "Requirement already satisfied: fonttools>=4.22.0 in /usr/local/lib/python3.12/dist-packages (from matplotlib>=3.7->matrixpfn) (4.61.1)\n",
82
+ "Requirement already satisfied: kiwisolver>=1.3.1 in /usr/local/lib/python3.12/dist-packages (from matplotlib>=3.7->matrixpfn) (1.4.9)\n",
83
+ "Requirement already satisfied: pillow>=8 in /usr/local/lib/python3.12/dist-packages (from matplotlib>=3.7->matrixpfn) (11.3.0)\n",
84
+ "Requirement already satisfied: pyparsing>=2.3.1 in /usr/local/lib/python3.12/dist-packages (from matplotlib>=3.7->matrixpfn) (3.3.2)\n",
85
+ "Requirement already satisfied: python-dateutil>=2.7 in /usr/local/lib/python3.12/dist-packages (from matplotlib>=3.7->matrixpfn) (2.9.0.post0)\n",
86
+ "Collecting igraph==1.0.0 (from python-igraph>=1.0->matrixpfn)\n",
87
+ " Using cached igraph-1.0.0-cp39-abi3-manylinux_2_28_x86_64.whl.metadata (4.4 kB)\n",
88
+ "Collecting texttable>=1.6.2 (from igraph==1.0.0->python-igraph>=1.0->matrixpfn)\n",
89
+ " Using cached texttable-1.7.0-py2.py3-none-any.whl.metadata (9.8 kB)\n",
90
+ "Requirement already satisfied: setuptools in /usr/local/lib/python3.12/dist-packages (from torch>=2.0->matrixpfn) (75.2.0)\n",
91
+ "Requirement already satisfied: sympy>=1.13.3 in /usr/local/lib/python3.12/dist-packages (from torch>=2.0->matrixpfn) (1.14.0)\n",
92
+ "Requirement already satisfied: networkx>=2.5.1 in /usr/local/lib/python3.12/dist-packages (from torch>=2.0->matrixpfn) (3.6.1)\n",
93
+ "Requirement already satisfied: jinja2 in /usr/local/lib/python3.12/dist-packages (from torch>=2.0->matrixpfn) (3.1.6)\n",
94
+ "Requirement already satisfied: cuda-bindings==12.9.4 in /usr/local/lib/python3.12/dist-packages (from torch>=2.0->matrixpfn) (12.9.4)\n",
95
+ "Requirement already satisfied: nvidia-cuda-nvrtc-cu12==12.8.93 in /usr/local/lib/python3.12/dist-packages (from torch>=2.0->matrixpfn) (12.8.93)\n",
96
+ "Requirement already satisfied: nvidia-cuda-runtime-cu12==12.8.90 in /usr/local/lib/python3.12/dist-packages (from torch>=2.0->matrixpfn) (12.8.90)\n",
97
+ "Requirement already satisfied: nvidia-cuda-cupti-cu12==12.8.90 in /usr/local/lib/python3.12/dist-packages (from torch>=2.0->matrixpfn) (12.8.90)\n",
98
+ "Requirement already satisfied: nvidia-cudnn-cu12==9.10.2.21 in /usr/local/lib/python3.12/dist-packages (from torch>=2.0->matrixpfn) (9.10.2.21)\n",
99
+ "Requirement already satisfied: nvidia-cublas-cu12==12.8.4.1 in /usr/local/lib/python3.12/dist-packages (from torch>=2.0->matrixpfn) (12.8.4.1)\n",
100
+ "Requirement already satisfied: nvidia-cufft-cu12==11.3.3.83 in /usr/local/lib/python3.12/dist-packages (from torch>=2.0->matrixpfn) (11.3.3.83)\n",
101
+ "Requirement already satisfied: nvidia-curand-cu12==10.3.9.90 in /usr/local/lib/python3.12/dist-packages (from torch>=2.0->matrixpfn) (10.3.9.90)\n",
102
+ "Requirement already satisfied: nvidia-cusolver-cu12==11.7.3.90 in /usr/local/lib/python3.12/dist-packages (from torch>=2.0->matrixpfn) (11.7.3.90)\n",
103
+ "Requirement already satisfied: nvidia-cusparse-cu12==12.5.8.93 in /usr/local/lib/python3.12/dist-packages (from torch>=2.0->matrixpfn) (12.5.8.93)\n",
104
+ "Requirement already satisfied: nvidia-cusparselt-cu12==0.7.1 in /usr/local/lib/python3.12/dist-packages (from torch>=2.0->matrixpfn) (0.7.1)\n",
105
+ "Requirement already satisfied: nvidia-nccl-cu12==2.27.5 in /usr/local/lib/python3.12/dist-packages (from torch>=2.0->matrixpfn) (2.27.5)\n",
106
+ "Requirement already satisfied: nvidia-nvshmem-cu12==3.4.5 in /usr/local/lib/python3.12/dist-packages (from torch>=2.0->matrixpfn) (3.4.5)\n",
107
+ "Requirement already satisfied: nvidia-nvtx-cu12==12.8.90 in /usr/local/lib/python3.12/dist-packages (from torch>=2.0->matrixpfn) (12.8.90)\n",
108
+ "Requirement already satisfied: nvidia-nvjitlink-cu12==12.8.93 in /usr/local/lib/python3.12/dist-packages (from torch>=2.0->matrixpfn) (12.8.93)\n",
109
+ "Requirement already satisfied: nvidia-cufile-cu12==1.13.1.3 in /usr/local/lib/python3.12/dist-packages (from torch>=2.0->matrixpfn) (1.13.1.3)\n",
110
+ "Requirement already satisfied: triton==3.6.0 in /usr/local/lib/python3.12/dist-packages (from torch>=2.0->matrixpfn) (3.6.0)\n",
111
+ "Requirement already satisfied: cuda-pathfinder~=1.1 in /usr/local/lib/python3.12/dist-packages (from cuda-bindings==12.9.4->torch>=2.0->matrixpfn) (1.4.0)\n",
112
+ "Requirement already satisfied: anyio in /usr/local/lib/python3.12/dist-packages (from httpx<1,>=0.23.0->huggingface-hub>=1.6.0->matrixpfn) (4.12.1)\n",
113
+ "Requirement already satisfied: certifi in /usr/local/lib/python3.12/dist-packages (from httpx<1,>=0.23.0->huggingface-hub>=1.6.0->matrixpfn) (2026.2.25)\n",
114
+ "Requirement already satisfied: httpcore==1.* in /usr/local/lib/python3.12/dist-packages (from httpx<1,>=0.23.0->huggingface-hub>=1.6.0->matrixpfn) (1.0.9)\n",
115
+ "Requirement already satisfied: idna in /usr/local/lib/python3.12/dist-packages (from httpx<1,>=0.23.0->huggingface-hub>=1.6.0->matrixpfn) (3.11)\n",
116
+ "Requirement already satisfied: h11>=0.16 in /usr/local/lib/python3.12/dist-packages (from httpcore==1.*->httpx<1,>=0.23.0->huggingface-hub>=1.6.0->matrixpfn) (0.16.0)\n",
117
+ "Requirement already satisfied: six>=1.5 in /usr/local/lib/python3.12/dist-packages (from python-dateutil>=2.7->matplotlib>=3.7->matrixpfn) (1.17.0)\n",
118
+ "Requirement already satisfied: mpmath<1.4,>=1.1.0 in /usr/local/lib/python3.12/dist-packages (from sympy>=1.13.3->torch>=2.0->matrixpfn) (1.3.0)\n",
119
+ "Requirement already satisfied: MarkupSafe>=2.0 in /usr/local/lib/python3.12/dist-packages (from jinja2->torch>=2.0->matrixpfn) (3.0.3)\n",
120
+ "Requirement already satisfied: click>=8.2.1 in /usr/local/lib/python3.12/dist-packages (from typer->huggingface-hub>=1.6.0->matrixpfn) (8.3.1)\n",
121
+ "Requirement already satisfied: shellingham>=1.3.0 in /usr/local/lib/python3.12/dist-packages (from typer->huggingface-hub>=1.6.0->matrixpfn) (1.5.4)\n",
122
+ "Requirement already satisfied: rich>=12.3.0 in /usr/local/lib/python3.12/dist-packages (from typer->huggingface-hub>=1.6.0->matrixpfn) (13.9.4)\n",
123
+ "Requirement already satisfied: annotated-doc>=0.0.2 in /usr/local/lib/python3.12/dist-packages (from typer->huggingface-hub>=1.6.0->matrixpfn) (0.0.4)\n",
124
+ "Requirement already satisfied: markdown-it-py>=2.2.0 in /usr/local/lib/python3.12/dist-packages (from rich>=12.3.0->typer->huggingface-hub>=1.6.0->matrixpfn) (4.0.0)\n",
125
+ "Requirement already satisfied: pygments<3.0.0,>=2.13.0 in /usr/local/lib/python3.12/dist-packages (from rich>=12.3.0->typer->huggingface-hub>=1.6.0->matrixpfn) (2.19.2)\n",
126
+ "Requirement already satisfied: mdurl~=0.1 in /usr/local/lib/python3.12/dist-packages (from markdown-it-py>=2.2.0->rich>=12.3.0->typer->huggingface-hub>=1.6.0->matrixpfn) (0.1.2)\n",
127
+ "Using cached matrixpfn-0.1.12-py3-none-any.whl (47 kB)\n",
128
+ "Using cached huggingface_hub-1.6.0-py3-none-any.whl (612 kB)\n",
129
+ "Using cached pyamg-5.3.0-cp312-cp312-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl (1.9 MB)\n",
130
+ "Using cached pyarrow-23.0.1-cp312-cp312-manylinux_2_28_x86_64.whl (47.6 MB)\n",
131
+ "Using cached python_igraph-1.0.0-py3-none-any.whl (9.2 kB)\n",
132
+ "Using cached igraph-1.0.0-cp39-abi3-manylinux_2_28_x86_64.whl (5.7 MB)\n",
133
+ "Downloading hf_xet-1.3.2-cp37-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl (4.2 MB)\n",
134
+ "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m4.2/4.2 MB\u001b[0m \u001b[31m43.8 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
135
+ "\u001b[?25hDownloading texttable-1.7.0-py2.py3-none-any.whl (10 kB)\n",
136
+ "Installing collected packages: texttable, pyarrow, igraph, hf-xet, python-igraph, pyamg, huggingface-hub, matrixpfn\n",
137
+ " Attempting uninstall: pyarrow\n",
138
+ " Found existing installation: pyarrow 18.1.0\n",
139
+ " Uninstalling pyarrow-18.1.0:\n",
140
+ " Successfully uninstalled pyarrow-18.1.0\n",
141
+ " Attempting uninstall: hf-xet\n",
142
+ " Found existing installation: hf-xet 1.3.1\n",
143
+ " Uninstalling hf-xet-1.3.1:\n",
144
+ " Successfully uninstalled hf-xet-1.3.1\n",
145
+ " Attempting uninstall: huggingface-hub\n",
146
+ " Found existing installation: huggingface_hub 1.5.0\n",
147
+ " Uninstalling huggingface_hub-1.5.0:\n",
148
+ " Successfully uninstalled huggingface_hub-1.5.0\n",
149
+ "Successfully installed hf-xet-1.3.2 huggingface-hub-1.6.0 igraph-1.0.0 matrixpfn-0.1.12 pyamg-5.3.0 pyarrow-23.0.1 python-igraph-1.0.0 texttable-1.7.0\n"
150
+ ]
151
+ }
152
+ ]
153
+ },
154
+ {
155
+ "cell_type": "markdown",
156
+ "metadata": {
157
+ "id": "ZfJO3eDm149L"
158
+ },
159
+ "source": [
160
+ "## Imports & Device Setup"
161
+ ]
162
+ },
163
+ {
164
+ "cell_type": "code",
165
+ "metadata": {
166
+ "colab": {
167
+ "base_uri": "https://localhost:8080/"
168
+ },
169
+ "id": "UdqQg8ob149L",
170
+ "outputId": "9edb9124-ce12-4805-864e-40ce04b41ad1"
171
+ },
172
+ "source": [
173
+ "import json\n",
174
+ "import time\n",
175
+ "import random\n",
176
+ "from pathlib import Path\n",
177
+ "from dataclasses import dataclass, field\n",
178
+ "\n",
179
+ "import numpy as np\n",
180
+ "import torch\n",
181
+ "\n",
182
+ "from matrixpfn.generator.base import MatrixDomain\n",
183
+ "from matrixpfn.generator.domains.diffusion import DiffusionGenerator\n",
184
+ "from matrixpfn.generator.domains.diffusion_advection import DiffusionAdvectionGenerator\n",
185
+ "from matrixpfn.generator.domains.fast_graph_laplacian import FastGraphLaplacianGenerator\n",
186
+ "from matrixpfn.generator.online import OnlineMatrixDataset\n",
187
+ "from matrixpfn.generator.registry import MatrixGeneratorRegistry\n",
188
+ "from matrixpfn.nn.context_resgcn import ContextResGCN, ContextResMPNN\n",
189
+ "from matrixpfn.precond.jacobi import Jacobi\n",
190
+ "from matrixpfn.precond.matrix_pfn import MatrixPFN, TrainingConfig\n",
191
+ "from matrixpfn.solver.fgmres import FGMRES, Preconditioner\n",
192
+ "\n",
193
+ "device = torch.device(\"cuda\" if torch.cuda.is_available() else \"cpu\")\n",
194
+ "print(f\"Device: {device}\")"
195
+ ],
196
+ "execution_count": 2,
197
+ "outputs": [
198
+ {
199
+ "output_type": "stream",
200
+ "name": "stdout",
201
+ "text": [
202
+ "Device: cuda\n"
203
+ ]
204
+ }
205
+ ]
206
+ },
207
+ {
208
+ "cell_type": "markdown",
209
+ "metadata": {
210
+ "id": "1WtJ8Rlt149M"
211
+ },
212
+ "source": [
213
+ "## Configuration"
214
+ ]
215
+ },
216
+ {
217
+ "cell_type": "code",
218
+ "metadata": {
219
+ "colab": {
220
+ "base_uri": "https://localhost:8080/"
221
+ },
222
+ "id": "sSIXV7nv149M",
223
+ "outputId": "9248bb04-7bad-439b-e432-612e58866b40"
224
+ },
225
+ "source": [
226
+ "RESULTS_FILE = Path(\"/content/ablation_edge_features_v3.json\")\n",
227
+ "\n",
228
+ "NUM_LAYERS = 8\n",
229
+ "EMBED_DIM = 16\n",
230
+ "HIDDEN_DIM = 32\n",
231
+ "NUM_CONTEXT_PAIRS = 5\n",
232
+ "\n",
233
+ "TRAINING_GRID_SIZES = (16, 24, 32)\n",
234
+ "EVAL_GRID_SIZES = (16, 24, 32, 48)\n",
235
+ "\n",
236
+ "TRAINING_EPOCHS = 1000\n",
237
+ "MATRICES_PER_EPOCH = 4\n",
238
+ "BATCH_SIZE = 16\n",
239
+ "LEARNING_RATE = 1e-3\n",
240
+ "\n",
241
+ "GMRES_RESTART = 30\n",
242
+ "GMRES_MAX_ITERS = 300\n",
243
+ "GMRES_RTOL = 1e-6\n",
244
+ "NUM_TEST_MATRICES = 20\n",
245
+ "\n",
246
+ "SEEDS = [42, 123, 456, 789, 1337]\n",
247
+ "\n",
248
+ "TRAIN_DOMAINS = [\"diffusion\", \"advection\"]\n",
249
+ "EVAL_DOMAINS = [\"diffusion\", \"advection\", \"graph_laplacian\"]\n",
250
+ "\n",
251
+ "print(f\"Seeds: {SEEDS}\")\n",
252
+ "print(f\"Training: {TRAIN_DOMAINS} on grids {TRAINING_GRID_SIZES}, {TRAINING_EPOCHS} epochs\")\n",
253
+ "print(f\"Eval: {EVAL_DOMAINS} on grids {EVAL_GRID_SIZES}\")"
254
+ ],
255
+ "execution_count": 3,
256
+ "outputs": [
257
+ {
258
+ "output_type": "stream",
259
+ "name": "stdout",
260
+ "text": [
261
+ "Seeds: [42, 123, 456, 789, 1337]\n",
262
+ "Training: ['diffusion', 'advection'] on grids (16, 24, 32), 1000 epochs\n",
263
+ "Eval: ['diffusion', 'advection', 'graph_laplacian'] on grids (16, 24, 32, 48)\n"
264
+ ]
265
+ }
266
+ ]
267
+ },
268
+ {
269
+ "cell_type": "markdown",
270
+ "metadata": {
271
+ "id": "NusZgIcf149M"
272
+ },
273
+ "source": [
274
+ "## Utilities"
275
+ ]
276
+ },
277
+ {
278
+ "cell_type": "code",
279
+ "metadata": {
280
+ "id": "idXLCklG149M"
281
+ },
282
+ "source": [
283
+ "@dataclass\n",
284
+ "class EvalResult:\n",
285
+ " iterations: list[int] = field(default_factory=list)\n",
286
+ " converged: list[bool] = field(default_factory=list)\n",
287
+ " final_residuals: list[float] = field(default_factory=list)\n",
288
+ " solve_times: list[float] = field(default_factory=list)\n",
289
+ "\n",
290
+ "\n",
291
+ "def count_parameters(model: torch.nn.Module) -> int:\n",
292
+ " return sum(p.numel() for p in model.parameters() if p.requires_grad)\n",
293
+ "\n",
294
+ "\n",
295
+ "def make_train_dataset(grid_sizes: tuple[int, ...], device: torch.device) -> OnlineMatrixDataset:\n",
296
+ " diff_gen = DiffusionGenerator(grid_sizes, device)\n",
297
+ " adv_gen = DiffusionAdvectionGenerator(diff_gen)\n",
298
+ " registry = MatrixGeneratorRegistry({\n",
299
+ " MatrixDomain.DIFFUSION: diff_gen,\n",
300
+ " MatrixDomain.DIFFUSION_ADVECTION: adv_gen,\n",
301
+ " })\n",
302
+ " return OnlineMatrixDataset(registry, NUM_CONTEXT_PAIRS)\n",
303
+ "\n",
304
+ "\n",
305
+ "def train_model(name: str, model: torch.nn.Module, device: torch.device, seed: int) -> dict:\n",
306
+ " print(f\"\\n Training {name} ({count_parameters(model):,} params) seed={seed}\")\n",
307
+ "\n",
308
+ " optimizer = torch.optim.Adam(model.parameters(), lr=LEARNING_RATE)\n",
309
+ " precond = MatrixPFN(model, model_device=device)\n",
310
+ " dataset = make_train_dataset(TRAINING_GRID_SIZES, device)\n",
311
+ "\n",
312
+ " config = TrainingConfig(\n",
313
+ " batch_size=BATCH_SIZE,\n",
314
+ " epochs=TRAINING_EPOCHS,\n",
315
+ " matrices_per_epoch=MATRICES_PER_EPOCH,\n",
316
+ " num_context_pairs=NUM_CONTEXT_PAIRS,\n",
317
+ " learning_rate=LEARNING_RATE,\n",
318
+ " )\n",
319
+ "\n",
320
+ " tic = time.perf_counter()\n",
321
+ " history = precond.train(dataset, config=config, optimizer=optimizer)\n",
322
+ " train_time = time.perf_counter() - tic\n",
323
+ "\n",
324
+ " best_loss = history[\"best_loss\"]\n",
325
+ " best_epoch = history[\"best_epoch\"]\n",
326
+ " final_loss = history[\"loss\"][-1]\n",
327
+ " print(f\" best={best_loss:.4e} @{best_epoch}, final={final_loss:.4e}, {train_time:.1f}s\")\n",
328
+ "\n",
329
+ " return {\n",
330
+ " \"name\": name,\n",
331
+ " \"param_count\": count_parameters(model),\n",
332
+ " \"train_time\": train_time,\n",
333
+ " \"train_history\": history[\"loss\"],\n",
334
+ " \"best_loss\": best_loss,\n",
335
+ " \"best_epoch\": best_epoch,\n",
336
+ " }\n",
337
+ "\n",
338
+ "\n",
339
+ "def generate_test_matrix(gen, num_context_pairs: int) -> tuple[torch.Tensor, torch.Tensor]:\n",
340
+ " data = gen.generate_batch(1, num_context_pairs)\n",
341
+ " A = torch.sparse_coo_tensor(\n",
342
+ " data.indices, data.values[0], (data.n, data.n)\n",
343
+ " ).coalesce().to_sparse_csc()\n",
344
+ " b = torch.randn(data.n, dtype=torch.float64, device=A.device)\n",
345
+ " return A, b\n",
346
+ "\n",
347
+ "\n",
348
+ "def make_test_generator(domain: str, grid_size: int, device: torch.device):\n",
349
+ " if domain == \"diffusion\":\n",
350
+ " return DiffusionGenerator(grid_size, device)\n",
351
+ " if domain == \"advection\":\n",
352
+ " return DiffusionAdvectionGenerator(DiffusionGenerator(grid_size, device))\n",
353
+ " if domain == \"graph_laplacian\":\n",
354
+ " return FastGraphLaplacianGenerator(grid_size * grid_size, device)\n",
355
+ " raise ValueError(f\"Unknown domain: {domain}\")\n",
356
+ "\n",
357
+ "\n",
358
+ "def evaluate_preconditioner(\n",
359
+ " precond_factory, test_matrices: list[tuple[torch.Tensor, torch.Tensor]],\n",
360
+ ") -> dict:\n",
361
+ " solver = FGMRES(restart=GMRES_RESTART, max_iters=GMRES_MAX_ITERS, rtol=GMRES_RTOL)\n",
362
+ " er = EvalResult()\n",
363
+ "\n",
364
+ " for A, b in test_matrices:\n",
365
+ " tic = time.perf_counter()\n",
366
+ " M = precond_factory(A)\n",
367
+ " sr = solver.solve(A, b, M=M, progress_bar=False)\n",
368
+ " elapsed = time.perf_counter() - tic\n",
369
+ "\n",
370
+ " er.iterations.append(sr.iterations)\n",
371
+ " er.converged.append(sr.converged)\n",
372
+ " er.final_residuals.append(sr.final_residual)\n",
373
+ " er.solve_times.append(elapsed)\n",
374
+ "\n",
375
+ " return {\n",
376
+ " \"iterations\": er.iterations,\n",
377
+ " \"converged\": er.converged,\n",
378
+ " \"final_residuals\": er.final_residuals,\n",
379
+ " \"solve_times\": er.solve_times,\n",
380
+ " }\n",
381
+ "\n",
382
+ "\n",
383
+ "def make_neural_factory(model: torch.nn.Module, device: torch.device):\n",
384
+ " def factory(A: torch.Tensor):\n",
385
+ " precond = MatrixPFN(model, model_device=device)\n",
386
+ " precond.prepare_for_solve(A, num_context_pairs=NUM_CONTEXT_PAIRS)\n",
387
+ " return precond\n",
388
+ " return factory"
389
+ ],
390
+ "execution_count": 4,
391
+ "outputs": []
392
+ },
393
+ {
394
+ "cell_type": "markdown",
395
+ "metadata": {
396
+ "id": "Iz6UY3O1149M"
397
+ },
398
+ "source": [
399
+ "## Save / Resume Logic\n",
400
+ "\n",
401
+ "Results are saved incrementally after each seed completes. If the notebook is interrupted, re-running will skip already-completed seeds."
402
+ ]
403
+ },
404
+ {
405
+ "cell_type": "code",
406
+ "metadata": {
407
+ "id": "szi5rxpl149M"
408
+ },
409
+ "source": [
410
+ "def load_existing_results() -> dict:\n",
411
+ " if RESULTS_FILE.exists():\n",
412
+ " with open(RESULTS_FILE) as f:\n",
413
+ " return json.load(f)\n",
414
+ " return {\n",
415
+ " \"config\": {\n",
416
+ " \"num_layers\": NUM_LAYERS,\n",
417
+ " \"embed_dim\": EMBED_DIM,\n",
418
+ " \"hidden_dim\": HIDDEN_DIM,\n",
419
+ " \"num_context_pairs\": NUM_CONTEXT_PAIRS,\n",
420
+ " \"training_grid_sizes\": list(TRAINING_GRID_SIZES),\n",
421
+ " \"eval_grid_sizes\": list(EVAL_GRID_SIZES),\n",
422
+ " \"training_epochs\": TRAINING_EPOCHS,\n",
423
+ " \"matrices_per_epoch\": MATRICES_PER_EPOCH,\n",
424
+ " \"batch_size\": BATCH_SIZE,\n",
425
+ " \"learning_rate\": LEARNING_RATE,\n",
426
+ " \"gmres_restart\": GMRES_RESTART,\n",
427
+ " \"gmres_max_iters\": GMRES_MAX_ITERS,\n",
428
+ " \"gmres_rtol\": GMRES_RTOL,\n",
429
+ " \"num_test_matrices\": NUM_TEST_MATRICES,\n",
430
+ " \"seeds\": SEEDS,\n",
431
+ " \"train_domains\": TRAIN_DOMAINS,\n",
432
+ " \"eval_domains\": EVAL_DOMAINS,\n",
433
+ " },\n",
434
+ " \"seeds\": [],\n",
435
+ " }\n",
436
+ "\n",
437
+ "\n",
438
+ "def save_results(data: dict):\n",
439
+ " RESULTS_FILE.parent.mkdir(parents=True, exist_ok=True)\n",
440
+ " with open(RESULTS_FILE, \"w\") as f:\n",
441
+ " json.dump(data, f, indent=2)\n",
442
+ "\n",
443
+ "\n",
444
+ "def completed_seeds(data: dict) -> set[int]:\n",
445
+ " return {s[\"seed\"] for s in data[\"seeds\"]}\n",
446
+ "\n",
447
+ "\n",
448
+ "def set_all_seeds(seed: int):\n",
449
+ " torch.manual_seed(seed)\n",
450
+ " random.seed(seed)\n",
451
+ " np.random.seed(seed)\n",
452
+ " if torch.cuda.is_available():\n",
453
+ " torch.cuda.manual_seed(seed)"
454
+ ],
455
+ "execution_count": 5,
456
+ "outputs": []
457
+ },
458
+ {
459
+ "cell_type": "markdown",
460
+ "metadata": {
461
+ "id": "IDoC_Red149M"
462
+ },
463
+ "source": [
464
+ "## Per-Seed Training & Evaluation"
465
+ ]
466
+ },
467
+ {
468
+ "cell_type": "code",
469
+ "metadata": {
470
+ "id": "hR2HLdoi149M"
471
+ },
472
+ "source": [
473
+ "def run_seed(seed: int, device: torch.device) -> dict:\n",
474
+ " set_all_seeds(seed)\n",
475
+ "\n",
476
+ " print(f\"\\n{'='*70}\")\n",
477
+ " print(f\"SEED {seed}\")\n",
478
+ " print(f\"{'='*70}\")\n",
479
+ "\n",
480
+ " gcn = ContextResGCN(\n",
481
+ " num_layers=NUM_LAYERS, embed=EMBED_DIM, hidden=HIDDEN_DIM,\n",
482
+ " drop_rate=0.0, num_context_pairs=NUM_CONTEXT_PAIRS, dtype=torch.float32,\n",
483
+ " ).to(device)\n",
484
+ "\n",
485
+ " mpnn = ContextResMPNN(\n",
486
+ " num_layers=NUM_LAYERS, embed=EMBED_DIM, hidden=HIDDEN_DIM,\n",
487
+ " drop_rate=0.0, num_context_pairs=NUM_CONTEXT_PAIRS, dtype=torch.float32,\n",
488
+ " ).to(device)\n",
489
+ "\n",
490
+ " gcn_train = train_model(\"GCN\", gcn, device, seed)\n",
491
+ " mpnn_train = train_model(\"MPNN\", mpnn, device, seed)\n",
492
+ "\n",
493
+ " test_seed = seed + 99999\n",
494
+ " set_all_seeds(test_seed)\n",
495
+ "\n",
496
+ " models = [\n",
497
+ " {\"name\": \"No Preconditioner\", \"param_count\": 0, \"train_time\": 0.0,\n",
498
+ " \"train_history\": [], \"best_loss\": None, \"best_epoch\": None,\n",
499
+ " \"factory\": lambda A: None},\n",
500
+ " {\"name\": \"Jacobi\", \"param_count\": 0, \"train_time\": 0.0,\n",
501
+ " \"train_history\": [], \"best_loss\": None, \"best_epoch\": None,\n",
502
+ " \"factory\": lambda A: Jacobi(A)},\n",
503
+ " {**gcn_train, \"factory\": make_neural_factory(gcn, device)},\n",
504
+ " {**mpnn_train, \"factory\": make_neural_factory(mpnn, device)},\n",
505
+ " ]\n",
506
+ "\n",
507
+ " for domain in EVAL_DOMAINS:\n",
508
+ " for gs in EVAL_GRID_SIZES:\n",
509
+ " key = f\"{domain}_{gs}\"\n",
510
+ " ood = gs not in TRAINING_GRID_SIZES\n",
511
+ " ood_domain = domain == \"graph_laplacian\"\n",
512
+ " tags = []\n",
513
+ " if ood:\n",
514
+ " tags.append(\"OOD-size\")\n",
515
+ " if ood_domain:\n",
516
+ " tags.append(\"OOD-domain\")\n",
517
+ " tag_str = f\" ({', '.join(tags)})\" if tags else \"\"\n",
518
+ " print(f\"\\n Eval: {domain} {gs}x{gs}{tag_str}\")\n",
519
+ "\n",
520
+ " gen = make_test_generator(domain, gs, device)\n",
521
+ " test_matrices = [generate_test_matrix(gen, NUM_CONTEXT_PAIRS) for _ in range(NUM_TEST_MATRICES)]\n",
522
+ "\n",
523
+ " for m in models:\n",
524
+ " eval_data = evaluate_preconditioner(m[\"factory\"], test_matrices)\n",
525
+ " conv = sum(eval_data[\"converged\"])\n",
526
+ " avg_iter = sum(eval_data[\"iterations\"]) / NUM_TEST_MATRICES\n",
527
+ " print(f\" {m['name']:<20s} conv={conv}/{NUM_TEST_MATRICES} avg_iter={avg_iter:.1f}\")\n",
528
+ "\n",
529
+ " if \"eval\" not in m:\n",
530
+ " m[\"eval\"] = {}\n",
531
+ " m[\"eval\"][key] = eval_data\n",
532
+ "\n",
533
+ " seed_result = {\"seed\": seed, \"models\": []}\n",
534
+ " for m in models:\n",
535
+ " model_data = {\n",
536
+ " \"name\": m[\"name\"],\n",
537
+ " \"param_count\": m[\"param_count\"],\n",
538
+ " \"train_time\": m[\"train_time\"],\n",
539
+ " \"train_history\": m[\"train_history\"],\n",
540
+ " \"best_loss\": m.get(\"best_loss\"),\n",
541
+ " \"best_epoch\": m.get(\"best_epoch\"),\n",
542
+ " \"eval\": m.get(\"eval\", {}),\n",
543
+ " }\n",
544
+ " seed_result[\"models\"].append(model_data)\n",
545
+ "\n",
546
+ " del gcn, mpnn\n",
547
+ " if torch.cuda.is_available():\n",
548
+ " torch.cuda.empty_cache()\n",
549
+ "\n",
550
+ " return seed_result"
551
+ ],
552
+ "execution_count": 6,
553
+ "outputs": []
554
+ },
555
+ {
556
+ "cell_type": "markdown",
557
+ "metadata": {
558
+ "id": "NFrRBXRL149N"
559
+ },
560
+ "source": [
561
+ "## Run All Seeds\n",
562
+ "\n",
563
+ "Completed seeds are skipped automatically. Results are saved to disk after each seed finishes."
564
+ ]
565
+ },
566
+ {
567
+ "cell_type": "code",
568
+ "metadata": {
569
+ "colab": {
570
+ "base_uri": "https://localhost:8080/"
571
+ },
572
+ "id": "gvgRzx1K149N",
573
+ "outputId": "0eb50eb0-3713-4a73-bd43-3297c8fc278f"
574
+ },
575
+ "source": [
576
+ "data = load_existing_results()\n",
577
+ "done = completed_seeds(data)\n",
578
+ "\n",
579
+ "for seed in SEEDS:\n",
580
+ " if seed in done:\n",
581
+ " print(f\"\\nSeed {seed} already completed, skipping.\")\n",
582
+ " continue\n",
583
+ "\n",
584
+ " seed_result = run_seed(seed, device)\n",
585
+ " data[\"seeds\"].append(seed_result)\n",
586
+ " save_results(data)\n",
587
+ " print(f\"\\n Seed {seed} saved to {RESULTS_FILE}\")\n",
588
+ " done.add(seed)\n",
589
+ "\n",
590
+ "print(f\"\\nAll seeds complete. Results at {RESULTS_FILE}\")"
591
+ ],
592
+ "execution_count": 7,
593
+ "outputs": [
594
+ {
595
+ "output_type": "stream",
596
+ "name": "stdout",
597
+ "text": [
598
+ "\n",
599
+ "======================================================================\n",
600
+ "SEED 42\n",
601
+ "======================================================================\n",
602
+ "\n",
603
+ " Training GCN (11,074 params) seed=42\n"
604
+ ]
605
+ },
606
+ {
607
+ "output_type": "stream",
608
+ "name": "stderr",
609
+ "text": [
610
+ "\rTraining: 0%| | 0/1000 [00:00<?, ?it/s]/usr/local/lib/python3.12/dist-packages/matrixpfn/precond/matrix_pfn.py:70: UserWarning: Sparse CSR tensor support is in beta state. If you miss a functionality in the sparse tensor support, please submit a feature request to https://github.com/pytorch/pytorch/issues. (Triggered internally at /pytorch/aten/src/ATen/SparseCsrTensorImpl.cpp:49.)\n",
611
+ " ).coalesce().to_sparse_csc()\n",
612
+ "Loss: 9.4065e-02: 100%|██████████| 1000/1000 [01:39<00:00, 10.09it/s]\n"
613
+ ]
614
+ },
615
+ {
616
+ "output_type": "stream",
617
+ "name": "stdout",
618
+ "text": [
619
+ " best=8.9670e-02 @948, final=9.4065e-02, 99.1s\n",
620
+ "\n",
621
+ " Training MPNN (15,426 params) seed=42\n"
622
+ ]
623
+ },
624
+ {
625
+ "output_type": "stream",
626
+ "name": "stderr",
627
+ "text": [
628
+ "Loss: 8.9550e-02: 100%|██████████| 1000/1000 [01:40<00:00, 9.91it/s]\n"
629
+ ]
630
+ },
631
+ {
632
+ "output_type": "stream",
633
+ "name": "stdout",
634
+ "text": [
635
+ " best=8.6703e-02 @994, final=8.9550e-02, 101.0s\n",
636
+ "\n",
637
+ " Eval: diffusion 16x16\n",
638
+ " No Preconditioner conv=20/20 avg_iter=90.7\n",
639
+ " Jacobi conv=20/20 avg_iter=62.4\n",
640
+ " GCN conv=20/20 avg_iter=24.6\n",
641
+ " MPNN conv=20/20 avg_iter=22.6\n",
642
+ "\n",
643
+ " Eval: diffusion 24x24\n",
644
+ " No Preconditioner conv=20/20 avg_iter=134.8\n",
645
+ " Jacobi conv=20/20 avg_iter=101.1\n",
646
+ " GCN conv=20/20 avg_iter=36.0\n",
647
+ " MPNN conv=20/20 avg_iter=31.6\n",
648
+ "\n",
649
+ " Eval: diffusion 32x32\n",
650
+ " No Preconditioner conv=20/20 avg_iter=208.3\n",
651
+ " Jacobi conv=20/20 avg_iter=131.8\n",
652
+ " GCN conv=20/20 avg_iter=49.9\n",
653
+ " MPNN conv=20/20 avg_iter=43.0\n",
654
+ "\n",
655
+ " Eval: diffusion 48x48 (OOD-size)\n",
656
+ " No Preconditioner conv=1/20 avg_iter=299.4\n",
657
+ " Jacobi conv=19/20 avg_iter=233.4\n",
658
+ " GCN conv=20/20 avg_iter=76.5\n",
659
+ " MPNN conv=20/20 avg_iter=59.0\n",
660
+ "\n",
661
+ " Eval: advection 16x16\n",
662
+ " No Preconditioner conv=20/20 avg_iter=84.5\n",
663
+ " Jacobi conv=20/20 avg_iter=61.3\n",
664
+ " GCN conv=20/20 avg_iter=24.6\n",
665
+ " MPNN conv=20/20 avg_iter=23.2\n",
666
+ "\n",
667
+ " Eval: advection 24x24\n",
668
+ " No Preconditioner conv=20/20 avg_iter=140.7\n",
669
+ " Jacobi conv=20/20 avg_iter=98.2\n",
670
+ " GCN conv=20/20 avg_iter=36.5\n",
671
+ " MPNN conv=20/20 avg_iter=32.5\n",
672
+ "\n",
673
+ " Eval: advection 32x32\n",
674
+ " No Preconditioner conv=20/20 avg_iter=214.2\n",
675
+ " Jacobi conv=20/20 avg_iter=140.9\n",
676
+ " GCN conv=20/20 avg_iter=50.9\n",
677
+ " MPNN conv=20/20 avg_iter=41.2\n",
678
+ "\n",
679
+ " Eval: advection 48x48 (OOD-size)\n",
680
+ " No Preconditioner conv=1/20 avg_iter=298.8\n",
681
+ " Jacobi conv=19/20 avg_iter=229.8\n",
682
+ " GCN conv=20/20 avg_iter=78.1\n",
683
+ " MPNN conv=20/20 avg_iter=58.8\n",
684
+ "\n",
685
+ " Eval: graph_laplacian 16x16 (OOD-domain)\n",
686
+ " No Preconditioner conv=20/20 avg_iter=14.2\n",
687
+ " Jacobi conv=20/20 avg_iter=8.7\n",
688
+ " GCN conv=20/20 avg_iter=6.8\n",
689
+ " MPNN conv=0/20 avg_iter=300.0\n",
690
+ "\n",
691
+ " Eval: graph_laplacian 24x24 (OOD-domain)\n",
692
+ " No Preconditioner conv=20/20 avg_iter=14.9\n",
693
+ " Jacobi conv=20/20 avg_iter=8.1\n",
694
+ " GCN conv=20/20 avg_iter=7.4\n",
695
+ " MPNN conv=0/20 avg_iter=300.0\n",
696
+ "\n",
697
+ " Eval: graph_laplacian 32x32 (OOD-domain)\n",
698
+ " No Preconditioner conv=20/20 avg_iter=14.6\n",
699
+ " Jacobi conv=20/20 avg_iter=7.3\n",
700
+ " GCN conv=20/20 avg_iter=7.9\n",
701
+ " MPNN conv=0/20 avg_iter=300.0\n",
702
+ "\n",
703
+ " Eval: graph_laplacian 48x48 (OOD-size, OOD-domain)\n",
704
+ " No Preconditioner conv=20/20 avg_iter=14.5\n",
705
+ " Jacobi conv=20/20 avg_iter=6.8\n",
706
+ " GCN conv=20/20 avg_iter=8.0\n",
707
+ " MPNN conv=0/20 avg_iter=300.0\n",
708
+ "\n",
709
+ " Seed 42 saved to /content/ablation_edge_features_v3.json\n",
710
+ "\n",
711
+ "======================================================================\n",
712
+ "SEED 123\n",
713
+ "======================================================================\n",
714
+ "\n",
715
+ " Training GCN (11,074 params) seed=123\n"
716
+ ]
717
+ },
718
+ {
719
+ "output_type": "stream",
720
+ "name": "stderr",
721
+ "text": [
722
+ "Loss: 1.0292e-01: 100%|██████████| 1000/1000 [01:41<00:00, 9.83it/s]\n"
723
+ ]
724
+ },
725
+ {
726
+ "output_type": "stream",
727
+ "name": "stdout",
728
+ "text": [
729
+ " best=9.0703e-02 @968, final=1.0292e-01, 101.8s\n",
730
+ "\n",
731
+ " Training MPNN (15,426 params) seed=123\n"
732
+ ]
733
+ },
734
+ {
735
+ "output_type": "stream",
736
+ "name": "stderr",
737
+ "text": [
738
+ "Loss: 1.1386e-01: 100%|██████████| 1000/1000 [01:46<00:00, 9.35it/s]\n"
739
+ ]
740
+ },
741
+ {
742
+ "output_type": "stream",
743
+ "name": "stdout",
744
+ "text": [
745
+ " best=9.3307e-02 @870, final=1.1386e-01, 107.0s\n",
746
+ "\n",
747
+ " Eval: diffusion 16x16\n",
748
+ " No Preconditioner conv=20/20 avg_iter=83.6\n",
749
+ " Jacobi conv=20/20 avg_iter=61.7\n",
750
+ " GCN conv=20/20 avg_iter=19.2\n",
751
+ " MPNN conv=20/20 avg_iter=24.4\n",
752
+ "\n",
753
+ " Eval: diffusion 24x24\n",
754
+ " No Preconditioner conv=20/20 avg_iter=142.6\n",
755
+ " Jacobi conv=20/20 avg_iter=102.5\n",
756
+ " GCN conv=20/20 avg_iter=28.2\n",
757
+ " MPNN conv=20/20 avg_iter=35.8\n",
758
+ "\n",
759
+ " Eval: diffusion 32x32\n",
760
+ " No Preconditioner conv=20/20 avg_iter=211.8\n",
761
+ " Jacobi conv=20/20 avg_iter=138.1\n",
762
+ " GCN conv=20/20 avg_iter=38.9\n",
763
+ " MPNN conv=20/20 avg_iter=43.0\n",
764
+ "\n",
765
+ " Eval: diffusion 48x48 (OOD-size)\n",
766
+ " No Preconditioner conv=0/20 avg_iter=300.0\n",
767
+ " Jacobi conv=20/20 avg_iter=230.8\n",
768
+ " GCN conv=20/20 avg_iter=61.5\n",
769
+ " MPNN conv=20/20 avg_iter=58.0\n",
770
+ "\n",
771
+ " Eval: advection 16x16\n",
772
+ " No Preconditioner conv=20/20 avg_iter=85.7\n",
773
+ " Jacobi conv=20/20 avg_iter=60.6\n",
774
+ " GCN conv=20/20 avg_iter=19.7\n",
775
+ " MPNN conv=20/20 avg_iter=25.9\n",
776
+ "\n",
777
+ " Eval: advection 24x24\n",
778
+ " No Preconditioner conv=20/20 avg_iter=139.4\n",
779
+ " Jacobi conv=20/20 avg_iter=102.5\n",
780
+ " GCN conv=20/20 avg_iter=27.9\n",
781
+ " MPNN conv=20/20 avg_iter=35.0\n",
782
+ "\n",
783
+ " Eval: advection 32x32\n",
784
+ " No Preconditioner conv=20/20 avg_iter=202.6\n",
785
+ " Jacobi conv=20/20 avg_iter=133.8\n",
786
+ " GCN conv=20/20 avg_iter=37.8\n",
787
+ " MPNN conv=20/20 avg_iter=45.1\n",
788
+ "\n",
789
+ " Eval: advection 48x48 (OOD-size)\n",
790
+ " No Preconditioner conv=2/20 avg_iter=296.1\n",
791
+ " Jacobi conv=19/20 avg_iter=228.9\n",
792
+ " GCN conv=20/20 avg_iter=61.8\n",
793
+ " MPNN conv=20/20 avg_iter=58.6\n",
794
+ "\n",
795
+ " Eval: graph_laplacian 16x16 (OOD-domain)\n",
796
+ " No Preconditioner conv=20/20 avg_iter=14.3\n",
797
+ " Jacobi conv=20/20 avg_iter=8.9\n",
798
+ " GCN conv=20/20 avg_iter=5.2\n",
799
+ " MPNN conv=0/20 avg_iter=300.0\n",
800
+ "\n",
801
+ " Eval: graph_laplacian 24x24 (OOD-domain)\n",
802
+ " No Preconditioner conv=20/20 avg_iter=14.7\n",
803
+ " Jacobi conv=20/20 avg_iter=8.0\n",
804
+ " GCN conv=20/20 avg_iter=5.7\n",
805
+ " MPNN conv=0/20 avg_iter=300.0\n",
806
+ "\n",
807
+ " Eval: graph_laplacian 32x32 (OOD-domain)\n",
808
+ " No Preconditioner conv=20/20 avg_iter=14.4\n",
809
+ " Jacobi conv=20/20 avg_iter=7.5\n",
810
+ " GCN conv=20/20 avg_iter=5.8\n",
811
+ " MPNN conv=0/20 avg_iter=300.0\n",
812
+ "\n",
813
+ " Eval: graph_laplacian 48x48 (OOD-size, OOD-domain)\n",
814
+ " No Preconditioner conv=20/20 avg_iter=14.2\n",
815
+ " Jacobi conv=20/20 avg_iter=7.0\n",
816
+ " GCN conv=20/20 avg_iter=5.9\n",
817
+ " MPNN conv=0/20 avg_iter=300.0\n",
818
+ "\n",
819
+ " Seed 123 saved to /content/ablation_edge_features_v3.json\n",
820
+ "\n",
821
+ "======================================================================\n",
822
+ "SEED 456\n",
823
+ "======================================================================\n",
824
+ "\n",
825
+ " Training GCN (11,074 params) seed=456\n"
826
+ ]
827
+ },
828
+ {
829
+ "output_type": "stream",
830
+ "name": "stderr",
831
+ "text": [
832
+ "Loss: 1.0780e-01: 100%|██████████| 1000/1000 [01:41<00:00, 9.88it/s]\n"
833
+ ]
834
+ },
835
+ {
836
+ "output_type": "stream",
837
+ "name": "stdout",
838
+ "text": [
839
+ " best=8.6019e-02 @986, final=1.0780e-01, 101.2s\n",
840
+ "\n",
841
+ " Training MPNN (15,426 params) seed=456\n"
842
+ ]
843
+ },
844
+ {
845
+ "output_type": "stream",
846
+ "name": "stderr",
847
+ "text": [
848
+ "Loss: 1.1538e-01: 100%|██████████| 1000/1000 [01:46<00:00, 9.38it/s]\n"
849
+ ]
850
+ },
851
+ {
852
+ "output_type": "stream",
853
+ "name": "stdout",
854
+ "text": [
855
+ " best=9.1982e-02 @907, final=1.1538e-01, 106.6s\n",
856
+ "\n",
857
+ " Eval: diffusion 16x16\n",
858
+ " No Preconditioner conv=20/20 avg_iter=82.8\n",
859
+ " Jacobi conv=20/20 avg_iter=61.5\n",
860
+ " GCN conv=20/20 avg_iter=23.4\n",
861
+ " MPNN conv=20/20 avg_iter=22.9\n",
862
+ "\n",
863
+ " Eval: diffusion 24x24\n",
864
+ " No Preconditioner conv=20/20 avg_iter=141.1\n",
865
+ " Jacobi conv=20/20 avg_iter=102.0\n",
866
+ " GCN conv=20/20 avg_iter=36.0\n",
867
+ " MPNN conv=20/20 avg_iter=33.6\n",
868
+ "\n",
869
+ " Eval: diffusion 32x32\n",
870
+ " No Preconditioner conv=20/20 avg_iter=209.9\n",
871
+ " Jacobi conv=20/20 avg_iter=138.5\n",
872
+ " GCN conv=20/20 avg_iter=51.2\n",
873
+ " MPNN conv=20/20 avg_iter=41.6\n",
874
+ "\n",
875
+ " Eval: diffusion 48x48 (OOD-size)\n",
876
+ " No Preconditioner conv=0/20 avg_iter=300.0\n",
877
+ " Jacobi conv=20/20 avg_iter=228.5\n",
878
+ " GCN conv=20/20 avg_iter=79.3\n",
879
+ " MPNN conv=20/20 avg_iter=53.5\n",
880
+ "\n",
881
+ " Eval: advection 16x16\n",
882
+ " No Preconditioner conv=20/20 avg_iter=86.2\n",
883
+ " Jacobi conv=20/20 avg_iter=62.8\n",
884
+ " GCN conv=20/20 avg_iter=23.6\n",
885
+ " MPNN conv=20/20 avg_iter=23.7\n",
886
+ "\n",
887
+ " Eval: advection 24x24\n",
888
+ " No Preconditioner conv=20/20 avg_iter=141.2\n",
889
+ " Jacobi conv=20/20 avg_iter=108.5\n",
890
+ " GCN conv=20/20 avg_iter=35.9\n",
891
+ " MPNN conv=20/20 avg_iter=31.9\n",
892
+ "\n",
893
+ " Eval: advection 32x32\n",
894
+ " No Preconditioner conv=20/20 avg_iter=214.6\n",
895
+ " Jacobi conv=20/20 avg_iter=133.5\n",
896
+ " GCN conv=20/20 avg_iter=50.4\n",
897
+ " MPNN conv=20/20 avg_iter=42.6\n",
898
+ "\n",
899
+ " Eval: advection 48x48 (OOD-size)\n",
900
+ " No Preconditioner conv=0/20 avg_iter=300.0\n",
901
+ " Jacobi conv=20/20 avg_iter=231.3\n",
902
+ " GCN conv=20/20 avg_iter=79.3\n",
903
+ " MPNN conv=20/20 avg_iter=57.2\n",
904
+ "\n",
905
+ " Eval: graph_laplacian 16x16 (OOD-domain)\n",
906
+ " No Preconditioner conv=20/20 avg_iter=14.3\n",
907
+ " Jacobi conv=20/20 avg_iter=8.6\n",
908
+ " GCN conv=20/20 avg_iter=5.0\n",
909
+ " MPNN conv=0/20 avg_iter=300.0\n",
910
+ "\n",
911
+ " Eval: graph_laplacian 24x24 (OOD-domain)\n",
912
+ " No Preconditioner conv=20/20 avg_iter=14.6\n",
913
+ " Jacobi conv=20/20 avg_iter=8.1\n",
914
+ " GCN conv=20/20 avg_iter=5.0\n",
915
+ " MPNN conv=0/20 avg_iter=300.0\n",
916
+ "\n",
917
+ " Eval: graph_laplacian 32x32 (OOD-domain)\n",
918
+ " No Preconditioner conv=20/20 avg_iter=14.5\n",
919
+ " Jacobi conv=20/20 avg_iter=7.7\n",
920
+ " GCN conv=20/20 avg_iter=5.0\n",
921
+ " MPNN conv=0/20 avg_iter=300.0\n",
922
+ "\n",
923
+ " Eval: graph_laplacian 48x48 (OOD-size, OOD-domain)\n",
924
+ " No Preconditioner conv=20/20 avg_iter=14.4\n",
925
+ " Jacobi conv=20/20 avg_iter=7.0\n",
926
+ " GCN conv=20/20 avg_iter=5.0\n",
927
+ " MPNN conv=0/20 avg_iter=300.0\n",
928
+ "\n",
929
+ " Seed 456 saved to /content/ablation_edge_features_v3.json\n",
930
+ "\n",
931
+ "======================================================================\n",
932
+ "SEED 789\n",
933
+ "======================================================================\n",
934
+ "\n",
935
+ " Training GCN (11,074 params) seed=789\n"
936
+ ]
937
+ },
938
+ {
939
+ "output_type": "stream",
940
+ "name": "stderr",
941
+ "text": [
942
+ "Loss: 1.0237e-01: 100%|██████████| 1000/1000 [01:40<00:00, 9.92it/s]\n"
943
+ ]
944
+ },
945
+ {
946
+ "output_type": "stream",
947
+ "name": "stdout",
948
+ "text": [
949
+ " best=9.4219e-02 @950, final=1.0237e-01, 100.8s\n",
950
+ "\n",
951
+ " Training MPNN (15,426 params) seed=789\n"
952
+ ]
953
+ },
954
+ {
955
+ "output_type": "stream",
956
+ "name": "stderr",
957
+ "text": [
958
+ "Loss: 1.2242e-01: 100%|██████████| 1000/1000 [01:49<00:00, 9.15it/s]\n"
959
+ ]
960
+ },
961
+ {
962
+ "output_type": "stream",
963
+ "name": "stdout",
964
+ "text": [
965
+ " best=9.5065e-02 @983, final=1.2242e-01, 109.3s\n",
966
+ "\n",
967
+ " Eval: diffusion 16x16\n",
968
+ " No Preconditioner conv=20/20 avg_iter=84.0\n",
969
+ " Jacobi conv=20/20 avg_iter=60.5\n",
970
+ " GCN conv=20/20 avg_iter=22.2\n",
971
+ " MPNN conv=20/20 avg_iter=25.2\n",
972
+ "\n",
973
+ " Eval: diffusion 24x24\n",
974
+ " No Preconditioner conv=20/20 avg_iter=141.4\n",
975
+ " Jacobi conv=20/20 avg_iter=95.8\n",
976
+ " GCN conv=20/20 avg_iter=32.1\n",
977
+ " MPNN conv=20/20 avg_iter=36.5\n",
978
+ "\n",
979
+ " Eval: diffusion 32x32\n",
980
+ " No Preconditioner conv=20/20 avg_iter=215.9\n",
981
+ " Jacobi conv=20/20 avg_iter=138.6\n",
982
+ " GCN conv=20/20 avg_iter=46.4\n",
983
+ " MPNN conv=20/20 avg_iter=45.5\n",
984
+ "\n",
985
+ " Eval: diffusion 48x48 (OOD-size)\n",
986
+ " No Preconditioner conv=1/20 avg_iter=299.8\n",
987
+ " Jacobi conv=19/20 avg_iter=231.6\n",
988
+ " GCN conv=20/20 avg_iter=75.5\n",
989
+ " MPNN conv=20/20 avg_iter=64.1\n",
990
+ "\n",
991
+ " Eval: advection 16x16\n",
992
+ " No Preconditioner conv=20/20 avg_iter=86.6\n",
993
+ " Jacobi conv=20/20 avg_iter=62.2\n",
994
+ " GCN conv=20/20 avg_iter=22.1\n",
995
+ " MPNN conv=20/20 avg_iter=26.2\n",
996
+ "\n",
997
+ " Eval: advection 24x24\n",
998
+ " No Preconditioner conv=20/20 avg_iter=139.8\n",
999
+ " Jacobi conv=20/20 avg_iter=102.1\n",
1000
+ " GCN conv=20/20 avg_iter=32.5\n",
1001
+ " MPNN conv=20/20 avg_iter=37.0\n",
1002
+ "\n",
1003
+ " Eval: advection 32x32\n",
1004
+ " No Preconditioner conv=20/20 avg_iter=221.5\n",
1005
+ " Jacobi conv=20/20 avg_iter=140.7\n",
1006
+ " GCN conv=20/20 avg_iter=45.5\n",
1007
+ " MPNN conv=20/20 avg_iter=46.4\n",
1008
+ "\n",
1009
+ " Eval: advection 48x48 (OOD-size)\n",
1010
+ " No Preconditioner conv=1/20 avg_iter=298.2\n",
1011
+ " Jacobi conv=20/20 avg_iter=228.2\n",
1012
+ " GCN conv=20/20 avg_iter=75.0\n",
1013
+ " MPNN conv=20/20 avg_iter=63.9\n",
1014
+ "\n",
1015
+ " Eval: graph_laplacian 16x16 (OOD-domain)\n",
1016
+ " No Preconditioner conv=20/20 avg_iter=14.8\n",
1017
+ " Jacobi conv=20/20 avg_iter=8.9\n",
1018
+ " GCN conv=20/20 avg_iter=7.2\n",
1019
+ " MPNN conv=0/20 avg_iter=300.0\n",
1020
+ "\n",
1021
+ " Eval: graph_laplacian 24x24 (OOD-domain)\n",
1022
+ " No Preconditioner conv=20/20 avg_iter=14.4\n",
1023
+ " Jacobi conv=20/20 avg_iter=8.1\n",
1024
+ " GCN conv=20/20 avg_iter=8.1\n",
1025
+ " MPNN conv=0/20 avg_iter=300.0\n",
1026
+ "\n",
1027
+ " Eval: graph_laplacian 32x32 (OOD-domain)\n",
1028
+ " No Preconditioner conv=20/20 avg_iter=14.3\n",
1029
+ " Jacobi conv=20/20 avg_iter=7.4\n",
1030
+ " GCN conv=20/20 avg_iter=8.1\n",
1031
+ " MPNN conv=0/20 avg_iter=300.0\n",
1032
+ "\n",
1033
+ " Eval: graph_laplacian 48x48 (OOD-size, OOD-domain)\n",
1034
+ " No Preconditioner conv=20/20 avg_iter=14.3\n",
1035
+ " Jacobi conv=20/20 avg_iter=6.9\n",
1036
+ " GCN conv=20/20 avg_iter=8.4\n",
1037
+ " MPNN conv=0/20 avg_iter=300.0\n",
1038
+ "\n",
1039
+ " Seed 789 saved to /content/ablation_edge_features_v3.json\n",
1040
+ "\n",
1041
+ "======================================================================\n",
1042
+ "SEED 1337\n",
1043
+ "======================================================================\n",
1044
+ "\n",
1045
+ " Training GCN (11,074 params) seed=1337\n"
1046
+ ]
1047
+ },
1048
+ {
1049
+ "output_type": "stream",
1050
+ "name": "stderr",
1051
+ "text": [
1052
+ "Loss: 1.1140e-01: 100%|██████████| 1000/1000 [01:41<00:00, 9.88it/s]\n"
1053
+ ]
1054
+ },
1055
+ {
1056
+ "output_type": "stream",
1057
+ "name": "stdout",
1058
+ "text": [
1059
+ " best=9.2423e-02 @980, final=1.1140e-01, 101.2s\n",
1060
+ "\n",
1061
+ " Training MPNN (15,426 params) seed=1337\n"
1062
+ ]
1063
+ },
1064
+ {
1065
+ "output_type": "stream",
1066
+ "name": "stderr",
1067
+ "text": [
1068
+ "Loss: 1.2413e-01: 100%|██████████| 1000/1000 [01:47<00:00, 9.32it/s]\n"
1069
+ ]
1070
+ },
1071
+ {
1072
+ "output_type": "stream",
1073
+ "name": "stdout",
1074
+ "text": [
1075
+ " best=9.3399e-02 @964, final=1.2413e-01, 107.3s\n",
1076
+ "\n",
1077
+ " Eval: diffusion 16x16\n",
1078
+ " No Preconditioner conv=20/20 avg_iter=85.0\n",
1079
+ " Jacobi conv=20/20 avg_iter=62.9\n",
1080
+ " GCN conv=20/20 avg_iter=22.4\n",
1081
+ " MPNN conv=20/20 avg_iter=25.7\n",
1082
+ "\n",
1083
+ " Eval: diffusion 24x24\n",
1084
+ " No Preconditioner conv=20/20 avg_iter=140.8\n",
1085
+ " Jacobi conv=20/20 avg_iter=105.3\n",
1086
+ " GCN conv=20/20 avg_iter=33.5\n",
1087
+ " MPNN conv=20/20 avg_iter=38.8\n",
1088
+ "\n",
1089
+ " Eval: diffusion 32x32\n",
1090
+ " No Preconditioner conv=20/20 avg_iter=207.9\n",
1091
+ " Jacobi conv=20/20 avg_iter=136.5\n",
1092
+ " GCN conv=20/20 avg_iter=47.0\n",
1093
+ " MPNN conv=20/20 avg_iter=47.1\n",
1094
+ "\n",
1095
+ " Eval: diffusion 48x48 (OOD-size)\n",
1096
+ " No Preconditioner conv=0/20 avg_iter=300.0\n",
1097
+ " Jacobi conv=20/20 avg_iter=232.8\n",
1098
+ " GCN conv=20/20 avg_iter=73.1\n",
1099
+ " MPNN conv=20/20 avg_iter=61.3\n",
1100
+ "\n",
1101
+ " Eval: advection 16x16\n",
1102
+ " No Preconditioner conv=20/20 avg_iter=82.5\n",
1103
+ " Jacobi conv=20/20 avg_iter=61.7\n",
1104
+ " GCN conv=20/20 avg_iter=22.5\n",
1105
+ " MPNN conv=20/20 avg_iter=25.4\n",
1106
+ "\n",
1107
+ " Eval: advection 24x24\n",
1108
+ " No Preconditioner conv=20/20 avg_iter=137.6\n",
1109
+ " Jacobi conv=20/20 avg_iter=98.5\n",
1110
+ " GCN conv=20/20 avg_iter=33.3\n",
1111
+ " MPNN conv=20/20 avg_iter=38.3\n",
1112
+ "\n",
1113
+ " Eval: advection 32x32\n",
1114
+ " No Preconditioner conv=20/20 avg_iter=210.8\n",
1115
+ " Jacobi conv=20/20 avg_iter=138.7\n",
1116
+ " GCN conv=20/20 avg_iter=46.5\n",
1117
+ " MPNN conv=20/20 avg_iter=45.9\n",
1118
+ "\n",
1119
+ " Eval: advection 48x48 (OOD-size)\n",
1120
+ " No Preconditioner conv=1/20 avg_iter=298.2\n",
1121
+ " Jacobi conv=19/20 avg_iter=234.7\n",
1122
+ " GCN conv=20/20 avg_iter=71.6\n",
1123
+ " MPNN conv=20/20 avg_iter=62.2\n",
1124
+ "\n",
1125
+ " Eval: graph_laplacian 16x16 (OOD-domain)\n",
1126
+ " No Preconditioner conv=20/20 avg_iter=14.5\n",
1127
+ " Jacobi conv=20/20 avg_iter=8.6\n",
1128
+ " GCN conv=20/20 avg_iter=6.0\n",
1129
+ " MPNN conv=0/20 avg_iter=300.0\n",
1130
+ "\n",
1131
+ " Eval: graph_laplacian 24x24 (OOD-domain)\n",
1132
+ " No Preconditioner conv=20/20 avg_iter=14.7\n",
1133
+ " Jacobi conv=20/20 avg_iter=8.1\n",
1134
+ " GCN conv=20/20 avg_iter=6.0\n",
1135
+ " MPNN conv=0/20 avg_iter=300.0\n",
1136
+ "\n",
1137
+ " Eval: graph_laplacian 32x32 (OOD-domain)\n",
1138
+ " No Preconditioner conv=20/20 avg_iter=14.3\n",
1139
+ " Jacobi conv=20/20 avg_iter=7.3\n",
1140
+ " GCN conv=20/20 avg_iter=6.0\n",
1141
+ " MPNN conv=0/20 avg_iter=300.0\n",
1142
+ "\n",
1143
+ " Eval: graph_laplacian 48x48 (OOD-size, OOD-domain)\n",
1144
+ " No Preconditioner conv=20/20 avg_iter=14.2\n",
1145
+ " Jacobi conv=20/20 avg_iter=7.0\n",
1146
+ " GCN conv=20/20 avg_iter=6.0\n",
1147
+ " MPNN conv=0/20 avg_iter=300.0\n",
1148
+ "\n",
1149
+ " Seed 1337 saved to /content/ablation_edge_features_v3.json\n",
1150
+ "\n",
1151
+ "All seeds complete. Results at /content/ablation_edge_features_v3.json\n"
1152
+ ]
1153
+ }
1154
+ ]
1155
+ },
1156
+ {
1157
+ "cell_type": "markdown",
1158
+ "metadata": {
1159
+ "id": "3DBhiLfE149N"
1160
+ },
1161
+ "source": [
1162
+ "## Summary"
1163
+ ]
1164
+ },
1165
+ {
1166
+ "cell_type": "code",
1167
+ "metadata": {
1168
+ "colab": {
1169
+ "base_uri": "https://localhost:8080/"
1170
+ },
1171
+ "id": "Ej1BD-aD149N",
1172
+ "outputId": "93668e59-a7df-43d1-eb53-4411dc32ae0e"
1173
+ },
1174
+ "source": [
1175
+ "model_names = [\"No Preconditioner\", \"Jacobi\", \"GCN\", \"MPNN\"]\n",
1176
+ "\n",
1177
+ "print(f\"\\n{'='*90}\")\n",
1178
+ "print(\"FINAL SUMMARY\")\n",
1179
+ "print(f\"{'='*90}\")\n",
1180
+ "\n",
1181
+ "print(f\"\\n{'Domain':<20s} {'Grid':>5s} \", end=\"\")\n",
1182
+ "for name in model_names:\n",
1183
+ " print(f\"{'':>2s}{name:>18s}\", end=\"\")\n",
1184
+ "print()\n",
1185
+ "print(\"-\" * 100)\n",
1186
+ "\n",
1187
+ "for domain in EVAL_DOMAINS:\n",
1188
+ " for gs in EVAL_GRID_SIZES:\n",
1189
+ " key = f\"{domain}_{gs}\"\n",
1190
+ " ood = gs not in TRAINING_GRID_SIZES\n",
1191
+ " tag = \" *\" if ood else \"\"\n",
1192
+ "\n",
1193
+ " print(f\"{domain:<20s} {gs:>3d}x{gs}{tag:>2s} \", end=\"\")\n",
1194
+ "\n",
1195
+ " for model_name in model_names:\n",
1196
+ " all_conv = []\n",
1197
+ " all_iter = []\n",
1198
+ " for seed_data in data[\"seeds\"]:\n",
1199
+ " for m in seed_data[\"models\"]:\n",
1200
+ " if m[\"name\"] == model_name and key in m.get(\"eval\", {}):\n",
1201
+ " ev = m[\"eval\"][key]\n",
1202
+ " all_conv.extend(ev[\"converged\"])\n",
1203
+ " all_iter.extend(ev[\"iterations\"])\n",
1204
+ "\n",
1205
+ " if all_conv:\n",
1206
+ " conv_rate = sum(all_conv) / len(all_conv) * 100\n",
1207
+ " avg_iter = sum(all_iter) / len(all_iter)\n",
1208
+ " print(f\" {conv_rate:5.1f}% {avg_iter:5.1f}it\", end=\"\")\n",
1209
+ " else:\n",
1210
+ " print(f\" {'N/A':>13s}\", end=\"\")\n",
1211
+ "\n",
1212
+ " print()\n",
1213
+ "\n",
1214
+ "print(f\"\\n--- Training (avg over {len(data['seeds'])} seeds) ---\")\n",
1215
+ "for model_name in [\"GCN\", \"MPNN\"]:\n",
1216
+ " losses = []\n",
1217
+ " times = []\n",
1218
+ " for seed_data in data[\"seeds\"]:\n",
1219
+ " for m in seed_data[\"models\"]:\n",
1220
+ " if m[\"name\"] == model_name and m.get(\"best_loss\") is not None:\n",
1221
+ " losses.append(m[\"best_loss\"])\n",
1222
+ " times.append(m[\"train_time\"])\n",
1223
+ " if losses:\n",
1224
+ " print(f\" {model_name}: best_loss={np.mean(losses):.4e} +/- {np.std(losses):.4e}, \"\n",
1225
+ " f\"time={np.mean(times):.1f}s\")\n",
1226
+ "\n",
1227
+ "print(f\"\\n* = OOD grid size (not in training set)\")\n",
1228
+ "print(f\"graph_laplacian = OOD domain (not in training set)\")"
1229
+ ],
1230
+ "execution_count": 8,
1231
+ "outputs": [
1232
+ {
1233
+ "output_type": "stream",
1234
+ "name": "stdout",
1235
+ "text": [
1236
+ "\n",
1237
+ "==========================================================================================\n",
1238
+ "FINAL SUMMARY\n",
1239
+ "==========================================================================================\n",
1240
+ "\n",
1241
+ "Domain Grid No Preconditioner Jacobi GCN MPNN\n",
1242
+ "----------------------------------------------------------------------------------------------------\n",
1243
+ "diffusion 16x16 100.0% 85.2it 100.0% 61.8it 100.0% 22.4it 100.0% 24.1it\n",
1244
+ "diffusion 24x24 100.0% 140.1it 100.0% 101.3it 100.0% 33.2it 100.0% 35.3it\n",
1245
+ "diffusion 32x32 100.0% 210.8it 100.0% 136.7it 100.0% 46.7it 100.0% 44.0it\n",
1246
+ "diffusion 48x48 * 2.0% 299.8it 98.0% 231.4it 100.0% 73.2it 100.0% 59.2it\n",
1247
+ "advection 16x16 100.0% 85.1it 100.0% 61.7it 100.0% 22.5it 100.0% 24.9it\n",
1248
+ "advection 24x24 100.0% 139.7it 100.0% 102.0it 100.0% 33.2it 100.0% 34.9it\n",
1249
+ "advection 32x32 100.0% 212.7it 100.0% 137.5it 100.0% 46.2it 100.0% 44.2it\n",
1250
+ "advection 48x48 * 5.0% 298.3it 97.0% 230.6it 100.0% 73.2it 100.0% 60.1it\n",
1251
+ "graph_laplacian 16x16 100.0% 14.5it 100.0% 8.8it 100.0% 6.0it 0.0% 300.0it\n",
1252
+ "graph_laplacian 24x24 100.0% 14.7it 100.0% 8.1it 100.0% 6.4it 0.0% 300.0it\n",
1253
+ "graph_laplacian 32x32 100.0% 14.4it 100.0% 7.4it 100.0% 6.5it 0.0% 300.0it\n",
1254
+ "graph_laplacian 48x48 * 100.0% 14.3it 100.0% 6.9it 100.0% 6.7it 0.0% 300.0it\n",
1255
+ "\n",
1256
+ "--- Training (avg over 5 seeds) ---\n",
1257
+ " GCN: best_loss=9.0607e-02 +/- 2.7669e-03, time=100.8s\n",
1258
+ " MPNN: best_loss=9.2091e-02 +/- 2.8662e-03, time=106.2s\n",
1259
+ "\n",
1260
+ "* = OOD grid size (not in training set)\n",
1261
+ "graph_laplacian = OOD domain (not in training set)\n"
1262
+ ]
1263
+ }
1264
+ ]
1265
+ },
1266
+ {
1267
+ "cell_type": "markdown",
1268
+ "metadata": {
1269
+ "id": "lQ7I7SCp149N"
1270
+ },
1271
+ "source": [
1272
+ "## Download Results"
1273
+ ]
1274
+ },
1275
+ {
1276
+ "cell_type": "code",
1277
+ "metadata": {
1278
+ "colab": {
1279
+ "base_uri": "https://localhost:8080/",
1280
+ "height": 17
1281
+ },
1282
+ "id": "kENoYRAw149N",
1283
+ "outputId": "487860a3-1e67-4797-c369-8576c0330309"
1284
+ },
1285
+ "source": [
1286
+ "from google.colab import files\n",
1287
+ "files.download(str(RESULTS_FILE))"
1288
+ ],
1289
+ "execution_count": 9,
1290
+ "outputs": [
1291
+ {
1292
+ "output_type": "display_data",
1293
+ "data": {
1294
+ "text/plain": [
1295
+ "<IPython.core.display.Javascript object>"
1296
+ ],
1297
+ "application/javascript": [
1298
+ "\n",
1299
+ " async function download(id, filename, size) {\n",
1300
+ " if (!google.colab.kernel.accessAllowed) {\n",
1301
+ " return;\n",
1302
+ " }\n",
1303
+ " const div = document.createElement('div');\n",
1304
+ " const label = document.createElement('label');\n",
1305
+ " label.textContent = `Downloading \"${filename}\": `;\n",
1306
+ " div.appendChild(label);\n",
1307
+ " const progress = document.createElement('progress');\n",
1308
+ " progress.max = size;\n",
1309
+ " div.appendChild(progress);\n",
1310
+ " document.body.appendChild(div);\n",
1311
+ "\n",
1312
+ " const buffers = [];\n",
1313
+ " let downloaded = 0;\n",
1314
+ "\n",
1315
+ " const channel = await google.colab.kernel.comms.open(id);\n",
1316
+ " // Send a message to notify the kernel that we're ready.\n",
1317
+ " channel.send({})\n",
1318
+ "\n",
1319
+ " for await (const message of channel.messages) {\n",
1320
+ " // Send a message to notify the kernel that we're ready.\n",
1321
+ " channel.send({})\n",
1322
+ " if (message.buffers) {\n",
1323
+ " for (const buffer of message.buffers) {\n",
1324
+ " buffers.push(buffer);\n",
1325
+ " downloaded += buffer.byteLength;\n",
1326
+ " progress.value = downloaded;\n",
1327
+ " }\n",
1328
+ " }\n",
1329
+ " }\n",
1330
+ " const blob = new Blob(buffers, {type: 'application/binary'});\n",
1331
+ " const a = document.createElement('a');\n",
1332
+ " a.href = window.URL.createObjectURL(blob);\n",
1333
+ " a.download = filename;\n",
1334
+ " div.appendChild(a);\n",
1335
+ " a.click();\n",
1336
+ " div.remove();\n",
1337
+ " }\n",
1338
+ " "
1339
+ ]
1340
+ },
1341
+ "metadata": {}
1342
+ },
1343
+ {
1344
+ "output_type": "display_data",
1345
+ "data": {
1346
+ "text/plain": [
1347
+ "<IPython.core.display.Javascript object>"
1348
+ ],
1349
+ "application/javascript": [
1350
+ "download(\"download_b376d41a-0d96-402a-a2c9-fa9b462b4e8e\", \"ablation_edge_features_v3.json\", 953198)"
1351
+ ]
1352
+ },
1353
+ "metadata": {}
1354
+ }
1355
+ ]
1356
+ }
1357
+ ]
1358
+ }