DeepSpeed
DeepSpeed copied to clipboard
[BUG] unable to run inference with gpt-j-6b
Describe the bug Trying to run hugging face gpt-j-6b using deepspeed inference (v0.9.0) gives me this error:
File "/transformers/venv/lib/python3.10/site-packages/transformers/models/gptj/modeling_gptj.py", line 687, in forward
outputs = block(
File "/transformers/venv/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1501, in _call_impl
return forward_call(*args, **kwargs)
File "/transformers/venv/lib/python3.10/site-packages/deepspeed/model_implementations/transformers/ds_transformer.py", line 161, in forward
output = self.mlp(attention_output, input, inp_norm, self.attention.attn_ob)
File "/transformers/venv/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1501, in _call_impl
return forward_call(*args, **kwargs)
File "/transformers/venv/lib/python3.10/site-packages/deepspeed/ops/transformer/inference/ds_mlp.py", line 65, in forward
output = self.fused_gemm_gelu(input=residual_norm,
File "/transformers/venv/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1501, in _call_impl
return forward_call(*args, **kwargs)
File "/transformers/venv/lib/python3.10/site-packages/deepspeed/ops/transformer/inference/op_binding/gelu_gemm.py", line 26, in forward
output = self.fused_gemm_gelu(input, weight, weight.scale, bias, weight_out, weight_out.scale,
AttributeError: 'Parameter' object has no attribute 'scale'
To Reproduce
def load_model():
model_name = "EleutherAI/gpt-j-6b"
model = AutoModelForCausalLM.from_pretrained(
model_name,
torch_dtype=torch.float16,
).eval()
ds_model = deepspeed.init_inference(
model=model, # Transformers models
mp_size=1, # Number of GPU
dtype=torch.float16, # dtype of the weights (fp16)
replace_method="auto", # Lets DS autmatically identify the layer to replace
replace_with_kernel_inject=True, # replace the model with the kernel injector
)
tokenizer = AutoTokenizer.from_pretrained(
model_name,
)
return tokenizer, ds_model
def generate(tokenizer, model, prompt):
inputs = tokenizer(
prompt,
return_tensors="pt",
).to("cuda")
# fails here
completion = model.generate(
inputs.input_ids,
do_sample=True, max_length=100
)
return completion
if __name__ == "__main__":
tokenizer, model = load_model()
generate(tokenizer, model, "Test prompt")
ds_report output
--------------------------------------------------
DeepSpeed C++/CUDA extension op report
--------------------------------------------------
NOTE: Ops not installed will be just-in-time (JIT) compiled at
runtime if needed. Op compatibility means that your system
meet the required dependencies to JIT install the op.
--------------------------------------------------
JIT compiled ops requires ninja
ninja .................. [OKAY]
--------------------------------------------------
op name ................ installed .. compatible
--------------------------------------------------
[WARNING] async_io requires the dev libaio .so object and headers but these were not found.
[WARNING] async_io: please install the libaio-dev package with apt
[WARNING] If libaio is already installed (perhaps from source), try setting the CFLAGS and LDFLAGS environment variables to where it can be found.
async_io ............... [NO] ....... [NO]
cpu_adagrad ............ [NO] ....... [OKAY]
cpu_adam ............... [NO] ....... [OKAY]
fused_adam ............. [NO] ....... [OKAY]
fused_lamb ............. [NO] ....... [OKAY]
quantizer .............. [NO] ....... [OKAY]
random_ltd ............. [NO] ....... [OKAY]
[WARNING] sparse_attn requires a torch version >= 1.5 but detected 2.0
[WARNING] using untested triton version (2.0.0), only 1.0.0 is known to be compatible
sparse_attn ............ [NO] ....... [NO]
spatial_inference ...... [NO] ....... [OKAY]
transformer ............ [NO] ....... [OKAY]
stochastic_transformer . [NO] ....... [OKAY]
transformer_inference .. [NO] ....... [OKAY]
utils .................. [NO] ....... [OKAY]
--------------------------------------------------
DeepSpeed general environment info:
torch install path ............... ['/transformers/venv/lib/python3.10/site-packages/torch']
torch version .................... 2.0.0+cu118
deepspeed install path ........... ['/transformers/venv/lib/python3.10/site-packages/deepspeed']
deepspeed info ................... 0.9.0, unknown, unknown
torch cuda version ............... 11.8
torch hip version ................ None
nvcc version ..................... 11.8
deepspeed wheel compiled w. ...... torch 2.0, cuda 11.8
System info (please complete the following information):
GPU 3090
CPU Ryzen 5950x
Same problem https://github.com/microsoft/DeepSpeed/issues/3242
Hi @abacaj, I have created a PR (https://github.com/microsoft/DeepSpeed/pull/3256) where I am now seeing results align between DeepSpeed and the HuggingFace baseline. If you could validate in your environment as well that outputs are now matching, that would be great!