{"id":528,"date":"2023-05-23T12:05:19","date_gmt":"2023-05-23T19:05:19","guid":{"rendered":"https:\/\/devblogs.microsoft.com\/windowsai\/?p=528"},"modified":"2023-05-25T10:23:14","modified_gmt":"2023-05-25T17:23:14","slug":"optimize-directml-performance-with-olive","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/windowsai\/optimize-directml-performance-with-olive\/","title":{"rendered":"Optimize DirectML performance with Olive"},"content":{"rendered":"<p><span data-contrast=\"auto\">Are you ready to revolutionize the way you optimize your AI models? Say hello to Olive (ONNX Live), the advanced model optimization tool that integrates seamlessly with DirectML for hardware acceleration across the breadth of the Windows ecosystem.<\/span><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559739&quot;:160,&quot;335559740&quot;:259}\">\u00a0<\/span><\/p>\n<p><span data-contrast=\"auto\">With Olive, you can easily incorporate cutting-edge techniques like model compression, optimization, and compilation, all in one powerful tool. And the best part? You don&#8217;t need to be an expert in optimizing models for underlying GPUs or NPUs &#8211; Olive does all the heavy lifting for you to get the best possible performance with DirectML!<\/span><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559739&quot;:160,&quot;335559740&quot;:259}\">\u00a0<\/span><\/p>\n<p><span data-contrast=\"auto\">In our Stable Diffusion tests, we saw over 6x speed increase to generate an image after optimizing with Olive for DirectML!<\/span><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559739&quot;:160,&quot;335559740&quot;:259}\">\u00a0<\/span><\/p>\n<h3 aria-level=\"1\"><span style=\"font-size: 18pt;\">Olive and DirectML in Practice<\/span><\/h3>\n<p><span data-contrast=\"auto\">The Olive workflow consists of configuring passes to optimize a model for one or more metrics. Olive then executes each pass to find the best candidate model. Our recommended passes for GPU optimization with DirectML are as follows:<\/span><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559739&quot;:160,&quot;335559740&quot;:259}\">\u00a0<\/span><\/p>\n<h6><span style=\"font-size: 14pt;\"><b>Generic non-transformer models<\/b>\u00a0<\/span><\/h6>\n<ol>\n<li><a href=\"https:\/\/microsoft.github.io\/Olive\/api\/passes.html#onnxconversion\"><span data-contrast=\"none\">Convert to ONNX<\/span><\/a><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559739&quot;:160,&quot;335559740&quot;:259}\">\u00a0<\/span><\/li>\n<li data-leveltext=\"%1.\" data-font=\"Calibri\" data-listid=\"3\" data-list-defn-props=\"{&quot;335552541&quot;:0,&quot;335559684&quot;:-1,&quot;335559685&quot;:720,&quot;335559991&quot;:360,&quot;469769242&quot;:[65533,0],&quot;469777803&quot;:&quot;left&quot;,&quot;469777804&quot;:&quot;%1.&quot;,&quot;469777815&quot;:&quot;hybridMultilevel&quot;}\" aria-setsize=\"-1\" data-aria-posinset=\"2\" data-aria-level=\"1\"><a href=\"https:\/\/microsoft.github.io\/Olive\/api\/passes.html#onnxfloattofloat16\"><span data-contrast=\"none\">Convert to fp16<\/span><\/a><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559739&quot;:160,&quot;335559740&quot;:259}\">\u00a0<\/span><\/li>\n<\/ol>\n<h6><span style=\"font-size: 14pt;\"><b>Transformer models:<\/b>\u00a0<\/span><\/h6>\n<ol>\n<li><a href=\"https:\/\/microsoft.github.io\/Olive\/api\/passes.html#onnxconversion\"><span data-contrast=\"none\">Convert to ONNX<\/span><\/a><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559739&quot;:160,&quot;335559740&quot;:259}\">\u00a0<\/span><\/li>\n<li data-leveltext=\"%1.\" data-font=\"Calibri\" data-listid=\"4\" data-list-defn-props=\"{&quot;335552541&quot;:0,&quot;335559684&quot;:-1,&quot;335559685&quot;:720,&quot;335559991&quot;:360,&quot;469769242&quot;:[65533,0],&quot;469777803&quot;:&quot;left&quot;,&quot;469777804&quot;:&quot;%1.&quot;,&quot;469777815&quot;:&quot;hybridMultilevel&quot;}\" aria-setsize=\"-1\" data-aria-posinset=\"2\" data-aria-level=\"1\"><a href=\"https:\/\/microsoft.github.io\/Olive\/api\/passes.html#orttransformersoptimization\"><span data-contrast=\"none\">Orttransformeroptimizations<\/span><\/a><span data-contrast=\"auto\"> with the following parameters:<\/span><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559739&quot;:160,&quot;335559740&quot;:259}\">\u00a0<\/span>\n<ol>\n<li data-leveltext=\"%1.\" data-font=\"Calibri\" data-listid=\"4\" data-list-defn-props=\"{&quot;335552541&quot;:0,&quot;335559684&quot;:-1,&quot;335559685&quot;:720,&quot;335559991&quot;:360,&quot;469769242&quot;:[65533,0],&quot;469777803&quot;:&quot;left&quot;,&quot;469777804&quot;:&quot;%1.&quot;,&quot;469777815&quot;:&quot;hybridMultilevel&quot;}\" aria-setsize=\"-1\" data-aria-posinset=\"2\" data-aria-level=\"1\"><span data-contrast=\"auto\">\u201cuse_gpu\u201d: true<\/span><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559739&quot;:160,&quot;335559740&quot;:259}\">\u00a0<\/span><\/li>\n<li data-leveltext=\"%1.\" data-font=\"Calibri\" data-listid=\"4\" data-list-defn-props=\"{&quot;335552541&quot;:0,&quot;335559684&quot;:-1,&quot;335559685&quot;:720,&quot;335559991&quot;:360,&quot;469769242&quot;:[65533,0],&quot;469777803&quot;:&quot;left&quot;,&quot;469777804&quot;:&quot;%1.&quot;,&quot;469777815&quot;:&quot;hybridMultilevel&quot;}\" aria-setsize=\"-1\" data-aria-posinset=\"2\" data-aria-level=\"1\"><span data-contrast=\"auto\">\u201cfloat16\u201d: true<\/span><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559739&quot;:160,&quot;335559740&quot;:259}\">\u00a0<\/span><\/li>\n<li data-leveltext=\"%1.\" data-font=\"Calibri\" data-listid=\"4\" data-list-defn-props=\"{&quot;335552541&quot;:0,&quot;335559684&quot;:-1,&quot;335559685&quot;:720,&quot;335559991&quot;:360,&quot;469769242&quot;:[65533,0],&quot;469777803&quot;:&quot;left&quot;,&quot;469777804&quot;:&quot;%1.&quot;,&quot;469777815&quot;:&quot;hybridMultilevel&quot;}\" aria-setsize=\"-1\" data-aria-posinset=\"2\" data-aria-level=\"1\"><span data-contrast=\"auto\">\u201coptimization_options\u201d: <\/span><a href=\"https:\/\/github.com\/microsoft\/Olive\/blob\/0697e20b1cb6c9eb93ea9eea430fd6b3924e0e0b\/examples\/directml\/stable_diffusion\/config_unet.json#L63\"><span data-contrast=\"none\">see example<\/span><\/a><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559739&quot;:160,&quot;335559740&quot;:259}\">\u00a0<\/span><\/li>\n<\/ol>\n<\/li>\n<\/ol>\n<p><span data-contrast=\"auto\">For configuring multi-model pipelines (e.g. Stable Diffusion), see our <\/span><a href=\"https:\/\/github.com\/microsoft\/Olive\/tree\/main\/examples\/directml\/stable_diffusion\"><span data-contrast=\"none\">sample on the Olive repository<\/span><\/a><span data-contrast=\"auto\">. To learn more about configuring Olive passes, visit: <\/span><a href=\"https:\/\/microsoft.github.io\/Olive\/tutorials\/configure_pass.html\"><span data-contrast=\"none\">Configuring Pass \u2014 Olive documentation (microsoft.github.io)<\/span><\/a><\/p>\n<p><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559739&quot;:160,&quot;335559740&quot;:259}\">\n<\/span><span style=\"font-size: 1rem; -webkit-tap-highlight-color: transparent; -webkit-text-size-adjust: 100%;\" data-contrast=\"auto\">With Olive, you&#8217;ll be able to take your AI models to the next level. Say goodbye to complicated optimization processes and hello to a streamlined, efficient workflow. To get started, check out our <\/span><a style=\"font-size: 1rem; -webkit-tap-highlight-color: transparent; -webkit-text-size-adjust: 100%;\" href=\"https:\/\/github.com\/microsoft\/Olive\/tree\/main\/examples\/directml\"><span data-contrast=\"none\">Olive &amp; DirectML samples<\/span><\/a><span style=\"font-size: 1rem; -webkit-tap-highlight-color: transparent; -webkit-text-size-adjust: 100%;\" data-contrast=\"auto\"> and stay tuned for additional DirectML samples like quantization.<\/span><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Are you ready to revolutionize the way you optimize your AI models? Say hello to Olive (ONNX Live), the advanced model optimization tool that integrates seamlessly with DirectML for hardware acceleration across the breadth of the Windows ecosystem.\u00a0 With Olive, you can easily incorporate cutting-edge techniques like model compression, optimization, and compilation, all in one [&hellip;]<\/p>\n","protected":false},"author":60022,"featured_media":74,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1],"tags":[],"class_list":["post-528","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-windows-ai"],"acf":[],"blog_post_summary":"<p>Are you ready to revolutionize the way you optimize your AI models? Say hello to Olive (ONNX Live), the advanced model optimization tool that integrates seamlessly with DirectML for hardware acceleration across the breadth of the Windows ecosystem.\u00a0 With Olive, you can easily incorporate cutting-edge techniques like model compression, optimization, and compilation, all in one [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/windowsai\/wp-json\/wp\/v2\/posts\/528","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/windowsai\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/windowsai\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/windowsai\/wp-json\/wp\/v2\/users\/60022"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/windowsai\/wp-json\/wp\/v2\/comments?post=528"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/windowsai\/wp-json\/wp\/v2\/posts\/528\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/windowsai\/wp-json\/wp\/v2\/media\/74"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/windowsai\/wp-json\/wp\/v2\/media?parent=528"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/windowsai\/wp-json\/wp\/v2\/categories?post=528"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/windowsai\/wp-json\/wp\/v2\/tags?post=528"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}