git clone https://huggingface.co/bigscience/bloom
You will need Git LFS and ~330GB of free space though.It is possible to run inference locally, even without very much RAM/VRAM (though it will be very slow). Get the most recent versions of "transformers" and "accelerate" from git, and then:
import torch
from transformers import AutoTokenizer, AutoModelForCausalLM
tokenizer = AutoTokenizer.from_pretrained('./bloom')
inputs = tokenizer("Hacker News is", return_tensors="pt")
model = AutoModelForCausalLM.from_pretrained('./bloom', device_map="auto", offload_folder='offload', torch_dtype=torch.bfloat16)
output = model.generate(inputs["input_ids"].to(0), min_length=30, max_length=30, do_sample=True)
print(tokenizer.decode(output[0].tolist()))
After the model is loaded you can also look at where it put each part of the model (GPU, CPU RAM, or on disk): print(model.hf_device_map)
Here's a screenshot of it in action on my machine, which has 256GB RAM and 2xA6000 GPUs:Comment 1: git-lfs is now close to saturating my gigabit ethernet connection, around 990Mb/sec
$ du -csh pytorch_model*.bin | tail -n 1
329G total
$ du -sh .git
329G .git
Not sure if there's a way to get git-lfs not to do that...I believe there are performance enhancements planned in Accelerate that will allow layers to be preloaded in parallel as other layers are executing inference, which should make things faster: https://github.com/huggingface/accelerate/issues/512#issueco...
File "/home/dek/miniconda3/lib/python3.9/site-packages/accelerate/utils/offload.py", line 25, in offload_weight
array = weight.numpy()
I verified my numpy knows nothing of bfloat16:>>> import torch >>> t=torch.arange(0,6).resize(2,3).to(dtype=torch.bfloat16) /home/dek/miniconda3/lib/python3.9/site-packages/torch/_tensor.py:586: UserWarning: non-inplace resize is deprecated warnings.warn("non-inplace resize is deprecated") >>> t tensor([[0., 1., 2.], [3., 4., 5.]], dtype=torch.bfloat16) >>> t.numpy() Traceback (most recent call last): File "<stdin>", line 1, in <module> TypeError: Got unsupported ScalarType BFloat16
Seems par for the course that I'd be able to get the world's most advanced NLP model downloaded over gigabit to my home supercomputer only to be stymied by a data type.
Then it failed again:
File "/home/dek/miniconda3/lib/python3.9/site-packages/accelerate/big_modeling.py", line 188, in dispatch_model
main_device = [d for d in device_map.values() if d not in ["cpu", "disk"] [0]
IndexError: list index out of range
Now I'm curious just how long it will take to repro this error (IE, running again, with the offload files aalready written). It's also puzzling since I set the device_map to 'auto'.Again, all par for the course and stuff I expected (having worked in HPC/ML/science for 3 decades, you get used to research codes).
https://github.com/huggingface/accelerate/commit/f13c59f91e2...