-
Notifications
You must be signed in to change notification settings - Fork 357
[Lint] Enable whitespace and permission bit hooks #1439
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
base: main
Are you sure you want to change the base?
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! 🚀 |
WalkthroughThe PR applies widespread formatting and linting fixes including enabling pre-commit hooks (trailing-whitespace, end-of-file-fixer, check-executables-have-shebangs, check-shebang-scripts-are-executable, check-ast, debug-statements, file-contents-sorter), adding bash shebangs to shell scripts, enforcing trailing newlines across files, and removing trailing whitespace in documentation. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested reviewers
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: defaults Review profile: CHILL Plan: Pro 📒 Files selected for processing (13)
✅ Files skipped from review due to trivial changes (3)
🚧 Files skipped from review as they are similar to previous changes (6)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (5)
🔇 Additional comments (6)
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 |
bfb33fd to
1b8d044
Compare
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.
Actionable comments posted: 2
🧹 Nitpick comments (2)
maint/scripts/apply_mit_license.sh (1)
29-30: Consider refactoring fragile for-loop pattern.The for-loop over
findoutput (lines 29–30) can behave unexpectedly with filenames containing whitespace or special characters. While this may be a pre-existing pattern in the codebase, consider usingfind -execor awhile readloop for greater robustness.Example refactor using
while read:find . -path './3rdparty' -prune -false -o -path './build' -prune -false -o -type f -not -name \ '*apply_mit_liscense.sh' -not -name '*check_mit_liscense.sh' -name '*.sh' | while read SRC_FILE; do sed -i '/\#\s*Microsoft\s*(c)/Id' "${SRC_FILE}" if ! (grep -q "Copyright (c) Tile-AI Corporation." "${SRC_FILE}"); then line=$(head -n 1 "${SRC_FILE}") if [[ $line == "#!/bin/bash"* ]]; then (echo "${line}"; echo ''; cat maint/scripts/mit_liscense2.txt; tail -n +2 "${SRC_FILE}") > "${SRC_FILE}.new" else cat maint/scripts/mit_liscense2.txt "${SRC_FILE}" > "${SRC_FILE}.new" fi mv "${SRC_FILE}.new" "${SRC_FILE}" fi doneAlso note:
${SRC_FILE}should be quoted in all command substitutions to handle whitespace safely.examples/gemm_fp8/README.md (1)
1-1: Minor wording improvement suggested by static analysis.The LanguageTool linter flags "in future" as British English. Consider updating it to "in the future" for consistency with American English conventions, though this is optional.
Apply this diff to align with standard English conventions:
-**Notes**: Now we only support fp8 with mma instructions instead of `T.gemm`, because the cutlass version of tilelang is too old, we should update the cutlass version in future. +**Notes**: Now we only support fp8 with mma instructions instead of `T.gemm`, because the cutlass version of tilelang is too old, we should update the cutlass version in the future.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (3)
docs/_static/img/logo-row.svgis excluded by!**/*.svgimages/MatmulExample.svgis excluded by!**/*.svgimages/logo-row.svgis excluded by!**/*.svg
📒 Files selected for processing (63)
.pre-commit-config.yaml(1 hunks)LICENSE(1 hunks)README.md(3 hunks)THIRDPARTYNOTICES.txt(1 hunks)benchmark/mamba2/README.md(1 hunks)docker/Dockerfile.cu118(1 hunks)docker/Dockerfile.cu120(1 hunks)docs/.gitignore(1 hunks)docs/CNAME(1 hunks)docs/_static/custom.css(0 hunks)docs/compiler_internals/tensor_checks.md(0 hunks)docs/deeplearning_operators/deepseek_mla.md(4 hunks)docs/deeplearning_operators/elementwise.md(2 hunks)docs/deeplearning_operators/gemv.md(2 hunks)docs/deeplearning_operators/matmul_sparse.md(3 hunks)docs/get_started/overview.md(1 hunks)docs/programming_guides/instructions.md(1 hunks)docs/programming_guides/type_system.md(0 hunks)docs/tutorials/auto_tuning.md(2 hunks)docs/tutorials/logging.md(0 hunks)examples/attention_sink/README.md(1 hunks)examples/bitnet-1.58b/.gitignore(1 hunks)examples/bitnet-1.58b/README.md(1 hunks)examples/bitnet-1.58b/benchmark.sh(1 hunks)examples/bitnet-1.58b/maint/README.md(1 hunks)examples/bitnet-1.58b/maint/generate_bitnet_model_bitblas_format.sh(1 hunks)examples/bitnet-1.58b/maint/generate_bitnet_model_native_format.sh(1 hunks)examples/bitnet-1.58b/maint/quantize_config.json(1 hunks)examples/bitnet-1.58b/maint/upload_models.sh(1 hunks)examples/bitnet-1.58b/nvidia_measure_memory.sh(1 hunks)examples/blocksparse_attention/README.md(1 hunks)examples/deepseek_mla/README.md(3 hunks)examples/deepseek_nsa/requirements.txt(1 hunks)examples/deepseek_v32/README.md(1 hunks)examples/deepseek_v32/inference/README.md(1 hunks)examples/deepseek_v32/inference/config_671B_v3.2.json(1 hunks)examples/deepseek_v32/inference/convert.py(1 hunks)examples/deepseek_v32/inference/requirements.txt(1 hunks)examples/dequantize_gemm/README.md(1 hunks)examples/flash_attention/README.md(2 hunks)examples/gemm_fp8/README.md(1 hunks)examples/gemm_sm100/README.md(0 hunks)maint/precision/cuda_ops.cu(1 hunks)maint/scripts/apply_mit_license.sh(2 hunks)maint/scripts/build_docs.sh(1 hunks)maint/scripts/check_mit_license.sh(2 hunks)maint/scripts/local_distribution.sh(1 hunks)maint/scripts/pypi_distribution.sh(1 hunks)pyproject.toml(1 hunks)src/op/gemm_sp_py.h(1 hunks)src/tl_templates/cpp/common.h(1 hunks)src/tl_templates/cpu/common.h(1 hunks)src/tl_templates/cuda/debug.h(1 hunks)src/tl_templates/cuda/gemm_sp_sm90.h(1 hunks)src/tl_templates/cuda/ldsm.h(1 hunks)src/tl_templates/cuda/nvrtc_std.h(1 hunks)src/tl_templates/hip/hip_fp8.h(1 hunks)src/tl_templates/hip/ldsm.h(1 hunks)src/transform/atomicadd_vectorize.h(1 hunks)src/transform/common/assume.h(1 hunks)src/transform/common/loop_vectorization_utils.h(1 hunks)tilelang/carver/README.md(2 hunks)tilelang/jit/adapter/cython/cython_wrapper.pyx(4 hunks)
💤 Files with no reviewable changes (5)
- docs/compiler_internals/tensor_checks.md
- docs/tutorials/logging.md
- examples/gemm_sm100/README.md
- docs/_static/custom.css
- docs/programming_guides/type_system.md
🧰 Additional context used
🧠 Learnings (2)
📚 Learning: 2025-09-15T10:51:06.985Z
Learnt from: botbw
Repo: tile-ai/tilelang PR: 691
File: src/tl_templates/cuda/gemm_sp_sm80.h:81-85
Timestamp: 2025-09-15T10:51:06.985Z
Learning: In CUTLASS tensor operation layouts, crosswise constants should be computed using sizeof(T) (bytes), not cutlass::sizeof_bits<T>::value (bits). This is the established pattern in the official CUTLASS codebase, as seen in default_mma_core_sparse_sm80.h.
Applied to files:
docs/deeplearning_operators/matmul_sparse.mdexamples/gemm_fp8/README.md
📚 Learning: 2025-09-15T10:51:06.985Z
Learnt from: botbw
Repo: tile-ai/tilelang PR: 691
File: src/tl_templates/cuda/gemm_sp_sm80.h:81-85
Timestamp: 2025-09-15T10:51:06.985Z
Learning: In CUTLASS tensor operation layouts, crosswise constants should be computed using sizeof(T) (bytes), not cutlass::sizeof_bits<T>::value (bits). However, the layout template parameter should use sizeof_bits<T>::value (bits). This is the established pattern in the official CUTLASS codebase, as seen in default_mma_core_sparse_sm80.h where Crosswise uses sizeof(ElementA) but the layout template uses sizeof_bits<ElementA>::value.
Applied to files:
docs/deeplearning_operators/matmul_sparse.md
🪛 LanguageTool
docs/deeplearning_operators/gemv.md
[grammar] ~464-~464: Use a hyphen to join words.
Context: ...el and learn that TileLang exposes low level control to user such as thread-lev...
(QB_NEW_EN_HYPHEN)
examples/gemm_fp8/README.md
[locale-violation] ~1-~1: The phrase ‘in future’ is British English. Did you mean: “in the future”?
Context: ...d, we should update the cutlass version in future.
(IN_FUTURE)
🪛 markdownlint-cli2 (0.18.1)
docs/get_started/overview.md
39-39: Link text should be descriptive
(MD059, descriptive-link-text)
39-39: Link text should be descriptive
(MD059, descriptive-link-text)
🪛 Shellcheck (0.11.0)
maint/scripts/apply_mit_license.sh
[error] 23-23: You are missing a required space after the !.
(SC1035)
[warning] 29-30: For loops over find output are fragile. Use find -exec or a while read loop.
(SC2044)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (5)
- GitHub Check: Test for Python 3.12 with Metal (on macos-latest)
- GitHub Check: Build wheels for Python 3.9 on macos-latest with Metal
- GitHub Check: Build wheels for Python 3.9 on ubuntu-24.04-arm with CUDA-12.8
- GitHub Check: Build wheels for Python 3.9 on ubuntu-latest with CUDA-12.8
- GitHub Check: Build SDist
🔇 Additional comments (62)
examples/bitnet-1.58b/.gitignore (1)
1-1: LGTM!The EOF newline normalization aligns with the pre-commit hook enablement goal outlined in the PR objectives. No functional impact on
.gitignorebehavior.examples/deepseek_v32/inference/config_671B_v3.2.json (1)
26-26: End-of-file newline formatting applied correctly.The JSON file retains its valid structure and configuration values. The newline added at the end of the file aligns with the pre-commit hook standards.
examples/deepseek_v32/inference/requirements.txt (1)
1-5: LGTM!The requirements.txt file is properly formatted with correct dependency syntax and appropriate version pinning (tilelang==0.1.6). The trailing newline restoration aligns perfectly with the PR's code hygiene objectives to normalize end-of-file formatting.
docs/programming_guides/instructions.md (1)
174-174: LGTM!The whitespace normalization in the "Register control" section is consistent with the PR objective to enable trailing-whitespace and end-of-file-fixer pre-commit hooks across the codebase.
examples/deepseek_v32/inference/convert.py (1)
36-48: Docstring formatting improvement approved.The blank line inserted after the parameter list (line 45) adds clearer visual separation between the
ArgsandReturnssections in the docstring. This aligns with the PR's formatting standardization objectives and is a minor improvement to readability.tilelang/jit/adapter/cython/cython_wrapper.pyx (2)
84-88: Formatting improvement to multi-line conditional for readability.The device index matching logic has been reformatted across multiple lines, improving code readability without any functional change. Logically equivalent to the prior version.
118-118: Whitespace normalization aligns with pre-commit hook standards.Trailing whitespace removal and blank line adjustments (removal at line 118, normalization at lines 178 and 241) are consistent with the PR's objective to enable
trailing-whitespaceandend-of-file-fixerhooks. No semantic or behavioral impact.Also applies to: 178-178, 241-241
docs/tutorials/auto_tuning.md (2)
17-17: Documentation content retained correctly.The sentence describing the Matrix Multiplication example has been preserved with only whitespace normalization applied, maintaining the tutorial's instructional value.
148-148: EOF normalization applied correctly.The code block terminator has been updated to ensure a trailing newline after the closing fence, aligning with the pre-commit hook standardization.
docs/deeplearning_operators/matmul_sparse.md (1)
8-8: LGTM!The trailing whitespace removal and EOF newline addition are proper linting improvements that align with the PR objectives. The Python code fence formatting on line 43 is correct.
Also applies to: 43-43, 262-262
examples/bitnet-1.58b/maint/generate_bitnet_model_bitblas_format.sh (1)
1-2: Shebang addition improves script portability and executability.The addition of
#!/usr/bin/env bashenables direct script execution and ensures the script runs with the bash interpreter across different systems. The blank line following the shebang follows standard shell scripting conventions.examples/bitnet-1.58b/nvidia_measure_memory.sh (1)
1-2: Shebang addition for GPU memory monitoring utility.The shebang enables this utility script to be invoked directly, improving usability for monitoring GPU memory usage.
examples/bitnet-1.58b/maint/upload_models.sh (1)
1-2: Shebang addition for model upload automation.The shebang enables this git/git-lfs automation script to run directly, improving workflow integration for model uploads.
examples/bitnet-1.58b/maint/generate_bitnet_model_native_format.sh (1)
1-7: Shebang addition with robust dependency checking.The shebang enables direct execution, and the existing dependency check (lines 4-7) properly validates that git-lfs is installed before proceeding, exiting with an appropriate error message if missing. This defensive approach prevents silent failures.
examples/bitnet-1.58b/benchmark.sh (1)
1-2: Shebang addition for benchmark automation.The shebang enables this benchmark script to be invoked directly, improving the workflow for running the six sequential benchmark configurations with output logging.
maint/scripts/pypi_distribution.sh (1)
1-1: Correct shebang addition for bash script.Adding the explicit interpreter directive allows the pre-commit hooks to properly identify and validate the script, and enables direct execution without explicitly invoking bash.
maint/scripts/build_docs.sh (1)
1-1: Correct shebang addition for bash script.The explicit interpreter directive is appropriate for this documentation build script.
maint/scripts/check_mit_license.sh (1)
1-6: Well-structured script initialization with proper root context.Adding the shebang and establishing the repository root via
pushdensures the script executes correctly from any working directory and finds source files consistently.maint/scripts/local_distribution.sh (1)
1-3: Correct shebang and strict bash execution mode.Adding
set -euxenables fail-fast behavior and explicit logging, which is appropriate for build automation scripts to catch errors early and provide debugging visibility.maint/scripts/apply_mit_license.sh (2)
1-8: Correct shebang and root directory setup.The script initialization follows the established pattern with proper interpreter directive and repository root context via
pushd.
31-41: Good enhancement: shebang preservation logic for shell scripts.The new logic (lines 33–38) correctly handles shell scripts with existing shebangs by preserving the
#!/bin/bashline and inserting the license header after it. This ensures scripts remain executable after license insertion.src/tl_templates/cuda/gemm_sp_sm90.h (1)
233-234: EOF newline formatting conformance.Adding the trailing newline aligns with the project's enabled end-of-file-fixer pre-commit hook. No functional changes.
docker/Dockerfile.cu120 (1)
1-1: No substantive change detected.The FROM instruction remains unchanged. This appears to be part of the formatting normalization pass. No functional changes to the Dockerfile.
examples/blocksparse_attention/README.md (1)
3-3: Documentation formatting improvement.Line wrapping adjusted for readability without altering content or meaning. Pure formatting change.
Also applies to: 5-5
examples/deepseek_nsa/requirements.txt (1)
1-1: EOF newline formatting adjustment.Dependency URL remains unchanged. EOF newline normalization per pre-commit hook configuration. No functional changes.
src/transform/common/loop_vectorization_utils.h (1)
783-784: EOF newline formatting conformance.Trailing newline added after final namespace closure to align with end-of-file-fixer standards. No functional changes.
src/tl_templates/cuda/ldsm.h (1)
121-121: EOF newline formatting conformance.Trailing newline added after namespace closure. Aligns with pre-commit end-of-file-fixer hook. No functional changes.
docs/deeplearning_operators/elementwise.md (1)
11-11: Documentation formatting improvements.Line 11: Trailing whitespace removed from warning block. Lines 283–284: Function signature line-wrapping adjusted for readability. Both are pure formatting changes per pre-commit hook standards. No content changes.
Also applies to: 283-284
src/transform/atomicadd_vectorize.h (1)
60-60: EOF newline formatting conformance.Trailing newline added after header guard closure to align with end-of-file-fixer pre-commit hook. No functional changes.
README.md (1)
1-247: Formatting changes look good.All modifications are trailing whitespace removal and blank line normalization, aligning with the pre-commit hook enablement objective. No content changes to documentation or examples.
docs/.gitignore (1)
1-2: Ignore patterns preserved.The reordering of patterns does not impact functionality; both
_build/andautoapi/remain ignored as expected.src/op/gemm_sp_py.h (1)
9-94: Include guards and EOF formatting in order.The include-guard names are consistent, and the end-of-file newline addition is standard practice for header files.
THIRDPARTYNOTICES.txt (1)
1-2: License notice formatting preserved.The line wrapping of the introductory statement maintains all content and improves readability. All license texts remain unchanged.
src/tl_templates/cuda/nvrtc_std.h (1)
174-176: EOF newline properly added.The end-of-file newline follows standard C++ header conventions and does not affect the type definitions or implementations.
src/tl_templates/cpu/common.h (1)
1-7: EOF newline added to minimal header.The file structure is preserved; the end-of-file newline follows pre-commit standards.
src/tl_templates/hip/hip_fp8.h (1)
1-167: FP8 definitions and device functions preserved with EOF newline.All type definitions, struct declarations, and device functions remain unchanged. The end-of-file newline follows standard practices.
LICENSE (1)
1-23: License text and collaboration terms fully preserved.The line wrapping of the Microsoft collaboration period statement maintains all legal content and improves document readability. The MIT license terms remain complete.
src/transform/common/assume.h (1)
28-28: Formatting change approved.This trailing newline addition aligns with the pre-commit hook objective for consistent EOF formatting.
examples/flash_attention/README.md (1)
82-82: Formatting improvements approved.The added blank lines enhance code block readability by separating logical sections, consistent with Python formatting conventions.
Also applies to: 111-111
examples/bitnet-1.58b/README.md (1)
97-97: Formatting change approved.EOF newline addition ensures consistency with trailing-whitespace and end-of-file-fixer hooks.
examples/deepseek_v32/inference/README.md (1)
14-14: Formatting change approved.EOF newline addition aligns with pre-commit hook formatting objectives.
pyproject.toml (1)
125-125: Formatting improvement approved.The added blank line improves visual separation between TVM and CUTLASS package mapping sections.
examples/attention_sink/README.md (1)
46-46: Markdown syntax correction approved.Changed from "->" to ">" to use proper blockquote markdown syntax, improving documentation rendering.
examples/bitnet-1.58b/maint/quantize_config.json (1)
10-10: Formatting change approved.EOF newline addition ensures consistent file ending across the codebase, aligned with hook objectives.
docs/CNAME (1)
1-1: LGTM!Trailing newline added at EOF aligns with the
end-of-file-fixerpre-commit hook being enabled.tilelang/carver/README.md (1)
3-3: LGTM!Trailing whitespace removed from documentation lines. No semantic changes to content or code examples.
Also applies to: 36-37
src/tl_templates/cpp/common.h (1)
8-8: LGTM!Trailing newline added at EOF. Header content unchanged.
src/tl_templates/hip/ldsm.h (1)
1-3: LGTM!Trailing newline added at EOF. Header content unchanged.
docker/Dockerfile.cu118 (1)
1-1: LGTM!Trailing whitespace removed from the
FROMinstruction. No functional change to the Dockerfile.examples/bitnet-1.58b/maint/README.md (1)
84-91: Formatting: BibTeX fence and EOF newline are correctProperly closing the BibTeX block and adding an EOF newline matches the new whitespace hooks and avoids Markdown rendering glitches.
maint/precision/cuda_ops.cu (1)
235-242: Formatting: Added newline at end of CUDA sourceEOF newline after the module definition is standard and aligns with
end-of-file-fixer; no behavioral impact.benchmark/mamba2/README.md (1)
54-59: Formatting: Figure block now has proper EOF newlineAdding a newline after the closing
</figure>keeps the Markdown/HTML well‑formed and consistent with the new EOF checks.examples/deepseek_mla/README.md (1)
27-29: Docs: MLA README additions/readability improvements look goodThe added performance summary (including the “~80 lines of Python” note), the cleaned Python fence, the clarified explanation of partitioning
acc_o, and the explicit mention of split/combine kernels withnum_splitall improve readability without changing technical meaning.Also applies to: 34-49, 57-60, 140-140
src/tl_templates/cuda/debug.h (1)
121-128: Formatting: Restored EOF newline in debug headerAdding the newline after the final brace keeps the header compliant with EOF conventions and matches the new pre-commit hooks.
examples/dequantize_gemm/README.md (1)
20-24: Docs: ReflowedT.Pipelinedcall improves readabilityBreaking the
T.Pipelinedarguments onto separate lines makes the example clearer while preserving the same semantics..pre-commit-config.yaml (1)
16-17: Tooling: Stronger pre-commit hygiene hooks are appropriateEnabling whitespace/EOF fixes, shebang checks, AST validation, debug-statement detection, and sorting for the spelling word list is consistent with this PR’s objectives and should catch common issues early while keeping
build/and3rdparty/excluded.Also applies to: 21-22, 26-31
examples/deepseek_v32/README.md (1)
191-203: Docs: Sparse MLA backward description and snippet formatting improvedThe added spacing in the code example, consistent bullet styling for the gradient formulas, and the rewrapped
T.atomic_addx4call make the backward-pass section easier to read without altering the described algorithm.Also applies to: 206-209, 213-217
docs/deeplearning_operators/deepseek_mla.md (1)
5-5: ✓ Whitespace and formatting cleanup looks good.The trailing whitespace removals and code fence formatting align with the PR's lint hook objectives. The content addition at lines 35–36 (noting TileLang's ~80-line implementation) is consistent with the cross-file updates mentioned in the summary and provides useful context without altering logic.
Also applies to: 35-36, 42-42, 65-65, 170-170
docs/get_started/overview.md (4)
18-19: ✓ Trailing whitespace cleanup in bullet lists.The removal of trailing spaces from the Beginner, Developer, and Expert level descriptions is correct and aligns with the PR's linting objectives.
Also applies to: 23-24, 28-29
34-34: ✓ Compilation Flow section restructured for clarity.Converting from negative-prefixed items to explicit numbered items (1–6) improves readability and provides a clearer progression through the compilation pipeline. The content and meaning are preserved.
Also applies to: 37-37, 40-40, 43-43, 46-46, 49-49
54-61: ✓ Tile-based Programming Model section enhanced.The minor line breaks and addition of "and operator calls to manage data movement and computation with fine-grained control" clarifies the GEMM example's scope without changing the section's intent.
1-90: Verify MD059 link text descriptive compliance.Static analysis flags indicate a potential issue with non-descriptive link text at line 39 (reported twice). Please verify and resolve any links that do not use descriptive anchor text per Markdown lint standards.
|
@XuehaiPan After excluding SVG I think we can merge it. Other part looks good to me. |
Since we enabled
ruff formatand landed a HUUUUGE PR #1417.Most tracked Python files now have trimed tailing whitespaces and ensured a blank line at the end-of-file. I think it's time to enable the pre-commit hook
trailing-whitespaceandend-of-file-fixerin the whole codebase not only.pyfiles.Summary by CodeRabbit
Chores
Style
Documentation
Bug Fixes
✏️ Tip: You can customize this high-level summary in your review settings.