Skip to content

Commit

Permalink
move to device in run_qa instead of accelerator
Browse files Browse the repository at this point in the history
  • Loading branch information
skaulintel committed Mar 7, 2025
1 parent 78c7135 commit 7abf940
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 3 deletions.
2 changes: 2 additions & 0 deletions examples/question-answering/run_qa.py
Original file line number Diff line number Diff line change
Expand Up @@ -376,6 +376,8 @@ def main():
token=model_args.token,
trust_remote_code=model_args.trust_remote_code,
)
device = torch.device("hpu")
model = model.to(device)

# Tokenizer check: this script requires a fast tokenizer.
if not isinstance(tokenizer, PreTrainedTokenizerFast):
Expand Down
3 changes: 0 additions & 3 deletions optimum/habana/accelerate/accelerator.py
Original file line number Diff line number Diff line change
Expand Up @@ -476,9 +476,6 @@ def prepare_model(self, model: torch.nn.Module, device_placement: bool = None, e
"limit_all_gathers": fsdp_plugin.limit_all_gathers,
"device_id": torch.device("hpu", torch.hpu.current_device()),
}
# There's issue with moving view tensors to device within FSDP class [See: https://github.com/pytorch/pytorch/issues/147321]
# Due to above issue, view tensor's may lead to silent incorrent behavior, while pretending to be view they're really not
model = model.to(kwargs["device_id"])
model = FSDP(model, **kwargs)
if fsdp_plugin.activation_checkpointing:
from torch.distributed.algorithms._checkpoint.checkpoint_wrapper import (
Expand Down

0 comments on commit 7abf940

Please sign in to comment.