Skip to content

test(linalg): strengthen GPU Kron/Outer coverage (salvaged from #1100)#1108

Open
yingjerkao wants to merge 1 commit into
masterfrom
test/1003-gpu-kron-outer-coverage
Open

test(linalg): strengthen GPU Kron/Outer coverage (salvaged from #1100)#1108
yingjerkao wants to merge 1 commit into
masterfrom
test/1003-gpu-kron-outer-coverage

Conversation

@yingjerkao

Copy link
Copy Markdown
Collaborator

Problem

PR #1100 added stronger GPU Kron/Outer test 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 on master via #1105/#1106, so this PR salvages them.

Fix

Fold #1100's stronger tests into master's existing tests/gpu/linalg_test/{Kron,Outer}_test.cpp, while keeping master's unique regression cases:

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 ran GpuKron.* / GpuOuter.*11/11 passed. clang-format v14 clean.

Supersedes #1100 (which I'm closing in favor of this). Related: #1099 (closed, superseded), #1105, #1106.

🤖 Generated with Claude Code

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>
@gemini-code-assist

Copy link
Copy Markdown
Contributor

Caution

The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased.

@codecov

codecov Bot commented Jul 22, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 73.07%. Comparing base (2d66464) to head (401e4ce).
✅ All tests successful. No failed tests found.

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           
Flag Coverage Δ
cpp 73.19% <ø> (ø)
python 64.13% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Components Coverage Δ
C++ backend 72.55% <ø> (ø)
Python bindings 76.75% <ø> (ø)
Python package 64.13% <ø> (ø)

Continue to review full report in Codecov by Harness.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 2d66464...401e4ce. Read the comment docs.

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Comment on lines +107 to +115
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);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

We can use this tool here

bool AreNearlyEqTensor(const Tensor& T1, const Tensor& T2, const cytnx_double tol = 0);

namespace {

TEST(Outer, GpuRealRectangularShapeAndValues) {
TEST(GpuOuter, DoubleMatchesHandComputed) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Test names are prefixed with Gpu not test suite name.

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