-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path6e21ff35.c90a6f95.js
More file actions
1 lines (1 loc) · 14 KB
/
6e21ff35.c90a6f95.js
File metadata and controls
1 lines (1 loc) · 14 KB
1
(window.webpackJsonp=window.webpackJsonp||[]).push([[11],{114:function(e,t,n){"use strict";n.r(t),n.d(t,"frontMatter",(function(){return o})),n.d(t,"metadata",(function(){return c})),n.d(t,"rightToc",(function(){return s})),n.d(t,"default",(function(){return b}));var a=n(2),i=n(6),r=(n(0),n(125)),o={id:"memory-report",title:"Memory Report"},c={id:"memory-report",isDocsHomePage:!1,title:"Memory Report",description:"This page describes the database schema of the memory report that is generated",source:"@site/docs/memory-report.md",permalink:"/docs/memory-report",editUrl:"https://github.com/skylineprof/skyline/edit/master/website/docs/memory-report.md",sidebar:"sidebar",previous:{title:"Run Time Report",permalink:"/docs/run-time-report"}},s=[{value:"Overview",id:"overview",children:[]},{value:"Tables",id:"tables",children:[{value:"<code>weight_entries</code>",id:"weight_entries",children:[]},{value:"<code>activation_entries</code>",id:"activation_entries",children:[]},{value:"<code>entry_types</code>",id:"entry_types",children:[]},{value:"<code>stack_correlation</code>",id:"stack_correlation",children:[]},{value:"<code>stack_frames</code>",id:"stack_frames",children:[]},{value:"<code>misc_sizes</code>",id:"misc_sizes",children:[]}]}],l={rightToc:s};function b(e){var t=e.components,n=Object(i.a)(e,["components"]);return Object(r.b)("wrapper",Object(a.a)({},l,n,{components:t,mdxType:"MDXLayout"}),Object(r.b)("p",null,"This page describes the database schema of the memory report that is generated\nby Skyline's ",Object(r.b)("a",Object(a.a)({parentName:"p"},{href:"/docs/cli#memory-profiling"}),Object(r.b)("inlineCode",{parentName:"a"},"memory")," subcommand"),". Recall\nthat Skyline's reports (memory and run time) are ",Object(r.b)("a",Object(a.a)({parentName:"p"},{href:"https://www.sqlite.org/"}),"SQLite database\nfiles"),"."),Object(r.b)("div",{className:"admonition admonition-note alert alert--secondary"},Object(r.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-heading"}),Object(r.b)("h5",{parentName:"div"},Object(r.b)("span",Object(a.a)({parentName:"h5"},{className:"admonition-icon"}),Object(r.b)("svg",Object(a.a)({parentName:"span"},{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"16",viewBox:"0 0 14 16"}),Object(r.b)("path",Object(a.a)({parentName:"svg"},{fillRule:"evenodd",d:"M6.3 5.69a.942.942 0 0 1-.28-.7c0-.28.09-.52.28-.7.19-.18.42-.28.7-.28.28 0 .52.09.7.28.18.19.28.42.28.7 0 .28-.09.52-.28.7a1 1 0 0 1-.7.3c-.28 0-.52-.11-.7-.3zM8 7.99c-.02-.25-.11-.48-.31-.69-.2-.19-.42-.3-.69-.31H6c-.27.02-.48.13-.69.31-.2.2-.3.44-.31.69h1v3c.02.27.11.5.31.69.2.2.42.31.69.31h1c.27 0 .48-.11.69-.31.2-.19.3-.42.31-.69H8V7.98v.01zM7 2.3c-3.14 0-5.7 2.54-5.7 5.68 0 3.14 2.56 5.7 5.7 5.7s5.7-2.55 5.7-5.7c0-3.15-2.56-5.69-5.7-5.69v.01zM7 .98c3.86 0 7 3.14 7 7s-3.14 7-7 7-7-3.12-7-7 3.14-7 7-7z"})))),"note")),Object(r.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-content"}),Object(r.b)("p",{parentName:"div"},"Skyline's memory profiling is for GPU memory only."))),Object(r.b)("h2",{id:"overview"},"Overview"),Object(r.b)("p",null,"Skyline tracks the memory usage associated with a model's ",Object(r.b)("em",{parentName:"p"},"weights")," and\n",Object(r.b)("em",{parentName:"p"},"activations"),". Skyline will also report the peak amount of memory allocated\nduring a training iteration."),Object(r.b)("p",null,"Just like the run time report, Skyline also includes the stack trace associated\nwith each activation or weight in the report. Skyline only includes the stack\nframes associated with files inside your project (i.e. files under your\nproject's root directory)."),Object(r.b)("h2",{id:"tables"},"Tables"),Object(r.b)("h3",{id:"weight_entries"},Object(r.b)("inlineCode",{parentName:"h3"},"weight_entries")),Object(r.b)("pre",null,Object(r.b)("code",Object(a.a)({parentName:"pre"},{className:"language-sql",metastring:'title="Schema"',title:'"Schema"'}),"CREATE TABLE weight_entries (\n id INTEGER PRIMARY KEY,\n name TEXT NOT NULL,\n size_bytes INTEGER NOT NULL,\n grad_size_bytes INTEGER NOT NULL\n);\n")),Object(r.b)("p",null,"This table holds the memory used by the model's weights. The ",Object(r.b)("inlineCode",{parentName:"p"},"size_bytes"),"\ncolumn is the number of bytes used by the weight and ",Object(r.b)("inlineCode",{parentName:"p"},"grad_size_bytes")," is the\nnumber of bytes used by the weight's gradient tensor. The ",Object(r.b)("inlineCode",{parentName:"p"},"name")," column holds\nthe weight's name, which is assigned by PyTorch."),Object(r.b)("h3",{id:"activation_entries"},Object(r.b)("inlineCode",{parentName:"h3"},"activation_entries")),Object(r.b)("pre",null,Object(r.b)("code",Object(a.a)({parentName:"pre"},{className:"language-sql",metastring:'title="Schema"',title:'"Schema"'}),"CREATE TABLE activation_entries (\n id INTEGER PRIMARY KEY,\n operation_name TEXT NOT NULL,\n size_bytes INTEGER NOT NULL\n);\n")),Object(r.b)("p",null,"This table holds the memory used by the model's activations in one training\niteration. The ",Object(r.b)("inlineCode",{parentName:"p"},"size_bytes")," column is the number of bytes used by the\nactivation. The ",Object(r.b)("inlineCode",{parentName:"p"},"operation_name")," column is the name of the operation that\ngenerated the activation."),Object(r.b)("h3",{id:"entry_types"},Object(r.b)("inlineCode",{parentName:"h3"},"entry_types")),Object(r.b)("pre",null,Object(r.b)("code",Object(a.a)({parentName:"pre"},{className:"language-sql",metastring:'title="Schema"',title:'"Schema"'}),"CREATE TABLE entry_types (\n entry_type INTEGER PRIMARY KEY,\n name TEXT NOT NULL\n);\n")),Object(r.b)("p",null,"This is a table that stores mappings of Skyline's memory entry types\n(activations, weights) to numeric identifiers. Skyline maps weights to an entry\ntype of ",Object(r.b)("inlineCode",{parentName:"p"},"1"),", and activations to an entry type of ",Object(r.b)("inlineCode",{parentName:"p"},"2"),"."),Object(r.b)("h3",{id:"stack_correlation"},Object(r.b)("inlineCode",{parentName:"h3"},"stack_correlation")),Object(r.b)("pre",null,Object(r.b)("code",Object(a.a)({parentName:"pre"},{className:"language-sql",metastring:'title="Schema"',title:'"Schema"'}),"CREATE TABLE stack_correlation (\n correlation_id INTEGER PRIMARY KEY,\n entry_id INTEGER NOT NULL,\n entry_type INTEGER NOT NULL,\n UNIQUE (correlation_id, entry_id)\n);\nCREATE UNIQUE INDEX entry_type_and_id\n ON stack_correlation(entry_type, entry_id);\n")),Object(r.b)("p",null,"This table maps entries to a ",Object(r.b)("inlineCode",{parentName:"p"},"correlation_id"),", which can be used to look up a\nmemory entry's relevant stack frames in the ",Object(r.b)("inlineCode",{parentName:"p"},"stack_frames")," table. The\n",Object(r.b)("inlineCode",{parentName:"p"},"entry_type")," column contains either ",Object(r.b)("inlineCode",{parentName:"p"},"1")," or ",Object(r.b)("inlineCode",{parentName:"p"},"2"),", which corresponds to the\nweights and activations respectively."),Object(r.b)("p",null,"For all rows where ",Object(r.b)("inlineCode",{parentName:"p"},"entry_type == 1"),", the ",Object(r.b)("inlineCode",{parentName:"p"},"entry_id")," column will act as a\nforeign key for the ",Object(r.b)("inlineCode",{parentName:"p"},"id")," column in the ",Object(r.b)("inlineCode",{parentName:"p"},"weight_entries")," table. Similarly for\nall rows where ",Object(r.b)("inlineCode",{parentName:"p"},"entry_type == 2"),", the ",Object(r.b)("inlineCode",{parentName:"p"},"entry_id")," column will act as a foreign\nkey for the ",Object(r.b)("inlineCode",{parentName:"p"},"id")," column in the ",Object(r.b)("inlineCode",{parentName:"p"},"activation_entries")," table."),Object(r.b)("h3",{id:"stack_frames"},Object(r.b)("inlineCode",{parentName:"h3"},"stack_frames")),Object(r.b)("pre",null,Object(r.b)("code",Object(a.a)({parentName:"pre"},{className:"language-sql",metastring:'title="Schema"',title:'"Schema"'}),"CREATE TABLE stack_frames (\n correlation_id INTEGER NOT NULL,\n ordering INTEGER NOT NULL,\n file_path TEXT NOT NULL,\n line_number INTEGER NOT NULL,\n PRIMARY KEY (correlation_id, ordering)\n);\n")),Object(r.b)("p",null,"This table holds the stack frames associated with a memory usage entry (both\nweights and activations). The ",Object(r.b)("inlineCode",{parentName:"p"},"correlation_id")," column is a foreign key that\nreferences the ",Object(r.b)("inlineCode",{parentName:"p"},"correlation_id")," in the ",Object(r.b)("inlineCode",{parentName:"p"},"stack_correlation")," table. File paths\nstored in the ",Object(r.b)("inlineCode",{parentName:"p"},"file_path")," column will be relative to the project's root\ndirectory and line numbers are 1-based."),Object(r.b)("div",{className:"admonition admonition-note alert alert--secondary"},Object(r.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-heading"}),Object(r.b)("h5",{parentName:"div"},Object(r.b)("span",Object(a.a)({parentName:"h5"},{className:"admonition-icon"}),Object(r.b)("svg",Object(a.a)({parentName:"span"},{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"16",viewBox:"0 0 14 16"}),Object(r.b)("path",Object(a.a)({parentName:"svg"},{fillRule:"evenodd",d:"M6.3 5.69a.942.942 0 0 1-.28-.7c0-.28.09-.52.28-.7.19-.18.42-.28.7-.28.28 0 .52.09.7.28.18.19.28.42.28.7 0 .28-.09.52-.28.7a1 1 0 0 1-.7.3c-.28 0-.52-.11-.7-.3zM8 7.99c-.02-.25-.11-.48-.31-.69-.2-.19-.42-.3-.69-.31H6c-.27.02-.48.13-.69.31-.2.2-.3.44-.31.69h1v3c.02.27.11.5.31.69.2.2.42.31.69.31h1c.27 0 .48-.11.69-.31.2-.19.3-.42.31-.69H8V7.98v.01zM7 2.3c-3.14 0-5.7 2.54-5.7 5.68 0 3.14 2.56 5.7 5.7 5.7s5.7-2.55 5.7-5.7c0-3.15-2.56-5.69-5.7-5.69v.01zM7 .98c3.86 0 7 3.14 7 7s-3.14 7-7 7-7-3.12-7-7 3.14-7 7-7z"})))),"note")),Object(r.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-content"}),Object(r.b)("p",{parentName:"div"},"Skyline does not add an explicit foreign key constraint to the ",Object(r.b)("inlineCode",{parentName:"p"},"correlation_id"),"\ncolumn."))),Object(r.b)("p",null,Object(r.b)("strong",{parentName:"p"},"Ordering."),"\nThere may be multiple stack frames associated with any given memory entry (i.e.\nany given ",Object(r.b)("inlineCode",{parentName:"p"},"correlation_id"),"). The ",Object(r.b)("inlineCode",{parentName:"p"},"ordering")," column is used to keep track of the\nordering among stack frames that share the same ",Object(r.b)("inlineCode",{parentName:"p"},"correlation_id"),". When sorted\nin ascending order by the ",Object(r.b)("inlineCode",{parentName:"p"},"ordering")," column, the stack frames will be ordered\nfrom most-specific (i.e. ",Object(r.b)("em",{parentName:"p"},"closest")," to the weight or operation responsible for\nthe activation) to least-specific (i.e. ",Object(r.b)("em",{parentName:"p"},"farthest")," from the weight or operation\nresponsible for the activation)."),Object(r.b)("p",null,Object(r.b)("strong",{parentName:"p"},"Connecting to Entries."),"\nTo get the stack frames for a given entry, you need to first query the\n",Object(r.b)("inlineCode",{parentName:"p"},"stack_correlation")," table to find the ",Object(r.b)("inlineCode",{parentName:"p"},"correlation_id")," associated with your\n",Object(r.b)("inlineCode",{parentName:"p"},"entry_id")," and ",Object(r.b)("inlineCode",{parentName:"p"},"entry_type")," combination. Then you can use that ",Object(r.b)("inlineCode",{parentName:"p"},"correlation_id"),"\nto look up the associated stack frames in this table."),Object(r.b)("h3",{id:"misc_sizes"},Object(r.b)("inlineCode",{parentName:"h3"},"misc_sizes")),Object(r.b)("pre",null,Object(r.b)("code",Object(a.a)({parentName:"pre"},{className:"language-sql",metastring:'title="Schema"',title:'"Schema"'}),"CREATE TABLE misc_sizes (\n key TEXT PRIMARY KEY,\n size_bytes INT NOT NULL\n);\n")),Object(r.b)("p",null,"This table holds any miscellaneous memory usage information that is reported by\nSkyline. Currently, Skyline only uses this table to report the peak memory\nusage during one training iteration. This memory usage is reported using the\n",Object(r.b)("inlineCode",{parentName:"p"},"peak_usage_bytes")," key."))}b.isMDXComponent=!0},125:function(e,t,n){"use strict";n.d(t,"a",(function(){return p})),n.d(t,"b",(function(){return h}));var a=n(0),i=n.n(a);function r(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function o(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);t&&(a=a.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,a)}return n}function c(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?o(Object(n),!0).forEach((function(t){r(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):o(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function s(e,t){if(null==e)return{};var n,a,i=function(e,t){if(null==e)return{};var n,a,i={},r=Object.keys(e);for(a=0;a<r.length;a++)n=r[a],t.indexOf(n)>=0||(i[n]=e[n]);return i}(e,t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);for(a=0;a<r.length;a++)n=r[a],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}var l=i.a.createContext({}),b=function(e){var t=i.a.useContext(l),n=t;return e&&(n="function"==typeof e?e(t):c(c({},t),e)),n},p=function(e){var t=b(e.components);return i.a.createElement(l.Provider,{value:t},e.children)},m={inlineCode:"code",wrapper:function(e){var t=e.children;return i.a.createElement(i.a.Fragment,{},t)}},d=i.a.forwardRef((function(e,t){var n=e.components,a=e.mdxType,r=e.originalType,o=e.parentName,l=s(e,["components","mdxType","originalType","parentName"]),p=b(n),d=a,h=p["".concat(o,".").concat(d)]||p[d]||m[d]||r;return n?i.a.createElement(h,c(c({ref:t},l),{},{components:n})):i.a.createElement(h,c({ref:t},l))}));function h(e,t){var n=arguments,a=t&&t.mdxType;if("string"==typeof e||a){var r=n.length,o=new Array(r);o[0]=d;var c={};for(var s in t)hasOwnProperty.call(t,s)&&(c[s]=t[s]);c.originalType=e,c.mdxType="string"==typeof e?e:a,o[1]=c;for(var l=2;l<r;l++)o[l]=n[l];return i.a.createElement.apply(null,o)}return i.a.createElement.apply(null,n)}d.displayName="MDXCreateElement"}}]);