Skip to content

Commit a37b0a8

Browse files
GregoryComermalfet
authored andcommitted
Improve error messages and README for download errors (#477)
1 parent a74cd78 commit a37b0a8

File tree

2 files changed

+22
-4
lines changed

2 files changed

+22
-4
lines changed

README.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,13 @@ python3 torchchat.py download llama3
5252
View available models with `python3 torchchat.py list`. You can also remove downloaded models
5353
with `python3 torchchat.py remove llama3`.
5454

55+
### Common Issues
56+
57+
* **CERTIFICATE_VERIFY_FAILED**:
58+
Run `pip install --upgrade certifi`.
59+
* **Access to model is restricted and you are not in the authorized list. Visit \[link\] to ask for access**:
60+
Some models require an additional step to access. Follow the link to fill out the request form on HuggingFace.
61+
5562
## What can you do with torchchat?
5663

5764
* Run models via PyTorch / Python:
@@ -106,7 +113,7 @@ Quantization is the process of converting a model into a more memory-efficient r
106113

107114
Depending on the model and the target device, different quantization recipes may be applied. Torchchat contains two example configurations to optimize performance for GPU-based systems `config/data/cuda.json` , and mobile systems `config/data/mobile.json`. The GPU configuration is targeted towards optimizing for memory bandwidth which is a scarce resource in powerful GPUs (and to a less degree, memory footprint to fit large models into a device's memory). The mobile configuration is targeted towards optimizing for memory fotoprint because in many devices, a single application is limited to as little as GB or less of memory.
108115

109-
You can use the quantization recipes in conjunction with any of the `chat`, `generate` and `browser` commands to test their impact and accelerate model execution. You will apply these recipes to the export comamnds below, to optimize the exported models. To adapt these recipes or wrote your own, please refer to the [quantization overview](docs/quantization.md).
116+
You can use the quantization recipes in conjunction with any of the `chat`, `generate` and `browser` commands to test their impact and accelerate model execution. You will apply these recipes to the export comamnds below, to optimize the exported models. To adapt these recipes or wrote your own, please refer to the [quantization overview](docs/quantization.md).
110117

111118
---
112119
*TO BE REPLACED BY SUITABLE ORDING PROVIDED BY LEGAL*

download.py

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
# LICENSE file in the root directory of this source tree.
66
import os
77
import shutil
8+
import sys
89
import urllib.request
910
from pathlib import Path
1011
from typing import Optional
@@ -35,10 +36,20 @@ def _download_hf_snapshot(
3536
ignore_patterns="*safetensors*",
3637
)
3738
except HTTPError as e:
38-
if e.response.status_code == 401:
39-
raise RuntimeError(
40-
"Access denied. Run huggingface-cli login to authenticate."
39+
if e.response.status_code == 401: # Missing HuggingFace CLI login.
40+
print(
41+
"Access denied. Create a HuggingFace account and run 'pip3 install huggingface_hub' and 'huggingface-cli login' to authenticate.",
42+
file=sys.stderr
43+
)
44+
exit(1)
45+
elif e.response.status_code == 403: # No access to the specific model.
46+
# The error message includes a link to request access to the given model. This prints nicely and does not include
47+
# a traceback.
48+
print(
49+
str(e),
50+
file=sys.stderr
4151
)
52+
exit(1)
4253
else:
4354
raise e
4455

0 commit comments

Comments
 (0)