Buckets:

rtrm's picture
download
raw
8.47 kB
<meta charset="utf-8" /><meta http-equiv="content-security-policy" content=""><meta name="hf:doc:metadata" content="{&quot;local&quot;:&quot;configuration-classes-for-neuron-exports&quot;,&quot;sections&quot;:[{&quot;local&quot;:&quot;supported-architectures&quot;,&quot;title&quot;:&quot;Supported architectures&quot;}],&quot;title&quot;:&quot;Configuration classes for Neuron exports&quot;}" data-svelte="svelte-1phssyn">
<link rel="modulepreload" href="/docs/optimum.neuron/main/en/_app/assets/pages/__layout.svelte-hf-doc-builder.css">
<link rel="modulepreload" href="/docs/optimum.neuron/main/en/_app/start-hf-doc-builder.js">
<link rel="modulepreload" href="/docs/optimum.neuron/main/en/_app/chunks/vendor-hf-doc-builder.js">
<link rel="modulepreload" href="/docs/optimum.neuron/main/en/_app/chunks/paths-hf-doc-builder.js">
<link rel="modulepreload" href="/docs/optimum.neuron/main/en/_app/pages/__layout.svelte-hf-doc-builder.js">
<link rel="modulepreload" href="/docs/optimum.neuron/main/en/_app/pages/package_reference/configuration.mdx-hf-doc-builder.js">
<link rel="modulepreload" href="/docs/optimum.neuron/main/en/_app/chunks/Tip-hf-doc-builder.js">
<link rel="modulepreload" href="/docs/optimum.neuron/main/en/_app/chunks/IconCopyLink-hf-doc-builder.js">
<h1 class="relative group"><a id="configuration-classes-for-neuron-exports" 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="#configuration-classes-for-neuron-exports"><span><svg class="" 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>Configuration classes for Neuron exports
</span></h1>
<p>Exporting a PyTorch model to neuron compiled model involves specifying:</p>
<ol><li>The input names.</li>
<li>The output names.</li>
<li>Dummy inputs used to trace the model. This is needed for Neuron-Compiler to record the computational graph and convert it to TorchScript module.</li>
<li>Compilation arguments used to control the trade-off between hardware efficiency(latency, throughput) and accuracy.</li></ol>
<p>Depending on the choice of model and task, we represent the data above with <em>configuration classes</em>. Each configuration class is associated with
a specific model architecture, and follows the naming convention <code>ArchitectureNameNeuronConfig</code>. For instance, the configuration which specifies the Neuron
export of BERT models is <code>BertNeuronConfig</code>.</p>
<p>Since many architectures share similar properties for their Neuron configuration, 🤗 Optimum adopts a 3-level class hierarchy:</p>
<ol><li>Abstract and generic base classes. These handle all the fundamental features, while being agnostic to the modality (text, image, audio, etc).</li>
<li>Middle-end classes. These are aware of the modality, but multiple can exist for the same modality depending on the inputs they support.
They specify which input generators should be used for the dummy inputs, but remain model-agnostic.</li>
<li>Model-specific classes like the <code>BertNeuronConfig</code> mentioned above. These are the ones actually used to export models.</li></ol>
<h2 class="relative group"><a id="supported-architectures" 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="#supported-architectures"><span><svg class="" 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>Supported architectures
</span></h2>
<table><thead><tr><th>Architecture</th>
<th>Task</th></tr></thead>
<tbody><tr><td>ALBERT</td>
<td>feature-extraction, fill-mask, multiple-choice, question-answering, text-classification, token-classification</td></tr>
<tr><td>BERT</td>
<td>feature-extraction, fill-mask, multiple-choice, question-answering, text-classification, token-classification</td></tr>
<tr><td>CamemBERT</td>
<td>feature-extraction, fill-mask, multiple-choice, question-answering, text-classification, token-classification</td></tr>
<tr><td>ConvBERT</td>
<td>feature-extraction, fill-mask, multiple-choice, question-answering, text-classification, token-classification</td></tr>
<tr><td>DeBERTa (INF2 only)</td>
<td>feature-extraction, fill-mask, multiple-choice, question-answering, text-classification, token-classification</td></tr>
<tr><td>DeBERTa-v2 (INF2 only)</td>
<td>feature-extraction, fill-mask, multiple-choice, question-answering, text-classification, token-classification</td></tr>
<tr><td>DistilBERT</td>
<td>feature-extraction, fill-mask, multiple-choice, question-answering, text-classification, token-classification</td></tr>
<tr><td>ELECTRA</td>
<td>feature-extraction, fill-mask, multiple-choice, question-answering, text-classification, token-classification</td></tr>
<tr><td>FlauBERT</td>
<td>feature-extraction, fill-mask, multiple-choice, question-answering, text-classification, token-classification</td></tr>
<tr><td>GPT2</td>
<td>text-generation</td></tr>
<tr><td>MobileBERT</td>
<td>feature-extraction, fill-mask, multiple-choice, question-answering, text-classification, token-classification</td></tr>
<tr><td>MPNet</td>
<td>feature-extraction, fill-mask, multiple-choice, question-answering, text-classification, token-classification</td></tr>
<tr><td>RoBERTa</td>
<td>feature-extraction, fill-mask, multiple-choice, question-answering, text-classification, token-classification</td></tr>
<tr><td>RoFormer</td>
<td>feature-extraction, fill-mask, multiple-choice, question-answering, text-classification, token-classification</td></tr>
<tr><td>XLM</td>
<td>feature-extraction, fill-mask, multiple-choice, question-answering, text-classification, token-classification</td></tr>
<tr><td>XLM-RoBERTa</td>
<td>feature-extraction, fill-mask, multiple-choice, question-answering, text-classification, token-classification</td></tr></tbody></table>
<div class="course-tip bg-gradient-to-br dark:bg-gradient-to-r before:border-green-500 dark:before:border-green-800 from-green-50 dark:from-gray-900 to-white dark:to-gray-950 border border-green-50 text-green-700 dark:text-gray-400"><p>More details for checking supported tasks <a href="https://huggingface.co/docs/optimum-neuron/guides/export_model#selecting-a-task" rel="nofollow">here</a>.</p></div>
<p>More architectures coming soon, stay tuned! 🚀</p>
<script type="module" data-hydrate="2892mj">
import { start } from "/docs/optimum.neuron/main/en/_app/start-hf-doc-builder.js";
start({
target: document.querySelector('[data-hydrate="2892mj"]').parentNode,
paths: {"base":"/docs/optimum.neuron/main/en","assets":"/docs/optimum.neuron/main/en"},
session: {},
route: false,
spa: false,
trailing_slash: "never",
hydrate: {
status: 200,
error: null,
nodes: [
import("/docs/optimum.neuron/main/en/_app/pages/__layout.svelte-hf-doc-builder.js"),
import("/docs/optimum.neuron/main/en/_app/pages/package_reference/configuration.mdx-hf-doc-builder.js")
],
params: {}
}
});
</script>

Xet Storage Details

Size:
8.47 kB
·
Xet hash:
3bd8f23b8b2469ece22a33097452adabf4c44423a88e89dc642afe1101c34fde

Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.