Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable use_batch_forward Optimization on Battlemage GPU #12516

Merged
merged 5 commits into from
Dec 12, 2024

Conversation

liu-shaojun
Copy link
Contributor

@liu-shaojun liu-shaojun commented Dec 9, 2024

Description:

Enable use_batch_forward Optimization on Intel® Arc™ B-Series Graphics Cards (Battlemage)

Currently, torch.xpu.get_device_name(0) returns Intel(R) Graphics [0xe20b] on Intel® Arc™ B-Series graphics cards (code-named Battlemage), unlike the Intel® Arc™ A-Series which returns more specific names such as Intel(R) Arc(TM) A770 Graphics.

This PR updates the device name matching logic to recognize Intel(R) Graphics [0xe20b] as an indicator for Battlemage GPUs, enabling the use_batch_forward optimization on these devices.

Changes:

  • Extend device name matching to include Intel(R) Graphics [0xe20b].

Testing:

@liu-shaojun liu-shaojun changed the title Update get_xpu_device_type() to support bmg Enable use_batch_forward Optimization on Intel® Arc™ B-Series Graphics Cards (Battlemage) Dec 9, 2024
@liu-shaojun liu-shaojun changed the title Enable use_batch_forward Optimization on Intel® Arc™ B-Series Graphics Cards (Battlemage) Enable use_batch_forward Optimization on Battlemage GPU Dec 9, 2024
@liu-shaojun liu-shaojun marked this pull request as ready for review December 9, 2024 08:59
@@ -405,6 +405,7 @@ def use_batch_forward(x: torch.Tensor, qtype: int, output_len: int):
or (device in ["arc", "flex"] and qtype in [SYM_INT8, FP4])
or (device in ["arc", "flex", "mtl"] and qtype in [FP8E4])
or (device in ["lnl"] and qtype in [SYM_INT4] and x.shape[1] % 512 == 0)
or (device in ["bmg"] and qtype in [SYM_INT4])
Copy link
Contributor

Choose a reason for hiding this comment

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

To support more inference and serving requirements on BMG, shall we also verify that FP8/INT8 can benefit from use_batch_forward. @jason-dai

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I collected FP8 data on BMG using the all-in-one. Models larger than 7B cause the machine to crash, while models smaller than 7B show a 1-2% improvement in next-token performance after enabling the batch kernel.

Should we enable the batch kernel for qtype=FP8E5 as well?

Copy link
Contributor

@glorysdj glorysdj left a comment

Choose a reason for hiding this comment

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

LGTM

@liu-shaojun liu-shaojun merged commit 2cce896 into intel-analytics:main Dec 12, 2024
1 check passed
@liu-shaojun liu-shaojun deleted the bmg branch December 12, 2024 04:44
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.

3 participants