fix: replace M_LOG2E with portable typed constants #8051
All Vouch review confidence checks passed
Residual risk 0.21 = Change Risk (0.52) × (1 − Review Confidence (0.60)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.52 · 650 lines diff across 8 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.388
Shallow Review Depth
shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #8051"
general
weight: 0.35
qsang-nv
<!-- .github/pull_request_template.md -->
📌 Description
Fix CUDA/MSVC compilation failures caused by
M_LOG2Ebeing unavailable in FMHA v2 and Blackwell MLA. Replace all nine executable uses with FlashInfer-owned constants while preserving each expression's precision: three usemath::log2e_f, and six usemath::log2e_d. Keep the existingmath::log2eas a float value alias for source compatibility.Add direct math-header includes and supply the configured FlashInfer and CCCL include paths to standalone FMHA v2 kernel-traits generation. The latter is required for its epilogue header to compile after the direct include.
🔍 Related Issues
NVBug: https://nvbugspro.nvidia.com/bug/7003364
🚀 Pull Request Checklist
Thank you for contributing to FlashInfer! Before we review your pull request, please make sure the following items are complete.
✅ Pre-commit Checks
pre-commitby runningpip install pre-commit(or used your preferred method).pre-commit install.pre-commit run --all-filesand fixed any reported issues.Changed-file
pre-commit run --files ...andgit diff --checkpassed. The repository-wide--all-filescheck was not run.🧪 Tests
unittest, etc.).Reason: Targeted attention coverage is appropriate; full-scope CI is not requested.
Suggested CI test targets (optional; paths under
tests/, whitespace-separated — a startingpoint for
@flashinfer-bot run <targets>//bot run <targets>, reviewers may adjust):tests/attention/test_fmha_v2_prefill.py tests/attention/test_cutlass_mla_fp8_output.py tests/attention/test_deepseek_mla.py tests/attention/test_trtllm_gen_attention_decode.py tests/attention/test_trtllm_gen_attention_prefill.pyTargeted validation passed:
The final naming-only change was compared against the kernel-validated patch, reproducing all nine prior file hashes after reversing only names, the alias declaration and two formatter line wraps. Full kernel tests were not repeated after that rename. No new permanent regression test was added; the precision harness was run separately. Full test matrices were not run, so the broad checklist items remain unchecked.
🔬 Experimental Track
<!-- Only for PRs submitted under the experimental policy (CONTRIBUTING.md → "Experimental APIs and Backends").
Leave this section untouched for normal PRs. -->
flashinfer/experimental/and/or an@flashinfer_experimental_api. Tracking issue: #- [ ] The tracking issue names an owner, the reason for the experimental path, and a graduation plan with a target release.
- [ ] Core changes are limited to a thin entry point (signature, shared validation, feature-gate check, backend selection, handoff).
- [ ] Tests live in
tests/experimental/and were validated on the intended hardware; a runnable example is included.- [ ] Nothing is registered in
flashinfer/aot.py, and no experimental backend is reachable frombackend="auto"withoutFLASHINFER_ALLOW_EXPERIMENTAL_AUTO_BACKENDS=1. (Calling an@flashinfer_experimental_apior naming a backend explicitly is itself the opt-in and needs no environment variable.)- [ ] Test scope declared below. The experimental CI lane runs exactly these targets, so keep them as narrow as the change allows.
<!-- Required for experimental PRs. Replace the commented lines below with your targets.
Do not delete the fence or change its
experimental-teststag — the experimental-trackwatcher reads it verbatim to decide which targets to ask CI for. -->
``
experimental-tests
`One target per line: a directory or a file. (A pytest ::selector is not
supported -- the sharding runner cannot consume one.) Must be under
tests/experimental/ and must exist. Delete these comment lines and add yours, e.g.
# tests/experimental/test_my_backend.py
tests/experimental/my_backend/
# Declaring the whole tree (tests/experimental/) is allowed but means every
experimental PR pays for every other feature's tests, in every matrix cell.
Reviewer Notes
The six double constants intentionally preserve the original macro's double intermediates, even where the destination is float. Please retain the float type of the legacy math::log2e
alias.Windows validation used the existing Windows port and does not establish general Windows support. The binding's Hopper-only expression has compile/type coverage; Hopper numerical coverage uses the generic launcher. Standalone reducer runtime coverage is BF16 with PDL disabled. An earlier H100 debug-mode failure also reproduced with the unchanged launcher; optimized validation passed.
Validation was performed on the branch based at e3b5b1e340187121b4301124a916bf3458bfe637
. The patch applies cleanly to current main (fca8897833d7b8daac9485aa7f29d2da3c65e6b5`), but newer upstream Hopper DMA scheduling has not been exercised with this patch. Focused merged-head FMHA v2 CI is recommended before merge.<!-- This is an auto-generated comment: release notes by coderabbit.ai -->
<!-- coderabbit-ai-generated:v1 -->
Summary by CodeRabbit
Bug Fixes
Improved numerical consistency in attention scaling across supported kernels, with precision-specific constants for float and double calculations.
* Updated JIT kernel builds to include the required CUDA and FlashInfer headers, improving build reliability.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->