"use strict";(self.webpackChunkrspress_doc_template=self.webpackChunkrspress_doc_template||[]).push([["4238"],{75202:function(e,t,o){o.r(t);var n=o(85893),r=o(50065);function i(e){let t=Object.assign({h1:"h1",a:"a",p:"p",br:"br",pre:"pre",code:"code",span:"span",div:"div"},(0,r.ah)(),e.components);return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)(t.h1,{id:"introduction",children:[(0,n.jsx)(t.a,{className:"header-anchor","aria-hidden":"true",href:"#introduction",children:"#"}),"Introduction"]}),"\n",(0,n.jsxs)(t.p,{children:["The quantization refers to an inference acceleration technique that performs computations and stores tensors using bit widths lower than floating-point precision. Quantized computations only support forward propagation.",(0,n.jsx)(t.br,{}),"\n","Quantized models use integers instead of floating-point values to perform some or all operations on tensors.",(0,n.jsx)(t.br,{}),"\n","Compared with typical FP32 models, quantized models can save computational resources. Taking INT8 quantization as an example, the model size is reduced by 4 times, and the memory bandwidth requirement is reduced by 4 times. Hardware support for INT8 computations is typically 2 to 4 times faster than FP32 computations."]}),"\n",(0,n.jsx)(t.p,{children:"horizon_plugin_pytorch provides the BPU-adapted quantization operations and supports quantized awareness training (QAT). The QAT uses fake-quantization modules to model the quantization errors in forward computation and backpropagation. Note that the computation process of the QAT is performed by using floating-point operations. At the end of the QAT, horizon_plugin_pytorch provides the conversion functions to convert the trained model to a fixed-point model, using a more compact model for representation and high-performance vectorization on the BPU."}),"\n",(0,n.jsx)(t.p,{children:"This section gives you a detailed introduction to horizon_plugin_pytorch quantitative training tool developed on the basis of PyTorch."}),"\n",(0,n.jsxs)(t.p,{children:["Horizon_plugin_pytorch is developed based on PyTorch, in order to reduce the learning cost of you, we refer to the design of PyTorch on quantized awareness training.\r\nThis doc doesn't repeat the contents which PyTorch doc already contains, if you want to understand the details of the tool, we recommend that you read the ",(0,n.jsx)(t.a,{href:"https://github.com/pytorch/pytorch/tree/v2.0.0/torch/ao",target:"_blank",rel:"noopener noreferrer",children:"Official source code"})," or the python source code of this tool.\r\nTo ensure a smooth experience, we recommend that you first read the PyTorch documentation and familiarize yourself with the quantized awareness training and deployment tools provided by PyTorch."]}),"\n",(0,n.jsx)(t.p,{children:"For the purpose of brevity, the code in the documentation has been replaced with the following aliases by default:"}),"\n",(0,n.jsx)(t.pre,{className:"code",children:(0,n.jsx)(t.pre,{className:"shiki css-variables has-line-number",style:{backgroundColor:"var(--shiki-color-background)"},tabIndex:"0",children:(0,n.jsxs)(t.code,{className:"language-python",meta:"",children:[(0,n.jsxs)(t.span,{className:"line line-number",children:[(0,n.jsx)(t.span,{style:{color:"var(--shiki-token-keyword)"},children:"import"}),(0,n.jsx)(t.span,{style:{color:"var(--shiki-color-text)"},children:" horizon_plugin_pytorch "}),(0,n.jsx)(t.span,{style:{color:"var(--shiki-token-keyword)"},children:"as"}),(0,n.jsx)(t.span,{style:{color:"var(--shiki-color-text)"},children:" horizon"})]}),"\n"]})})}),"\n",(0,n.jsxs)(t.div,{className:"rspress-directive warning",children:[(0,n.jsx)(t.div,{className:"rspress-directive-title",children:"Attention"}),(0,n.jsx)(t.div,{className:"rspress-directive-content",children:(0,n.jsx)(t.p,{children:"\nQAT requires necessary modifications to the floating-point model. Please ensure a deep understanding of the BPU deployment, be familiarity with the structure of the floating-point model and the related code. It is recommended that algorithm engineers who work on floating-point models participate in QAT."})})]})]})}function s(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},{wrapper:t}=Object.assign({},(0,r.ah)(),e.components);return t?(0,n.jsx)(t,Object.assign({},e,{children:(0,n.jsx)(i,e)})):i(e)}t.default=s,s.__RSPRESS_PAGE_META={},s.__RSPRESS_PAGE_META["latest%2Fen%2Fguide%2Fplugin%2Fintroduce.mdx"]={toc:[],title:"Introduction",frontmatter:{}}}}]);