test: compare H(R)/S(R) CSR outputs by matrix values - #7880
Open
GenZeal-Lin wants to merge 1 commit into
Open
Conversation
GenZeal-Lin
force-pushed
the
fix/nao-gpu-csr-output-pr2
branch
from
August 29, 2026 16:19
643bacd to
d9594e9
Compare
Collaborator
|
I want to comment on the PR you submitted. This is actually a very interesting issue — the GPU produces a few extra terms. Your current approach makes the tests pass, but a more thorough solution would be to investigate where exactly those extra 8/2 terms on the GPU come from, and why the CPU doesn't have them. A difference on the order of 10⁻¹⁰ isn't purely numerical error; it could be a subtle bug. |
mohanchen
self-requested a review
August 31, 2026 07:51
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR makes the integration-test comparison of ASCII H(R)/S(R) CSR outputs aware of sparse-matrix semantics.
CPU and GPU calculations can produce different CSR sparsity patterns for numerically near-zero matrix elements. The previous generic file comparison rejects such outputs when the NNZ / CSR layout differs, even when the actual matrix-value difference is well below the configured test tolerance.
This PR:
scf_out_hsr_spin4andnscf_out_hsr_tr_rrin CUDA CI.Addresses #7860.
Problem
For
nscf_out_hsr_tr_rr, the same CUDA-enabled ABACUS binary produces:The two GPU-only entries are approximately
4.83e-10.The integration test uses an accuracy of 8 (
1e-8), so these entries are numerically within the existing tolerance.However,
CompareFile.pycompares the serialized CSR representation and fails immediately on the NNZ difference:Therefore, numerically equivalent sparse matrices can fail the test only because their storage layouts differ.
Changes
A new
compare_hsr_csr.pycomparator:(row, column);catch_properties.shnow uses this comparator for ASCII H(R)/S(R) outputs instead of the generic token-by-token file comparator.The existing numerical tolerance is unchanged.
Validation
On an NVIDIA GeForce RTX 4090:
4.83e-10Comparison results:
1e-8: FAIL on NNZ mismatch1e-8: PASS1e-10: FAIL1e-5error: FAIL1e-5error: FAILThe two CUDA cases previously excluded because of this issue are enabled again:
scf_out_hsr_spin4nscf_out_hsr_tr_rrScope
This PR does not modify the GPU Gint implementation, production H(R)/S(R) output, or the production sparse threshold.
It only changes the integration-test comparison semantics so that the existing numerical tolerance is applied to matrix values rather than to the serialized CSR layout.