Update README.md
Browse files
README.md
CHANGED
|
@@ -28,7 +28,6 @@ configs:
|
|
| 28 |
- split: test
|
| 29 |
path: data/test-*
|
| 30 |
---
|
| 31 |
-
|
| 32 |
# Laser Powder Bed Fusion (LPBF) Additive Manufacturing Dataset
|
| 33 |
|
| 34 |
As part of our paper **[FLARE: Fast Low-Rank Attention Routing Engine](https://huggingface.co/papers/2508.12594)** ([arXiv:2508.12594](https://arxiv.org/abs/2508.12594)), we release a new **3D field prediction benchmark** derived from numerical simulations of the **Laser Powder Bed Fusion (LPBF)** additive manufacturing process.
|
|
@@ -55,6 +54,180 @@ Each sample consists of:
|
|
| 55 |
|
| 56 |
---
|
| 57 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 58 |
## Source & Generation
|
| 59 |
|
| 60 |
- Geometries are taken from the **Fusion 360 segmentation dataset**.
|
|
|
|
| 28 |
- split: test
|
| 29 |
path: data/test-*
|
| 30 |
---
|
|
|
|
| 31 |
# Laser Powder Bed Fusion (LPBF) Additive Manufacturing Dataset
|
| 32 |
|
| 33 |
As part of our paper **[FLARE: Fast Low-Rank Attention Routing Engine](https://huggingface.co/papers/2508.12594)** ([arXiv:2508.12594](https://arxiv.org/abs/2508.12594)), we release a new **3D field prediction benchmark** derived from numerical simulations of the **Laser Powder Bed Fusion (LPBF)** additive manufacturing process.
|
|
|
|
| 54 |
|
| 55 |
---
|
| 56 |
|
| 57 |
+
## Usage
|
| 58 |
+
|
| 59 |
+
### Quick Start
|
| 60 |
+
|
| 61 |
+
Load the LPBF dataset using the optimized PyTorch Geometric interface:
|
| 62 |
+
|
| 63 |
+
```python
|
| 64 |
+
from pdebench.dataset.utils import LPBFDataset
|
| 65 |
+
|
| 66 |
+
# Load train and test datasets
|
| 67 |
+
train_dataset = LPBFDataset(split='train')
|
| 68 |
+
test_dataset = LPBFDataset(split='test')
|
| 69 |
+
|
| 70 |
+
print(f"Train samples: {len(train_dataset)}")
|
| 71 |
+
print(f"Test samples: {len(test_dataset)}")
|
| 72 |
+
|
| 73 |
+
# Access a sample
|
| 74 |
+
sample = train_dataset[0]
|
| 75 |
+
print(f"Nodes: {sample.x.shape}") # [N, 3] - node coordinates
|
| 76 |
+
print(f"Edges: {sample.edge_index.shape}") # [2, E] - edge connectivity
|
| 77 |
+
print(f"Target: {sample.y.shape}") # [N] - Z-displacement values
|
| 78 |
+
print(f"Elements: {sample.elems.shape}") # [M, 8] - hex element connectivity
|
| 79 |
+
```
|
| 80 |
+
|
| 81 |
+
### PyTorch DataLoader Integration
|
| 82 |
+
|
| 83 |
+
```python
|
| 84 |
+
from torch_geometric.loader import DataLoader
|
| 85 |
+
|
| 86 |
+
# Create DataLoader for training
|
| 87 |
+
train_loader = DataLoader(train_dataset, batch_size=4, shuffle=True)
|
| 88 |
+
test_loader = DataLoader(test_dataset, batch_size=4, shuffle=False)
|
| 89 |
+
|
| 90 |
+
# Training loop example
|
| 91 |
+
for batch in train_loader:
|
| 92 |
+
# batch.x: [batch_size*N, 3] - node coordinates
|
| 93 |
+
# batch.y: [batch_size*N] - target Z-displacements
|
| 94 |
+
# batch.edge_index: [2, batch_size*E] - edges
|
| 95 |
+
# batch.batch: [batch_size*N] - batch assignment
|
| 96 |
+
|
| 97 |
+
# Your model forward pass here
|
| 98 |
+
pred = model(batch.x, batch.edge_index, batch.batch)
|
| 99 |
+
loss = loss_fn(pred, batch.y)
|
| 100 |
+
```
|
| 101 |
+
|
| 102 |
+
### Performance Features
|
| 103 |
+
|
| 104 |
+
- **โก Fast initialization**: ~0.8s (vs 18s+ for naive approaches)
|
| 105 |
+
- **๐ Efficient loading**: ~8ms per sample access
|
| 106 |
+
- **๐พ Smart caching**: Downloads once, cached locally
|
| 107 |
+
- **๐ Lazy loading**: Files downloaded only when first accessed
|
| 108 |
+
|
| 109 |
+
### Data Fields
|
| 110 |
+
|
| 111 |
+
Each sample contains:
|
| 112 |
+
- `x` (pos): Node coordinates [N, 3]
|
| 113 |
+
- `edge_index`: Edge connectivity [2, E]
|
| 114 |
+
- `y`: Target Z-displacement [N]
|
| 115 |
+
- `elems`: Element connectivity [M, 8]
|
| 116 |
+
- `temp`: Temperature field [N]
|
| 117 |
+
- `disp`: Full displacement field [N, 3]
|
| 118 |
+
- `vmstr`: Von Mises stress [N]
|
| 119 |
+
- `metadata`: Simulation metadata
|
| 120 |
+
|
| 121 |
+
## Implementation
|
| 122 |
+
|
| 123 |
+
### LPBFDataset Class
|
| 124 |
+
|
| 125 |
+
The optimized `LPBFDataset` implementation with lazy loading and efficient caching:
|
| 126 |
+
|
| 127 |
+
```python
|
| 128 |
+
import os
|
| 129 |
+
import json
|
| 130 |
+
import numpy as np
|
| 131 |
+
import torch
|
| 132 |
+
import torch_geometric as pyg
|
| 133 |
+
import datasets
|
| 134 |
+
import huggingface_hub
|
| 135 |
+
|
| 136 |
+
class LPBFDataset(pyg.data.Dataset):
|
| 137 |
+
def __init__(self, split='train', transform=None):
|
| 138 |
+
assert split in ['train', 'test'], f"Invalid split: {split}. Must be one of: 'train', 'test'."
|
| 139 |
+
|
| 140 |
+
self.repo_id = 'vedantpuri/LPBF_FLARE'
|
| 141 |
+
|
| 142 |
+
print(f"Initializing {split} dataset...")
|
| 143 |
+
|
| 144 |
+
# Fast initialization: Load dataset index first (lightweight)
|
| 145 |
+
import time
|
| 146 |
+
start_time = time.time()
|
| 147 |
+
self.dataset = datasets.load_dataset(self.repo_id, split=split, keep_in_memory=True)
|
| 148 |
+
dataset_time = time.time() - start_time
|
| 149 |
+
print(f"Dataset index load: {dataset_time:.2f}s")
|
| 150 |
+
|
| 151 |
+
# Lazy cache initialization - only download when needed
|
| 152 |
+
self._cache_dir = None
|
| 153 |
+
|
| 154 |
+
print(f"โ
Loaded {len(self.dataset)} samples for {split} split")
|
| 155 |
+
|
| 156 |
+
super().__init__(None, transform=transform)
|
| 157 |
+
|
| 158 |
+
@property
|
| 159 |
+
def cache_dir(self):
|
| 160 |
+
"""Lazy loading of cache directory - only download when first sample is accessed."""
|
| 161 |
+
if self._cache_dir is None:
|
| 162 |
+
print("Downloading repository files on first access...")
|
| 163 |
+
import time
|
| 164 |
+
start_time = time.time()
|
| 165 |
+
self._cache_dir = huggingface_hub.snapshot_download(self.repo_id, repo_type="dataset")
|
| 166 |
+
download_time = time.time() - start_time
|
| 167 |
+
print(f"Repository download/cache: {download_time:.2f}s")
|
| 168 |
+
print(f"Cache directory: {self._cache_dir}")
|
| 169 |
+
return self._cache_dir
|
| 170 |
+
|
| 171 |
+
def len(self):
|
| 172 |
+
return len(self.dataset)
|
| 173 |
+
|
| 174 |
+
def get(self, idx):
|
| 175 |
+
# Get file path from index
|
| 176 |
+
entry = self.dataset[idx]
|
| 177 |
+
rel_path = entry["file"]
|
| 178 |
+
npz_path = os.path.join(self.cache_dir, rel_path)
|
| 179 |
+
|
| 180 |
+
# Load NPZ file (main bottleneck check)
|
| 181 |
+
data = np.load(npz_path, allow_pickle=True)
|
| 182 |
+
graph = pyg.data.Data()
|
| 183 |
+
|
| 184 |
+
# Convert to tensors efficiently
|
| 185 |
+
for key, value in data.items():
|
| 186 |
+
if key == "_metadata":
|
| 187 |
+
graph["metadata"] = json.loads(value[0])["metadata"]
|
| 188 |
+
else:
|
| 189 |
+
# Use torch.from_numpy for faster conversion when possible
|
| 190 |
+
if value.dtype.kind == "f":
|
| 191 |
+
tensor = torch.from_numpy(value.astype(np.float32))
|
| 192 |
+
else:
|
| 193 |
+
tensor = torch.from_numpy(value.astype(np.int64)) if value.dtype != np.int64 else torch.from_numpy(value)
|
| 194 |
+
graph[key] = tensor
|
| 195 |
+
|
| 196 |
+
# Set standard attributes
|
| 197 |
+
graph.x = graph.pos
|
| 198 |
+
graph.y = graph.disp[:, 2]
|
| 199 |
+
|
| 200 |
+
return graph
|
| 201 |
+
```
|
| 202 |
+
|
| 203 |
+
### Key Implementation Features
|
| 204 |
+
|
| 205 |
+
#### ๐ **Lazy Loading Strategy**
|
| 206 |
+
- **Fast initialization** (~0.8s): Only loads lightweight parquet index
|
| 207 |
+
- **Deferred downloads**: Heavy NPZ files downloaded on first sample access
|
| 208 |
+
- **Property-based caching**: `@property cache_dir` ensures files download only when needed
|
| 209 |
+
|
| 210 |
+
#### โก **Efficient Tensor Conversion**
|
| 211 |
+
```python
|
| 212 |
+
# Optimized: Direct numpy->torch conversion (zero-copy when possible)
|
| 213 |
+
tensor = torch.from_numpy(value.astype(np.float32))
|
| 214 |
+
|
| 215 |
+
# vs. Slower: torch.tensor() creates new copy
|
| 216 |
+
tensor = torch.tensor(value, dtype=torch.float32)
|
| 217 |
+
```
|
| 218 |
+
|
| 219 |
+
#### ๐พ **Smart Caching**
|
| 220 |
+
- Uses HuggingFace's built-in caching system
|
| 221 |
+
- Files downloaded once, reused across all dataset instances
|
| 222 |
+
- Automatic cache validation and updates
|
| 223 |
+
|
| 224 |
+
#### ๐ฏ **Memory Efficiency**
|
| 225 |
+
- No preloading of samples
|
| 226 |
+
- On-demand loading with `np.load()`
|
| 227 |
+
- Minimal memory footprint during initialization
|
| 228 |
+
|
| 229 |
+
---
|
| 230 |
+
|
| 231 |
## Source & Generation
|
| 232 |
|
| 233 |
- Geometries are taken from the **Fusion 360 segmentation dataset**.
|