Skip to content

Conversation

XuehaiPan
Copy link
Contributor

@XuehaiPan XuehaiPan commented Oct 15, 2025

Summary by CodeRabbit

  • Chores

    • CI now runs clang-tidy on Linux with fresh CMake builds, automatic source discovery, artifact cleanup, improved error reporting (prints diffs, preserves exit codes), dynamic runner selection, and optional automatic fixes.
    • Removed legacy formatting/orchestration script and added CMake build outputs to .gitignore.
    • Bumped clang-format/clang-tidy tool versions and restructured clang-tidy configuration.
  • Style

    • Widespread non-functional formatting, whitespace, and const-reference refinements across the codebase.

Copy link

👋 Hi! Thank you for contributing to the TileLang project.

Please remember to run pre-commit run --all-files in the root directory of the project to ensure your changes are properly linted and formatted. This will help ensure your contribution passes the format check.

We appreciate you taking this step! Our team will review your contribution, and we look forward to your awesome work! 🚀

Copy link
Contributor

coderabbitai bot commented Oct 15, 2025

Walkthrough

Replaces CI format-check with a clang-tidy-driven job (fresh CMake build, discover sources, run run-clang-tidy/clang-tidy with optional auto-fix, print git diff on failure), adds cmake-build to .gitignore, removes legacy format.sh, restructures .clang-tidy, bumps clang tooling versions, and applies many small formatting and const-ref binding tweaks across sources.

Changes

Cohort / File(s) Summary
CI workflow: clang-tidy job
.github/workflows/ci.yml
Replaces prior format-check with a Linux-focused clang-tidy job: prepares LLVM if needed, runs cmake -S . -B cmake-build --fresh with CLANG_TIDY_CMAKE_OPTIONS, discovers C/C++ sources under src, uses run-clang-tidy when available or downloads run-clang-tidy.py (invoked via uv), enables --fix when clang-apply-replacements exists, invokes clang-tidy with -clang-tidy-binary and -p cmake-build, prints git diff on non-zero exit, and removes artifacts after run.
VCS ignores for CMake artifacts
.gitignore
Adds cmake-build/ and cmake-build-*/ to ignore CMake build outputs.
Remove legacy formatting/lint orchestration
format.sh
Deletes the monolithic format/lint orchestration script that handled yapf/ruff/codespell/clang-format/clang-tidy and change-file selection logic.
clang-tidy configuration restructure
.clang-tidy
Converts flat Checks: layout into a structured YAML header (adds InheritParentConfig, ExtraArgs, FormatStyle, UseColor, WarningsAsErrors, ExcludeHeaderFilterRegex) and moves Checks into its own block while preserving enabled checks.
Tooling versions / pre-commit
requirements-lint.txt, .pre-commit-config.yaml
Bumps clang-format/clang-tidy versions and updates pre-commit clang-format mirror revision.
Formatting, style tweaks & const-ref bindings
src/...
Many small, local edits: spacing/initializer formatting, macro spacing, bitfield reflow, added NOLINT annotations, switching some local by-value bindings to const &, minor container reserve/emplace usage. Affected files include src/op/gemm.cc, src/op/parallel.h, src/target/codegen_cuda.cc, src/target/cuda.h, src/tl_templates/cpp/half.hpp, src/tl_templates/cuda/common.h, src/transform/cluster_planning.cc, src/transform/common/loop_fusion_utils.h, src/transform/layout_inference.cc, src/runtime/runtime.cc, src/target/codegen_webgpu.cc, src/transform/layout_reducer.cc, src/transform/lower_thread_allreduce.cc, src/transform/storage_access.cc, src/transform/warp_specialized_rewriter.cc, src/layout/utils.cc, src/transform/make_packed_api.cc.

Sequence Diagram(s)

sequenceDiagram
    autonumber
    actor Dev as Developer
    participant GH as GitHub Actions
    participant Job as CI Job
    participant CMake as CMake (cmake-build)
    participant Wrapper as run-clang-tidy / wrapper
    participant Tidy as clang-tidy
    participant Git as git

    Dev->>GH: push / open PR
    GH->>Job: start workflow
    Job->>Job: prepare env (install LLVM if needed)
    Job->>CMake: cmake -S . -B cmake-build --fresh
    Job->>Job: discover C/C++ sources under src/
    alt run-clang-tidy present
        Job->>Wrapper: run-clang-tidy -clang-tidy-binary ... -p cmake-build <files> [--fix]
    else download wrapper
        Job->>Job: download run-clang-tidy.py
        Job->>Wrapper: python run-clang-tidy.py -clang-tidy-binary ... -p cmake-build <files> [--fix]
    end
    opt clang-tidy failure
        Wrapper->>Git: git --no-pager diff --color=always
        Job-->>GH: fail with clang-tidy exit code
    end
    Job->>Job: cleanup cmake-build/ and run-clang-tidy.py
    Job-->>GH: finish
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related PRs

Suggested reviewers

  • chengyupku
  • xysmlx

Poem

I hop where build dirs once did lie,
clang-tidy hums beneath the sky,
old script gone, new checks align,
I nibble diffs and mark each line,
tidy rabbit hops — code looks fine. 🐇

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The PR title "[CI][Lint] Retire format.sh and add clang-tidy to GHA workflow" accurately reflects the primary changes in this changeset. The two main modifications are: (1) removal of the entire format.sh script that previously orchestrated multi-tool formatting and linting, and (2) integration of clang-tidy checks into the GitHub Actions workflow for Linux runners. While the PR includes secondary changes like source code formatting updates, .clang-tidy configuration restructuring, and version bumps, these are consequences of or supporting changes for the core infrastructure migration. The title is specific, clear, and appropriately scoped to convey the main objective to developers reviewing the commit history.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 94abe23 and 8c7ce10.

📒 Files selected for processing (1)
  • src/transform/layout_inference.cc (3 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/transform/layout_inference.cc
⏰ 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). (3)
  • GitHub Check: Test for Python 3.12 with CUDA-12.8 (on self-hosted-nvidia)
  • GitHub Check: Test for Python 3.12 with ROCm-6.3 (on self-hosted-amd)
  • GitHub Check: Test for Python 3.12 with Metal (on macos-latest)

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 8ce2778 and 6ab0d66.

📒 Files selected for processing (3)
  • .github/workflows/ci.yml (1 hunks)
  • .gitignore (1 hunks)
  • format.sh (0 hunks)
💤 Files with no reviewable changes (1)
  • format.sh

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
.clang-tidy (1)

10-58: Checks block includes inline comments; clang-tidy will treat them as unknown check names

Lines starting with “# …” are part of the folded string, not YAML comments. clang-tidy will parse them as tokens and likely fail. Remove the comment lines from within the Checks string (keep comments outside the scalar).

Apply this diff:

 Checks: >-
-  # 1. Retained categories: easier to find bugs/performance issues
   clang-analyzer-*,
   cppcoreguidelines-pro-type-static-cast-downcast,
   cppcoreguidelines-pro-type-member-init,
   cppcoreguidelines-pro-bounds-array-to-pointer-decay,
   cppcoreguidelines-pro-bounds-pointer-arithmetic,
   cppcoreguidelines-slicing,
   cppcoreguidelines-narrowing-conversions,
   performance-*,
-
-  # 2. Readability: only keep useful rules
   readability-braces-around-statements,
   readability-container-size-empty,
   readability-delete-null-pointer,
   readability-redundant-member-init,
   readability-redundant-smartptr-get,
   readability-redundant-string-cstr,
-
-  # 3. Disable all intrusive/style-breaking rules
   -readability-identifier-length,
   -readability-avoid-const-params-in-decls,
   -readability-else-after-return,
   -cppcoreguidelines-avoid-magic-numbers,
   -modernize-use-trailing-return-type,
   -modernize-use-nodiscard,
   -modernize-use-auto,
   -modernize-pass-by-value,
   -modernize-return-braced-init-list,
   -modernize-use-default-member-init,
   -modernize-loop-convert,
   -modernize-concat-nested-namespaces,
   -llvm-include-order,
   -bugprone-unused-return-value,
   -clang-diagnostic-unused-result,
   -cppcoreguidelines-special-member-functions,
   -performance-noexcept-move-constructor,
   -cppcoreguidelines-narrowing-conversions,
   -clang-diagnostic-error,
   -cppcoreguidelines-pro-type-member-init,
   -clang-analyzer-optin.cplusplus.UninitializedObject,
   -cppcoreguidelines-pro-type-static-cast-downcast,
   -performance-unnecessary-value-param,
   -performance-enum-size,
   -cppcoreguidelines-pro-bounds-pointer-arithmetic,
   -cppcoreguidelines-pro-bounds-array-to-pointer-decay,
   -clang-analyzer-deadcode.DeadStores,
   -clang-analyzer-optin.cplusplus.VirtualCall,
   -clang-diagnostic-tautological-constant-compare,
🧹 Nitpick comments (4)
.clang-tidy (4)

49-51: Conflicting toggles disable key safety checks

You enable these earlier but later disable them; last-match-wins means they end up disabled:

  • cppcoreguidelines-pro-type-member-init (Line 49)
  • cppcoreguidelines-pro-type-static-cast-downcast (Line 51)
  • cppcoreguidelines-narrowing-conversions (Line 47)

Is this intentional? If not, drop the later “-…” entries.


7-7: HeaderFilterRegex is too broad; may exclude legitimate paths containing “build”

Pattern excludes any path with substring “build” (e.g., src/builders/…). Prefer segment-based exclusion and the actual build dir name.

Apply this tweak:

-HeaderFilterRegex: '^(?!.*(3rdparty|build)).*$'
+HeaderFilterRegex: '^(?!.*(?:^|/)(?:3rdparty|cmake-build)(?:/|$)).*$'

6-6: WarningsAsErrors: "*" will fail CI on any warning

Good for strictness, but brittle for large diffs and third‑party headers that slip through. Confirm this is intended now that format.sh is retired.

Option: narrow to high-signal checks (e.g., “clang-analyzer-,performance-”) or gate via CI env to allow temporary soft-fail.


3-3: ExtraArgs: ['-v'] increases CI noise

Verbose compilation output can flood logs. Consider dropping “-v” unless needed for debugging.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 6ab0d66 and 9d915d2.

📒 Files selected for processing (2)
  • .clang-tidy (1 hunks)
  • .github/workflows/ci.yml (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • .github/workflows/ci.yml

@XuehaiPan XuehaiPan changed the title [Lint] Retire format.sh and add clang-tidy to GHA workflow [CI][Lint] Retire format.sh and add clang-tidy to GHA workflow Oct 15, 2025
@XuehaiPan XuehaiPan force-pushed the retire-format-sh branch 5 times, most recently from b7fbeb0 to b4b454d Compare October 15, 2025 16:39
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

♻️ Duplicate comments (1)
.github/workflows/ci.yml (1)

320-324: Restrict clang-tidy inputs to translation units from compile_commands.json (and add parallelism).

Current find:

  • Includes headers and misses proper grouping, risking false positives and failures.
  • Prior review already flagged headers in the list causing clang-tidy errors. Use compile_commands.json instead and parallelize runs.
-          CXX_FILES=$(find src -type f -iname "*.[ch]pp" -o -iname "*.cc" -o -iname "*.c" -o -iname "*.h")
-          rc=0
-          "${CLANG_TIDY[@]}" -clang-tidy-binary="$(command -v clang-tidy)" \
-            -p="cmake-build" ${CXX_FILES} || rc="$?"
+          # Extract translation units from compile_commands.json (exclude headers)
+          mapfile -t CXX_FILES < <(jq -r '.[].file' cmake-build/compile_commands.json | \
+            awk '/\.(c|cc|cpp|cxx|cu|m|mm)$/ {print}' | sort -u)
+          if (( ${#CXX_FILES[@]} == 0 )); then
+            echo "::warning::No translation units found in compile_commands.json; skipping clang-tidy."
+            exit 0
+          fi
+          # Determine reasonable parallelism
+          if command -v nproc >/dev/null; then JOBS="$(nproc)"; else JOBS="$(sysctl -n hw.ncpu 2>/dev/null || echo 2)"; fi
+          rc=0
+          "${CLANG_TIDY[@]}" -j "${JOBS}" -clang-tidy-binary="$(command -v clang-tidy)" \
+            -p="cmake-build" "${CXX_FILES[@]}" || rc="$?"

If jq may be missing on some self-hosted runners, consider adding a minimal jq install or a small Python fallback. Based on learnings

🧹 Nitpick comments (2)
.github/workflows/ci.yml (2)

229-239: Guard Homebrew ops and export only if brew exists (Metal runners).

On non-GitHub-hosted/mac runners without Homebrew, these commands will fail. Add a guard and quieter install.

-          brew update --quiet --force
-          brew list --formula llvm >/dev/null || brew install --formula llvm
-          export PATH="$(brew --prefix llvm)/bin:${PATH}"
-          export CPPFLAGS="-I$(brew --prefix llvm)/include${CPPFLAGS:+ ${CPPFLAGS}}"
+          if command -v brew >/dev/null; then
+            brew update --quiet --force
+            brew list --formula llvm >/dev/null || brew install --quiet --formula llvm
+            export PATH="$(brew --prefix llvm)/bin:${PATH}"
+            export CPPFLAGS="-I$(brew --prefix llvm)/include${CPPFLAGS:+ ${CPPFLAGS}}"
+          else
+            echo "::warning::Homebrew not found; relying on system LLVM/clang-tidy."
+          fi

302-315: Match run-clang-tidy version to clang-tidy and avoid duplicate -fix.

  • Hardcoded 20.x may mismatch installed clang-tidy and cause option/diagnostic drift.
  • You append -fix twice when run-clang-tidy is present.
-          if [[ -x "$(command -v run-clang-tidy)" ]]; then
-            echo "Using run-clang-tidy from $(command -v run-clang-tidy)"
-            CLANG_TIDY=(run-clang-tidy -fix)
-          else
-            echo "Downloading run-clang-tidy script"
-            wget -O run-clang-tidy.py https://raw.githubusercontent.com/llvm/llvm-project/refs/heads/release/20.x/clang-tools-extra/clang-tidy/tool/run-clang-tidy.py
-            CLANG_TIDY=(uv run --no-project --script -- run-clang-tidy.py)
-          fi
-          if [[ -x "$(command -v clang-apply-replacements)" ]]; then
-            echo "Using clang-apply-replacements from $(command -v clang-apply-replacements)"
-            CLANG_TIDY+=(-fix -clang-apply-replacements-binary="$(command -v clang-apply-replacements)")
-          else
-            echo "::warning::clang-apply-replacements not found in PATH, automatic fixing disabled."
-          fi
+          if [[ -x "$(command -v run-clang-tidy)" ]]; then
+            echo "Using run-clang-tidy from $(command -v run-clang-tidy)"
+            CLANG_TIDY=(run-clang-tidy)
+          else
+            echo "Downloading run-clang-tidy script"
+            LLVM_MAJOR="$(clang-tidy --version | sed -nE 's/.*version ([0-9]+).*/\1/p')"
+            LLVM_BRANCH="release/${LLVM_MAJOR}.x"
+            curl -fsSL -o run-clang-tidy.py "https://raw.githubusercontent.com/llvm/llvm-project/refs/heads/${LLVM_BRANCH}/clang-tools-extra/clang-tidy/tool/run-clang-tidy.py"
+            CLANG_TIDY=(uv run --no-project --script -- run-clang-tidy.py)
+          fi
+          if [[ -x "$(command -v clang-apply-replacements)" ]]; then
+            echo "Using clang-apply-replacements from $(command -v clang-apply-replacements)"
+            CLANG_TIDY+=(-fix -clang-apply-replacements-binary="$(command -v clang-apply-replacements)")
+          else
+            echo "::warning::clang-apply-replacements not found in PATH, automatic fixing disabled."
+          fi
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between b7fbeb0 and b4b454d.

📒 Files selected for processing (1)
  • .github/workflows/ci.yml (2 hunks)
⏰ 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). (2)
  • GitHub Check: Test for Python 3.12 with Nightly-ROCm-7.0 (on self-hosted-amd)
  • GitHub Check: Test for Python 3.12 with Metal (on macos-latest)

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

♻️ Duplicate comments (2)
.github/workflows/ci.yml (2)

322-324: Gate cmake --fresh behind a capability check.

Older CMake releases (common on self-hosted runners) do not recognize --fresh, so this step will fail before we obtain compile_commands.json. Fall back to rm -rf cmake-build && cmake … when --fresh is unavailable.

Suggested change:

-          cmake -S . -B cmake-build --fresh ${CLANG_TIDY_CMAKE_OPTIONS}  # no quotes here
+          if cmake --help 2>/dev/null | grep -q -- '--fresh'; then
+            cmake -S . -B cmake-build --fresh ${CLANG_TIDY_CMAKE_OPTIONS}  # no quotes here
+          else
+            rm -rf cmake-build
+            cmake -S . -B cmake-build ${CLANG_TIDY_CMAKE_OPTIONS}  # no quotes here
+          fi

325-329: Only feed translation units to clang-tidy.

The current find includes headers (*.h, *.hpp) that have no compile command; clang-tidy exits with “Error while processing…” and the workflow fails. Extract the translation units listed in compile_commands.json (e.g., .c, .cc, .cpp, .cxx, .cu) instead of scanning headers.

One option:

-          CXX_FILES=$(find src -type f -iname "*.[ch]pp" -o -iname "*.cc" -o -iname "*.c" -o -iname "*.h")
-          "${CLANG_TIDY[@]}" -clang-tidy-binary="$(command -v clang-tidy)" \
-            -p="cmake-build" ${CXX_FILES} || rc="$?"
+          mapfile -t CXX_FILES < <(python - <<'PY'
+import json, os
+with open("cmake-build/compile_commands.json") as fh:
+    seen = []
+    exts = {".c", ".cc", ".cpp", ".cxx", ".cu"}
+    for entry in json.load(fh):
+        path = entry["file"]
+        if os.path.splitext(path)[1] in exts and path not in seen:
+            seen.append(path)
+for path in seen:
+    print(path)
+PY
+)
+          if ((${#CXX_FILES[@]} == 0)); then
+            echo "::error::No translation units found in compile_commands.json"
+            exit 1
+          fi
+          "${CLANG_TIDY[@]}" -clang-tidy-binary="$(command -v clang-tidy)" \
+            -p="cmake-build" "${CXX_FILES[@]}" || rc="$?"
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between b4b454d and 0cfe663.

📒 Files selected for processing (1)
  • .github/workflows/ci.yml (2 hunks)
⏰ 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). (3)
  • GitHub Check: Test for Python 3.12 with CUDA-12.8 (on self-hosted-nvidia)
  • GitHub Check: Test for Python 3.12 with Nightly-ROCm-7.0 (on self-hosted-amd)
  • GitHub Check: Test for Python 3.12 with Metal (on macos-latest)

@XuehaiPan XuehaiPan force-pushed the retire-format-sh branch 2 times, most recently from 138457d to 23a43a4 Compare October 16, 2025 05:01
Copy link
Contributor

@coderabbitai coderabbitai bot left a 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

♻️ Duplicate comments (2)
.github/workflows/ci.yml (2)

323-323: Add fallback for older CMake when --fresh is unsupported.

-          cmake -S . -B cmake-build --fresh ${CLANG_TIDY_CMAKE_OPTIONS}  # no quotes here
+          if cmake --help 2>/dev/null | grep -q -- '--fresh'; then
+            cmake -S . -B cmake-build --fresh ${CLANG_TIDY_CMAKE_OPTIONS}  # no quotes here
+          else
+            rm -rf cmake-build
+            cmake -S . -B cmake-build ${CLANG_TIDY_CMAKE_OPTIONS}  # no quotes here
+          fi

Based on past review comment.


325-325: Restrict clang-tidy inputs to translation units (exclude headers).

Feeding headers that lack compile commands causes clang-tidy to error. Use only TU extensions.

-          CXX_FILES=$(find src -type f -iname "*.[ch]pp" -o -iname "*.cc" -o -iname "*.c" -o -iname "*.h")
+          CXX_FILES=$(find src -type f \( -iname "*.c" -o -iname "*.cc" -o -iname "*.cpp" -o -iname "*.cxx" \))

(Optional: extract from compile_commands.json for exact TUs.)

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 138457d and 23a43a4.

📒 Files selected for processing (1)
  • .github/workflows/ci.yml (2 hunks)

@XuehaiPan XuehaiPan force-pushed the retire-format-sh branch 3 times, most recently from 1a76e51 to 743b42b Compare October 16, 2025 10:03
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
.clang-tidy (1)

10-58: Resolve conflicting enable/disable checks to avoid ambiguity.

You enable several checks and later disable the same ones. Order-dependent outcomes are brittle. Remove duplicates so intent is clear.

Apply:

   # 1. Retained categories: easier to find bugs/performance issues
   clang-analyzer-*,
-  cppcoreguidelines-pro-type-static-cast-downcast,
-  cppcoreguidelines-pro-type-member-init,
-  cppcoreguidelines-pro-bounds-array-to-pointer-decay,
-  cppcoreguidelines-pro-bounds-pointer-arithmetic,
   cppcoreguidelines-slicing,
-  cppcoreguidelines-narrowing-conversions,
   performance-*,

This keeps the explicit disables below authoritative and removes contradictions.

♻️ Duplicate comments (2)
.github/workflows/ci.yml (2)

313-313: Add fallback when cmake --fresh is unavailable.

Self-hosted runners may have CMake < 3.24; --fresh will fail and break the job. Add a capability check and fallback.

Apply:

-          cmake -S . -B cmake-build --fresh ${CLANG_TIDY_CMAKE_OPTIONS}  # no quotes here
+          if cmake --help 2>/dev/null | grep -q -- '--fresh'; then
+            cmake -S . -B cmake-build --fresh ${CLANG_TIDY_CMAKE_OPTIONS}  # no quotes here
+          else
+            rm -rf cmake-build
+            cmake -S . -B cmake-build ${CLANG_TIDY_CMAKE_OPTIONS}  # no quotes here
+          fi

315-319: Don’t feed headers to clang-tidy; use compile_commands.json (prevents failures and ARG_MAX issues).

Passing *.h/*.hpp causes “Error while processing …” for headers without compile commands and risks long arg lists. Let run-clang-tidy enumerate TUs from -p instead.

Preferred:

-          CXX_FILES=$(find src -type f -iname "*.[ch]pp" -o -iname "*.cc" -o -iname "*.c" -o -iname "*.h")
-          rc=0
-          "${CLANG_TIDY[@]}" -clang-tidy-binary="$(command -v clang-tidy)" \
-            -p="cmake-build" ${CXX_FILES} || rc="$?"
+          rc=0
+          # Let run-clang-tidy traverse all translation units from compile_commands.json
+          "${CLANG_TIDY[@]}" -clang-tidy-binary="$(command -v clang-tidy)" -p="cmake-build" || rc="$?"

If you must pass files, at least restrict to TUs:

-          CXX_FILES=$(find src -type f -iname "*.[ch]pp" -o -iname "*.cc" -o -iname "*.c" -o -iname "*.h")
+          CXX_FILES=$(find src -type f \( -iname "*.c" -o -iname "*.cc" -o -iname "*.cpp" -o -iname "*.cxx" \))
🧹 Nitpick comments (1)
.github/workflows/ci.yml (1)

320-323: Improve failure hint for local reproduction.

Recommend the exact repro command users should run.

-            echo "::error::clang-tidy found issues (exit code: ${rc}). Please run 'clang-tidy --fix' locally to fix them."
+            echo "::error::clang-tidy found issues (exit code: ${rc}). Reproduce locally with:"
+            echo "  cmake -S . -B cmake-build -DCMAKE_EXPORT_COMPILE_COMMANDS=ON"
+            echo "  run-clang-tidy -p cmake-build -fix -clang-apply-replacements-binary=\$(command -v clang-apply-replacements)"
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 743b42b and dfd1c30.

📒 Files selected for processing (23)
  • .clang-tidy (1 hunks)
  • .github/workflows/ci.yml (2 hunks)
  • .gitignore (1 hunks)
  • .pre-commit-config.yaml (1 hunks)
  • format.sh (0 hunks)
  • requirements-lint.txt (1 hunks)
  • src/layout/utils.cc (1 hunks)
  • src/op/gemm.cc (1 hunks)
  • src/op/parallel.h (1 hunks)
  • src/runtime/runtime.cc (1 hunks)
  • src/target/codegen_cuda.cc (1 hunks)
  • src/target/codegen_webgpu.cc (1 hunks)
  • src/target/cuda.h (1 hunks)
  • src/tl_templates/cpp/half.hpp (2 hunks)
  • src/tl_templates/cuda/common.h (1 hunks)
  • src/transform/cluster_planning.cc (1 hunks)
  • src/transform/common/loop_fusion_utils.h (1 hunks)
  • src/transform/layout_inference.cc (3 hunks)
  • src/transform/layout_reducer.cc (1 hunks)
  • src/transform/lower_thread_allreduce.cc (4 hunks)
  • src/transform/make_packed_api.cc (1 hunks)
  • src/transform/storage_access.cc (1 hunks)
  • src/transform/warp_specialized_rewriter.cc (4 hunks)
💤 Files with no reviewable changes (1)
  • format.sh
✅ Files skipped from review due to trivial changes (4)
  • src/transform/common/loop_fusion_utils.h
  • src/layout/utils.cc
  • src/op/parallel.h
  • requirements-lint.txt
🚧 Files skipped from review as they are similar to previous changes (12)
  • src/runtime/runtime.cc
  • src/transform/layout_reducer.cc
  • src/transform/cluster_planning.cc
  • src/op/gemm.cc
  • src/tl_templates/cpp/half.hpp
  • src/transform/storage_access.cc
  • src/target/codegen_webgpu.cc
  • .pre-commit-config.yaml
  • .gitignore
  • src/transform/layout_inference.cc
  • src/target/codegen_cuda.cc
  • src/tl_templates/cuda/common.h
⏰ 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). (3)
  • GitHub Check: Test for Python 3.12 with Nightly-ROCm-7.0 (on self-hosted-amd)
  • GitHub Check: Test for Python 3.12 with CUDA-12.8 (on self-hosted-nvidia)
  • GitHub Check: Test for Python 3.12 with Metal (on macos-latest)
🔇 Additional comments (10)
src/target/cuda.h (1)

5026-5031: LGTM! Formatting improvements from clang-tidy.

The spacing around the binary minus operator now aligns with standard C/C++ formatting conventions. These changes are purely stylistic with no functional impact.

src/transform/make_packed_api.cc (1)

480-480: LGTM: Efficient binding avoids copy.

Binding opt.value() as a const reference instead of copying is appropriate here, as the prim_func is only read in the subsequent call to RequiresPackedAPI.

src/transform/lower_thread_allreduce.cc (2)

499-501: LGTM: Preallocating and constructing in place.

Reserving capacity upfront and using emplace_back instead of push_back are solid optimizations that avoid unnecessary reallocations and temporary object creation.


608-608: LGTM: Const reference bindings eliminate copies.

Binding shared_bufs[i] and local_bufs[i] as const references instead of by value avoids unnecessary Buffer copies. These variables are only read in subsequent operations, so const ref is both safe and efficient.

Also applies to: 627-627, 643-643

src/transform/warp_specialized_rewriter.cc (4)

533-537: LGTM - Appropriate clang-tidy suppression.

The ternary expression preserves the original semantics, and the NOLINTNEXTLINE suppression for performance-move-const-arg is appropriate here. The move is valid since block_stmt is not const and won't be used after constructing the SeqStmt.


701-706: LGTM - Consistent pattern.

This change follows the same pattern as line 533, correctly preserving semantics while addressing clang-tidy formatting requirements.


740-745: LGTM.

Consistent application of the ternary pattern with appropriate suppression.


774-778: LGTM - Formatting update complete.

Final instance of the consistent ternary pattern. All changes in this file are localized, preserve semantics, and appropriately integrate clang-tidy requirements.

.github/workflows/ci.yml (1)

297-310: Good: gate -fix behind clang-apply-replacements.

Initialization no longer pre-seeds -fix and only adds it when the replacement tool exists. This avoids failures and duplication.

.clang-tidy (1)

2-7: Verify ExcludeHeaderFilterRegex support in CI clang-tidy
The sandbox lacked clang-tidy, so confirm your CI runner’s version recognizes ExcludeHeaderFilterRegex. If not, replace with a compatible HeaderFilterRegex:

-ExcludeHeaderFilterRegex: '^(3rdparty|tvm)/.*$'
+HeaderFilterRegex: '^(?!3rdparty/|tvm/).*$'

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

would be better to maintain format.p referable, as it is more convenient though provides similar functionality to pre-commit. Developers should not be forced to install pre-commit when they're developing; instead, we could modify the content of format.sh to install and run pre-commit directly.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about moving format.sh as a Makefile with the following target (Unix-like systems always have make executable):

make format

We can add more targets like:

make install
make docs
make test
make clang-tidy
make clean
...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I opened a new PR to resolve this.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants