Skip to content

Inferencing on Gaudi is failing#2211

Description

@dkiran1

Hi,
I used the below code sample to infer the model on Gaudi cluster
import logging
from transformers import AutoTokenizer, AutoModelForCausalLM
from optimum.habana import GaudiTextGenerationPipeline, GaudiConfig

MODEL_NAME = "Qwen/Qwen3-4B-Thinking-2507"
DEVICE = "hpu"

tokenizer = AutoTokenizer.from_pretrained(MODEL_NAME, use_fast=False)

model = AutoModelForCausalLM.from_pretrained(
MODEL_NAME,
device_map=DEVICE,
trust_remote_code=True
)

gaudi_config = GaudiConfig(
use_hpu_graphs=True, # enable graph compilation for speed
use_kv_cache=True, # faster decoding
attention_op="gaudi_scaled_dot_product_attention"
)
pipe = GaudiTextGenerationPipeline(
model=model,
tokenizer=tokenizer,
gaudi_config=gaudi_config
)
prompt = "Explain the importance of space exploration in simple terms."
output = pipe(
prompt,
max_new_tokens=128,
batch_size=1,
do_sample=True,
top_p=0.9,
temperature=0.7
)
print("\n--- Generated Output ---\n")
print(output[0]["generated_text"])

Iam getting below error ImportError: cannot import name '_VALID_DICT_FIELDS' from 'transformers.training_args' (/usr/local/lib/python3.10/dist-packages/transformers/training_args.py)

Here is my config transformers :- 4.55.2, habana: 1.21.3.57_, optimum-habana 1.18.0 and optimum version 1.27.0 ,Can this be due to version mismatch? can you please provide the sample inferencing code on Gaudi?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions