Skip to content

Drop the unsupported window_size argument from attention backend queries - #3479

Open
Anai-Guo wants to merge 1 commit into
NVIDIA:mainfrom
Anai-Guo:fix-attention-backends-window-size
Open

Drop the unsupported window_size argument from attention backend queries#3479
Anai-Guo wants to merge 1 commit into
NVIDIA:mainfrom
Anai-Guo:fix-attention-backends-window-size

Conversation

@Anai-Guo

@Anai-Guo Anai-Guo commented Sep 4, 2026

Copy link
Copy Markdown

Description

get_available_attention_backends() (tests/pytorch/utils.py:335) does not accept a window_size argument and has no **kwargs:

def get_available_attention_backends(
    config: ModelConfig,
    qkv_dtype: torch.dtype,
    qkv_layout: str,
    pad_between_seqs: bool = False,
    deterministic: bool = False,
    fp8: bool = False,
    fp8_meta: Optional[Dict[str, Any]] = None,
    is_training: bool = True,
    inference_params: Optional[InferenceParams] = None,
    score_mod: bool = False,
    score_mod_bprop: bool = False,
) -> Tuple[List, List]:

Two call sites still pass it, so both raise TypeError before a single backend is queried:

  • benchmarks/attention/benchmark_attention.py:198
  • docs/examples/attention/example_attention.py:93
TypeError: get_available_attention_backends() got an unexpected keyword argument 'window_size'

The second one is the script the attention documentation tells readers to run — docs/examples/attention/attention.ipynb executes !NVTE_DEBUG=1 NVTE_DEBUG_LEVEL=1 python example_attention.py — so the documented example currently cannot run.

The argument is redundant as well as invalid: get_available_attention_backends already reads the window size off the config itself when it assembles the DotProductAttention kwargs (tests/pytorch/utils.py:392, window_size=config.window_size). Every one of the ~20 other call sites (tests/pytorch/attention/test_attention.py, test_attention_with_cp.py, test_flex_attention.py, test_kv_cache.py, …) omits it.

Fix

Drop the window_size=config.window_size, line from the two offending calls. No behaviour change — the helper derives the same value from config.

Verification

No GPU is required to see the failure; it is argument binding, before any CUDA work. Reconstructed the real signature out of tests/pytorch/utils.py with ast and replayed both call shapes through inspect.Signature.bind:

SIGNATURE: (config, qkv_dtype, qkv_layout, pad_between_seqs=None, deterministic=None,
            fp8=None, fp8_meta=None, is_training=None, inference_params=None,
            score_mod=None, score_mod_bprop=None)

FAIL  benchmark_attention.py:198 & docs/example_attention.py:93
      -> TypeError: got an unexpected keyword argument 'window_size'
OK    tests/pytorch/attention/test_attention.py:215 (sibling call, no window_size)

After the patch both call sites bind cleanly. black 24.4.2 --line-length=100 --preview --enable-unstable-feature=string_processing reports both files unchanged.


🤖 Generated with Claude Code

get_available_attention_backends() in tests/pytorch/utils.py has no
window_size parameter and no **kwargs, so both call sites that pass
window_size=config.window_size raise TypeError before any backend is
queried. The helper already reads config.window_size internally when it
builds the DotProductAttention kwargs, so the argument is redundant as
well as invalid; every other call site omits it.

Signed-off-by: Anai-Guo <antai12232931@outlook.com>
@github-actions github-actions Bot added the community-contribution PRs from external contributor outside the core maintainers, representing community-driven work. label Sep 4, 2026
@greptile-apps

greptile-apps Bot commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

Removes an unsupported and redundant window_size keyword from two attention backend queries, allowing the benchmark and documented example to run while preserving backend-selection behavior.

  • Fixes argument binding in the attention benchmark.
  • Fixes the equivalent call in the documented attention example.
  • Continues deriving the window size from the supplied model configuration.

Confidence Score: 5/5

The PR appears safe to merge with no actionable regressions identified.

Both changed calls now match the helper signature, and the helper still reads the intended window size from each caller’s configuration.

Important Files Changed

Filename Overview
benchmarks/attention/benchmark_attention.py Correctly removes an unsupported keyword; the helper obtains the intended window size from the passed configuration.
docs/examples/attention/example_attention.py Correctly fixes the documented example’s backend query without changing its attention configuration.

Reviews (1): Last reviewed commit: "Drop the unsupported window_size argumen..." | Re-trigger Greptile

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

Labels

community-contribution PRs from external contributor outside the core maintainers, representing community-driven work.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant