Skip to content

Conversation

@LoserCheems
Copy link
Collaborator

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.

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.
Copy link
Contributor

Copilot AI left a 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_SWITCH definition guarded by FLASHATTENTION_DISABLE_SOFTCAP
  • Forces the softcap logic to be no-op (always false) when disabled
  • Defaults to existing BOOL_SWITCH behavior 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_SWITCH and how the disable flag alters its behavior for future maintainers.
#ifdef FLASHATTENTION_DISABLE_SOFTCAP


#ifdef FLASHATTENTION_DISABLE_SOFTCAP
#define SOFTCAP_SWITCH(COND, CONST_NAME, ...) \
[&] { \
Copy link

Copilot AI Jun 23, 2025

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.

Suggested change
[&] { \
[&] { \
(void)COND; \

Copilot uses AI. Check for mistakes.

#ifdef FLASHATTENTION_DISABLE_SOFTCAP
#define SOFTCAP_SWITCH(COND, CONST_NAME, ...) \
[&] { \
Copy link

Copilot AI Jun 23, 2025

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 [].

Suggested change
[&] { \
[] { \

Copilot uses AI. Check for mistakes.
#ifdef FLASHATTENTION_DISABLE_SOFTCAP
#define SOFTCAP_SWITCH(COND, CONST_NAME, ...) \
[&] { \
constexpr static bool CONST_NAME = false; \
Copy link

Copilot AI Jun 23, 2025

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.

Copilot uses AI. Check for mistakes.
@LoserCheems LoserCheems merged commit e474268 into main Jun 23, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature New feature request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants