Repository navigation
Conversation
…MemcpyAsync cuGetElems_contiguous_kernel and the (cd, cd) and (cf, cf) overloads of cuSetElems_conti_gpu_kernel copied each unit with a device-side cudaMemcpyAsync, one dynamic-parallelism child launch per kernel thread, and discarded its return value. The device runtime holds at most cudaLimitDevRuntimePendingLaunchCount (default 2048) pending launches, so a call selecting more units silently left a random subset uncopied and occasionally never returned. Copy the unit with a plain loop, as the other cuSetElems overloads already do. Add GPU regression tests for get and complex set of 30000 single-element units. Fixes #1229 Co-Authored-By: Claude <noreply@anthropic.com>
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 201aa14c0b
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #1230 +/- ##
=======================================
Coverage 69.43% 69.43%
=======================================
Files 209 209
Lines 22614 22614
Branches 72 72
=======================================
Hits 15701 15701
Misses 6891 6891
Partials 22 22
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report in Codecov by Harness.
🚀 New features to boost your workflow:
|
The counters added for #1229 are plain loop indices, not dtype-backed values, so they take a standard type per AGENTS.md. Neighbouring pre-existing loops are left as they are. Co-Authored-By: Claude <noreply@anthropic.com>
|
@ianmccul Pleaase help to review tihs. |
|
The fix looks correct. One device-side Two cheap follow-ups:
|
Add a domain gotcha recording the cause of #1229, as suggested in review: the get/set kernels were a line-by-line port of a CPU memcpy, a mistake that is easy to repeat. Co-Authored-By: Claude <noreply@anthropic.com>
|
Posted by Claude Code on behalf of @pcchen Thanks for the review.
Agreed as well that the general GPU get/set path cost is out of scope here. |
We enable LTO now, so those two flag may need to be enabled to generate SASS for multiple sm. I have forgot the context. However, #1171 mentions these two flags. @pcchen for verifying this before making the change. |
Posted by Claude Code on behalf of @pcchen
Fixes #1229.
Problem
cuGetElems_contiguous_kerneland the(cd, cd)and(cf, cf)overloads ofcuSetElems_conti_gpu_kernelcopied each selected unit with a device-sidecudaMemcpyAsync, which is one CUDA dynamic-parallelism child launch per kernel thread, and discarded its return value. The device runtime holds at mostcudaLimitDevRuntimePendingLaunchCount(default 2048) pending launches. A GPUTensor::get, or a complexTensor::set, selecting more units than that therefore:cudaFree), which is the intermittent hang oflinalg_Test.GpuBkUtSvdTruncate1/2.Details and the Cytnx-free reproducer results are in #1229.
Fix
Copy the unit with a plain loop inside the kernel, as the other
cuSetElems_conti_gpu_kerneloverloads already do. No element selection or arithmetic changes; only how the bytes are moved. After this change nothing insrc/uses device-side launches.Two regression tests in
tests/gpu/Tensor_test.cpp(TensorGetSetManyElements.*): GPUgetand complex GPUsetof 30000 single-element units, checked against independently computed values.Testing
GPU builds with
-DUSE_CUTENSOR=OFF -DUSE_CUQUANTUM=OFF. "Unpatched" is the same tree with the two kernel files reverted.Tesla V100, CUDA 12.9:
GpuBkUtSvdTruncate*looped as fresh processesgpu_test_main(ateade1422plus this change)masterf9e1027: new testsmasterf9e1027:GpuBkUtSvdTruncate*plus new tests, looped 200 timesmasterf9e1027: fullgpu_test_mainmasterc7fda0a(8de452f): fullgpu_test_mainThe 2 tests excluded from the full run at
f9e1027areGesvdTruncate.GpuFlagCombinationsandRsvd.GpuFlagCombinations. At that base each ended the test process withCUSOLVER_STATUS_EXECUTION_FAILEDfromcusolverDnDgesvdj, with or without this change. That was #1102, fixed by #1228, which has since merged: at the current branch head both tests pass on the V100 (5 of 5 runs each) and nothing is excluded from the full run.GeForce MX450 2 GB (sm_75), CUDA 13.2, first commit on
f9e1027, 95 Tensor/Accessor/SVD/linalg tests run one process each:GpuBkUtSvdTruncate*looped 100 timesThe 2 failures on the MX450 are the same two
gesvdjtests (#1102). Withmasterc7fda0athey pass there too (3 of 3 runs each, checked with the get/set kernels unpatched).The second commit (
std::uint64_tloop counters, from review) was rebuilt on the V100 only: 33 Tensor/Accessor get/set tests pass and 60 looped SVD-truncate runs gave 0 hangs.Not tested: a Cytnx build on the A100 (only the standalone reproducer in #1229 was run there), and performance of GPU
get/set; no speed claim is made. CPU builds do not compile the changed files.pre-commit(clang-format v14) passes on the changed files.🤖 Generated with Claude Code