Skip to content

Conversation

McPatate
Copy link
Member

@McPatate McPatate commented Sep 2, 2025

In #40479, we introduced a new --continuous_batching flag. Here we add a check to make sure the --attn_implementation is compatible with CB and error when not.

@McPatate McPatate requested a review from LysandreJik September 2, 2025 10:47
@McPatate McPatate force-pushed the feat/error_when_unsupported_attn_impl branch from a1e18b1 to 11c5581 Compare September 2, 2025 10:49
@HuggingFaceDocBuilderDev

The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.

Copy link
Member

@LysandreJik LysandreJik left a comment

Choose a reason for hiding this comment

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

Nice! Please add a test :)

@McPatate McPatate force-pushed the feat/error_when_unsupported_attn_impl branch 3 times, most recently from 457baa5 to a8a0fca Compare September 5, 2025 12:58
@McPatate
Copy link
Member Author

McPatate commented Sep 5, 2025

Will add more advanced tests in CB later to test that the returned list of attention implementations is indeed compatible.

@McPatate McPatate requested a review from LysandreJik September 5, 2025 13:01
@McPatate McPatate force-pushed the feat/error_when_unsupported_attn_impl branch from a8a0fca to a2b348d Compare September 8, 2025 13:48
Comment on lines +486 to +498
if self.use_continuous_batching:
default_attn_impl = ContinuousBatchingManager.default_attention_implementation()
# checking if attn_implementation is supported by continuous batching
if self.args.attn_implementation is None:
self.args.attn_implementation = default_attn_impl # default to sdpa_paged
logger.info(f"No attn_implementation passed, defaulting to {default_attn_impl}")
supported_attn_impl = ContinuousBatchingManager.supported_attention_implementations()
if self.args.attn_implementation not in supported_attn_impl:
raise ValueError(
f"Continuous batching only supports {supported_attn_impl} as attn_implementation, got "
f"{self.args.attn_implementation}"
f"Try setting `--attn_implementation={default_attn_impl}`"
)
Copy link
Collaborator

Choose a reason for hiding this comment

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

wdy about putting this directly in CB's api? would be better in general + we can automatically add paged_{attn_implememntation} no?

@McPatate McPatate enabled auto-merge (squash) September 8, 2025 14:17
Copy link
Collaborator

@ArthurZucker ArthurZucker left a comment

Choose a reason for hiding this comment

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

🤗 Okay!

Comment on lines +492 to +494
supported_attn_impl = ContinuousBatchingManager.supported_attention_implementations()
if self.args.attn_implementation not in supported_attn_impl:
raise ValueError(
Copy link
Collaborator

Choose a reason for hiding this comment

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

here if attn impelmeention not supported, you can try to map it to the correct ones?
Because for sdpa eager and flash, its easy to map: prefix with paged|
But up to you !

@McPatate McPatate merged commit 2077f17 into main Sep 8, 2025
24 checks passed
@McPatate McPatate deleted the feat/error_when_unsupported_attn_impl branch September 8, 2025 14:31
vijayabhaskar-ev pushed a commit to vijayabhaskar-ev/transformers that referenced this pull request Oct 2, 2025
huggingface#40618)

* feat: err when unsupported attn impl is set w/ `--continuous_batching`

* refactor: move defaults and support list to CB code

* feat: add action item in error msg

* fix(serve): add default attn implementation

* feat(serve): add log when `attn_implementation` is `None`

* feat: raise Exception when attn_implementation is not supported by CB
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.

4 participants