Skip to content

test(svd): align with Paddle compat svd behavior#67

Open
youge325 wants to merge 9 commits into
PFCCLab:masterfrom
youge325:test/svd-20260529
Open

test(svd): align with Paddle compat svd behavior#67
youge325 wants to merge 9 commits into
PFCCLab:masterfrom
youge325:test/svd-20260529

Conversation

@youge325

Copy link
Copy Markdown
Contributor

Add cross-framework comparison tests for at::svd / Tensor::svd to verify Paddle compat layer behavior matches PyTorch.

Test coverage

  • Shape: small(2x3), square(4x4), wide(3x5), large(10x10), batch(2x3x4)
  • Dtype: kFloat, kDouble
  • API variants: at::svd(t), t.svd(), svd(t, some=false), svd(t, compute_uv=false)

Related: PaddlePaddle/Paddle#79187

Copilot AI review requested due to automatic review settings May 29, 2026 08:47

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Adds a cross-framework SVD test that exercises at::svd and Tensor::svd() over a matrix of shapes, dtypes, and API variants, and records the alignment work in the mismatch-API log. The test relies on the existing glob-based CMake harness, so it will be built as both paddle_SvdTest and torch_SvdTest, with results diffed via test/result_cmp.sh. Because SVD outputs are not bit-stable, the test only serializes tensor metadata (dim, numel, sizes, dtype) rather than numeric values.

Changes:

  • New test/ATen/ops/SvdTest.cpp with 11 test cases covering shape, dtype, and API-variant matrix.
  • New "对齐迭代记录(2026-05-29)" section in doc/ATen/ops/mismatch_api_record.md documenting compat-layer mapping and validation.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
test/ATen/ops/SvdTest.cpp New cross-framework SVD test; serializes metadata for U/S/V across shapes, dtypes, and some/compute_uv variants.
doc/ATen/ops/mismatch_api_record.md Adds alignment-iteration record for at::svd / Tensor::svd, listing compat-layer paths, coverage, and validation results.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread test/ATen/ops/SvdTest.cpp
Comment on lines +211 to +220
// 验证 U 和 V 都是零
float u_sum = U.abs().sum().item().template to<float>();
float v_sum = V.abs().sum().item().template to<float>();
bool u_all_zero = u_sum == 0.0f;
bool v_all_zero = v_sum == 0.0f;
file << std::to_string(u_all_zero) << " ";
file << std::to_string(v_all_zero) << " ";
file << "\n";
file.saveFile();
}
Comment thread test/ATen/ops/SvdTest.cpp
Comment on lines +246 to +254
float u_sum = U.abs().sum().item().template to<float>();
float v_sum = V.abs().sum().item().template to<float>();
bool u_all_zero = u_sum == 0.0f;
bool v_all_zero = v_sum == 0.0f;
file << std::to_string(u_all_zero) << " ";
file << std::to_string(v_all_zero) << " ";
file << "\n";
file.saveFile();
}
Comment thread doc/ATen/ops/mismatch_api_record.md Outdated

### 2) 测试覆盖
- 测试文件:`test/ATen/ops/SvdTest.cpp`(PCAT)、`test/cpp/compat/ATen_svd_test.cc`(Paddle compat)
- 新增/修改用例:SvdBasic、SmallMatrix、SquareMatrix、WideMatrix、LargeMatrix、BatchMatrix、Float64Dtype、FullMatrices、NoComputeUv、MethodSvd、FullNoComputeUv
@youge325 youge325 force-pushed the test/svd-20260529 branch 2 times, most recently from 013ef8f to 8bef3b7 Compare June 14, 2026 10:33
@youge325 youge325 force-pushed the test/svd-20260529 branch from 8bef3b7 to c08598c Compare June 28, 2026 20:10
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