Buckets:
| import{s as kt,n as Gt,o as xt}from"../chunks/scheduler.56725da7.js";import{S as Vt,i as At,e as o,s as a,c as r,h as Ht,a as i,d as l,b as s,f as Rt,g as m,j as p,k as Et,l as qt,m as n,n as M,t as c,o as u,p as d}from"../chunks/index.18a26576.js";import{C as Qt}from"../chunks/CopyLLMTxtMenu.a1f2bcd7.js";import{C as h}from"../chunks/CodeBlock.d6d1e300.js";import{H as me}from"../chunks/MermaidChart.svelte_svelte_type_style_lang.9f98faf7.js";function Ft(st){let y,Me,pe,ce,T,ue,w,de,J,ot='In this tutorial you will learn how to deploy <a href="https://huggingface.co/meta-llama/Llama-3.3-70B-Instruct" rel="nofollow">/meta-llama/Llama-3.3-70B-Instruct</a> model on AWS Inferentia2 with Hugging Face Optimum on Amazon SageMaker. We are going to use the Hugging Face vLLM Neuron Container, a purpose-built Inference Container to easily deploy LLMs on AWS Inferentia2 powered by <a href="https://github.com/vllm-project/vllm.git" rel="nofollow">vLLM</a> and <a href="https://huggingface.co/docs/optimum-neuron/index" rel="nofollow">Optimum Neuron</a>.',ye,f,it="We will cover how to:",he,U,pt='<li><a href="#1-setup-development-environment">Setup development environment</a></li> <li><a href="#2-retrieve-the-new-hugging-face-vllm-neuron-dlc">Retrieve the new Hugging Face vLLM Neuron DLC</a></li> <li><a href="#3-deploy-llama-33-70b-to-inferentia2">Deploy Llama 3.3 70B to inferentia2</a></li> <li><a href="#4-clean-up">Clean up</a></li>',Te,j,rt="Lets get started! 🚀",we,b,mt='<a href="https://aws.amazon.com/ec2/instance-types/inf2/" rel="nofollow">AWS inferentia (Inf2)</a> are purpose-built EC2 for deep learning (DL) inference workloads. Here are the different instances of the Inferentia2 family.',Je,g,Mt="<thead><tr><th>instance size</th> <th>accelerators</th> <th>Neuron Cores</th> <th>accelerator memory</th> <th>vCPU</th> <th>CPU Memory</th> <th>on-demand price ($/h)</th></tr></thead> <tbody><tr><td>inf2.xlarge</td> <td>1</td> <td>2</td> <td>32</td> <td>4</td> <td>16</td> <td>0.76</td></tr> <tr><td>inf2.8xlarge</td> <td>1</td> <td>2</td> <td>32</td> <td>32</td> <td>128</td> <td>1.97</td></tr> <tr><td>inf2.24xlarge</td> <td>6</td> <td>12</td> <td>192</td> <td>96</td> <td>384</td> <td>6.49</td></tr> <tr><td>inf2.48xlarge</td> <td>12</td> <td>24</td> <td>384</td> <td>192</td> <td>768</td> <td>12.98</td></tr></tbody>",fe,I,Ue,C,ct="For this tutorial, we are going to use a Notebook Instance in Amazon SageMaker with the Python 3 (ipykernel) and the <code>sagemaker</code> python SDK to deploy Llama 3.3 70B to a SageMaker inference endpoint.",je,v,ut="Make sur you have the latest version of the SageMaker SDK installed.",be,B,ge,W,dt="Then, instantiate the sagemaker role and session.",Ie,Z,Ce,S,ve,_,yt='The latest Hugging Face vLLM Neuron DLCs can be used to run inference on AWS Inferentia2. To retrieve it you can use the method <code>image_uris.retrieve</code> of the Sagemaker SDK. However, if you have the Optimum Neuron package installed, you can use the <code>ecr.image_uri</code> function to retrieve the appropriate Hugging Face vLLM Neuron DLC URI based on your desired <code>region</code> and <code>version</code>. Default values can be deduced by your AWS credentials. For more details see the <a href="https://huggingface.co/docs/optimum-neuron/containers" rel="nofollow">containers</a> documentation.',Be,L,We,N,Ze,$,ht=`At the time of writing, <a href="https://awsdocs-neuron.readthedocs-hosted.com/en/v2.6.0/general/arch/neuron-features/dynamic-shapes.html#neuron-dynamic-shapes" rel="nofollow">AWS Inferentia2 does not support dynamic shapes for inference</a>, which means that we need to specify our sequence length and batch size ahead of time. | |
| To make it easier for customers to utilize the full power of Inferentia2, we created a <a href="https://huggingface.co/docs/optimum-neuron/guides/cache_system" rel="nofollow">neuron model cache</a>, which contains pre-compiled configurations for the most popular LLMs, including Llama 3.3 70B.`,Se,R,Tt='This means we don’t need to compile the model ourselves, but we can use the pre-compiled model from the cache. You can find compiled/cached configurations on the <a href="https://huggingface.co/aws-neuron/optimum-neuron-cache/tree/main/inference-cache-config" rel="nofollow">Hugging Face Hub</a>. If your desired configuration is not yet cached, you can compile it yourself using the <a href="https://huggingface.co/docs/optimum-neuron/guides/export_model" rel="nofollow">Optimum CLI</a> or open a request at the <a href="https://huggingface.co/aws-neuron/optimum-neuron-cache/discussions" rel="nofollow">Cache repository</a>.',_e,E,wt="<strong>Deploying Llama 3.3 70B to a SageMaker Endpoint</strong>",Le,k,Jt="All we need when deploying the model to Amazon SageMaker, is to set the Hugging Face model id and token.",Ne,G,ft="<li><code>SM_ON_MODEL</code>: The Hugging Face model ID.</li> <li><code>HF_TOKEN</code>: The Hugging Face API token to access gated models.</li>",$e,x,Ut="Note: even if you model is not gated, we recommend setting your Hugging Face token to avoid rate limitations when fetching weights or pre-compiled neuron artifacts.",Re,V,jt="Optionally, you can specify some deployment parameters to select a specific cached configuration (otherwise a default one will be selected).",Ee,A,bt="<li><code>SM_ON_TENSOR_PARALLEL_SIZE</code>: Number of Neuron Cores used for the compilation.</li> <li><code>SM_ON_BATCH_SIZE</code>: The batch size that was used to compile the model.</li> <li><code>SM_ON_SEQUENCE_LENGTH</code>: The sequence length that was used to compile the model.</li>",ke,H,gt="<strong>Select the right instance type</strong>",Ge,q,It='Llama 3.3 70B is a large model and requires a lot of memory. We are going to use the <code>inf2.48xlarge</code> instance type, which has 192 vCPUs and 384 GB of accelerator memory. The <code>inf2.48xlarge</code> instance comes with 12 Inferentia2 accelerators that include 24 Neuron Cores. If you want to find the cached configurations for Llama 3.3 70B, you can find them <a href="https://huggingface.co/aws-neuron/optimum-neuron-cache/blob/main/inference-cache-config/llama3-70b.json" rel="nofollow">here</a>. Here we will let the framework select one of them automatically, so we won’t specify any specific deployment parameter.',xe,Q,Ct='Before we can deploy Llama 3.3 70B to Inferentia2, we need to make sure we have the necessary permissions to access the model. You can request access to the model <a href="https://huggingface.co/meta-llama/Llama-3.3-70B-Instruct" rel="nofollow">here</a> and create a User access token following this <a href="https://huggingface.co/docs/hub/en/security-tokens" rel="nofollow">guide</a>.',Ve,F,vt="After that we can create our endpoint configuration and deploy the model to Amazon SageMaker.",Ae,X,He,z,Bt="After we have created the <code>Model</code> we need to define a deployment configuration. We will deploy the model with the <code>ml.inf2.48xlarge</code> instance type. vLLM will automatically distribute and shard the model across all Inferentia devices.",qe,Y,Qe,P,Wt="We can now deploy the <code>Model</code> to an <code>Endpoint</code>.",Fe,D,Xe,O,Zt="SageMaker will now create our endpoint and deploy the model to it. It takes around 30 minutes for deployment.",ze,K,St="After our endpoint is deployed we can run inference on it. We will use the <code>invoke</code> method to run inference on our endpoint.",Ye,ee,_t="The endpoint supports the Messages API, which is fully compatible with the OpenAI Chat Completion API. The Messages API allows us to interact with the model in a conversational way. We can define the role of the message and the content. The role can be either <code>system</code>,<code>assistant</code> or <code>user</code>. The <code>system</code> role is used to provide context to the model and the <code>user</code> role is used to ask questions or provide input to the model.",Pe,te,Lt='Parameters can be defined as separate attributes of the payload. Check out the chat completion <a href="https://platform.openai.com/docs/api-reference/chat/create" rel="nofollow">documentation</a> to find supported parameters.',De,le,Oe,ne,Nt="Okay lets test it.",Ke,ae,et,se,tt,oe,$t="To clean up, we can delete the model and endpoint.",lt,ie,nt,re,at;return T=new Qt({props:{containerStyle:"float: right; margin-left: 10px; display: inline-flex; position: relative; z-index: 10;"}}),w=new me({props:{title:"Deploy Llama 3.3 70B on AWS Inferentia2",local:"deploy-llama-33-70b-on-aws-inferentia2",headingTag:"h1"}}),I=new me({props:{title:"1. Setup development environment",local:"1-setup-development-environment",headingTag:"h2"}}),B=new h({props:{code:"IXBpcCUyMGluc3RhbGwlMjBzYWdlbWFrZXIlMjAtLXVwZ3JhZGUlMjAtLXF1aWV0",highlighted:"!pip install sagemaker --upgrade --quiet",lang:"python",wrap:!1}}),Z=new h({props:{code:"aW1wb3J0JTIwYm90bzMlMEFmcm9tJTIwc2FnZW1ha2VyLmNvcmUuaGVscGVyLnNlc3Npb25faGVscGVyJTIwaW1wb3J0JTIwZ2V0X2V4ZWN1dGlvbl9yb2xlJTBBJTBBdHJ5JTNBJTBBJTIwJTIwJTIwJTIwcm9sZSUyMCUzRCUyMGdldF9leGVjdXRpb25fcm9sZSgpJTBBZXhjZXB0JTIwVmFsdWVFcnJvciUzQSUwQSUyMCUyMCUyMCUyMGlhbSUyMCUzRCUyMGJvdG8zLmNsaWVudCglMjJpYW0lMjIpJTBBJTIwJTIwJTIwJTIwcm9sZSUyMCUzRCUyMGlhbS5nZXRfcm9sZShSb2xlTmFtZSUzRCUyMnNhZ2VtYWtlcl9leGVjdXRpb25fcm9sZSUyMiklNUIlMjJSb2xlJTIyJTVEJTVCJTIyQXJuJTIyJTVEJTBBJTBBcHJpbnQoZiUyMnNhZ2VtYWtlciUyMHJvbGUlMjBhcm4lM0ElMjAlN0Jyb2xlJTdEJTIyKQ==",highlighted:`<span class="hljs-keyword">import</span> boto3 | |
| <span class="hljs-keyword">from</span> sagemaker.core.helper.session_helper <span class="hljs-keyword">import</span> get_execution_role | |
| <span class="hljs-keyword">try</span>: | |
| role = get_execution_role() | |
| <span class="hljs-keyword">except</span> ValueError: | |
| iam = boto3.client(<span class="hljs-string">"iam"</span>) | |
| role = iam.get_role(RoleName=<span class="hljs-string">"sagemaker_execution_role"</span>)[<span class="hljs-string">"Role"</span>][<span class="hljs-string">"Arn"</span>] | |
| <span class="hljs-built_in">print</span>(<span class="hljs-string">f"sagemaker role arn: <span class="hljs-subst">{role}</span>"</span>)`,lang:"python",wrap:!1}}),S=new me({props:{title:"2. Retrieve the latest Hugging Face vLLM Neuron DLC",local:"2-retrieve-the-latest-hugging-face-vllm-neuron-dlc",headingTag:"h2"}}),L=new h({props:{code:"IXBpcCUyMGluc3RhbGwlMjBvcHRpbXVtLW5ldXJvbiU1Qm5ldXJvbnglNUQlMEFmcm9tJTIwb3B0aW11bS5uZXVyb24udXRpbHMlMjBpbXBvcnQlMjBlY3IlMEElMEFSRUdJT04lMjAlM0QlMjAlMjJ1cy1lYXN0LTElMjIlMEFsbG1faW1hZ2UlMjAlM0QlMjBlY3IuaW1hZ2VfdXJpKCUyMnZsbG0lMjIlMkMlMjByZWdpb24lM0RSRUdJT04pJTBBJTIzJTIwcHJpbnQlMjBpbWFnZSUyMHVyaSUwQXByaW50KGYlMjJsbG0lMjBpbWFnZSUyMHVyaSUzQSUyMCU3QmxsbV9pbWFnZSU3RCUyMik=",highlighted:`!pip install optimum-neuron[neuronx] | |
| <span class="hljs-keyword">from</span> optimum.neuron.utils <span class="hljs-keyword">import</span> ecr | |
| REGION = <span class="hljs-string">"us-east-1"</span> | |
| llm_image = ecr.image_uri(<span class="hljs-string">"vllm"</span>, region=REGION) | |
| <span class="hljs-comment"># print image uri</span> | |
| <span class="hljs-built_in">print</span>(<span class="hljs-string">f"llm image uri: <span class="hljs-subst">{llm_image}</span>"</span>)`,lang:"python",wrap:!1}}),N=new me({props:{title:"3. Deploy Llama 3.3 70B to Inferentia2",local:"3-deploy-llama-33-70b-to-inferentia2",headingTag:"h2"}}),X=new h({props:{code:"ZnJvbSUyMHNhZ2VtYWtlci5jb3JlLnJlc291cmNlcyUyMGltcG9ydCUyME1vZGVsJTJDJTIwQ29udGFpbmVyRGVmaW5pdGlvbiUwQSUwQSUwQSUyMyUyMERlZmluZSUyME1vZGVsJTIwYW5kJTIwRW5kcG9pbnQlMjBjb25maWd1cmF0aW9uJTIwcGFyYW1ldGVyJTBBZW52aXJvbm1lbnQlMjAlM0QlMjAlN0IlMEElMjAlMjAlMjAlMjAlMjJTTV9PTl9NT0RFTCUyMiUzQSUyMCUyMm1ldGEtbGxhbWElMkZMbGFtYS0zLjMtNzBCLUluc3RydWN0JTIyJTJDJTBBJTIwJTIwJTIwJTIwJTIySEZfVE9LRU4lMjIlM0ElMjAlMjIlM0NSRVBMQUNFJTIwV0lUSCUyMFlPVVIlMjBUT0tFTiUzRSUyMiUyQyUwQSU3RCUwQSUwQWFzc2VydCUyMGVudmlyb25tZW50JTVCJTIySEZfVE9LRU4lMjIlNUQlMjAhJTNEJTIwJTIyJTNDUkVQTEFDRSUyMFdJVEglMjBZT1VSJTIwVE9LRU4lM0UlMjIlMkMlMjAoJTBBJTIwJTIwJTIwJTIwJTIyUGxlYXNlJTIwcmVwbGFjZSUyMCclM0NSRVBMQUNFJTIwV0lUSCUyMFlPVVIlMjBUT0tFTiUzRSclMjB3aXRoJTIweW91ciUyMEh1Z2dpbmclMjBGYWNlJTIwSHViJTIwQVBJJTIwdG9rZW4lMjIlMEEpJTBBJTBBY29udGFpbmVyJTIwJTNEJTIwQ29udGFpbmVyRGVmaW5pdGlvbihpbWFnZSUzRGxsbV9pbWFnZSUyQyUyMGVudmlyb25tZW50JTNEZW52aXJvbm1lbnQpJTBBJTBBJTIzJTIwY3JlYXRlJTIwTW9kZWwlMjB3aXRoJTIwdGhlJTIwY29udGFpbmVyJTIwZGVmaW5pdGlvbiUwQW1vZGVsJTIwJTNEJTIwTW9kZWwuY3JlYXRlKCUwQSUyMCUyMCUyMCUyMG1vZGVsX25hbWUlM0QlMjJsbGFtYS0zLTMtNzBiLW5ldXJvbngtbW9kZWwlMjIlMkMlMjBwcmltYXJ5X2NvbnRhaW5lciUzRGNvbnRhaW5lciUyQyUyMGV4ZWN1dGlvbl9yb2xlX2FybiUzRHJvbGUlMkMlMjByZWdpb24lM0RSRUdJT04lMEEp",highlighted:`<span class="hljs-keyword">from</span> sagemaker.core.resources <span class="hljs-keyword">import</span> Model, ContainerDefinition | |
| <span class="hljs-comment"># Define Model and Endpoint configuration parameter</span> | |
| environment = { | |
| <span class="hljs-string">"SM_ON_MODEL"</span>: <span class="hljs-string">"meta-llama/Llama-3.3-70B-Instruct"</span>, | |
| <span class="hljs-string">"HF_TOKEN"</span>: <span class="hljs-string">"<REPLACE WITH YOUR TOKEN>"</span>, | |
| } | |
| <span class="hljs-keyword">assert</span> environment[<span class="hljs-string">"HF_TOKEN"</span>] != <span class="hljs-string">"<REPLACE WITH YOUR TOKEN>"</span>, ( | |
| <span class="hljs-string">"Please replace '<REPLACE WITH YOUR TOKEN>' with your Hugging Face Hub API token"</span> | |
| ) | |
| container = ContainerDefinition(image=llm_image, environment=environment) | |
| <span class="hljs-comment"># create Model with the container definition</span> | |
| model = Model.create( | |
| model_name=<span class="hljs-string">"llama-3-3-70b-neuronx-model"</span>, primary_container=container, execution_role_arn=role, region=REGION | |
| )`,lang:"python",wrap:!1}}),Y=new h({props:{code:"ZnJvbSUyMHNhZ2VtYWtlci5jb3JlLnJlc291cmNlcyUyMGltcG9ydCUyMEVuZHBvaW50Q29uZmlnJTJDJTIwUHJvZHVjdGlvblZhcmlhbnQlMEElMEElMjMlMjBzYWdlbWFrZXIlMjBjb25maWclMEFpbnN0YW5jZV90eXBlJTIwJTNEJTIwJTIybWwuaW5mMi40OHhsYXJnZSUyMiUwQWhlYWx0aF9jaGVja190aW1lb3V0JTIwJTNEJTIwMzYwMCUyMCUyMCUyMyUyMGFkZGl0aW9uYWwlMjB0aW1lJTIwdG8lMjBsb2FkJTIwdGhlJTIwbW9kZWwlMEF2b2x1bWVfc2l6ZSUyMCUzRCUyMDUxMiUyMCUyMCUyMyUyMHNpemUlMjBpbiUyMEdCJTIwb2YlMjB0aGUlMjBFQlMlMjB2b2x1bWUlMEElMEFlbmRwb2ludF9jb25maWclMjAlM0QlMjBFbmRwb2ludENvbmZpZy5jcmVhdGUoJTBBJTIwJTIwJTIwJTIwZW5kcG9pbnRfY29uZmlnX25hbWUlM0QlMjJsbGFtYS0zLTMtNzBiLW5ldXJvbngtZW5kcG9pbnQtY29uZmlnJTIyJTJDJTBBJTIwJTIwJTIwJTIwcHJvZHVjdGlvbl92YXJpYW50cyUzRCU1QiUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMFByb2R1Y3Rpb25WYXJpYW50KCUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMHZhcmlhbnRfbmFtZSUzRCUyMkFsbFRyYWZmaWMlMjIlMkMlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjBtb2RlbF9uYW1lJTNEbW9kZWwubW9kZWxfbmFtZSUyQyUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMGluaXRpYWxfaW5zdGFuY2VfY291bnQlM0QxJTJDJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwaW5zdGFuY2VfdHlwZSUzRGluc3RhbmNlX3R5cGUlMkMlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjBjb250YWluZXJfc3RhcnR1cF9oZWFsdGhfY2hlY2tfdGltZW91dF9pbl9zZWNvbmRzJTNEaGVhbHRoX2NoZWNrX3RpbWVvdXQlMkMlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjB2b2x1bWVfc2l6ZV9pbl9nYiUzRHZvbHVtZV9zaXplJTJDJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwaW5mZXJlbmNlX2FtaV92ZXJzaW9uJTNEJTIyYWwyLWFtaS1zYWdlbWFrZXItaW5mZXJlbmNlLW5ldXJvbi0yJTIyJTJDJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwKSUwQSUyMCUyMCUyMCUyMCU1RCUyQyUwQSk=",highlighted:`<span class="hljs-keyword">from</span> sagemaker.core.resources <span class="hljs-keyword">import</span> EndpointConfig, ProductionVariant | |
| <span class="hljs-comment"># sagemaker config</span> | |
| instance_type = <span class="hljs-string">"ml.inf2.48xlarge"</span> | |
| health_check_timeout = <span class="hljs-number">3600</span> <span class="hljs-comment"># additional time to load the model</span> | |
| volume_size = <span class="hljs-number">512</span> <span class="hljs-comment"># size in GB of the EBS volume</span> | |
| endpoint_config = EndpointConfig.create( | |
| endpoint_config_name=<span class="hljs-string">"llama-3-3-70b-neuronx-endpoint-config"</span>, | |
| production_variants=[ | |
| ProductionVariant( | |
| variant_name=<span class="hljs-string">"AllTraffic"</span>, | |
| model_name=model.model_name, | |
| initial_instance_count=<span class="hljs-number">1</span>, | |
| instance_type=instance_type, | |
| container_startup_health_check_timeout_in_seconds=health_check_timeout, | |
| volume_size_in_gb=volume_size, | |
| inference_ami_version=<span class="hljs-string">"al2-ami-sagemaker-inference-neuron-2"</span>, | |
| ) | |
| ], | |
| )`,lang:"python",wrap:!1}}),D=new h({props:{code:"ZnJvbSUyMHNhZ2VtYWtlci5jb3JlLnJlc291cmNlcyUyMGltcG9ydCUyMEVuZHBvaW50JTBBJTBBJTBBZW5kcG9pbnQlMjAlM0QlMjBFbmRwb2ludC5jcmVhdGUoJTBBJTIwJTIwJTIwJTIwZW5kcG9pbnRfbmFtZSUzRCUyMmxsYW1hLTMtMy03MGItbmV1cm9ueC1lbmRwb2ludCUyMiUyQyUwQSUyMCUyMCUyMCUyMGVuZHBvaW50X2NvbmZpZ19uYW1lJTNEZW5kcG9pbnRfY29uZmlnLmVuZHBvaW50X2NvbmZpZ19uYW1lJTJDJTBBKSUwQSUwQWVuZHBvaW50LndhaXRfZm9yX3N0YXR1cyh0YXJnZXRfc3RhdHVzJTNEJTIySW5TZXJ2aWNlJTIyKQ==",highlighted:`<span class="hljs-keyword">from</span> sagemaker.core.resources <span class="hljs-keyword">import</span> Endpoint | |
| endpoint = Endpoint.create( | |
| endpoint_name=<span class="hljs-string">"llama-3-3-70b-neuronx-endpoint"</span>, | |
| endpoint_config_name=endpoint_config.endpoint_config_name, | |
| ) | |
| endpoint.wait_for_status(target_status=<span class="hljs-string">"InService"</span>)`,lang:"python",wrap:!1}}),le=new h({props:{code:"JTIzJTIwUHJvbXB0JTIwdG8lMjBnZW5lcmF0ZSUwQW1lc3NhZ2VzJTIwJTNEJTIwJTVCJTBBJTIwJTIwJTIwJTIwJTdCJTIycm9sZSUyMiUzQSUyMCUyMnN5c3RlbSUyMiUyQyUyMCUyMmNvbnRlbnQlMjIlM0ElMjAlMjJZb3UlMjBhcmUlMjBhJTIwaGVscGZ1bCUyMGFzc2lzdGFudC4lMjIlN0QlMkMlMEElMjAlMjAlMjAlMjAlN0IlMjJyb2xlJTIyJTNBJTIwJTIydXNlciUyMiUyQyUyMCUyMmNvbnRlbnQlMjIlM0ElMjAlMjJXaGF0JTIwaXMlMjBkZWVwJTIwbGVhcm5pbmclMjBpbiUyMG9uZSUyMHNlbnRlbmNlJTNGJTIyJTdEJTJDJTBBJTVE",highlighted:`<span class="hljs-comment"># Prompt to generate</span> | |
| messages = [ | |
| {<span class="hljs-string">"role"</span>: <span class="hljs-string">"system"</span>, <span class="hljs-string">"content"</span>: <span class="hljs-string">"You are a helpful assistant."</span>}, | |
| {<span class="hljs-string">"role"</span>: <span class="hljs-string">"user"</span>, <span class="hljs-string">"content"</span>: <span class="hljs-string">"What is deep learning in one sentence?"</span>}, | |
| ]`,lang:"python",wrap:!1}}),ae=new h({props:{code:"aW1wb3J0JTIwanNvbiUwQSUwQSUyMyUyMEdlbmVyYXRpb24lMjBhcmd1bWVudHMlMjBodHRwcyUzQSUyRiUyRnBsYXRmb3JtLm9wZW5haS5jb20lMkZkb2NzJTJGYXBpLXJlZmVyZW5jZSUyRmNoYXQlMkZjcmVhdGUlMEFyZXN1bHQlMjAlM0QlMjBlbmRwb2ludC5pbnZva2UoJTBBJTIwJTIwJTIwJTIwYm9keSUzRGpzb24uZHVtcHMoJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTdCJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIybWVzc2FnZXMlMjIlM0ElMjBtZXNzYWdlcyUyQyUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMm1heF90b2tlbnMlMjIlM0ElMjA1MCUyQyUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMnRvcF9rJTIyJTNBJTIwNTAlMkMlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjJ0b3BfcCUyMiUzQSUyMDAuOSUyQyUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMnRlbXBlcmF0dXJlJTIyJTNBJTIwMC43JTJDJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTdEJTBBJTIwJTIwJTIwJTIwKSUyQyUwQSUyMCUyMCUyMCUyMGNvbnRlbnRfdHlwZSUzRCUyMmFwcGxpY2F0aW9uJTJGanNvbiUyMiUyQyUwQSklMEFvdXRwdXQlMjAlM0QlMjBqc29uLmxvYWRzKHJlc3VsdC5ib2R5LnJlYWQoKS5kZWNvZGUoJTIydXRmLTglMjIpKSUwQW1lc3NhZ2UlMjAlM0QlMjBvdXRwdXQlNUIlMjJjaG9pY2VzJTIyJTVEJTVCMCU1RCU1QiUyMm1lc3NhZ2UlMjIlNUQlMEFhc3NlcnQlMjBtZXNzYWdlJTVCJTIycm9sZSUyMiU1RCUyMCUzRCUzRCUyMCUyMmFzc2lzdGFudCUyMiUwQXByaW50KCUyMkdlbmVyYXRlZCUyMHJlc3BvbnNlJTNBJTIyJTJDJTIwbWVzc2FnZSU1QiUyMmNvbnRlbnQlMjIlNUQp",highlighted:`<span class="hljs-keyword">import</span> json | |
| <span class="hljs-comment"># Generation arguments https://platform.openai.com/docs/api-reference/chat/create</span> | |
| result = endpoint.invoke( | |
| body=json.dumps( | |
| { | |
| <span class="hljs-string">"messages"</span>: messages, | |
| <span class="hljs-string">"max_tokens"</span>: <span class="hljs-number">50</span>, | |
| <span class="hljs-string">"top_k"</span>: <span class="hljs-number">50</span>, | |
| <span class="hljs-string">"top_p"</span>: <span class="hljs-number">0.9</span>, | |
| <span class="hljs-string">"temperature"</span>: <span class="hljs-number">0.7</span>, | |
| } | |
| ), | |
| content_type=<span class="hljs-string">"application/json"</span>, | |
| ) | |
| output = json.loads(result.body.read().decode(<span class="hljs-string">"utf-8"</span>)) | |
| message = output[<span class="hljs-string">"choices"</span>][<span class="hljs-number">0</span>][<span class="hljs-string">"message"</span>] | |
| <span class="hljs-keyword">assert</span> message[<span class="hljs-string">"role"</span>] == <span class="hljs-string">"assistant"</span> | |
| <span class="hljs-built_in">print</span>(<span class="hljs-string">"Generated response:"</span>, message[<span class="hljs-string">"content"</span>])`,lang:"python",wrap:!1}}),se=new me({props:{title:"4. Clean up",local:"4-clean-up",headingTag:"h2"}}),ie=new h({props:{code:"bW9kZWwuZGVsZXRlKCklMEFlbmRwb2ludF9jb25maWcuZGVsZXRlKCklMEFlbmRwb2ludC5kZWxldGUoKQ==",highlighted:`model.delete() | |
| endpoint_config.delete() | |
| endpoint.delete()`,lang:"python",wrap:!1}}),{c(){y=o("meta"),Me=a(),pe=o("p"),ce=a(),r(T.$$.fragment),ue=a(),r(w.$$.fragment),de=a(),J=o("p"),J.innerHTML=ot,ye=a(),f=o("p"),f.textContent=it,he=a(),U=o("ol"),U.innerHTML=pt,Te=a(),j=o("p"),j.textContent=rt,we=a(),b=o("p"),b.innerHTML=mt,Je=a(),g=o("table"),g.innerHTML=Mt,fe=a(),r(I.$$.fragment),Ue=a(),C=o("p"),C.innerHTML=ct,je=a(),v=o("p"),v.textContent=ut,be=a(),r(B.$$.fragment),ge=a(),W=o("p"),W.textContent=dt,Ie=a(),r(Z.$$.fragment),Ce=a(),r(S.$$.fragment),ve=a(),_=o("p"),_.innerHTML=yt,Be=a(),r(L.$$.fragment),We=a(),r(N.$$.fragment),Ze=a(),$=o("p"),$.innerHTML=ht,Se=a(),R=o("p"),R.innerHTML=Tt,_e=a(),E=o("p"),E.innerHTML=wt,Le=a(),k=o("p"),k.textContent=Jt,Ne=a(),G=o("ul"),G.innerHTML=ft,$e=a(),x=o("p"),x.textContent=Ut,Re=a(),V=o("p"),V.textContent=jt,Ee=a(),A=o("ul"),A.innerHTML=bt,ke=a(),H=o("p"),H.innerHTML=gt,Ge=a(),q=o("p"),q.innerHTML=It,xe=a(),Q=o("p"),Q.innerHTML=Ct,Ve=a(),F=o("p"),F.textContent=vt,Ae=a(),r(X.$$.fragment),He=a(),z=o("p"),z.innerHTML=Bt,qe=a(),r(Y.$$.fragment),Qe=a(),P=o("p"),P.innerHTML=Wt,Fe=a(),r(D.$$.fragment),Xe=a(),O=o("p"),O.textContent=Zt,ze=a(),K=o("p"),K.innerHTML=St,Ye=a(),ee=o("p"),ee.innerHTML=_t,Pe=a(),te=o("p"),te.innerHTML=Lt,De=a(),r(le.$$.fragment),Oe=a(),ne=o("p"),ne.textContent=Nt,Ke=a(),r(ae.$$.fragment),et=a(),r(se.$$.fragment),tt=a(),oe=o("p"),oe.textContent=$t,lt=a(),r(ie.$$.fragment),nt=a(),re=o("p"),this.h()},l(e){const t=Ht("svelte-u9bgzb",document.head);y=i(t,"META",{name:!0,content:!0}),t.forEach(l),Me=s(e),pe=i(e,"P",{}),Rt(pe).forEach(l),ce=s(e),m(T.$$.fragment,e),ue=s(e),m(w.$$.fragment,e),de=s(e),J=i(e,"P",{"data-svelte-h":!0}),p(J)!=="svelte-70qgmy"&&(J.innerHTML=ot),ye=s(e),f=i(e,"P",{"data-svelte-h":!0}),p(f)!=="svelte-df2280"&&(f.textContent=it),he=s(e),U=i(e,"OL",{"data-svelte-h":!0}),p(U)!=="svelte-gvdc6b"&&(U.innerHTML=pt),Te=s(e),j=i(e,"P",{"data-svelte-h":!0}),p(j)!=="svelte-fedw35"&&(j.textContent=rt),we=s(e),b=i(e,"P",{"data-svelte-h":!0}),p(b)!=="svelte-1q2zsrn"&&(b.innerHTML=mt),Je=s(e),g=i(e,"TABLE",{"data-svelte-h":!0}),p(g)!=="svelte-1tmwmqe"&&(g.innerHTML=Mt),fe=s(e),m(I.$$.fragment,e),Ue=s(e),C=i(e,"P",{"data-svelte-h":!0}),p(C)!=="svelte-1e6mm58"&&(C.innerHTML=ct),je=s(e),v=i(e,"P",{"data-svelte-h":!0}),p(v)!=="svelte-gxxxnf"&&(v.textContent=ut),be=s(e),m(B.$$.fragment,e),ge=s(e),W=i(e,"P",{"data-svelte-h":!0}),p(W)!=="svelte-k2b9z7"&&(W.textContent=dt),Ie=s(e),m(Z.$$.fragment,e),Ce=s(e),m(S.$$.fragment,e),ve=s(e),_=i(e,"P",{"data-svelte-h":!0}),p(_)!=="svelte-1awnn15"&&(_.innerHTML=yt),Be=s(e),m(L.$$.fragment,e),We=s(e),m(N.$$.fragment,e),Ze=s(e),$=i(e,"P",{"data-svelte-h":!0}),p($)!=="svelte-w7lp5p"&&($.innerHTML=ht),Se=s(e),R=i(e,"P",{"data-svelte-h":!0}),p(R)!=="svelte-1kijx5w"&&(R.innerHTML=Tt),_e=s(e),E=i(e,"P",{"data-svelte-h":!0}),p(E)!=="svelte-prnhqf"&&(E.innerHTML=wt),Le=s(e),k=i(e,"P",{"data-svelte-h":!0}),p(k)!=="svelte-qkir6d"&&(k.textContent=Jt),Ne=s(e),G=i(e,"UL",{"data-svelte-h":!0}),p(G)!=="svelte-1f783f3"&&(G.innerHTML=ft),$e=s(e),x=i(e,"P",{"data-svelte-h":!0}),p(x)!=="svelte-1fl683x"&&(x.textContent=Ut),Re=s(e),V=i(e,"P",{"data-svelte-h":!0}),p(V)!=="svelte-rcd9mj"&&(V.textContent=jt),Ee=s(e),A=i(e,"UL",{"data-svelte-h":!0}),p(A)!=="svelte-sq03vv"&&(A.innerHTML=bt),ke=s(e),H=i(e,"P",{"data-svelte-h":!0}),p(H)!=="svelte-1qiwbk5"&&(H.innerHTML=gt),Ge=s(e),q=i(e,"P",{"data-svelte-h":!0}),p(q)!=="svelte-1h03olo"&&(q.innerHTML=It),xe=s(e),Q=i(e,"P",{"data-svelte-h":!0}),p(Q)!=="svelte-1mh0xpb"&&(Q.innerHTML=Ct),Ve=s(e),F=i(e,"P",{"data-svelte-h":!0}),p(F)!=="svelte-10wr0tf"&&(F.textContent=vt),Ae=s(e),m(X.$$.fragment,e),He=s(e),z=i(e,"P",{"data-svelte-h":!0}),p(z)!=="svelte-4gejcg"&&(z.innerHTML=Bt),qe=s(e),m(Y.$$.fragment,e),Qe=s(e),P=i(e,"P",{"data-svelte-h":!0}),p(P)!=="svelte-aha0vi"&&(P.innerHTML=Wt),Fe=s(e),m(D.$$.fragment,e),Xe=s(e),O=i(e,"P",{"data-svelte-h":!0}),p(O)!=="svelte-hs5wbn"&&(O.textContent=Zt),ze=s(e),K=i(e,"P",{"data-svelte-h":!0}),p(K)!=="svelte-pojg70"&&(K.innerHTML=St),Ye=s(e),ee=i(e,"P",{"data-svelte-h":!0}),p(ee)!=="svelte-7vzs06"&&(ee.innerHTML=_t),Pe=s(e),te=i(e,"P",{"data-svelte-h":!0}),p(te)!=="svelte-iif644"&&(te.innerHTML=Lt),De=s(e),m(le.$$.fragment,e),Oe=s(e),ne=i(e,"P",{"data-svelte-h":!0}),p(ne)!=="svelte-1pq3qhh"&&(ne.textContent=Nt),Ke=s(e),m(ae.$$.fragment,e),et=s(e),m(se.$$.fragment,e),tt=s(e),oe=i(e,"P",{"data-svelte-h":!0}),p(oe)!=="svelte-100mxno"&&(oe.textContent=$t),lt=s(e),m(ie.$$.fragment,e),nt=s(e),re=i(e,"P",{}),Rt(re).forEach(l),this.h()},h(){Et(y,"name","hf:doc:metadata"),Et(y,"content",Xt)},m(e,t){qt(document.head,y),n(e,Me,t),n(e,pe,t),n(e,ce,t),M(T,e,t),n(e,ue,t),M(w,e,t),n(e,de,t),n(e,J,t),n(e,ye,t),n(e,f,t),n(e,he,t),n(e,U,t),n(e,Te,t),n(e,j,t),n(e,we,t),n(e,b,t),n(e,Je,t),n(e,g,t),n(e,fe,t),M(I,e,t),n(e,Ue,t),n(e,C,t),n(e,je,t),n(e,v,t),n(e,be,t),M(B,e,t),n(e,ge,t),n(e,W,t),n(e,Ie,t),M(Z,e,t),n(e,Ce,t),M(S,e,t),n(e,ve,t),n(e,_,t),n(e,Be,t),M(L,e,t),n(e,We,t),M(N,e,t),n(e,Ze,t),n(e,$,t),n(e,Se,t),n(e,R,t),n(e,_e,t),n(e,E,t),n(e,Le,t),n(e,k,t),n(e,Ne,t),n(e,G,t),n(e,$e,t),n(e,x,t),n(e,Re,t),n(e,V,t),n(e,Ee,t),n(e,A,t),n(e,ke,t),n(e,H,t),n(e,Ge,t),n(e,q,t),n(e,xe,t),n(e,Q,t),n(e,Ve,t),n(e,F,t),n(e,Ae,t),M(X,e,t),n(e,He,t),n(e,z,t),n(e,qe,t),M(Y,e,t),n(e,Qe,t),n(e,P,t),n(e,Fe,t),M(D,e,t),n(e,Xe,t),n(e,O,t),n(e,ze,t),n(e,K,t),n(e,Ye,t),n(e,ee,t),n(e,Pe,t),n(e,te,t),n(e,De,t),M(le,e,t),n(e,Oe,t),n(e,ne,t),n(e,Ke,t),M(ae,e,t),n(e,et,t),M(se,e,t),n(e,tt,t),n(e,oe,t),n(e,lt,t),M(ie,e,t),n(e,nt,t),n(e,re,t),at=!0},p:Gt,i(e){at||(c(T.$$.fragment,e),c(w.$$.fragment,e),c(I.$$.fragment,e),c(B.$$.fragment,e),c(Z.$$.fragment,e),c(S.$$.fragment,e),c(L.$$.fragment,e),c(N.$$.fragment,e),c(X.$$.fragment,e),c(Y.$$.fragment,e),c(D.$$.fragment,e),c(le.$$.fragment,e),c(ae.$$.fragment,e),c(se.$$.fragment,e),c(ie.$$.fragment,e),at=!0)},o(e){u(T.$$.fragment,e),u(w.$$.fragment,e),u(I.$$.fragment,e),u(B.$$.fragment,e),u(Z.$$.fragment,e),u(S.$$.fragment,e),u(L.$$.fragment,e),u(N.$$.fragment,e),u(X.$$.fragment,e),u(Y.$$.fragment,e),u(D.$$.fragment,e),u(le.$$.fragment,e),u(ae.$$.fragment,e),u(se.$$.fragment,e),u(ie.$$.fragment,e),at=!1},d(e){e&&(l(Me),l(pe),l(ce),l(ue),l(de),l(J),l(ye),l(f),l(he),l(U),l(Te),l(j),l(we),l(b),l(Je),l(g),l(fe),l(Ue),l(C),l(je),l(v),l(be),l(ge),l(W),l(Ie),l(Ce),l(ve),l(_),l(Be),l(We),l(Ze),l($),l(Se),l(R),l(_e),l(E),l(Le),l(k),l(Ne),l(G),l($e),l(x),l(Re),l(V),l(Ee),l(A),l(ke),l(H),l(Ge),l(q),l(xe),l(Q),l(Ve),l(F),l(Ae),l(He),l(z),l(qe),l(Qe),l(P),l(Fe),l(Xe),l(O),l(ze),l(K),l(Ye),l(ee),l(Pe),l(te),l(De),l(Oe),l(ne),l(Ke),l(et),l(tt),l(oe),l(lt),l(nt),l(re)),l(y),d(T,e),d(w,e),d(I,e),d(B,e),d(Z,e),d(S,e),d(L,e),d(N,e),d(X,e),d(Y,e),d(D,e),d(le,e),d(ae,e),d(se,e),d(ie,e)}}}const Xt='{"title":"Deploy Llama 3.3 70B on AWS Inferentia2","local":"deploy-llama-33-70b-on-aws-inferentia2","sections":[{"title":"1. Setup development environment","local":"1-setup-development-environment","sections":[],"depth":2},{"title":"2. Retrieve the latest Hugging Face vLLM Neuron DLC","local":"2-retrieve-the-latest-hugging-face-vllm-neuron-dlc","sections":[],"depth":2},{"title":"3. Deploy Llama 3.3 70B to Inferentia2","local":"3-deploy-llama-33-70b-to-inferentia2","sections":[],"depth":2},{"title":"4. Clean up","local":"4-clean-up","sections":[],"depth":2}],"depth":1}';function zt(st){return xt(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class el extends Vt{constructor(y){super(),At(this,y,zt,Ft,kt,{})}}export{el as component}; | |
Xet Storage Details
- Size:
- 29 kB
- Xet hash:
- f852ad1bbd44a2646efc3b2faa7f32628b953c9c18d75fcf1b410967ad47a354
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.