diff --git a/docs/build/html/.buildinfo b/docs/build/html/.buildinfo index 2d869d048b..02b67f3136 100644 --- a/docs/build/html/.buildinfo +++ b/docs/build/html/.buildinfo @@ -1,4 +1,4 @@ # Sphinx build info version 1 # This file hashes the configuration used when building these files. When it is not found, a full rebuild will be done. -config: dc184c72b1e34abbbd1ce48d8eb9f987 +config: 3b02955047d4e4b232f01bccda3ed898 tags: 645f666f9bcd5a90fca523b33c5a78b7 diff --git a/docs/build/html/_images/capture.png b/docs/build/html/_images/capture.png new file mode 100644 index 0000000000..156e9b1cf9 Binary files /dev/null and b/docs/build/html/_images/capture.png differ diff --git a/docs/build/html/_images/schema.png b/docs/build/html/_images/schema.png new file mode 100644 index 0000000000..f84ff53bf2 Binary files /dev/null and b/docs/build/html/_images/schema.png differ diff --git a/docs/build/html/_sources/python/_autosummary/mlx.core.custom_function.jvp.rst b/docs/build/html/_sources/python/_autosummary/mlx.core.custom_function.jvp.rst deleted file mode 100644 index 84ffd2d0aa..0000000000 --- a/docs/build/html/_sources/python/_autosummary/mlx.core.custom_function.jvp.rst +++ /dev/null @@ -1,6 +0,0 @@ -mlx.core.custom\_function.jvp -============================= - -.. currentmodule:: mlx.core - -.. automethod:: custom_function.jvp \ No newline at end of file diff --git a/docs/build/html/_sources/python/_autosummary/mlx.core.einsum.rst b/docs/build/html/_sources/python/_autosummary/mlx.core.einsum.rst new file mode 100644 index 0000000000..236ce6a049 --- /dev/null +++ b/docs/build/html/_sources/python/_autosummary/mlx.core.einsum.rst @@ -0,0 +1,6 @@ +mlx.core.einsum +=============== + +.. currentmodule:: mlx.core + +.. autofunction:: einsum \ No newline at end of file diff --git a/docs/build/html/_sources/python/_autosummary/mlx.core.einsum_path.rst b/docs/build/html/_sources/python/_autosummary/mlx.core.einsum_path.rst new file mode 100644 index 0000000000..40e0afbf2e --- /dev/null +++ b/docs/build/html/_sources/python/_autosummary/mlx.core.einsum_path.rst @@ -0,0 +1,6 @@ +mlx.core.einsum\_path +===================== + +.. currentmodule:: mlx.core + +.. autofunction:: einsum_path \ No newline at end of file diff --git a/docs/build/html/_sources/python/_autosummary/mlx.core.nan_to_num.rst b/docs/build/html/_sources/python/_autosummary/mlx.core.nan_to_num.rst new file mode 100644 index 0000000000..35272b464f --- /dev/null +++ b/docs/build/html/_sources/python/_autosummary/mlx.core.nan_to_num.rst @@ -0,0 +1,6 @@ +mlx.core.nan\_to\_num +===================== + +.. currentmodule:: mlx.core + +.. autofunction:: nan_to_num \ No newline at end of file diff --git a/docs/build/html/_sources/python/_autosummary/mlx.core.random.laplace.rst b/docs/build/html/_sources/python/_autosummary/mlx.core.random.laplace.rst new file mode 100644 index 0000000000..012091a5d7 --- /dev/null +++ b/docs/build/html/_sources/python/_autosummary/mlx.core.random.laplace.rst @@ -0,0 +1,6 @@ +mlx.core.random.laplace +======================= + +.. currentmodule:: mlx.core.random + +.. autofunction:: laplace \ No newline at end of file diff --git a/docs/build/html/_sources/python/ops.rst b/docs/build/html/_sources/python/ops.rst index 0d75f7d62c..d848473d80 100644 --- a/docs/build/html/_sources/python/ops.rst +++ b/docs/build/html/_sources/python/ops.rst @@ -57,6 +57,8 @@ Operations diagonal divide divmod + einsum + einsum_path equal erf erfinv @@ -104,6 +106,7 @@ Operations minimum moveaxis multiply + nan_to_num negative not_equal ones diff --git a/docs/build/html/_sources/python/optimizers.rst b/docs/build/html/_sources/python/optimizers.rst index 84ab933acf..1897483d88 100644 --- a/docs/build/html/_sources/python/optimizers.rst +++ b/docs/build/html/_sources/python/optimizers.rst @@ -31,6 +31,41 @@ model's parameters and the **optimizer state**. # Compute the new parameters but also the optimizer state. mx.eval(model.parameters(), optimizer.state) +Saving and Loading +------------------ + +To serialize an optimizer, save its state. To load an optimizer, load and set +the saved state. Here's a simple example: + +.. code-block:: python + + import mlx.core as mx + from mlx.utils import tree_flatten, tree_unflatten + import mlx.optimizers as optim + + optimizer = optim.Adam(learning_rate=1e-2) + + # Perform some updates with the optimizer + model = {"w" : mx.zeros((5, 5))} + grads = {"w" : mx.ones((5, 5))} + optimizer.update(model, grads) + + # Save the state + state = tree_flatten(optimizer.state) + mx.save_safetensors("optimizer.safetensors", dict(state)) + + # Later on, for example when loading from a checkpoint, + # recreate the optimizer and load the state + optimizer = optim.Adam(learning_rate=1e-2) + + state = tree_unflatten(list(mx.load("optimizer.safetensors").items())) + optimizer.state = state + +Note, not every optimizer configuation parameter is saved in the state. For +example, for Adam the learning rate is saved but the ``betas`` and ``eps`` +parameters are not. A good rule of thumb is if the parameter can be scheduled +then it will be included in the optimizer state. + .. toctree:: optimizers/optimizer diff --git a/docs/build/html/_sources/python/random.rst b/docs/build/html/_sources/python/random.rst index d08d5a7df0..5d98304bb8 100644 --- a/docs/build/html/_sources/python/random.rst +++ b/docs/build/html/_sources/python/random.rst @@ -44,3 +44,4 @@ we use a splittable version of Threefry, which is a counter-based PRNG. split truncated_normal uniform + laplace diff --git a/docs/build/html/_static/documentation_options.js b/docs/build/html/_static/documentation_options.js index e19651305c..d6799b6791 100644 --- a/docs/build/html/_static/documentation_options.js +++ b/docs/build/html/_static/documentation_options.js @@ -1,5 +1,5 @@ const DOCUMENTATION_OPTIONS = { - VERSION: '0.16.0', + VERSION: '0.16.1', LANGUAGE: 'en', COLLAPSE_INDEX: false, BUILDER: 'html', diff --git a/docs/build/html/cpp/ops.html b/docs/build/html/cpp/ops.html index 20d9e20a56..50d70f3b00 100644 --- a/docs/build/html/cpp/ops.html +++ b/docs/build/html/cpp/ops.html @@ -8,7 +8,7 @@ - Operations — MLX 0.16.0 documentation + Operations — MLX 0.16.1 documentation @@ -36,7 +36,7 @@ - + @@ -131,8 +131,8 @@ - MLX 0.16.0 documentation - Home - + MLX 0.16.1 documentation - Home + @@ -296,6 +296,8 @@
  • mlx.core.diagonal
  • mlx.core.divide
  • mlx.core.divmod
  • +
  • mlx.core.einsum
  • +
  • mlx.core.einsum_path
  • mlx.core.equal
  • mlx.core.erf
  • mlx.core.erfinv
  • @@ -343,6 +345,7 @@
  • mlx.core.minimum
  • mlx.core.moveaxis
  • mlx.core.multiply
  • +
  • mlx.core.nan_to_num
  • mlx.core.negative
  • mlx.core.not_equal
  • mlx.core.ones
  • @@ -414,6 +417,7 @@
  • mlx.core.random.split
  • mlx.core.random.truncated_normal
  • mlx.core.random.uniform
  • +
  • mlx.core.random.laplace
  • Transforms
  • Transforms
  • Transforms
  • Transforms
  • Transforms
  • Transforms
  • Transforms