[BugFix] Fix absmax and abssum for uint dtypes - #2845
Conversation
|
👋 Hi! Thank you for contributing to the TileLang project. Please remember to run We appreciate you taking this step! Our team will review your contribution, and we look forward to your awesome work! 🚀 |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughScalar ChangesUnsigned absolute reductions
Estimated code review effort: 2 (Simple) | ~10 minutes Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@testing/python/issue/test_tilelang_issue_2624.py`:
- Line 17: Update the reducer selection in make_kernel to map absmax to
T.reduce_absmax, abssum to T.reduce_abssum, and sum to T.reduce_sum, while
retaining T.reduce_max as the fallback for other operations.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: bca65cf9-fcbf-447a-9b1d-b4343dacc164
📒 Files selected for processing (2)
src/backend/common/op/reduce.htesting/python/issue/test_tilelang_issue_2624.py
| As = T.alloc_fragment((N,), dt) | ||
| Bs = T.alloc_fragment((1,), dt) | ||
| T.copy(A, As) | ||
| (T.reduce_absmax if op == "absmax" else T.reduce_max)(As, Bs, dim=0) |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟠 Major | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
set -euo pipefail
rg -n -C 2 'reduce_(absmax|abssum|max|sum)' testing/python/issue/test_tilelang_issue_2624.py srcRepository: tile-ai/tilelang
Length of output: 6351
🏁 Script executed:
#!/bin/bash
set -euo pipefail
echo "== test file =="
cat -n testing/python/issue/test_tilelang_issue_2624.py
echo
echo "== reducer symbol definitions/usages =="
rg -n -C 3 'reduce_absmax|reduce_abssum|reduce_max|reduce_sum|warp_reduce_(abs)?(abssum|max|sum|min)' src testing/python/issue/test_tilelang_issue_2624.py python tilelang | head -n 220Repository: tile-ai/tilelang
Length of output: 15370
🏁 Script executed:
#!/bin/bash
set -euo pipefail
echo "== tilelang/language/reduce_op.py outline/slice =="
sed -n '1,220p' tilelang/language/reduce_op.py
echo
echo "== search abssum symbols =="
rg -n -C 3 'reduce_abssum|abssum|warp_reduce_abssum|warp_reduce.*abs' .Repository: tile-ai/tilelang
Length of output: 20569
Route each operation to the matching reducer.
abssum cases call make_kernel(op.replace("abs", ""), ...) with "sum", but make_kernel only distinguishes "absmax" and falls back to T.reduce_max for everything else. Map "absmax" to T.reduce_absmax, "abssum" to T.reduce_abssum, "sum" to T.reduce_sum, and keep the fallback on T.reduce_max.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@testing/python/issue/test_tilelang_issue_2624.py` at line 17, Update the
reducer selection in make_kernel to map absmax to T.reduce_absmax, abssum to
T.reduce_abssum, and sum to T.reduce_sum, while retaining T.reduce_max as the
fallback for other operations.
The
absfunction duringreduce_absmax/reduce_abssumis implemented asmax(rhs, -rhs), which silently fails whenrhsis unsigned.Simply use
rhsif we know it is unsigned, and fall back tomax(rhs, -rhs)otherwise.Fixes #2624
Summary
uint32anduint64handling inAbsMaxandAbsSumreductions.Max(rhs, -rhs)for signed and floating-point dtypes.absmaxandabssumagainstmaxandsum.C++ style / lint notes
docs/developer_guide/cpp_style.md.