test(linalg): strengthen GPU Kron/Outer coverage (salvaged from #1100)#1108
test(linalg): strengthen GPU Kron/Outer coverage (salvaged from #1100)#1108yingjerkao wants to merge 1 commit into
Conversation
Problem: PR #1100 added more thorough GPU Kron/Outer tests but was stacked on the (now-closed) #1099 branch and functionally superseded by #1105/#1106, so it could not be merged as-is. Fix: fold #1100's stronger tests into master's existing tests/gpu/linalg_test/{Kron,Outer}_test.cpp, keeping master's unique regression cases: - 2-D hand-computed Kron/Outer with fractional and negative values (independent expected values, not a same-path comparison); - complex x complex hand-computed cases; - the ComplexFloat x Double -> ComplexDouble promotion discriminator (#984/#999); - a broad GPU-vs-CPU differential over every real/complex dtype and several shapes (GpuMatchesCpuAllDtypes), with the looser ComplexFloat tolerance at ~1e6-magnitude products (matches Mul_test); - kept master's Int16 hand-computed Kron and the #1099 Int16-diagonal Outer segfault regression guard. Testing: built gpu_test_main (CUDA 13, RTX 4070 Ti SUPER, USE_CUTENSOR=OFF) and ran GpuKron.*/GpuOuter.* -> 11/11 passed. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
|
Caution The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #1108 +/- ##
=======================================
Coverage 73.07% 73.07%
=======================================
Files 224 224
Lines 27643 27643
Branches 71 71
=======================================
Hits 20200 20200
Misses 7422 7422
Partials 21 21
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:
|
| auto near = [&](cytnx_uint64 i, cytnx_uint64 j, double re, double im) { | ||
| auto v = out.at<cytnx_complex128>({i, j}); | ||
| EXPECT_NEAR(v.real(), re, 1e-12) << "real at (" << i << "," << j << ")"; | ||
| EXPECT_NEAR(v.imag(), im, 1e-12) << "imag at (" << i << "," << j << ")"; | ||
| }; | ||
| near(0, 0, -1, 1); | ||
| near(0, 1, 1, 2); | ||
| near(1, 0, 3, 3); | ||
| near(1, 1, 6, -3); |
There was a problem hiding this comment.
We can use this tool here
Cytnx/tests/gpu/gpu_test_tools.h
Line 53 in 3bb3c90
| namespace { | ||
|
|
||
| TEST(Outer, GpuRealRectangularShapeAndValues) { | ||
| TEST(GpuOuter, DoubleMatchesHandComputed) { |
There was a problem hiding this comment.
Test names are prefixed with Gpu not test suite name.
Problem
PR #1100 added stronger GPU
Kron/Outertest coverage, but it was stacked on the (now-closed) #1099 branch and functionally superseded by #1105/#1106 — so it couldn't be merged as-is. Its tests are genuinely more thorough than what landed onmastervia #1105/#1106, so this PR salvages them.Fix
Fold #1100's stronger tests into
master's existingtests/gpu/linalg_test/{Kron,Outer}_test.cpp, while keepingmaster's unique regression cases:Kron/Outerwith fractional and negative values (independent expected values, never a same-path comparison);ComplexFloat × Double → ComplexDoublepromotion discriminator (fix(linalg): replace lower-enum-index dtype selection with Type.type_promote #984/GPU build broken: cuKron fails to compile (CUDA 13) after the #982 type_promote change #999);GpuMatchesCpuAllDtypes), with the looserComplexFloattolerance at ~1e6-magnitude products (matchingMul_test);master's Int16 hand-computedKronand the fix(linalg): register missing Int16/Uint16/Bool rows in CPU Outer dispatch (fixes segfault) #1099 Int16-diagonalOutersegfault regression guard.No production code changes — tests only. Both files are already registered in
tests/gpu/CMakeLists.txt.Testing
Built
gpu_test_main(CUDA 13, RTX 4070 Ti SUPER,USE_CUTENSOR=OFF) and ranGpuKron.*/GpuOuter.*→ 11/11 passed.clang-formatv14 clean.Supersedes #1100 (which I'm closing in favor of this). Related: #1099 (closed, superseded), #1105, #1106.
🤖 Generated with Claude Code