Vicente Alvarez commited on
Commit
2c155c4
·
1 Parent(s): 6889bbf

Fast parallel downloads with hf_transfer

Browse files
Files changed (3) hide show
  1. README.md +1 -1
  2. app.py +29 -7
  3. requirements.txt +2 -0
README.md CHANGED
@@ -8,7 +8,7 @@ sdk_version: 6.8.0
8
  python_version: '3.12'
9
  app_file: app.py
10
  pinned: false
11
- short_description: Fast video generation with fp8 optimization
12
  ---
13
 
14
  # Element-16 Video Generator
 
8
  python_version: '3.12'
9
  app_file: app.py
10
  pinned: false
11
+ short_description: Fast video generation with bf16 model
12
  ---
13
 
14
  # Element-16 Video Generator
app.py CHANGED
@@ -1,8 +1,12 @@
1
  import os
2
  import subprocess
3
  import sys
 
 
 
 
 
4
 
5
- # Cache bust: 2024-05-16-v2
6
  # Disable torch.compile / dynamo before any torch import
7
  os.environ["TORCH_COMPILE_DISABLE"] = "1"
8
  os.environ["TORCHDYNAMO_DISABLE"] = "1"
@@ -111,15 +115,33 @@ DISTILL_LORA_REPO = "SulphurAI/Sulphur-2-base"
111
  LTX_MODEL_REPO = "Lightricks/LTX-2.3"
112
  GEMMA_REPO = "Lightricks/gemma-3-12b-it-qat-q4_0-unquantized"
113
 
114
- # Download model checkpoints
115
  print("=" * 80)
116
- print("Downloading Element-16 dev + distill LoRA + Gemma...")
117
  print("=" * 80)
118
 
119
- checkpoint_path = hf_hub_download(repo_id=CHECKPOINT_REPO, filename="sulphur_dev_bf16.safetensors")
120
- distilled_lora_path = hf_hub_download(repo_id=DISTILL_LORA_REPO, filename="distill_loras/ltx-2.3-22b-distilled-lora-1.1_fro90_ceil72_condsafe.safetensors")
121
- spatial_upsampler_path = hf_hub_download(repo_id=LTX_MODEL_REPO, filename="ltx-2.3-spatial-upscaler-x2-1.0.safetensors")
122
- gemma_root = snapshot_download(repo_id=GEMMA_REPO)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
123
 
124
  print(f"Checkpoint: {checkpoint_path}")
125
  print(f"Distilled LoRA: {distilled_lora_path}")
 
1
  import os
2
  import subprocess
3
  import sys
4
+ from concurrent.futures import ThreadPoolExecutor
5
+
6
+ # Enable fast downloads
7
+ os.environ["HF_HUB_ENABLE_HF_TRANSFER"] = "1"
8
+ os.environ["HF_XET_HIGH_PERFORMANCE"] = "1"
9
 
 
10
  # Disable torch.compile / dynamo before any torch import
11
  os.environ["TORCH_COMPILE_DISABLE"] = "1"
12
  os.environ["TORCHDYNAMO_DISABLE"] = "1"
 
115
  LTX_MODEL_REPO = "Lightricks/LTX-2.3"
116
  GEMMA_REPO = "Lightricks/gemma-3-12b-it-qat-q4_0-unquantized"
117
 
118
+ # Download model checkpoints in parallel for speed
119
  print("=" * 80)
120
+ print("Downloading Element-16 dev + distill LoRA + Gemma (parallel)...")
121
  print("=" * 80)
122
 
123
+ def download_checkpoint():
124
+ return hf_hub_download(repo_id=CHECKPOINT_REPO, filename="sulphur_dev_bf16.safetensors")
125
+
126
+ def download_lora():
127
+ return hf_hub_download(repo_id=DISTILL_LORA_REPO, filename="distill_loras/ltx-2.3-22b-distilled-lora-1.1_fro90_ceil72_condsafe.safetensors")
128
+
129
+ def download_upsampler():
130
+ return hf_hub_download(repo_id=LTX_MODEL_REPO, filename="ltx-2.3-spatial-upscaler-x2-1.0.safetensors")
131
+
132
+ def download_gemma():
133
+ return snapshot_download(repo_id=GEMMA_REPO)
134
+
135
+ with ThreadPoolExecutor(max_workers=4) as executor:
136
+ future_checkpoint = executor.submit(download_checkpoint)
137
+ future_lora = executor.submit(download_lora)
138
+ future_upsampler = executor.submit(download_upsampler)
139
+ future_gemma = executor.submit(download_gemma)
140
+
141
+ checkpoint_path = future_checkpoint.result()
142
+ distilled_lora_path = future_lora.result()
143
+ spatial_upsampler_path = future_upsampler.result()
144
+ gemma_root = future_gemma.result()
145
 
146
  print(f"Checkpoint: {checkpoint_path}")
147
  print(f"Distilled LoRA: {distilled_lora_path}")
requirements.txt CHANGED
@@ -1,6 +1,8 @@
1
  transformers==4.57.6
2
  accelerate
3
  torch==2.8.0
 
 
4
  einops
5
  scipy
6
  av
 
1
  transformers==4.57.6
2
  accelerate
3
  torch==2.8.0
4
+ hf_transfer
5
+ huggingface_hub[hf_xet]
6
  einops
7
  scipy
8
  av