Run this model with HF Jobs

Run alpindale/dbrx-instruct on Hugging Face's managed compute, monitor its progress, and retrieve the results when it's done.

Paste one of these prompts into your coding agent:

Fine-tune on my dataset

Use HF Jobs and TRL to fine-tune https://huggingface.co/alpindale/dbrx-instruct. Ask me which dataset to train on, then push the fine-tuned model to a new model repo. Run `hf jobs --help` first to learn the CLI.

Run batch inference

Use HF Jobs to run batch inference with https://huggingface.co/alpindale/dbrx-instruct on the inputs in a mounted HF Bucket. Ask me which Bucket to use, then write the outputs back to it and keep each input ID. Run `hf jobs --help` first to learn the CLI.

Evaluate on a benchmark

Use HF Jobs to evaluate https://huggingface.co/alpindale/dbrx-instruct. Ask me which benchmark to run, then save the scores and the per-example results to a new dataset repo. Run `hf jobs --help` first to learn the CLI.

Quantize for lower memory use

Use HF Jobs to create a 4-bit version of https://huggingface.co/alpindale/dbrx-instruct. Push it to a new model repo, then reload it from there and report its memory footprint. Run `hf jobs --help` first to learn the CLI.

Failing to 4-bit quantize with BitsAndBytes

#1
by simsim314 - opened

My goals is to run 4-bit quant of the model.

While this usual code provided executes fine... takes forever to generate single token on cpu but runs without errors:

from transformers import AutoTokenizer, AutoModelForCausalLM
import torch

tokenizer = AutoTokenizer.from_pretrained("alpindale/dbrx-instruct", trust_remote_code=True)
model = AutoModelForCausalLM.from_pretrained("alpindale/dbrx-instruct", device_map="cpu", torch_dtype=torch.bfloat16, trust_remote_code=True)

input_text = "What does it take to build a great LLM?"
messages = [{"role": "user", "content": input_text}]
input_ids = tokenizer.apply_chat_template(messages, return_dict=True, tokenize=True, add_generation_prompt=True, return_tensors="pt")

outputs = model.generate(**input_ids, max_new_tokens=2)
print(tokenizer.decode(outputs[0]))

This code with BitsAndBytesConfig of nf4, throws an Error:

from transformers import AutoTokenizer, AutoModelForCausalLM
import torch
from transformers import BitsAndBytesConfig

tokenizer = AutoTokenizer.from_pretrained("alpindale/dbrx-instruct", trust_remote_code=True)

quantization_config = BitsAndBytesConfig(
    load_in_4bit=True,
    bnb_4bit_quant_type="nf4",
    bnb_4bit_compute_dtype=torch.bfloat16,
)

model = AutoModelForCausalLM.from_pretrained("alpindale/dbrx-instruct", device_map="cpu", quantization_config=quantization_config, trust_remote_code=True)

input_text = "What does it take to build a great LLM?"
messages = [{"role": "user", "content": input_text}]
input_ids = tokenizer.apply_chat_template(messages, return_dict=True, tokenize=True, add_generation_prompt=True, return_tensors="pt")

outputs = model.generate(**input_ids, max_new_tokens=200)
print(tokenizer.decode(outputs[0]))

Error:

RuntimeError: "LayerNormKernelImpl" not implemented for 'Half'

I am guessing it's some new layer they implemented in the custom code. So while llama.cpp fellows, managing their own bugs with 16 experts, why not add support for the basic 4-bits from BitsAndBytes, I am guessing it's much less work, but I don't know how to do it. I am guessing it's something in the custom code provided by databricks.

I've seen this error on any model when I tried to run it quantized on CPU. Doesn't seem to be related to dbrx in any way.

Apparently it's an issue on some of the scripts since this SinclairSchneider/dbrx-instruct-quantization-fixed reupload works fine.

Sign up or log in to comment