Skip to content

Nexus: add error screening functionality#6056

Open
jtkrogel wants to merge 2 commits into
QMCPACK:developfrom
jtkrogel:nx_error_keys
Open

Nexus: add error screening functionality#6056
jtkrogel wants to merge 2 commits into
QMCPACK:developfrom
jtkrogel:nx_error_keys

Conversation

@jtkrogel

Copy link
Copy Markdown
Contributor

This PR adds precursor functionality to screen for simulation run failures. Failure types come from various sources: operating system, filesystem, mpi, fortran/c++/cuda/hip runtime, compiled libraries, python, python modules, and error patterns specific to individual simulation codes.

In error_keys.py the find_error_keys function can be used to screen for errors from a target (.out / .err) file or text block. The types of errors being screened for can be selected flexibly. Regex is used extensively for efficiency. Can also output individual lines that contain error matches, but this should be much slower.

The eventual intention is to incorporate this function into the check_sim_status member function for each simulation code. The failure detection is meant to be a backup if success is not directly determined by inspecting e.g. files produced by simulation runs. For codes like pyscf, this will likely be the first line of defense since success is nearly impossible to gauge directly due to the complete flexibility allowed by the input script.

This PR was made with assistance from GPT-5.6 Sol.

@prckent

prckent commented Jul 24, 2026

Copy link
Copy Markdown
Contributor

Aside: What are your thoughts on handling errors such as when a submitted slurm job has simply disappeared and we don't have any error or output files? e.g. Sysadmin flushes all jobs from slurm queue. What parts of Nexus could catch that / should already catch that?

@brockdyer03 brockdyer03 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.

This is an incomplete review, but I figured I'd give a few bits of feedback while I had time.

Comment thread nexus/nexus/error_keys.py
return pattern


@lru_cache(maxsize=None)

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.

This should get replaced with functools.cache which provides the same functionality and is more common.

Comment thread nexus/nexus/error_keys.py
... )
True
>>> find_error_keys(
... "step 1\\nLAPACK computational failure: ZHEEV did not converge",

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.

Would be more readable as

'''
step 1
LAPACK computational failure: ZHEEV did not converge
'''

Comment thread nexus/nexus/error_keys.py
if not return_lines:
return pattern.search(text) is not None

lines = [line for line in text.splitlines() if pattern.search(line)]

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.

Explicit is better than implicit

lines = [
    line for line in text.splitlines() if pattern.search(line) is not None
    ]

Comment thread nexus/nexus/error_keys.py
return pattern.search(text) is not None

lines = [line for line in text.splitlines() if pattern.search(line)]
return bool(lines), lines

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.

Also here:

return (
    len(lines) > 0,
    lines
    )

@jtkrogel

Copy link
Copy Markdown
Contributor Author

@prckent Nexus queries the Slurm queue each poll. When a process drops out of the Slurm queue, the job is marked as finished and Simulation.check_sim_status is executed next. That function should check if all files exist, etc. If not, it should be marked as a failure (mostly is, I believe). For simulations exercising patience, a timeout limit should be added. This is on my todo list.

@brockdyer03

Copy link
Copy Markdown
Contributor

I recently authored a PR that added error checking to the PySCF check_sim_status, will this PR be in addition to that or replacing it?

If the intention is to replace it, you'll need to take the error types that I pulled out of PySCF and put them in here.

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.

3 participants