docs update

This commit is contained in:
Awni Hannun
2024-04-26 08:24:09 -07:00
committed by CircleCI Docs
parent f77d99b285
commit f946f689a6
502 changed files with 14665 additions and 15103 deletions

View File

@@ -8,7 +8,7 @@
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" /><meta name="generator" content="Docutils 0.18.1: http://docutils.sourceforge.net/" />
<title>mlx.nn.QuantizedLinear &#8212; MLX 0.10.0 documentation</title>
<title>mlx.nn.QuantizedLinear &#8212; MLX 0.12.0 documentation</title>
@@ -36,7 +36,7 @@
<link rel="preload" as="script" href="../../../_static/scripts/pydata-sphinx-theme.js?digest=5b4479735964841361fd" />
<script src="../../../_static/vendor/fontawesome/6.1.2/js/all.min.js?digest=5b4479735964841361fd"></script>
<script src="../../../_static/documentation_options.js?v=cb265169"></script>
<script src="../../../_static/documentation_options.js?v=e9e33cf0"></script>
<script src="../../../_static/doctools.js?v=888ff710"></script>
<script src="../../../_static/sphinx_highlight.js?v=dc90522c"></script>
<script src="../../../_static/scripts/sphinx-book-theme.js?v=efea14e4"></script>
@@ -44,7 +44,7 @@
<link rel="index" title="Index" href="../../../genindex.html" />
<link rel="search" title="Search" href="../../../search.html" />
<link rel="next" title="mlx.nn.RMSNorm" href="mlx.nn.RMSNorm.html" />
<link rel="prev" title="mlx.nn.PReLU" href="mlx.nn.PReLU.html" />
<link rel="prev" title="mlx.nn.QuantizedEmbedding" href="mlx.nn.QuantizedEmbedding.html" />
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<meta name="docsearch:language" content="en"/>
</head>
@@ -131,8 +131,8 @@
<img src="../../../_static/mlx_logo.png" class="logo__image only-light" alt="MLX 0.10.0 documentation - Home"/>
<script>document.write(`<img src="../../../_static/mlx_logo_dark.png" class="logo__image only-dark" alt="MLX 0.10.0 documentation - Home"/>`);</script>
<img src="../../../_static/mlx_logo.png" class="logo__image only-light" alt="MLX 0.12.0 documentation - Home"/>
<script>document.write(`<img src="../../../_static/mlx_logo_dark.png" class="logo__image only-dark" alt="MLX 0.12.0 documentation - Home"/>`);</script>
</a></div>
@@ -240,6 +240,7 @@
<li class="toctree-l2"><a class="reference internal" href="../../_autosummary/mlx.core.new_stream.html">mlx.core.new_stream</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../_autosummary/mlx.core.set_default_stream.html">mlx.core.set_default_stream</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../_autosummary/mlx.core.stream.html">mlx.core.stream</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../_autosummary/mlx.core.synchronize.html">mlx.core.synchronize</a></li>
</ul>
</li>
<li class="toctree-l1 has-children"><a class="reference internal" href="../../ops.html">Operations</a><input class="toctree-checkbox" id="toctree-checkbox-4" name="toctree-checkbox-4" type="checkbox"/><label class="toctree-toggle" for="toctree-checkbox-4"><i class="fa-solid fa-chevron-down"></i></label><ul>
@@ -264,6 +265,7 @@
<li class="toctree-l2"><a class="reference internal" href="../../_autosummary/mlx.core.atleast_2d.html">mlx.core.atleast_2d</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../_autosummary/mlx.core.atleast_3d.html">mlx.core.atleast_3d</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../_autosummary/mlx.core.broadcast_to.html">mlx.core.broadcast_to</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../_autosummary/mlx.core.block_masked_mm.html">mlx.core.block_masked_mm</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../_autosummary/mlx.core.ceil.html">mlx.core.ceil</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../_autosummary/mlx.core.clip.html">mlx.core.clip</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../_autosummary/mlx.core.concatenate.html">mlx.core.concatenate</a></li>
@@ -277,6 +279,7 @@
<li class="toctree-l2"><a class="reference internal" href="../../_autosummary/mlx.core.cummin.html">mlx.core.cummin</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../_autosummary/mlx.core.cumprod.html">mlx.core.cumprod</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../_autosummary/mlx.core.cumsum.html">mlx.core.cumsum</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../_autosummary/mlx.core.degrees.html">mlx.core.degrees</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../_autosummary/mlx.core.dequantize.html">mlx.core.dequantize</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../_autosummary/mlx.core.diag.html">mlx.core.diag</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../_autosummary/mlx.core.diagonal.html">mlx.core.diagonal</a></li>
@@ -325,6 +328,7 @@
<li class="toctree-l2"><a class="reference internal" href="../../_autosummary/mlx.core.moveaxis.html">mlx.core.moveaxis</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../_autosummary/mlx.core.multiply.html">mlx.core.multiply</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../_autosummary/mlx.core.negative.html">mlx.core.negative</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../_autosummary/mlx.core.not_equal.html">mlx.core.not_equal</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../_autosummary/mlx.core.ones.html">mlx.core.ones</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../_autosummary/mlx.core.ones_like.html">mlx.core.ones_like</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../_autosummary/mlx.core.outer.html">mlx.core.outer</a></li>
@@ -333,6 +337,7 @@
<li class="toctree-l2"><a class="reference internal" href="../../_autosummary/mlx.core.prod.html">mlx.core.prod</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../_autosummary/mlx.core.quantize.html">mlx.core.quantize</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../_autosummary/mlx.core.quantized_matmul.html">mlx.core.quantized_matmul</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../_autosummary/mlx.core.radians.html">mlx.core.radians</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../_autosummary/mlx.core.reciprocal.html">mlx.core.reciprocal</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../_autosummary/mlx.core.repeat.html">mlx.core.repeat</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../_autosummary/mlx.core.reshape.html">mlx.core.reshape</a></li>
@@ -436,12 +441,14 @@
<li class="toctree-l2"><a class="reference internal" href="../../_autosummary/mlx.core.metal.get_cache_memory.html">mlx.core.metal.get_cache_memory</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../_autosummary/mlx.core.metal.set_memory_limit.html">mlx.core.metal.set_memory_limit</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../_autosummary/mlx.core.metal.set_cache_limit.html">mlx.core.metal.set_cache_limit</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../_autosummary/mlx.core.metal.clear_cache.html">mlx.core.metal.clear_cache</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../_autosummary/mlx.core.metal.start_capture.html">mlx.core.metal.start_capture</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../_autosummary/mlx.core.metal.stop_capture.html">mlx.core.metal.stop_capture</a></li>
</ul>
</li>
<li class="toctree-l1 current active has-children"><a class="reference internal" href="../../nn.html">Neural Networks</a><input checked="" class="toctree-checkbox" id="toctree-checkbox-11" name="toctree-checkbox-11" type="checkbox"/><label class="toctree-toggle" for="toctree-checkbox-11"><i class="fa-solid fa-chevron-down"></i></label><ul class="current">
<li class="toctree-l2"><a class="reference internal" href="../../_autosummary/mlx.nn.value_and_grad.html">mlx.nn.value_and_grad</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../_autosummary/mlx.nn.quantize.html">mlx.nn.quantize</a></li>
<li class="toctree-l2 has-children"><a class="reference internal" href="../module.html">Module</a><input class="toctree-checkbox" id="toctree-checkbox-12" name="toctree-checkbox-12" type="checkbox"/><label class="toctree-toggle" for="toctree-checkbox-12"><i class="fa-solid fa-chevron-down"></i></label><ul>
<li class="toctree-l3"><a class="reference internal" href="mlx.nn.Module.training.html">mlx.nn.Module.training</a></li>
<li class="toctree-l3"><a class="reference internal" href="mlx.nn.Module.state.html">mlx.nn.Module.state</a></li>
@@ -488,6 +495,7 @@
<li class="toctree-l3"><a class="reference internal" href="mlx.nn.Mish.html">mlx.nn.Mish</a></li>
<li class="toctree-l3"><a class="reference internal" href="mlx.nn.MultiHeadAttention.html">mlx.nn.MultiHeadAttention</a></li>
<li class="toctree-l3"><a class="reference internal" href="mlx.nn.PReLU.html">mlx.nn.PReLU</a></li>
<li class="toctree-l3"><a class="reference internal" href="mlx.nn.QuantizedEmbedding.html">mlx.nn.QuantizedEmbedding</a></li>
<li class="toctree-l3 current active"><a class="current reference internal" href="#">mlx.nn.QuantizedLinear</a></li>
<li class="toctree-l3"><a class="reference internal" href="mlx.nn.RMSNorm.html">mlx.nn.RMSNorm</a></li>
<li class="toctree-l3"><a class="reference internal" href="mlx.nn.ReLU.html">mlx.nn.ReLU</a></li>
@@ -591,6 +599,7 @@
<li class="toctree-l2"><a class="reference internal" href="../../_autosummary/mlx.utils.tree_flatten.html">mlx.utils.tree_flatten</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../_autosummary/mlx.utils.tree_unflatten.html">mlx.utils.tree_unflatten</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../_autosummary/mlx.utils.tree_map.html">mlx.utils.tree_map</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../_autosummary/mlx.utils.tree_map_with_path.html">mlx.utils.tree_map_with_path</a></li>
</ul>
</li>
</ul>
@@ -786,28 +795,33 @@ document.write(`
<p>It is the quantized equivalent of <a class="reference internal" href="mlx.nn.Linear.html#mlx.nn.Linear" title="mlx.nn.Linear"><code class="xref py py-class docutils literal notranslate"><span class="pre">mlx.nn.Linear</span></code></a>. For now its
parameters are frozen and will not be included in any gradient computation
but this will probably change in the future.</p>
<p>QuantizedLinear also provides two useful classmethods to convert linear
layers to QuantizedLinear layers.</p>
<ul class="simple">
<li><p><code class="xref py py-meth docutils literal notranslate"><span class="pre">from_linear()</span></code> returns a QuantizedLinear layer that applies the same
linear transformation up to the quantization error.</p></li>
<li><p><code class="xref py py-meth docutils literal notranslate"><span class="pre">quantize_module()</span></code> swaps all the linear layers of the passed module
with QuantizedLinear ones.</p></li>
</ul>
<p><a class="reference internal" href="#mlx.nn.QuantizedLinear" title="mlx.nn.QuantizedLinear"><code class="xref py py-obj docutils literal notranslate"><span class="pre">QuantizedLinear</span></code></a> also provides a classmethod <code class="xref py py-meth docutils literal notranslate"><span class="pre">from_linear()</span></code> to
convert linear layers to <a class="reference internal" href="#mlx.nn.QuantizedLinear" title="mlx.nn.QuantizedLinear"><code class="xref py py-obj docutils literal notranslate"><span class="pre">QuantizedLinear</span></code></a> layers.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>input_dims</strong> (<a class="reference external" href="https://docs.python.org/3/library/functions.html#int" title="(in Python v3.12)"><em>int</em></a>) The dimensionality of the input features</p></li>
<li><p><strong>output_dims</strong> (<a class="reference external" href="https://docs.python.org/3/library/functions.html#int" title="(in Python v3.12)"><em>int</em></a>) The dimensionality of the output features</p></li>
<li><p><strong>input_dims</strong> (<a class="reference external" href="https://docs.python.org/3/library/functions.html#int" title="(in Python v3.12)"><em>int</em></a>) The dimensionality of the input features.</p></li>
<li><p><strong>output_dims</strong> (<a class="reference external" href="https://docs.python.org/3/library/functions.html#int" title="(in Python v3.12)"><em>int</em></a>) The dimensionality of the output features.</p></li>
<li><p><strong>bias</strong> (<a class="reference external" href="https://docs.python.org/3/library/functions.html#bool" title="(in Python v3.12)"><em>bool</em></a><em>, </em><em>optional</em>) If set to <code class="docutils literal notranslate"><span class="pre">False</span></code> then the layer will not use
a bias. (default: True).</p></li>
a bias. Default: <code class="docutils literal notranslate"><span class="pre">True</span></code>.</p></li>
<li><p><strong>group_size</strong> (<a class="reference external" href="https://docs.python.org/3/library/functions.html#int" title="(in Python v3.12)"><em>int</em></a><em>, </em><em>optional</em>) The group size to use for the quantized
weight. See <a class="reference internal" href="../../_autosummary/mlx.core.quantize.html#mlx.core.quantize" title="mlx.core.quantize"><code class="xref py py-func docutils literal notranslate"><span class="pre">quantize()</span></code></a>. (default: 64)</p></li>
weight. See <a class="reference internal" href="../../_autosummary/mlx.core.quantize.html#mlx.core.quantize" title="mlx.core.quantize"><code class="xref py py-func docutils literal notranslate"><span class="pre">quantize()</span></code></a>. Default: <code class="docutils literal notranslate"><span class="pre">64</span></code>.</p></li>
<li><p><strong>bits</strong> (<a class="reference external" href="https://docs.python.org/3/library/functions.html#int" title="(in Python v3.12)"><em>int</em></a><em>, </em><em>optional</em>) The bit width to use for the quantized weight.
See <a class="reference internal" href="../../_autosummary/mlx.core.quantize.html#mlx.core.quantize" title="mlx.core.quantize"><code class="xref py py-func docutils literal notranslate"><span class="pre">quantize()</span></code></a>. (default: 4)</p></li>
See <a class="reference internal" href="../../_autosummary/mlx.core.quantize.html#mlx.core.quantize" title="mlx.core.quantize"><code class="xref py py-func docutils literal notranslate"><span class="pre">quantize()</span></code></a>. Default: <code class="docutils literal notranslate"><span class="pre">4</span></code>.</p></li>
</ul>
</dd>
</dl>
<p class="rubric">Methods</p>
<table class="autosummary longtable table autosummary">
<tbody>
<tr class="row-odd"><td><p><code class="xref py py-obj docutils literal notranslate"><span class="pre">from_linear</span></code>(linear_layer[, group_size, bits])</p></td>
<td><p>Create a <a class="reference internal" href="#mlx.nn.QuantizedLinear" title="mlx.nn.QuantizedLinear"><code class="xref py py-obj docutils literal notranslate"><span class="pre">QuantizedLinear</span></code></a> layer from a <a class="reference internal" href="mlx.nn.Linear.html#mlx.nn.Linear" title="mlx.nn.Linear"><code class="xref py py-obj docutils literal notranslate"><span class="pre">Linear</span></code></a> layer.</p></td>
</tr>
<tr class="row-even"><td><p><code class="xref py py-obj docutils literal notranslate"><span class="pre">unfreeze</span></code>(*args, **kwargs)</p></td>
<td><p>Wrap unfreeze so that we unfreeze any layers we might contain but our parameters will remain frozen.</p></td>
</tr>
</tbody>
</table>
</dd></dl>
</section>
@@ -824,12 +838,12 @@ See <a class="reference internal" href="../../_autosummary/mlx.core.quantize.htm
<div class="prev-next-area">
<a class="left-prev"
href="mlx.nn.PReLU.html"
href="mlx.nn.QuantizedEmbedding.html"
title="previous page">
<i class="fa-solid fa-angle-left"></i>
<div class="prev-next-info">
<p class="prev-next-subtitle">previous</p>
<p class="prev-next-title">mlx.nn.PReLU</p>
<p class="prev-next-title">mlx.nn.QuantizedEmbedding</p>
</div>
</a>
<a class="right-next"