Skip to content

fix SF TDA/TDDFT fail and enable tests - #173

Closed
jeanwsr wants to merge 3 commits into
pyscf:masterfrom
jeanwsr:fix-sftd
Closed

jeanwsr wants to merge 3 commits into
pyscf:masterfrom
jeanwsr:fix-sftd

Conversation

@jeanwsr

@jeanwsr jeanwsr commented Jan 28, 2026 •

Copy link
Copy Markdown
Contributor

Currently any run of SF TDA/TDDFT fails because there's no self.max_space. For a quick fix I comment it since it's not used. Can be added back if someone want to use it.
Also, almost all tests for SF TDA/TDDFT are skipped because no mcfun installed. Now they are enabled.
Also fix the occri tests fail due to recent pyscf changes.

Copilot AI review requested due to automatic review settings January 28, 2026 10:21

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes a bug in SF TDA/TDDFT calculations where runs were failing due to a missing self.max_space attribute. The fix comments out the max_space parameter in the davidson solver calls, and enables previously skipped tests by installing the mcfun dependency in the CI pipeline.

Changes:

  • Commented out max_space parameter in uhf_sf.py and uks_sf.py to prevent AttributeError
  • Added mcfun installation to CI workflow to enable SF TDA/TDDFT tests

Reviewed changes

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

File Description
pyscf/sftda/uks_sf.py Comments out max_space parameter in davidson_nosym1 call to fix AttributeError
pyscf/sftda/uhf_sf.py Comments out max_space parameter in davidson1 call to fix AttributeError
.github/workflows/run_ci.sh Adds mcfun package installation to enable previously skipped SF TDA/TDDFT tests

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

Comment thread pyscf/sftda/uks_sf.py Outdated
Comment thread pyscf/sftda/uhf_sf.py
Comment thread pyscf/sftda/uks_sf.py Outdated
@jeanwsr

jeanwsr commented Jan 28, 2026

Copy link
Copy Markdown
Contributor Author

There're 4 test fails in SF TDA grad which are close to ref value. And 1 more in SF TDDFT which deviates a lot but occurs randomly. I have no idea about them.

@jeanwsr

jeanwsr commented Feb 12, 2026

Copy link
Copy Markdown
Contributor Author

Can @Haskiy or @hoshishin please help recover the failing tests?

@jeanwsr

jeanwsr commented Feb 12, 2026

Copy link
Copy Markdown
Contributor Author

I tested multiple pyscf version (see actions here. For the SF TDDFT BP86/TPSS energy test, it actually fails randomly with any pyscf versions from 2.5 to 2.9. But it may have a higher possibility to survive in 2.5 which misleads people.

@jeanwsr

jeanwsr commented Feb 12, 2026

Copy link
Copy Markdown
Contributor Author

And the 4 SF TDA grad tests start failing from pyscf 2.7. They don't deviate much so I guess we can simply updates the ref value.

@Haskiy

Haskiy commented Feb 12, 2026

Copy link
Copy Markdown
Contributor

I understand what you mean. When I wrote the unit tests initially, I kept six decimal places unchanged. This might be due to two reasons: first, the PySCF 2.5.0 version I was using at the time was related to this, and the tests passed; second, there was a bug in the code with the subspace size (i.e., the max_space parameter) when solving the spin flip TDA equations.
My suggestion is that we no longer use the gradients calculated from the excited states and transition vectors obtained via the davidson method as reference values. Instead, we should use the gradients computed from the excited states and transition vectors obtained via the full diagonalization method as reference values. Then, based on the current calculation results, we can uniformly set the number of decimal places to retain in the unit tests.

@wtpeter wtpeter mentioned this pull request Feb 12, 2026
@wtpeter

wtpeter commented Feb 12, 2026

Copy link
Copy Markdown
Contributor

Hi, I have opened a new PR #178 which incorporates this fix as part of a comprehensive refactor of the SF-TDDFT module. The new PR also resolves the max_space compatibility issue, adds ROKS support, and cleans up the codebase.

@jeanwsr jeanwsr closed this Feb 13, 2026
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.

4 participants