-
Notifications
You must be signed in to change notification settings - Fork 39
Adds conditional softcap switch macro #25
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
Conversation
Introduces a new SOFTCAP_SWITCH macro that can be conditionally disabled via the FLASHATTENTION_DISABLE_SOFTCAP preprocessor flag. When the flag is defined, the macro forces the condition to false, effectively disabling softcap functionality. Otherwise, it defaults to the standard BOOL_SWITCH behavior.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR introduces a new SOFTCAP_SWITCH macro that can be completely disabled with the FLASHATTENTION_DISABLE_SOFTCAP flag, falling back to BOOL_SWITCH when the flag is not set.
- Adds a conditional
SOFTCAP_SWITCHdefinition guarded byFLASHATTENTION_DISABLE_SOFTCAP - Forces the softcap logic to be no-op (always false) when disabled
- Defaults to existing
BOOL_SWITCHbehavior otherwise
Comments suppressed due to low confidence (1)
csrc/src/static_switch.h:49
- Please add a brief comment above this block explaining the purpose of
SOFTCAP_SWITCHand how the disable flag alters its behavior for future maintainers.
#ifdef FLASHATTENTION_DISABLE_SOFTCAP
|
|
||
| #ifdef FLASHATTENTION_DISABLE_SOFTCAP | ||
| #define SOFTCAP_SWITCH(COND, CONST_NAME, ...) \ | ||
| [&] { \ |
Copilot
AI
Jun 23, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The COND parameter is unused when FLASHATTENTION_DISABLE_SOFTCAP is defined, which may trigger an unused-parameter warning. Consider explicitly casting it away (e.g., (void)COND;) inside the lambda.
| [&] { \ | |
| [&] { \ | |
| (void)COND; \ |
|
|
||
| #ifdef FLASHATTENTION_DISABLE_SOFTCAP | ||
| #define SOFTCAP_SWITCH(COND, CONST_NAME, ...) \ | ||
| [&] { \ |
Copilot
AI
Jun 23, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The lambda capture list uses [&] but doesn't actually capture anything. For clarity and to avoid unexpected captures, use an empty capture list [].
| [&] { \ | |
| [] { \ |
| #ifdef FLASHATTENTION_DISABLE_SOFTCAP | ||
| #define SOFTCAP_SWITCH(COND, CONST_NAME, ...) \ | ||
| [&] { \ | ||
| constexpr static bool CONST_NAME = false; \ |
Copilot
AI
Jun 23, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using a macro parameter as a variable name (CONST_NAME) risks collisions. Consider generating a unique identifier (e.g., via __LINE__) or clearly documenting that callers must provide a unique name.
Introduces a new SOFTCAP_SWITCH macro that can be conditionally disabled via the FLASHATTENTION_DISABLE_SOFTCAP preprocessor flag.
When the flag is defined, the macro forces the condition to false, effectively disabling softcap functionality. Otherwise, it defaults to the standard BOOL_SWITCH behavior.