Skip to content

Commit

Permalink
InfV2 - remove generation config requirement (microsoft#4938)
Browse files Browse the repository at this point in the history
Fix for microsoft/DeepSpeed-MII#287

Some HF models do not have a generation config. We should only try to
load it if the `max_seq_length` is not present in the model config.

Also fix bug introduced in microsoft#4936
  • Loading branch information
mrwyattii authored and amaurya committed Feb 17, 2024
1 parent f54bf5c commit d657da0
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
5 changes: 4 additions & 1 deletion .github/workflows/nv-a6000.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,10 @@ jobs:
python -m pytest --color=yes --durations=0 --verbose -rF -m 'inference_v2_ops' unit/ --torch_ver="2.0" --cuda_ver="12"
- name: MII unit tests
run: |
BRANCH="${{ github.event.inputs.mii_branch }}"
BRANCH="main"
if [[ ! -z "${{ github.event.inputs.mii_branch }}" ]]; then
BRANCH="${{ github.event.inputs.mii_branch }}"
fi
echo "Cloning DeepSpeed-MII branch: $BRANCH"
git clone -b $BRANCH --depth=1 https://github.com/microsoft/DeepSpeed-MII.git
cd DeepSpeed-MII
Expand Down
10 changes: 5 additions & 5 deletions deepspeed/inference/v2/checkpoint/huggingface_engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@ def __init__(self, model_name_or_path: str, auth_token: str = None) -> None:
self.model_name_or_path = model_name_or_path
self.auth_token = auth_token
self.model_config = AutoConfig.from_pretrained(self.model_name_or_path)
self.generation_config = GenerationConfig.from_pretrained(self.model_name_or_path)
# Define this property here so we can use it in the model implementation
if not hasattr(self.model_config, "max_seq_length"):
self.model_config.max_seq_length = self.model_config.max_position_embeddings
else:
self.model_config.max_seq_length = self.generation_config.max_length

if hasattr(self.model_config, "max_position_embeddings"):
self.model_config.max_seq_length = self.model_config.max_position_embeddings
else:
generation_config = GenerationConfig.from_pretrained(self.model_name_or_path)
self.model_config.max_seq_length = generation_config.max_length
self._local_checkpoint_dir = None
self._all_ckpt_paths = self._fetch_checkpoint_files()

Expand Down

0 comments on commit d657da0

Please sign in to comment.