This repository has been archived by the owner on Feb 15, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: Remove model weights from container images (#786)
* chore: add PVC to deployments to store model weights * chore: add onCreate action to download model files * chore: use Zarf Injection to populate PVC with model files * chore: add zarf vars for pvc config
- Loading branch information
Showing
39 changed files
with
436 additions
and
57 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
apiVersion: v1 | ||
kind: PersistentVolumeClaim | ||
metadata: | ||
name: lfai-llama-pv-claim | ||
namespace: leapfrogai | ||
spec: | ||
{{- if .Values.persistence.storageClass }} | ||
storageClassName: {{ .Values.persistence.storageClass }} | ||
{{- end }} | ||
accessModes: | ||
- {{ .Values.persistence.accessModes | quote }} | ||
resources: | ||
requests: | ||
storage: {{ .Values.persistence.size | quote }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,7 @@ | ||
image: | ||
tag: "###ZARF_CONST_IMAGE_VERSION###" | ||
|
||
persistence: | ||
size: ###ZARF_VAR_PVC_SIZE### | ||
accessModes: ###ZARF_VAR_PVC_ACCESS_MODE### | ||
storageClass: ###ZARF_VAR_PVC_STORAGE_CLASS### |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,34 @@ | ||
import os | ||
import hashlib | ||
import urllib.request | ||
|
||
from huggingface_hub import hf_hub_download | ||
REPO_ID = os.environ.get("REPO_ID", "") | ||
FILENAME = os.environ.get("FILENAME", "") | ||
REVISION = os.environ.get("REVISION", "main") | ||
CHECKSUM = os.environ.get("SHA256_CHECKSUM", "") | ||
OUTPUT_FILE = os.environ.get("OUTPUT_FILE", ".model/model.gguf") | ||
|
||
REPO_ID = os.environ.get("REPO_ID", "TheBloke/SynthIA-7B-v2.0-GGUF") | ||
FILENAME = os.environ.get("FILENAME", "synthia-7b-v2.0.Q4_K_M.gguf") | ||
REVISION = os.environ.get("REVISION", "3f65d882253d1f15a113dabf473a7c02a004d2b5") | ||
|
||
os.environ["HF_HUB_ENABLE_HF_TRANSFER"] = "1" | ||
def download_model(): | ||
# Check if the model is already downloaded. | ||
if os.path.exists(OUTPUT_FILE) and CHECKSUM != "": | ||
if hashlib.sha256(open(OUTPUT_FILE, "rb").read()).hexdigest() == CHECKSUM: | ||
print("Model already downloaded.") | ||
return | ||
|
||
hf_hub_download( | ||
repo_id=REPO_ID, | ||
filename=FILENAME, | ||
local_dir=".model", | ||
local_dir_use_symlinks=False, | ||
revision=REVISION, | ||
) | ||
# Validate that require environment variables are provided | ||
if REPO_ID == "" or FILENAME == "": | ||
print("Please provide REPO_ID and FILENAME environment variables.") | ||
return | ||
|
||
# Download the model! | ||
print("Downloading model... This may take a while.") | ||
if not os.path.exists(".model"): | ||
os.mkdir(".model") | ||
urllib.request.urlretrieve( | ||
f"https://huggingface.co/{REPO_ID}/resolve/{REVISION}/{FILENAME}", OUTPUT_FILE | ||
) | ||
|
||
|
||
if __name__ == "__main__": | ||
download_model() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
apiVersion: v1 | ||
kind: PersistentVolumeClaim | ||
metadata: | ||
name: lfai-text-embeddings-pv-claim | ||
namespace: leapfrogai | ||
spec: | ||
{{- if .Values.persistence.storageClass }} | ||
storageClassName: {{ .Values.persistence.storageClass }} | ||
{{- end }} | ||
accessModes: | ||
- {{ .Values.persistence.accessModes | quote }} | ||
resources: | ||
requests: | ||
storage: {{ .Values.persistence.size | quote }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.