Buckets:
| <meta charset="utf-8" /><meta name="hf:doc:metadata" content="{"title":"FP-Quant","local":"fp-quant","sections":[{"title":"Installer FP-Quant","local":"install-fp-quant","sections":[],"depth":2},{"title":"Quantifier un modèle avec FP-Quant","local":"quantize-a-model-with-fp-quant","sections":[],"depth":2},{"title":"Configurer FP-Quant","local":"configure-fp-quant","sections":[],"depth":2},{"title":"Entraîner avec des poids quantifiés","local":"train-with-quantized-weights","sections":[],"depth":2},{"title":"Limites","local":"limitations","sections":[],"depth":2},{"title":"Ressources","local":"resources","sections":[],"depth":2}],"depth":1}"/> | |
| <link href="/docs/transformers/main/en/_app/immutable/entry/start.bKKV-GDt.js" rel="modulepreload"> | |
| <link href="/docs/transformers/main/en/_app/immutable/chunks/jZL2H18U.js" rel="modulepreload"> | |
| <link href="/docs/transformers/main/en/_app/immutable/chunks/Dl5NQtrR.js" rel="modulepreload"> | |
| <link href="/docs/transformers/main/en/_app/immutable/entry/app.D8t1f3B5.js" rel="modulepreload"> | |
| <link href="/docs/transformers/main/en/_app/immutable/chunks/CQY_nM_9.js" rel="modulepreload"> | |
| <link href="/docs/transformers/main/en/_app/immutable/chunks/DOLBYqcr.js" rel="modulepreload"> | |
| <link href="/docs/transformers/main/en/_app/immutable/chunks/DsnmJJEf.js" rel="modulepreload"> | |
| <link href="/docs/transformers/main/en/_app/immutable/chunks/qSxQr_2b.js" rel="modulepreload"> | |
| <link href="/docs/transformers/main/en/_app/immutable/nodes/0.BpVmqpTv.js" rel="modulepreload"> | |
| <link href="/docs/transformers/main/en/_app/immutable/chunks/CQMas4mt.js" rel="modulepreload"> | |
| <link href="/docs/transformers/main/en/_app/immutable/nodes/7.C4z0wB_X.js" rel="modulepreload"> | |
| <link href="/docs/transformers/main/en/_app/immutable/chunks/BIVg0dGc.js" rel="modulepreload"> | |
| <!--130dt37--><meta name="hf:doc:metadata" content="{"title":"FP-Quant","local":"fp-quant","sections":[{"title":"Install FP-Quant","local":"install-fp-quant","sections":[],"depth":2},{"title":"Quantize a model with FP-Quant","local":"quantize-a-model-with-fp-quant","sections":[],"depth":2},{"title":"Configure FP-Quant","local":"configure-fp-quant","sections":[],"depth":2},{"title":"Train with quantized weights","local":"train-with-quantized-weights","sections":[],"depth":2},{"title":"Limitations","local":"limitations","sections":[],"depth":2},{"title":"Resources","local":"resources","sections":[],"depth":2}],"depth":1}"/><!----> | |
| <link href="/docs/transformers/main/en/_app/immutable/assets/0.tn0RQdqM.css" rel="modulepreload"> <!--[--><!--[0--><!--[--><!--[0--><!--[--><p></p> <div class="items-center shrink-0 min-w-[100px] max-sm:min-w-[50px] justify-end ml-auto flex" style="float: inline-end; margin-inline-start: 10px; display: inline-flex; position: relative; z-index: 10;"><div dir="ltr" class="inline-flex rounded-md max-sm:rounded-sm"><button class="inline-flex items-center gap-1 h-7 max-sm:h-7 px-2 max-sm:px-1.5 text-sm font-medium text-gray-800 border border-r-0 rounded-l-md max-sm:rounded-l-sm border-gray-200 bg-white hover:shadow-inner dark:border-gray-850 dark:bg-gray-950 dark:text-gray-200 dark:hover:bg-gray-800" aria-live="polite"><span class="inline-flex items-center justify-center rounded-md p-0.5 max-sm:p-0 hover:text-gray-800 dark:hover:text-gray-200"><svg class="sm:size-3.5 size-3" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" fill="currentColor" focusable="false" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 32 32"><path d="M28,10V28H10V10H28m0-2H10a2,2,0,0,0-2,2V28a2,2,0,0,0,2,2H28a2,2,0,0,0,2-2V10a2,2,0,0,0-2-2Z" transform="translate(0)"></path><path d="M4,18H2V4A2,2,0,0,1,4,2H18V4H4Z" transform="translate(0)"></path><rect fill="none" width="32" height="32"></rect></svg><!----></span> <span dir="auto">Copy page</span></button> <button class="inline-flex items-center justify-center w-6 max-sm:w-5 h-7 max-sm:h-7 disabled:pointer-events-none text-sm text-gray-500 hover:text-gray-700 dark:hover:text-white rounded-r-md max-sm:rounded-r-sm border border-l transition border-gray-200 bg-white hover:shadow-inner dark:border-gray-850 dark:bg-gray-950 dark:text-gray-200 dark:hover:bg-gray-800" aria-haspopup="menu" aria-expanded="false" aria-label="Open copy menu"><svg class="transition-transform text-gray-400 overflow-visible sm:size-3.5 size-3 rotate-0" width="1em" height="1em" viewBox="0 0 12 7" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M1 1L6 6L11 1" stroke="currentColor"></path></svg><!----></button></div> <!--[-1--><!--]--></div><!----> <!--[0--><h1 class="relative group"><a id="fp-quant" class="header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full" href="#fp-quant"><span><svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg><!----></span></a> <span><!---->FP-Quant<!----></span></h1><!--]--><!----> <p><a href="https://github.com/IST-DASLab/FP-Quant" rel="nofollow">FP-Quant</a> quantifie les poids et les activations dans les formats <a href="./mxfp4">MXFP4</a> ou <a href="./nvfp4">NVFP4</a>, en appliquant une rotation (une transformation de Hadamard par défaut) avant la quantification, et exécute les produits matriciels avec les noyaux <a href="https://github.com/IST-DASLab/qutlass" rel="nofollow">QuTLASS</a> sur les GPU NVIDIA Blackwell. Utilisez-le pour l’inférence FP4 sur les GPU Blackwell, ou pour émuler la quantification FP4 sur d’autres GPU afin d’évaluer la précision ou d’exécuter un entraînement conscient de la quantification (QAT).</p> <p>Le tableau ci-dessous résume ce que FP-Quant prend en charge dans Transformers.</p> <table><thead><tr><th></th><th></th></tr></thead><tbody><tr><td>Configuration</td><td><a href="/docs/transformers/main/fr/main_classes/quantization#transformers.FPQuantConfig">FPQuantConfig</a></td></tr><tr><td><code>quant_method</code></td><td><code>fp_quant</code></td></tr><tr><td>Flux de travail</td><td>Quantifier lors du chargement</td></tr><tr><td>Bits</td><td>4</td></tr><tr><td>Matériel</td><td>GPU NVIDIA Blackwell ; autres GPU CUDA et XPU Intel avec <code>pseudoquantization=True</code></td></tr><tr><td>Enregistrer</td><td>✅</td></tr><tr><td>Ajustement fin</td><td>Uniquement avec <code>store_master_weights=True</code></td></tr><tr><td>Auto-compilation</td><td>❌</td></tr></tbody></table> <!--[1--><h2 class="relative group"><a id="install-fp-quant" class="header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full" href="#install-fp-quant"><span><svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg><!----></span></a> <span><!---->Installer FP-Quant<!----></span></h2><!--]--><!----> <p>Installez fp_quant 0.3.2 ou une version ultérieure. Pour exécuter les noyaux FP4 réels sur un GPU Blackwell, compilez également QuTLASS 0.2.0 ou une version ultérieure à partir du code source.</p> <div class="code-block relative "><div class="absolute top-2.5 right-4"><button class="inline-flex items-center relative text-sm focus:text-green-500 cursor-pointer focus:outline-none transition duration-200 ease-in-out opacity-0 mx-0.5 text-gray-600 " title="code excerpt" type="button"><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" fill="currentColor" focusable="false" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 32 32"><path d="M28,10V28H10V10H28m0-2H10a2,2,0,0,0-2,2V28a2,2,0,0,0,2,2H28a2,2,0,0,0,2-2V10a2,2,0,0,0-2-2Z" transform="translate(0)"></path><path d="M4,18H2V4A2,2,0,0,1,4,2H18V4H4Z" transform="translate(0)"></path><rect fill="none" width="32" height="32"></rect></svg><!----> <div class=" absolute pointer-events-none transition-opacity bg-black text-white py-1 px-2 leading-tight rounded font-normal shadow left-1/2 top-full transform -translate-x-1/2 translate-y-2 opacity-0 "><div class="absolute bottom-full left-1/2 transform -translate-x-1/2 w-0 h-0 border-black border-4 border-t-0" style="border-left-color: transparent; border-right-color: transparent;"></div> Copié</div><!----></button><!----></div> <pre class="language-bash "><!---->pip install -U <span class="hljs-string">"fp_quant>=0.3.2"</span> | |
| git <span class="hljs-built_in">clone</span> https://github.com/IST-DASLab/qutlass.git | |
| <span class="hljs-built_in">cd</span> qutlass && pip install --no-build-isolation .<!----></pre></div><!----> <!--[1--><h2 class="relative group"><a id="quantize-a-model-with-fp-quant" class="header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full" href="#quantize-a-model-with-fp-quant"><span><svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg><!----></span></a> <span><!---->Quantifier un modèle avec FP-Quant<!----></span></h2><!--]--><!----> <p>Créez un <a href="/docs/transformers/main/fr/main_classes/quantization#transformers.FPQuantConfig">FPQuantConfig</a> et passez-le à <a href="/docs/transformers/main/fr/main_classes/model#transformers.PreTrainedModel.from_pretrained">from_pretrained()</a>. Définissez <code>device_map</code> sur vos GPU. La configuration par défaut quantise chaque couche linéaire, à l'exception de <code>lm_head</code>, en NVFP4.</p> <div class="code-block relative "><div class="absolute top-2.5 right-4"><button class="inline-flex items-center relative text-sm focus:text-green-500 cursor-pointer focus:outline-none transition duration-200 ease-in-out opacity-0 mx-0.5 text-gray-600 " title="code excerpt" type="button"><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" fill="currentColor" focusable="false" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 32 32"><path d="M28,10V28H10V10H28m0-2H10a2,2,0,0,0-2,2V28a2,2,0,0,0,2,2H28a2,2,0,0,0,2-2V10a2,2,0,0,0-2-2Z" transform="translate(0)"></path><path d="M4,18H2V4A2,2,0,0,1,4,2H18V4H4Z" transform="translate(0)"></path><rect fill="none" width="32" height="32"></rect></svg><!----> <div class=" absolute pointer-events-none transition-opacity bg-black text-white py-1 px-2 leading-tight rounded font-normal shadow left-1/2 top-full transform -translate-x-1/2 translate-y-2 opacity-0 "><div class="absolute bottom-full left-1/2 transform -translate-x-1/2 w-0 h-0 border-black border-4 border-t-0" style="border-left-color: transparent; border-right-color: transparent;"></div> Copié</div><!----></button><!----></div> <pre class="language-py "><!----><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoModelForCausalLM, FPQuantConfig | |
| model = AutoModelForCausalLM.from_pretrained( | |
| <span class="hljs-string">"Qwen/Qwen3-8B"</span>, | |
| quantization_config=FPQuantConfig(), | |
| device_map=<span class="hljs-string">"cuda"</span>, | |
| )<!----></pre></div><!----> <p>FP-Quant ne prend en charge que bf16, le modèle est donc toujours chargé en bf16. Tout autre <code>dtype</code> est remplacé avec un avertissement.</p> <p>Sans GPU Blackwell, définissez <code>pseudoquantization=True</code>. FP-Quant émule alors la quantification FP4 à l’aide de noyaux Triton. Cela reproduit la précision du modèle quantifié, mais n’apporte pas d’accélération.</p> <div class="code-block relative "><div class="absolute top-2.5 right-4"><button class="inline-flex items-center relative text-sm focus:text-green-500 cursor-pointer focus:outline-none transition duration-200 ease-in-out opacity-0 mx-0.5 text-gray-600 " title="code excerpt" type="button"><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" fill="currentColor" focusable="false" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 32 32"><path d="M28,10V28H10V10H28m0-2H10a2,2,0,0,0-2,2V28a2,2,0,0,0,2,2H28a2,2,0,0,0,2-2V10a2,2,0,0,0-2-2Z" transform="translate(0)"></path><path d="M4,18H2V4A2,2,0,0,1,4,2H18V4H4Z" transform="translate(0)"></path><rect fill="none" width="32" height="32"></rect></svg><!----> <div class=" absolute pointer-events-none transition-opacity bg-black text-white py-1 px-2 leading-tight rounded font-normal shadow left-1/2 top-full transform -translate-x-1/2 translate-y-2 opacity-0 "><div class="absolute bottom-full left-1/2 transform -translate-x-1/2 w-0 h-0 border-black border-4 border-t-0" style="border-left-color: transparent; border-right-color: transparent;"></div> Copié</div><!----></button><!----></div> <pre class="language-py "><!---->model = AutoModelForCausalLM.from_pretrained( | |
| <span class="hljs-string">"Qwen/Qwen3-8B"</span>, | |
| quantization_config=FPQuantConfig(forward_dtype=<span class="hljs-string">"mxfp4"</span>, pseudoquantization=<span class="hljs-literal">True</span>), | |
| device_map=<span class="hljs-string">"cuda"</span>, | |
| )<!----></pre></div><!----> <p>Pour charger un modèle quantisé à l'avance avec GPTQ afin d'obtenir une meilleure précision, passez son dépôt Hub à <a href="/docs/transformers/main/fr/main_classes/model#transformers.PreTrainedModel.from_pretrained">from_pretrained()</a> sans <code>quantization_config</code>. L'organisation <a href="https://huggingface.co/ISTA-DASLab/models?search=FPQuant" rel="nofollow">ISTA-DASLab</a> héberge des points de contrôle FP-Quant, et le dépôt <a href="https://github.com/IST-DASLab/FP-Quant" rel="nofollow">FP-Quant</a> contient le code pour les créer.</p> <!--[1--><h2 class="relative group"><a id="configure-fp-quant" class="header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full" href="#configure-fp-quant"><span><svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg><!----></span></a> <span><!---->Configurer FP-Quant<!----></span></h2><!--]--><!----> <p>Ces paramètres <a href="/docs/transformers/main/fr/main_classes/quantization#transformers.FPQuantConfig">FPQuantConfig</a> modifient la manière dont les poids et les activations sont quantifiés.</p> <table><thead><tr><th>Paramètre</th><th>Par défaut</th><th>Effet</th></tr></thead><tbody><tr><td><code>forward_dtype</code></td><td><code>"nvfp4"</code></td><td>Format FP4 pour le passage avant, soit <code>"nvfp4"</code> soit <code>"mxfp4"</code>.</td></tr><tr><td><code>hadamard_group_size</code></td><td><code>None</code></td><td>Taille de la transformation de Hadamard. Avec <code>None</code>, elle est de 16 pour NVFP4 et de 32 pour MXFP4. NVFP4 accepte 16, 32, 64 et 128, et MXFP4 accepte 32, 64 et 128.</td></tr><tr><td><code>transform_init</code></td><td><code>"hadamard"</code></td><td>La façon dont la matrice de transformation est initialisée, soit <code>"hadamard"</code>, <code>"identity"</code> ou <code>"gsr"</code>.</td></tr><tr><td><code>pseudoquantization</code></td><td><code>False</code></td><td>Émule FP4 avec des noyaux Triton au lieu d'exécuter les noyaux QuTLASS. Requis sur les GPU autres que Blackwell.</td></tr></tbody></table> <p>Voir <a href="/docs/transformers/main/fr/main_classes/quantization#transformers.FPQuantConfig">FPQuantConfig</a> pour le reste des paramètres.</p> <!--[1--><h2 class="relative group"><a id="train-with-quantized-weights" class="header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full" href="#train-with-quantized-weights"><span><svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg><!----></span></a> <span><!---->Entraîner avec des poids quantifiés<!----></span></h2><!--]--><!----> <p>FP-Quant prend en charge le QAT. Définissez <code>store_master_weights=True</code> pour conserver les poids haute précision afin qu’ils puissent être mis à jour, et définissez <code>forward_method="quest"</code>, qui fonctionne mieux que <code>"abs_max"</code> pour le QAT. La méthode <code>"quest"</code> ne fonctionne qu’avec MXFP4. Lors d’un passage avant MXFP4, <code>backward_dtype</code> peut également quantifier le passage arrière en <code>"mxfp8"</code> ou <code>"mxfp4"</code> au lieu de <code>"bf16"</code>.</p> <div class="code-block relative "><div class="absolute top-2.5 right-4"><button class="inline-flex items-center relative text-sm focus:text-green-500 cursor-pointer focus:outline-none transition duration-200 ease-in-out opacity-0 mx-0.5 text-gray-600 " title="code excerpt" type="button"><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" fill="currentColor" focusable="false" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 32 32"><path d="M28,10V28H10V10H28m0-2H10a2,2,0,0,0-2,2V28a2,2,0,0,0,2,2H28a2,2,0,0,0,2-2V10a2,2,0,0,0-2-2Z" transform="translate(0)"></path><path d="M4,18H2V4A2,2,0,0,1,4,2H18V4H4Z" transform="translate(0)"></path><rect fill="none" width="32" height="32"></rect></svg><!----> <div class=" absolute pointer-events-none transition-opacity bg-black text-white py-1 px-2 leading-tight rounded font-normal shadow left-1/2 top-full transform -translate-x-1/2 translate-y-2 opacity-0 "><div class="absolute bottom-full left-1/2 transform -translate-x-1/2 w-0 h-0 border-black border-4 border-t-0" style="border-left-color: transparent; border-right-color: transparent;"></div> Copié</div><!----></button><!----></div> <pre class="language-py "><!----><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoModelForCausalLM, FPQuantConfig | |
| quantization_config = FPQuantConfig( | |
| forward_dtype=<span class="hljs-string">"mxfp4"</span>, | |
| forward_method=<span class="hljs-string">"quest"</span>, | |
| store_master_weights=<span class="hljs-literal">True</span>, | |
| pseudoquantization=<span class="hljs-literal">True</span>, | |
| ) | |
| model = AutoModelForCausalLM.from_pretrained( | |
| <span class="hljs-string">"Qwen/Qwen3-8B"</span>, | |
| quantization_config=quantization_config, | |
| device_map=<span class="hljs-string">"cuda"</span>, | |
| )<!----></pre></div><!----> <p>Les auteurs de FP-Quant notent que QAT ne fonctionne actuellement qu'avec <code>pseudoquantization=True</code>.</p> <!--[1--><h2 class="relative group"><a id="limitations" class="header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full" href="#limitations"><span><svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg><!----></span></a> <span><!---->Limites<!----></span></h2><!--]--><!----> <ul><li>FP-Quant nécessite un GPU CUDA ou un XPU Intel. Le chargement sans l'un d'eux provoque une <code>NotImplementedError</code>.</li> <li>Sans QuTLASS installé, le chargement avec <code>pseudoquantization=False</code> lève une <code>ImportError</code>.</li> <li>La pseudo-quantisation NVFP4 nécessite un GPU CUDA avec une capacité de calcul 9.0 ou supérieure (Hopper ou plus récent). Sur les GPU plus anciens, elle lève une <code>ValueError</code>. Utilisez plutôt <code>forward_dtype="mxfp4"</code>.</li> <li>Sans <code>pseudoquantization</code>, le chargement sans <code>device_map</code> lève une <code>ValueError</code>. Un <code>device_map</code> qui répartit le modèle entre un GPU et le CPU lève également une <code>ValueError</code>.</li> <li>Un <code>device_map</code> qui inclut <code>"disk"</code> lève une <code>ValueError</code>.</li> <li>La pseudo-quantisation ne prend pas en charge plusieurs GPU.</li> <li>L’entraînement sans <code>store_master_weights=True</code> n’est pas pris en charge.</li></ul> <!--[1--><h2 class="relative group"><a id="resources" class="header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full" href="#resources"><span><svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg><!----></span></a> <span><!---->Ressources<!----></span></h2><!--]--><!----> <ul><li><a href="https://arxiv.org/abs/2509.23202" rel="nofollow">Comblé l'écart entre la promesse et les performances de la quantification Microscaling FP4</a></li> <li><a href="https://github.com/IST-DASLab/FP-Quant" rel="nofollow">FP-Quant</a></li> <li><a href="https://github.com/IST-DASLab/qutlass" rel="nofollow">QuTLASS</a> du dépôt, y compris les benchmarks d'accélération</li></ul> <a class="!text-gray-400 !no-underline text-sm flex items-center not-prose mt-4" href="https://github.com/huggingface/transformers/blob/main/docs/source/en/quantization/fp_quant.md" target="_blank"><svg class="mr-1" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" fill="currentColor" focusable="false" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 32 32"><path d="M31,16l-7,7l-1.41-1.41L28.17,16l-5.58-5.59L24,9l7,7z"></path><path d="M1,16l7-7l1.41,1.41L3.83,16l5.58,5.59L8,23l-7-7z"></path><path d="M12.419,25.484L17.639,6.552l1.932,0.518L14.351,26.002z"></path></svg><!----> <span><span class="underline">Update</span> on GitHub</span></a><!----> <p></p><!--]--><!----><!--]--><!--]--><!--]--> <!--[-1--><!--]--><!--]--> | |
| <script> | |
| { | |
| __sveltekit_1fjlakw = { | |
| base: "/docs/transformers/main/en", | |
| assets: "/docs/transformers/main/en" | |
| }; | |
| const element = document.currentScript.parentElement; | |
| Promise.all([ | |
| import("/docs/transformers/main/en/_app/immutable/entry/start.bKKV-GDt.js"), | |
| import("/docs/transformers/main/en/_app/immutable/entry/app.D8t1f3B5.js") | |
| ]).then(([kit, app]) => { | |
| kit.start(app, element, { | |
| node_ids: [0, 7], | |
| data: [null,null], | |
| form: null, | |
| error: null | |
| }); | |
| }); | |
| } | |
| </script> | |
Xet Storage Details
- Size:
- 27.5 kB
- Xet hash:
- 8846079bbd2d69b979266ac96621181f33f9d37f47c8fff31da0508001abaf1c
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.