Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 12 additions & 4 deletions examples/arrow_multitask/arrow_phi3_mini.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,10 @@ def set_seed(seed: int):
random.seed(seed)
np.random.seed(seed)
torch.manual_seed(seed)
torch.cuda.manual_seed_all(seed)
if torch.cuda.is_available():
torch.cuda.manual_seed_all(seed)
elif hasattr(torch, "xpu") and torch.xpu.is_available():
torch.xpu.manual_seed_all(seed)


def compute_loglike_loss(logits, labels, reduction="none"):
Expand Down Expand Up @@ -215,11 +218,16 @@ def compute_loglike_loss(logits, labels, reduction="none"):


def evaluate_on_multi_choice_batched(
eval_dataset, model, tokenizer, ds_name, labels, predictions, args, batch_size=32, max_length=512, device="cuda"
eval_dataset, model, tokenizer, ds_name, labels, predictions, args, batch_size=32, max_length=512, device="auto"
):
# Local import to mirror your original function
model.eval()

if device == "auto":
device = torch.accelerator.current_accelerator().type if hasattr(torch, "accelerator") else "cuda"
else:
device = torch.device(device)

for start in tqdm(
range(0, len(eval_dataset), batch_size), total=(len(eval_dataset) + batch_size - 1) // batch_size
):
Expand Down Expand Up @@ -326,7 +334,7 @@ def evaluate_on_multi_choice_batched(
args,
batch_size=64, # tune this
max_length=512, # tune if options are long
device="cuda",
device="auto",
)
else:
general_adapter_paths = []
Expand Down Expand Up @@ -371,5 +379,5 @@ def evaluate_on_multi_choice_batched(
args,
batch_size=32, # tune this
max_length=512, # tune if options are long
device="cuda",
device="auto",
)
Loading