Load model from checkpoint. Args: tensorstore_specs: TensorStore specifications for each array. shardings: Target shardings for the restored arrays. global_shapes: Global shapes for each array. dtypes: Data types for each array. Returns: List of rest
(
tensorstore_specs: Sequence[Dict[str, Any]],
shardings: Sequence[jax.sharding.NamedSharding],
global_shapes: Sequence[tuple],
dtypes: Sequence[jnp.dtype],
)
| 198 | |
| 199 | |
| 200 | def load_model( |
| 201 | tensorstore_specs: Sequence[Dict[str, Any]], |
| 202 | shardings: Sequence[jax.sharding.NamedSharding], |
| 203 | global_shapes: Sequence[tuple], |
| 204 | dtypes: Sequence[jnp.dtype], |
| 205 | ): |
| 206 | """Load model from checkpoint. |
| 207 | |
| 208 | Args: |
| 209 | tensorstore_specs: TensorStore specifications for each array. |
| 210 | shardings: Target shardings for the restored arrays. |
| 211 | global_shapes: Global shapes for each array. |
| 212 | dtypes: Data types for each array. |
| 213 | |
| 214 | Returns: |
| 215 | List of restored JAX arrays. |
| 216 | """ |
| 217 | manager = GlobalAsyncCheckpointManager() |
| 218 | restored_values = manager.deserialize( |
| 219 | shardings=shardings, |
| 220 | tensorstore_specs=tensorstore_specs, |
| 221 | global_shapes=global_shapes, |
| 222 | dtypes=dtypes, |
| 223 | concurrent_gb=400, |
| 224 | ) |
| 225 | print(f"Loaded {len(restored_values)} arrays") |
| 226 | |
| 227 | return restored_values |
| 228 | |
| 229 | |
| 230 | def main(): |
no test coverage detected