Skip to content

[BugFix][Profiler] Use the current CUDA device when no device is specified - #3357

Merged
LeiWang1999 merged 4 commits into
tile-ai:mainfrom
Afloat16:fix/implicit-profiler-device
Oct 27, 2026
Merged

LeiWang1999 merged 4 commits into
tile-ai:mainfrom
Afloat16:fix/implicit-profiler-device

Conversation

@Afloat16

@Afloat16 Afloat16 commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

When the current CUDA device is nonzero and do_bench receives no explicit device, _cache_device(None) uses the module's cuda:0 default. The cache-flush allocation can therefore target a different GPU from the benchmarked work.

Use the unindexed "cuda" default so PyTorch resolves the active device when the buffer is allocated. Explicit device selection and the NPU/MPS defaults are preserved. The current diff is one line; the earlier standalone host tests were removed during maintainer revision.

Validation:

  • Upstream CI run 37915443170 completed successfully for head 971c4c4: Quick Lint, CUDA, ROCm, Metal, Ascend, and CuTeDSL examples.
  • The later pull-request runs require maintainer approval and have not executed tests.

No local CUDA hardware or timing benchmarks were run.

do_bench now uses "cuda" as its default device string when CUDA is available. This allows the current CUDA device to be resolved at each call. The NPU and MPS defaults remain unchanged.

No test results or formatting checks are established by the supplied repository evidence. The change does not touch C++, CI, lint tooling, or C++ style documentation.

@github-actions

github-actions Bot commented Oct 1, 2026

Copy link
Copy Markdown

👋 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! 🚀

@coderabbitai

coderabbitai Bot commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository: tile-ai/tilelang/.coderabbit.yaml
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 23946a9a-1ae5-40bf-a297-eaf477441a11
📥 Commits

Reviewing files that changed from the base of the PR and between 75660b9 and 971c4c4.

📒 Files selected for processing (1)
  • tilelang/profiler/bench.py

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review.

📝 Walkthrough

The benchmark code now uses "cuda" instead of "cuda:0" as its default device string when CUDA is available. The NPU and MPS defaults are unchanged.

Changes: Benchmark device default

Layer / File(s) Summary
Default benchmark device
tilelang/profiler/bench.py
The default CUDA device string changes from "cuda:0" to "cuda". NPU and MPS defaults remain unchanged.

Priority: ⬇️ Low

Estimated code review effort: 1 (Trivial) | ~3 minutes

Change: Bug fix

Merge Risk: ⚪ Minimal · up to 971c4

When the device is omitted, benchmark resources now follow the active CUDA device; explicit selection and non-CUDA defaults are preserved. No material merge risk is established.

Pre-merge checks: Passed 5
Check name Status Explanation
Docstring Coverage Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 7 functions across 2 files.
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title clearly and concisely describes the main change: using the current CUDA device when no device is specified in the profiler.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Autopilot is currently an internal CodeRabbit preview.

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.

Afloat16 commented Oct 1, 2026

Copy link
Copy Markdown
Contributor Author

Added docstrings for the touched helper and test methods in 7c99e7e. All five host regression tests and the targeted formatting checks pass.

@Afloat16 Afloat16 changed the title [BugFix][Profiler] Flush the current CUDA device when no device is specified [BugFix][Profiler] Use the current CUDA device when no device is specified Oct 1, 2026
SiriusNEO
SiriusNEO previously approved these changes Oct 9, 2026
@SiriusNEO SiriusNEO added bug Something isn't working python Pull requests that update python code labels Oct 15, 2026
@LeiWang1999
LeiWang1999 merged commit 004b7a2 into tile-ai:main Oct 27, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working python Pull requests that update python code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants