Skip to content

Fallback for unsupported Hybrid Engine policies - #8265

Open
LiRunGuo wants to merge 1 commit into
deepspeedai:masterfrom
LiRunGuo:fix/hybrid-engine-unsupported-policy
Open

Fallback for unsupported Hybrid Engine policies#8265
LiRunGuo wants to merge 1 commit into
deepspeedai:masterfrom
LiRunGuo:fix/hybrid-engine-unsupported-policy

Conversation

@LiRunGuo

Copy link
Copy Markdown

Summary

  • register Hybrid Engine auxiliary Linear/Embedding/LayerNorm policies only when the model contains a supported complete transformer policy
  • allow unsupported architectures such as Qwen2.5 to retain the native generate() fallback
  • add CPU-only unit coverage for supported and unsupported policy registration

Fixes #8263.

Why

The generic wrappers are auxiliary pieces of a complete transformer injection policy. Registering them when no transformer layer matches creates a partial inference path. With a ZeRO-3-partitioned Qwen model, container construction can then reach _mark_uc_metadata() with a one-dimensional normalization weight and fail on weight.shape[1].

The change first builds the complete-policy map and checks it against the model's module classes. If no complete policy matches, the map remains empty, no partial containers are created, and Hybrid Engine leaves the model's native generation method intact. Supported model behavior is unchanged.

Validation

  • pytest -q tests/unit/hybrid_engine/test_he_policy.py (2 passed)
  • pre-commit run --files deepspeed/runtime/hybrid_engine.py tests/unit/hybrid_engine/test_he_policy.py
  • Qwen2.5-0.5B / Qwen2.5-Math-7B OPSD completed a full prompt epoch and a separate 200-step run on 8 x MI250 with the fallback

Signed-off-by: LiRunGuo <li19107254665@gmail.com>
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.


has_transformer_policy = any(module.__class__ in self.inference_policies for module in self.module.modules())
if not has_transformer_policy:
self.inference_policies = {}

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add a logger.warning here for not matching inference_policies? This would give user proper expectations.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Hybrid Engine registers partial inference policies for unsupported Qwen architectures

2 participants