Buckets:
| import{s as Al,o as Fl,n as Kt}from"../chunks/scheduler.b108d059.js";import{S as Il,i as _l,g as a,s as i,r as u,A as Sl,h as o,f as l,c as s,j as Vl,u as p,x as c,k as Zl,y as Wl,a as n,v as f,d as m,t as g,w as h}from"../chunks/index.008de539.js";import{T as Qt}from"../chunks/Tip.aeb15ab7.js";import{C}from"../chunks/CodeBlock.3968c746.js";import{H as E,E as Hl}from"../chunks/EditOnGithub.d1c48e3d.js";function Pl(v){let r,$='Installing the <code>gke-gcloud-auth-plugin</code> does not need to be installed via <code>gcloud</code> specifically, to read more about the alternative installation methods, please visit <a href="https://cloud.google.com/kubernetes-engine/docs/how-to/cluster-access-for-kubectl#install_plugin" rel="nofollow">https://cloud.google.com/kubernetes-engine/docs/how-to/cluster-access-for-kubectl#install_plugin</a>.';return{c(){r=a("p"),r.innerHTML=$},l(d){r=o(d,"P",{"data-svelte-h":!0}),c(r)!=="svelte-sm1xw4"&&(r.innerHTML=$)},m(d,M){n(d,r,M)},p:Kt,d(d){d&&l(r)}}}function Rl(v){let r,$='Important to check before creating the GKE Autopilot Cluster the <a href="https://cloud.google.com/kubernetes-engine/docs/how-to/performance-pods" rel="nofollow">GKE Documentation - Optimize Autopilot Pod performance by choosing a machine series</a>, since not all the versions support GPU accelerators e.g. <code>nvidia-l4</code> is not supported in the GKE cluster versions 1.28.3 or lower.';return{c(){r=a("p"),r.innerHTML=$},l(d){r=o(d,"P",{"data-svelte-h":!0}),c(r)!=="svelte-1cdm5nv"&&(r.innerHTML=$)},m(d,M){n(d,r,M)},p:Kt,d(d){d&&l(r)}}}function Bl(v){let r,$="To select the specific version in your location of the GKE Cluster, you can run the following command:",d,M,T,w,U='For more information please visit <a href="https://cloud.google.com/kubernetes-engine/versioning#specifying_cluster_version" rel="nofollow">https://cloud.google.com/kubernetes-engine/versioning#specifying_cluster_version</a>.',N;return M=new C({props:{code:"Z2Nsb3VkJTIwY29udGFpbmVyJTIwZ2V0LXNlcnZlci1jb25maWclMjAlNUMlMEElMjAlMjAlMjAlMjAtLWZsYXR0ZW4lM0QlMjJjaGFubmVscyUyMiUyMCU1QyUwQSUyMCUyMCUyMCUyMC0tZmlsdGVyJTNEJTIyY2hhbm5lbHMuY2hhbm5lbCUzRFNUQUJMRSUyMiUyMCU1QyUwQSUyMCUyMCUyMCUyMC0tZm9ybWF0JTNEJTIyeWFtbChjaGFubmVscy5jaGFubmVsJTJDY2hhbm5lbHMuZGVmYXVsdFZlcnNpb24pJTIyJTIwJTVDJTBBJTIwJTIwJTIwJTIwLS1sb2NhdGlvbiUzRCUyNExPQ0FUSU9O",highlighted:`gcloud container get-server-config \\ | |
| --flatten=<span class="hljs-string">"channels"</span> \\ | |
| --filter=<span class="hljs-string">"channels.channel=STABLE"</span> \\ | |
| --format=<span class="hljs-string">"yaml(channels.channel,channels.defaultVersion)"</span> \\ | |
| --location=<span class="hljs-variable">$LOCATION</span>`,wrap:!1}}),{c(){r=a("p"),r.textContent=$,d=i(),u(M.$$.fragment),T=i(),w=a("p"),w.innerHTML=U},l(b){r=o(b,"P",{"data-svelte-h":!0}),c(r)!=="svelte-a3yff9"&&(r.textContent=$),d=s(b),p(M.$$.fragment,b),T=s(b),w=o(b,"P",{"data-svelte-h":!0}),c(w)!=="svelte-1y4gd42"&&(w.innerHTML=U)},m(b,y){n(b,r,y),n(b,d,y),f(M,b,y),n(b,T,y),n(b,w,y),N=!0},p:Kt,i(b){N||(m(M.$$.fragment,b),N=!0)},o(b){g(M.$$.fragment,b),N=!1},d(b){b&&(l(r),l(d),l(T),l(w)),h(M,b)}}}function Yl(v){let r,$='In this case, since you are running a batch job, it will only use one node as specified within the <a href="https://github.com/huggingface/Google-Cloud-Containers/tree/main/examples/gke/trl-lora-fine-tuning/job.yaml" rel="nofollow"><code>job.yaml</code></a> file, since you don’t need anything else than that. So on, the job will deploy one pod running the <code>trl sft</code> command on top of the Hugging Face PyTorch DLC container for training, and also the GCS FUSE container that is mounting the GCS Bucket into the <code>/data</code> path so as to store the generated artifacts in GCS. Once the job is completed, it will automatically scale back to 0, meaning that it will not consume resources.';return{c(){r=a("p"),r.innerHTML=$},l(d){r=o(d,"P",{"data-svelte-h":!0}),c(r)!=="svelte-mzjxjd"&&(r.innerHTML=$)},m(d,M){n(d,r,M)},p:Kt,d(d){d&&l(r)}}}function Ql(v){let r,$,d,M,T,w,U,N="Mistral is a family of models with varying sizes, created by the Mistral AI team; the Mistral 7B v0.3 LLM is a Mistral 7B v0.2 with extended vocabulary. TRL is a full stack library to fine-tune and align Large Language Models (LLMs) developed by Hugging Face. And, Google Kubernetes Engine (GKE) is a fully-managed Kubernetes service in Google Cloud that can be used to deploy and operate containerized applications at scale using GCP’s infrastructure.",b,y,Xt="This example showcases how to fine-tune Mistral 7B v0.3 with TRL via Supervised Fine-Tuning (SFT) and Low-Rank Adaptation (LoRA) in a single GPU on a GKE Cluster.",Fe,L,Ie,x,zt="First, you need to install both <code>gcloud</code> and <code>kubectl</code> in your local machine, which are the command-line tools for Google Cloud and Kubernetes, respectively, to interact with the GCP and the GKE Cluster.",_e,V,Dt='<li>To install <code>gcloud</code>, follow the instructions at <a href="https://cloud.google.com/sdk/docs/install" rel="nofollow">Cloud SDK Documentation - Install the gcloud CLI</a>.</li> <li>To install <code>kubectl</code>, follow the instructions at <a href="https://kubernetes.io/docs/tasks/tools/#kubectl" rel="nofollow">Kubernetes Documentation - Install Tools</a>.</li>',Se,Z,Ot="Optionally, to ease the usage of the commands within this tutorial, you need to set the following environment variables for GCP:",We,A,He,F,qt="Then you need to login into your GCP account and set the project ID to the one you want to use for the deployment of the GKE Cluster.",Pe,I,Re,_,el="Once you are logged in, you need to enable the necessary service APIs in GCP, such as the Google Kubernetes Engine API, the Google Container Registry API, and the Google Container File System API, which are necessary for the deployment of the GKE Cluster and the Hugging Face DLC for TGI.",Be,S,Ye,W,tl="Additionally, to use <code>kubectl</code> with the GKE Cluster credentials, you also need to install the <code>gke-gcloud-auth-plugin</code>, that can be installed with <code>gcloud</code> as follows:",Qe,H,Ke,j,Xe,P,ze,R,ll="Once everything’s set up, you can proceed with the creation of the GKE Cluster and the node pool, which in this case will be a single GPU node, in order to use the GPU accelerator for high performance inference, also following TGI recommendations based on their internal optimizations for GPUs.",De,B,nl="To deploy the GKE Cluster, the “Autopilot” mode will be used as it is the recommended one for most of the workloads, since the underlying infrastructure is managed by Google. Alternatively, you can also use the “Standard” mode.",Oe,G,qe,Y,et,J,tt,Q,il='<img src="https://raw.githubusercontent.com/huggingface/Google-Cloud-Containers/main/examples/gke/trl-lora-fine-tuning/imgs/gke-cluster.png" alt="GKE Cluster in the GCP Console"/>',lt,K,sl="Once the GKE Cluster is created, you can get the credentials to access it via <code>kubectl</code> with the following command:",nt,X,it,z,st,D,al="Before you run the fine-tuning job of the Hugging Face PyTorch DLC for training on the GKE Cluster, you need to set the IAM permissions for the GCS bucket so that the pod in the GKE Cluster can access the bucket, that will be mounted into the running container and use to write the generated artifacts so that those are automatically uploaded to the GCS Bucket. To do so, you need to create a namespace and a service account in the GKE Cluster, and then set the IAM permissions for the GCS Bucket.",at,O,ol="For convenience, as the reference to both the namespace and the service account will be used within the following steps, the environment variables <code>NAMESPACE</code> and <code>SERVICE_ACCOUNT</code> will be set.",ot,q,rt,ee,rl="Then you can create the namespace and the service account in the GKE Cluster, enabling the creation of the IAM permissions for the pods in that namespace to access the GCS Bucket when using that service account.",ct,te,ut,le,cl="Then you need to add the IAM policy binding to the bucket as follows:",pt,ne,ft,ie,mt,se,ul='As <a href="https://huggingface.co/mistralai/Mistral-7B-v0.3" rel="nofollow"><code>mistralai/Mistral-7B-v0.3</code></a> is a gated model, you need to set a Kubernetes secret with the Hugging Face Hub token via <code>kubectl</code>.',gt,ae,pl='To generate a custom token for the Hugging Face Hub, you can follow the instructions at <a href="https://huggingface.co/docs/hub/en/security-tokens" rel="nofollow">https://huggingface.co/docs/hub/en/security-tokens</a>; and the recommended way of setting it is to install the <code>huggingface_hub</code> Python SDK as follows:',ht,oe,dt,re,fl="And then login in with the generated token with read-access over the gated/private model:",bt,ce,Mt,ue,ml="Finally, you can create the Kubernetes secret with the generated token for the Hugging Face Hub as follows using the <code>huggingface_hub</code> Python SDK to retrieve the token:",Ct,pe,$t,fe,gl="Or, alternatively, you can directly set the token as follows:",yt,me,Tt,ge,hl='More information on how to set Kubernetes secrets in a GKE Cluster at <a href="https://cloud.google.com/secret-manager/docs/secret-manager-managed-csi-component" rel="nofollow">https://cloud.google.com/secret-manager/docs/secret-manager-managed-csi-component</a>.',wt,he,vt,de,dl='Before proceeding into the Kubernetes deployment of the batch job via the Hugging Face PyTorch DLC for training, you need to define first the configuration required for the job to run successfully i.e. which GPU is capable of fine-tuning <a href="https://huggingface.co/mistralai/Mistral-7B-v0.3" rel="nofollow"><code>mistralai/Mistral-7B-v0.3</code></a> in <code>bfloat16</code> using LoRA.',Ut,be,bl='As a rough calculation, you could assume that the amount of GPU VRAM required to fine-tune a model in half precision is about four times the model size (read more about it in <a href="https://blog.eleuther.ai/transformer-math/" rel="nofollow">Eleuther AI - Transformer Math 101</a>).',jt,Me,Ml='Alternatively, if your model is uploaded to the Hugging Face Hub, you can check the numbers in the community space <a href="https://huggingface.co/spaces/Vokturz/can-it-run-llm" rel="nofollow"><code>Vokturz/can-it-run-llm</code></a>, which does those calculations for you, based the model to fine-tune and the available hardware.',Gt,Ce,Cl='<img src="https://raw.githubusercontent.com/huggingface/Google-Cloud-Containers/main/examples/gke/trl-lora-fine-tuning/imgs/can-it-run-llm.png" alt="'Vokturz/can-it-run-llm' for 'mistralai/Mistral-7B-v0.3'"/>',Jt,$e,kt,ye,$l='Now you can already run the Kubernetes job in the Hugging Face PyTorch DLC for training on the GKE Cluster via <code>kubectl</code> from the <a href="https://github.com/huggingface/Google-Cloud-Containers/tree/main/examples/gke/trl-lora-fine-tuning/job.yaml" rel="nofollow"><code>job.yaml</code></a> configuration file, that contains the job specification for running the command <code>trl sft</code> provided by the TRL CLI for the SFT LoRA fine-tuning of <a href="https://huggingface.co/mistralai/Mistral-7B-v0.3" rel="nofollow"><code>mistralai/Mistral-7B-v0.3</code></a> in <code>bfloat16</code> using <a href="https://huggingface.co/datasets/timdettmers/openassistant-guanaco" rel="nofollow"><code>timdettmers/openassistant-guanaco</code></a>, which is a subset from <a href="https://huggingface.co/datasets/OpenAssistant/oasst1" rel="nofollow"><code>OpenAssistant/oasst1</code></a> with ~10k samples in a single L4 24GiB GPU, storing the generated artifacts into a volume mount under <code>/data</code> linked to a GCS Bucket.',Et,Te,Nt,we,yl='<img src="https://raw.githubusercontent.com/huggingface/Google-Cloud-Containers/main/examples/gke/trl-lora-fine-tuning/imgs/gke-job-created.png" alt="GKE Job Created in the GCP Console"/>',Lt,ve,Tl='<img src="https://raw.githubusercontent.com/huggingface/Google-Cloud-Containers/main/examples/gke/trl-lora-fine-tuning/imgs/gke-job-running.png" alt="GKE Job Running in the GCP Console"/>',xt,k,Vt,Ue,wl="Additionally, you can use <code>kubectl</code> to stream the logs of the job as it follows:",Zt,je,At,Ge,vl="Finally, once the job is completed, the pods will scale to 0 and the artifacts will be visible in the GCS Bucket mounted within the job.",Ft,Je,Ul='<img src="https://raw.githubusercontent.com/huggingface/Google-Cloud-Containers/main/examples/gke/trl-lora-fine-tuning/imgs/gke-job-logs.png" alt="GKE Job Logs in the GCP Console"/>',It,ke,jl='<img src="https://raw.githubusercontent.com/huggingface/Google-Cloud-Containers/main/examples/gke/trl-lora-fine-tuning/imgs/gke-job-completed.png" alt="GKE Job Completed in the GCP Console"/>',_t,Ee,Gl='<img src="https://raw.githubusercontent.com/huggingface/Google-Cloud-Containers/main/examples/gke/trl-lora-fine-tuning/imgs/gcs-bucket.png" alt="GCS Bucket with output artifacts in the GCP Console"/>',St,Ne,Wt,Le,Jl="Finally, once the fine-tuning job is completed, you can safely delete the GKE Cluster to avoid incurring in unnecessary costs.",Ht,xe,Pt,Ve,kl="Alternatively, you may decide to keep the GKE Cluster running even after the job is completed, since the default GKE Cluster deployed with GKE Autopilot mode is running just a single <code>e2-small</code> instance.",Rt,Ze,Bt,Ae,Yt;return T=new E({props:{title:"Fine-tune Mistral 7B v0.3 with PyTorch Training DLC using SFT + LoRA on GKE",local:"fine-tune-mistral-7b-v03-with-pytorch-training-dlc-using-sft--lora-on-gke",headingTag:"h1"}}),L=new E({props:{title:"Setup / Configuration",local:"setup--configuration",headingTag:"h2"}}),A=new C({props:{code:"ZXhwb3J0JTIwUFJPSkVDVF9JRCUzRHlvdXItcHJvamVjdC1pZCUwQWV4cG9ydCUyMExPQ0FUSU9OJTNEeW91ci1sb2NhdGlvbiUwQWV4cG9ydCUyMENMVVNURVJfTkFNRSUzRHlvdXItY2x1c3Rlci1uYW1l",highlighted:`<span class="hljs-built_in">export</span> PROJECT_ID=your-project-id | |
| <span class="hljs-built_in">export</span> LOCATION=your-location | |
| <span class="hljs-built_in">export</span> CLUSTER_NAME=your-cluster-name`,wrap:!1}}),I=new C({props:{code:"Z2Nsb3VkJTIwYXV0aCUyMGxvZ2luJTBBZ2Nsb3VkJTIwYXV0aCUyMGFwcGxpY2F0aW9uLWRlZmF1bHQlMjBsb2dpbiUyMCUyMCUyMyUyMEZvciUyMGxvY2FsJTIwZGV2ZWxvcG1lbnQlMEFnY2xvdWQlMjBjb25maWclMjBzZXQlMjBwcm9qZWN0JTIwJTI0UFJPSkVDVF9JRA==",highlighted:`gcloud auth login | |
| gcloud auth application-default login <span class="hljs-comment"># For local development</span> | |
| gcloud config <span class="hljs-built_in">set</span> project <span class="hljs-variable">$PROJECT_ID</span>`,wrap:!1}}),S=new C({props:{code:"Z2Nsb3VkJTIwc2VydmljZXMlMjBlbmFibGUlMjBjb250YWluZXIuZ29vZ2xlYXBpcy5jb20lMEFnY2xvdWQlMjBzZXJ2aWNlcyUyMGVuYWJsZSUyMGNvbnRhaW5lcnJlZ2lzdHJ5Lmdvb2dsZWFwaXMuY29tJTBBZ2Nsb3VkJTIwc2VydmljZXMlMjBlbmFibGUlMjBjb250YWluZXJmaWxlc3lzdGVtLmdvb2dsZWFwaXMuY29t",highlighted:`gcloud services <span class="hljs-built_in">enable</span> container.googleapis.com | |
| gcloud services <span class="hljs-built_in">enable</span> containerregistry.googleapis.com | |
| gcloud services <span class="hljs-built_in">enable</span> containerfilesystem.googleapis.com`,wrap:!1}}),H=new C({props:{code:"Z2Nsb3VkJTIwY29tcG9uZW50cyUyMGluc3RhbGwlMjBna2UtZ2Nsb3VkLWF1dGgtcGx1Z2lu",highlighted:"gcloud components install gke-gcloud-auth-plugin",wrap:!1}}),j=new Qt({props:{$$slots:{default:[Pl]},$$scope:{ctx:v}}}),P=new E({props:{title:"Create GKE Cluster",local:"create-gke-cluster",headingTag:"h2"}}),G=new Qt({props:{$$slots:{default:[Rl]},$$scope:{ctx:v}}}),Y=new C({props:{code:"Z2Nsb3VkJTIwY29udGFpbmVyJTIwY2x1c3RlcnMlMjBjcmVhdGUtYXV0byUyMCUyNENMVVNURVJfTkFNRSUyMCU1QyUwQSUyMCUyMCUyMCUyMC0tcHJvamVjdCUzRCUyNFBST0pFQ1RfSUQlMjAlNUMlMEElMjAlMjAlMjAlMjAtLWxvY2F0aW9uJTNEJTI0TE9DQVRJT04lMjAlNUMlMEElMjAlMjAlMjAlMjAtLXJlbGVhc2UtY2hhbm5lbCUzRHN0YWJsZSUyMCU1QyUwQSUyMCUyMCUyMCUyMC0tY2x1c3Rlci12ZXJzaW9uJTNEMS4yOCUyMCU1QyUwQSUyMCUyMCUyMCUyMC0tbm8tYXV0b3Byb3Zpc2lvbmluZy1lbmFibGUtaW5zZWN1cmUta3ViZWxldC1yZWFkb25seS1wb3J0",highlighted:`gcloud container clusters create-auto <span class="hljs-variable">$CLUSTER_NAME</span> \\ | |
| --project=<span class="hljs-variable">$PROJECT_ID</span> \\ | |
| --location=<span class="hljs-variable">$LOCATION</span> \\ | |
| --release-channel=stable \\ | |
| --cluster-version=1.28 \\ | |
| --no-autoprovisioning-enable-insecure-kubelet-readonly-port`,wrap:!1}}),J=new Qt({props:{$$slots:{default:[Bl]},$$scope:{ctx:v}}}),X=new C({props:{code:"Z2Nsb3VkJTIwY29udGFpbmVyJTIwY2x1c3RlcnMlMjBnZXQtY3JlZGVudGlhbHMlMjAlMjRDTFVTVEVSX05BTUUlMjAtLWxvY2F0aW9uJTNEJTI0TE9DQVRJT04=",highlighted:'gcloud container clusters get-credentials <span class="hljs-variable">$CLUSTER_NAME</span> --location=<span class="hljs-variable">$LOCATION</span>',wrap:!1}}),z=new E({props:{title:"Configure IAM for GCS",local:"configure-iam-for-gcs",headingTag:"h2"}}),q=new C({props:{code:"ZXhwb3J0JTIwTkFNRVNQQUNFJTNEaGYtZ2tlLW5hbWVzcGFjZSUwQWV4cG9ydCUyMFNFUlZJQ0VfQUNDT1VOVCUzRGhmLWdrZS1zZXJ2aWNlLWFjY291bnQ=",highlighted:`<span class="hljs-built_in">export</span> NAMESPACE=hf-gke-namespace | |
| <span class="hljs-built_in">export</span> SERVICE_ACCOUNT=hf-gke-service-account`,wrap:!1}}),te=new C({props:{code:"a3ViZWN0bCUyMGNyZWF0ZSUyMG5hbWVzcGFjZSUyMCUyNE5BTUVTUEFDRSUwQWt1YmVjdGwlMjBjcmVhdGUlMjBzZXJ2aWNlYWNjb3VudCUyMCUyNFNFUlZJQ0VfQUNDT1VOVCUyMC0tbmFtZXNwYWNlJTIwJTI0TkFNRVNQQUNF",highlighted:`kubectl create namespace <span class="hljs-variable">$NAMESPACE</span> | |
| kubectl create serviceaccount <span class="hljs-variable">$SERVICE_ACCOUNT</span> --namespace <span class="hljs-variable">$NAMESPACE</span>`,wrap:!1}}),ne=new C({props:{code:"Z2Nsb3VkJTIwc3RvcmFnZSUyMGJ1Y2tldHMlMjBhZGQtaWFtLXBvbGljeS1iaW5kaW5nJTIwJTVDJTBBJTIwJTIwJTIwJTIwZ3MlM0ElMkYlMkYlMjRCVUNLRVRfTkFNRSUyMCU1QyUwQSUyMCUyMCUyMCUyMC0tbWVtYmVyJTIwJTIycHJpbmNpcGFsJTNBJTJGJTJGaWFtLmdvb2dsZWFwaXMuY29tJTJGcHJvamVjdHMlMkYlMjQoZ2Nsb3VkJTIwcHJvamVjdHMlMjBkZXNjcmliZSUyMCUyNFBST0pFQ1RfSUQlMjAtLWZvcm1hdCUzRCUyMnZhbHVlKHByb2plY3ROdW1iZXIpJTIyKSUyRmxvY2F0aW9ucyUyRmdsb2JhbCUyRndvcmtsb2FkSWRlbnRpdHlQb29scyUyRiUyNFBST0pFQ1RfSUQuc3ZjLmlkLmdvb2clMkZzdWJqZWN0JTJGbnMlMkYlMjROQU1FU1BBQ0UlMkZzYSUyRiUyNFNFUlZJQ0VfQUNDT1VOVCUyMiUyMCU1QyUwQSUyMCUyMCUyMCUyMC0tcm9sZSUyMCUyMnJvbGVzJTJGc3RvcmFnZS5vYmplY3RVc2VyJTIy",highlighted:`gcloud storage buckets add-iam-policy-binding \\ | |
| gs://<span class="hljs-variable">$BUCKET_NAME</span> \\ | |
| --member <span class="hljs-string">"principal://iam.googleapis.com/projects/<span class="hljs-subst">$(gcloud projects describe $PROJECT_ID --format=<span class="hljs-string">"value(projectNumber)"</span>)</span>/locations/global/workloadIdentityPools/<span class="hljs-variable">$PROJECT_ID</span>.svc.id.goog/subject/ns/<span class="hljs-variable">$NAMESPACE</span>/sa/<span class="hljs-variable">$SERVICE_ACCOUNT</span>"</span> \\ | |
| --role <span class="hljs-string">"roles/storage.objectUser"</span>`,wrap:!1}}),ie=new E({props:{title:"Optional: Set Secrets in GKE",local:"optional-set-secrets-in-gke",headingTag:"h2"}}),oe=new C({props:{code:"cGlwJTIwaW5zdGFsbCUyMC0tdXBncmFkZSUyMC0tcXVpZXQlMjBodWdnaW5nZmFjZV9odWI=",highlighted:"pip install --upgrade --quiet huggingface_hub",wrap:!1}}),ce=new C({props:{code:"aHVnZ2luZ2ZhY2UtY2xpJTIwbG9naW4=",highlighted:"huggingface-cli login",wrap:!1}}),pe=new C({props:{code:"a3ViZWN0bCUyMGNyZWF0ZSUyMHNlY3JldCUyMGdlbmVyaWMlMjBoZi1zZWNyZXQlMjAlNUMlMEElMjAlMjAlMjAlMjAtLWZyb20tbGl0ZXJhbCUzRGhmX3Rva2VuJTNEJTI0KHB5dGhvbiUyMC1jJTIwJTIyZnJvbSUyMGh1Z2dpbmdmYWNlX2h1YiUyMGltcG9ydCUyMGdldF90b2tlbiUzQiUyMHByaW50KGdldF90b2tlbigpKSUyMiklMjAlNUMlMEElMjAlMjAlMjAlMjAtLWRyeS1ydW4lM0RjbGllbnQlMjAtbyUyMHlhbWwlMjAlNUMlMEElMjAlMjAlMjAlMjAtLW5hbWVzcGFjZSUyMCUyNE5BTUVTUEFDRSUyMCU3QyUyMGt1YmVjdGwlMjBhcHBseSUyMC1mJTIwLQ==",highlighted:`kubectl create secret generic hf-secret \\ | |
| --from-literal=hf_token=$(python -c <span class="hljs-string">"from huggingface_hub import get_token; print(get_token())"</span>) \\ | |
| --dry-run=client -o yaml \\ | |
| --namespace <span class="hljs-variable">$NAMESPACE</span> | kubectl apply -f -`,wrap:!1}}),me=new C({props:{code:"a3ViZWN0bCUyMGNyZWF0ZSUyMHNlY3JldCUyMGdlbmVyaWMlMjBoZi1zZWNyZXQlMjAlNUMlMEElMjAlMjAlMjAlMjAtLWZyb20tbGl0ZXJhbCUzRGhmX3Rva2VuJTNEaGZfKioqJTIwJTVDJTBBJTIwJTIwJTIwJTIwLS1kcnktcnVuJTNEY2xpZW50JTIwLW8lMjB5YW1sJTIwJTVDJTBBJTIwJTIwJTIwJTIwLS1uYW1lc3BhY2UlMjAlMjROQU1FU1BBQ0UlMjAlN0MlMjBrdWJlY3RsJTIwYXBwbHklMjAtZiUyMC0=",highlighted:`kubectl create secret generic hf-secret \\ | |
| --from-literal=hf_token=hf_*** \\ | |
| --dry-run=client -o yaml \\ | |
| --namespace <span class="hljs-variable">$NAMESPACE</span> | kubectl apply -f -`,wrap:!1}}),he=new E({props:{title:"Define Job Configuration",local:"define-job-configuration",headingTag:"h2"}}),$e=new E({props:{title:"Run Job",local:"run-job",headingTag:"h2"}}),Te=new C({props:{code:"a3ViZWN0bCUyMGFwcGx5JTIwLWYlMjBqb2IueWFtbA==",highlighted:"kubectl apply -f job.yaml",wrap:!1}}),k=new Qt({props:{$$slots:{default:[Yl]},$$scope:{ctx:v}}}),je=new C({props:{code:"a3ViZWN0bCUyMGxvZ3MlMjAtZiUyMGpvYiUyRnRybC1sb3JhLXNmdCUyMC0tY29udGFpbmVyJTIwdHJsLWNvbnRhaW5lciUyMC0tbmFtZXNwYWNlJTIwJTI0TkFNRVNQQUNF",highlighted:'kubectl logs -f job/trl-lora-sft --container trl-container --namespace <span class="hljs-variable">$NAMESPACE</span>',wrap:!1}}),Ne=new E({props:{title:"Delete GKE Cluster",local:"delete-gke-cluster",headingTag:"h2"}}),xe=new C({props:{code:"Z2Nsb3VkJTIwY29udGFpbmVyJTIwY2x1c3RlcnMlMjBkZWxldGUlMjAlMjRDTFVTVEVSX05BTUUlMjAtLWxvY2F0aW9uJTNEJTI0TE9DQVRJT04=",highlighted:'gcloud container clusters delete <span class="hljs-variable">$CLUSTER_NAME</span> --location=<span class="hljs-variable">$LOCATION</span>',wrap:!1}}),Ze=new Hl({props:{source:"https://github.com/huggingface/Google-Cloud-Containers/blob/main/docs/source/examples/gke-trl-lora-fine-tuning.mdx"}}),{c(){r=a("meta"),$=i(),d=a("p"),M=i(),u(T.$$.fragment),w=i(),U=a("p"),U.textContent=N,b=i(),y=a("p"),y.textContent=Xt,Fe=i(),u(L.$$.fragment),Ie=i(),x=a("p"),x.innerHTML=zt,_e=i(),V=a("ul"),V.innerHTML=Dt,Se=i(),Z=a("p"),Z.textContent=Ot,We=i(),u(A.$$.fragment),He=i(),F=a("p"),F.textContent=qt,Pe=i(),u(I.$$.fragment),Re=i(),_=a("p"),_.textContent=el,Be=i(),u(S.$$.fragment),Ye=i(),W=a("p"),W.innerHTML=tl,Qe=i(),u(H.$$.fragment),Ke=i(),u(j.$$.fragment),Xe=i(),u(P.$$.fragment),ze=i(),R=a("p"),R.textContent=ll,De=i(),B=a("p"),B.textContent=nl,Oe=i(),u(G.$$.fragment),qe=i(),u(Y.$$.fragment),et=i(),u(J.$$.fragment),tt=i(),Q=a("p"),Q.innerHTML=il,lt=i(),K=a("p"),K.innerHTML=sl,nt=i(),u(X.$$.fragment),it=i(),u(z.$$.fragment),st=i(),D=a("p"),D.textContent=al,at=i(),O=a("p"),O.innerHTML=ol,ot=i(),u(q.$$.fragment),rt=i(),ee=a("p"),ee.textContent=rl,ct=i(),u(te.$$.fragment),ut=i(),le=a("p"),le.textContent=cl,pt=i(),u(ne.$$.fragment),ft=i(),u(ie.$$.fragment),mt=i(),se=a("p"),se.innerHTML=ul,gt=i(),ae=a("p"),ae.innerHTML=pl,ht=i(),u(oe.$$.fragment),dt=i(),re=a("p"),re.textContent=fl,bt=i(),u(ce.$$.fragment),Mt=i(),ue=a("p"),ue.innerHTML=ml,Ct=i(),u(pe.$$.fragment),$t=i(),fe=a("p"),fe.textContent=gl,yt=i(),u(me.$$.fragment),Tt=i(),ge=a("p"),ge.innerHTML=hl,wt=i(),u(he.$$.fragment),vt=i(),de=a("p"),de.innerHTML=dl,Ut=i(),be=a("p"),be.innerHTML=bl,jt=i(),Me=a("p"),Me.innerHTML=Ml,Gt=i(),Ce=a("p"),Ce.innerHTML=Cl,Jt=i(),u($e.$$.fragment),kt=i(),ye=a("p"),ye.innerHTML=$l,Et=i(),u(Te.$$.fragment),Nt=i(),we=a("p"),we.innerHTML=yl,Lt=i(),ve=a("p"),ve.innerHTML=Tl,xt=i(),u(k.$$.fragment),Vt=i(),Ue=a("p"),Ue.innerHTML=wl,Zt=i(),u(je.$$.fragment),At=i(),Ge=a("p"),Ge.textContent=vl,Ft=i(),Je=a("p"),Je.innerHTML=Ul,It=i(),ke=a("p"),ke.innerHTML=jl,_t=i(),Ee=a("p"),Ee.innerHTML=Gl,St=i(),u(Ne.$$.fragment),Wt=i(),Le=a("p"),Le.textContent=Jl,Ht=i(),u(xe.$$.fragment),Pt=i(),Ve=a("p"),Ve.innerHTML=kl,Rt=i(),u(Ze.$$.fragment),Bt=i(),Ae=a("p"),this.h()},l(e){const t=Sl("svelte-u9bgzb",document.head);r=o(t,"META",{name:!0,content:!0}),t.forEach(l),$=s(e),d=o(e,"P",{}),Vl(d).forEach(l),M=s(e),p(T.$$.fragment,e),w=s(e),U=o(e,"P",{"data-svelte-h":!0}),c(U)!=="svelte-3ga704"&&(U.textContent=N),b=s(e),y=o(e,"P",{"data-svelte-h":!0}),c(y)!=="svelte-m92yj9"&&(y.textContent=Xt),Fe=s(e),p(L.$$.fragment,e),Ie=s(e),x=o(e,"P",{"data-svelte-h":!0}),c(x)!=="svelte-1qnmo38"&&(x.innerHTML=zt),_e=s(e),V=o(e,"UL",{"data-svelte-h":!0}),c(V)!=="svelte-a8ymuw"&&(V.innerHTML=Dt),Se=s(e),Z=o(e,"P",{"data-svelte-h":!0}),c(Z)!=="svelte-1i8n6rq"&&(Z.textContent=Ot),We=s(e),p(A.$$.fragment,e),He=s(e),F=o(e,"P",{"data-svelte-h":!0}),c(F)!=="svelte-1g39t6p"&&(F.textContent=qt),Pe=s(e),p(I.$$.fragment,e),Re=s(e),_=o(e,"P",{"data-svelte-h":!0}),c(_)!=="svelte-1c0v0sp"&&(_.textContent=el),Be=s(e),p(S.$$.fragment,e),Ye=s(e),W=o(e,"P",{"data-svelte-h":!0}),c(W)!=="svelte-wjaltb"&&(W.innerHTML=tl),Qe=s(e),p(H.$$.fragment,e),Ke=s(e),p(j.$$.fragment,e),Xe=s(e),p(P.$$.fragment,e),ze=s(e),R=o(e,"P",{"data-svelte-h":!0}),c(R)!=="svelte-lja57p"&&(R.textContent=ll),De=s(e),B=o(e,"P",{"data-svelte-h":!0}),c(B)!=="svelte-l7bdz6"&&(B.textContent=nl),Oe=s(e),p(G.$$.fragment,e),qe=s(e),p(Y.$$.fragment,e),et=s(e),p(J.$$.fragment,e),tt=s(e),Q=o(e,"P",{"data-svelte-h":!0}),c(Q)!=="svelte-huz8ij"&&(Q.innerHTML=il),lt=s(e),K=o(e,"P",{"data-svelte-h":!0}),c(K)!=="svelte-f29e6h"&&(K.innerHTML=sl),nt=s(e),p(X.$$.fragment,e),it=s(e),p(z.$$.fragment,e),st=s(e),D=o(e,"P",{"data-svelte-h":!0}),c(D)!=="svelte-4phvfh"&&(D.textContent=al),at=s(e),O=o(e,"P",{"data-svelte-h":!0}),c(O)!=="svelte-4fsaj7"&&(O.innerHTML=ol),ot=s(e),p(q.$$.fragment,e),rt=s(e),ee=o(e,"P",{"data-svelte-h":!0}),c(ee)!=="svelte-gi3hy9"&&(ee.textContent=rl),ct=s(e),p(te.$$.fragment,e),ut=s(e),le=o(e,"P",{"data-svelte-h":!0}),c(le)!=="svelte-1wspkh7"&&(le.textContent=cl),pt=s(e),p(ne.$$.fragment,e),ft=s(e),p(ie.$$.fragment,e),mt=s(e),se=o(e,"P",{"data-svelte-h":!0}),c(se)!=="svelte-14kqcrs"&&(se.innerHTML=ul),gt=s(e),ae=o(e,"P",{"data-svelte-h":!0}),c(ae)!=="svelte-zags7d"&&(ae.innerHTML=pl),ht=s(e),p(oe.$$.fragment,e),dt=s(e),re=o(e,"P",{"data-svelte-h":!0}),c(re)!=="svelte-4hmhsl"&&(re.textContent=fl),bt=s(e),p(ce.$$.fragment,e),Mt=s(e),ue=o(e,"P",{"data-svelte-h":!0}),c(ue)!=="svelte-cqv9s0"&&(ue.innerHTML=ml),Ct=s(e),p(pe.$$.fragment,e),$t=s(e),fe=o(e,"P",{"data-svelte-h":!0}),c(fe)!=="svelte-o99xdc"&&(fe.textContent=gl),yt=s(e),p(me.$$.fragment,e),Tt=s(e),ge=o(e,"P",{"data-svelte-h":!0}),c(ge)!=="svelte-1dqrub5"&&(ge.innerHTML=hl),wt=s(e),p(he.$$.fragment,e),vt=s(e),de=o(e,"P",{"data-svelte-h":!0}),c(de)!=="svelte-11kan6m"&&(de.innerHTML=dl),Ut=s(e),be=o(e,"P",{"data-svelte-h":!0}),c(be)!=="svelte-gy0104"&&(be.innerHTML=bl),jt=s(e),Me=o(e,"P",{"data-svelte-h":!0}),c(Me)!=="svelte-1qv2h88"&&(Me.innerHTML=Ml),Gt=s(e),Ce=o(e,"P",{"data-svelte-h":!0}),c(Ce)!=="svelte-evyt9b"&&(Ce.innerHTML=Cl),Jt=s(e),p($e.$$.fragment,e),kt=s(e),ye=o(e,"P",{"data-svelte-h":!0}),c(ye)!=="svelte-2c9dnl"&&(ye.innerHTML=$l),Et=s(e),p(Te.$$.fragment,e),Nt=s(e),we=o(e,"P",{"data-svelte-h":!0}),c(we)!=="svelte-1924k36"&&(we.innerHTML=yl),Lt=s(e),ve=o(e,"P",{"data-svelte-h":!0}),c(ve)!=="svelte-pzhmcy"&&(ve.innerHTML=Tl),xt=s(e),p(k.$$.fragment,e),Vt=s(e),Ue=o(e,"P",{"data-svelte-h":!0}),c(Ue)!=="svelte-1qnnqzs"&&(Ue.innerHTML=wl),Zt=s(e),p(je.$$.fragment,e),At=s(e),Ge=o(e,"P",{"data-svelte-h":!0}),c(Ge)!=="svelte-w5xk1d"&&(Ge.textContent=vl),Ft=s(e),Je=o(e,"P",{"data-svelte-h":!0}),c(Je)!=="svelte-1q4af4y"&&(Je.innerHTML=Ul),It=s(e),ke=o(e,"P",{"data-svelte-h":!0}),c(ke)!=="svelte-2t8d96"&&(ke.innerHTML=jl),_t=s(e),Ee=o(e,"P",{"data-svelte-h":!0}),c(Ee)!=="svelte-vzvsyl"&&(Ee.innerHTML=Gl),St=s(e),p(Ne.$$.fragment,e),Wt=s(e),Le=o(e,"P",{"data-svelte-h":!0}),c(Le)!=="svelte-1pq346d"&&(Le.textContent=Jl),Ht=s(e),p(xe.$$.fragment,e),Pt=s(e),Ve=o(e,"P",{"data-svelte-h":!0}),c(Ve)!=="svelte-4tn50h"&&(Ve.innerHTML=kl),Rt=s(e),p(Ze.$$.fragment,e),Bt=s(e),Ae=o(e,"P",{}),Vl(Ae).forEach(l),this.h()},h(){Zl(r,"name","hf:doc:metadata"),Zl(r,"content",Kl)},m(e,t){Wl(document.head,r),n(e,$,t),n(e,d,t),n(e,M,t),f(T,e,t),n(e,w,t),n(e,U,t),n(e,b,t),n(e,y,t),n(e,Fe,t),f(L,e,t),n(e,Ie,t),n(e,x,t),n(e,_e,t),n(e,V,t),n(e,Se,t),n(e,Z,t),n(e,We,t),f(A,e,t),n(e,He,t),n(e,F,t),n(e,Pe,t),f(I,e,t),n(e,Re,t),n(e,_,t),n(e,Be,t),f(S,e,t),n(e,Ye,t),n(e,W,t),n(e,Qe,t),f(H,e,t),n(e,Ke,t),f(j,e,t),n(e,Xe,t),f(P,e,t),n(e,ze,t),n(e,R,t),n(e,De,t),n(e,B,t),n(e,Oe,t),f(G,e,t),n(e,qe,t),f(Y,e,t),n(e,et,t),f(J,e,t),n(e,tt,t),n(e,Q,t),n(e,lt,t),n(e,K,t),n(e,nt,t),f(X,e,t),n(e,it,t),f(z,e,t),n(e,st,t),n(e,D,t),n(e,at,t),n(e,O,t),n(e,ot,t),f(q,e,t),n(e,rt,t),n(e,ee,t),n(e,ct,t),f(te,e,t),n(e,ut,t),n(e,le,t),n(e,pt,t),f(ne,e,t),n(e,ft,t),f(ie,e,t),n(e,mt,t),n(e,se,t),n(e,gt,t),n(e,ae,t),n(e,ht,t),f(oe,e,t),n(e,dt,t),n(e,re,t),n(e,bt,t),f(ce,e,t),n(e,Mt,t),n(e,ue,t),n(e,Ct,t),f(pe,e,t),n(e,$t,t),n(e,fe,t),n(e,yt,t),f(me,e,t),n(e,Tt,t),n(e,ge,t),n(e,wt,t),f(he,e,t),n(e,vt,t),n(e,de,t),n(e,Ut,t),n(e,be,t),n(e,jt,t),n(e,Me,t),n(e,Gt,t),n(e,Ce,t),n(e,Jt,t),f($e,e,t),n(e,kt,t),n(e,ye,t),n(e,Et,t),f(Te,e,t),n(e,Nt,t),n(e,we,t),n(e,Lt,t),n(e,ve,t),n(e,xt,t),f(k,e,t),n(e,Vt,t),n(e,Ue,t),n(e,Zt,t),f(je,e,t),n(e,At,t),n(e,Ge,t),n(e,Ft,t),n(e,Je,t),n(e,It,t),n(e,ke,t),n(e,_t,t),n(e,Ee,t),n(e,St,t),f(Ne,e,t),n(e,Wt,t),n(e,Le,t),n(e,Ht,t),f(xe,e,t),n(e,Pt,t),n(e,Ve,t),n(e,Rt,t),f(Ze,e,t),n(e,Bt,t),n(e,Ae,t),Yt=!0},p(e,[t]){const El={};t&2&&(El.$$scope={dirty:t,ctx:e}),j.$set(El);const Nl={};t&2&&(Nl.$$scope={dirty:t,ctx:e}),G.$set(Nl);const Ll={};t&2&&(Ll.$$scope={dirty:t,ctx:e}),J.$set(Ll);const xl={};t&2&&(xl.$$scope={dirty:t,ctx:e}),k.$set(xl)},i(e){Yt||(m(T.$$.fragment,e),m(L.$$.fragment,e),m(A.$$.fragment,e),m(I.$$.fragment,e),m(S.$$.fragment,e),m(H.$$.fragment,e),m(j.$$.fragment,e),m(P.$$.fragment,e),m(G.$$.fragment,e),m(Y.$$.fragment,e),m(J.$$.fragment,e),m(X.$$.fragment,e),m(z.$$.fragment,e),m(q.$$.fragment,e),m(te.$$.fragment,e),m(ne.$$.fragment,e),m(ie.$$.fragment,e),m(oe.$$.fragment,e),m(ce.$$.fragment,e),m(pe.$$.fragment,e),m(me.$$.fragment,e),m(he.$$.fragment,e),m($e.$$.fragment,e),m(Te.$$.fragment,e),m(k.$$.fragment,e),m(je.$$.fragment,e),m(Ne.$$.fragment,e),m(xe.$$.fragment,e),m(Ze.$$.fragment,e),Yt=!0)},o(e){g(T.$$.fragment,e),g(L.$$.fragment,e),g(A.$$.fragment,e),g(I.$$.fragment,e),g(S.$$.fragment,e),g(H.$$.fragment,e),g(j.$$.fragment,e),g(P.$$.fragment,e),g(G.$$.fragment,e),g(Y.$$.fragment,e),g(J.$$.fragment,e),g(X.$$.fragment,e),g(z.$$.fragment,e),g(q.$$.fragment,e),g(te.$$.fragment,e),g(ne.$$.fragment,e),g(ie.$$.fragment,e),g(oe.$$.fragment,e),g(ce.$$.fragment,e),g(pe.$$.fragment,e),g(me.$$.fragment,e),g(he.$$.fragment,e),g($e.$$.fragment,e),g(Te.$$.fragment,e),g(k.$$.fragment,e),g(je.$$.fragment,e),g(Ne.$$.fragment,e),g(xe.$$.fragment,e),g(Ze.$$.fragment,e),Yt=!1},d(e){e&&(l($),l(d),l(M),l(w),l(U),l(b),l(y),l(Fe),l(Ie),l(x),l(_e),l(V),l(Se),l(Z),l(We),l(He),l(F),l(Pe),l(Re),l(_),l(Be),l(Ye),l(W),l(Qe),l(Ke),l(Xe),l(ze),l(R),l(De),l(B),l(Oe),l(qe),l(et),l(tt),l(Q),l(lt),l(K),l(nt),l(it),l(st),l(D),l(at),l(O),l(ot),l(rt),l(ee),l(ct),l(ut),l(le),l(pt),l(ft),l(mt),l(se),l(gt),l(ae),l(ht),l(dt),l(re),l(bt),l(Mt),l(ue),l(Ct),l($t),l(fe),l(yt),l(Tt),l(ge),l(wt),l(vt),l(de),l(Ut),l(be),l(jt),l(Me),l(Gt),l(Ce),l(Jt),l(kt),l(ye),l(Et),l(Nt),l(we),l(Lt),l(ve),l(xt),l(Vt),l(Ue),l(Zt),l(At),l(Ge),l(Ft),l(Je),l(It),l(ke),l(_t),l(Ee),l(St),l(Wt),l(Le),l(Ht),l(Pt),l(Ve),l(Rt),l(Bt),l(Ae)),l(r),h(T,e),h(L,e),h(A,e),h(I,e),h(S,e),h(H,e),h(j,e),h(P,e),h(G,e),h(Y,e),h(J,e),h(X,e),h(z,e),h(q,e),h(te,e),h(ne,e),h(ie,e),h(oe,e),h(ce,e),h(pe,e),h(me,e),h(he,e),h($e,e),h(Te,e),h(k,e),h(je,e),h(Ne,e),h(xe,e),h(Ze,e)}}}const Kl='{"title":"Fine-tune Mistral 7B v0.3 with PyTorch Training DLC using SFT + LoRA on GKE","local":"fine-tune-mistral-7b-v03-with-pytorch-training-dlc-using-sft--lora-on-gke","sections":[{"title":"Setup / Configuration","local":"setup--configuration","sections":[],"depth":2},{"title":"Create GKE Cluster","local":"create-gke-cluster","sections":[],"depth":2},{"title":"Configure IAM for GCS","local":"configure-iam-for-gcs","sections":[],"depth":2},{"title":"Optional: Set Secrets in GKE","local":"optional-set-secrets-in-gke","sections":[],"depth":2},{"title":"Define Job Configuration","local":"define-job-configuration","sections":[],"depth":2},{"title":"Run Job","local":"run-job","sections":[],"depth":2},{"title":"Delete GKE Cluster","local":"delete-gke-cluster","sections":[],"depth":2}],"depth":1}';function Xl(v){return Fl(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class tn extends Il{constructor(r){super(),_l(this,r,Xl,Ql,Al,{})}}export{tn as component}; | |
Xet Storage Details
- Size:
- 32.4 kB
- Xet hash:
- 8303f00635d0191d1eaaa6b2226cc0c5a8e8e5b19726f04746f641d84369bd0d
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.