Skip to content

Feat/jobstats fallback - #94

Open
ovalerio wants to merge 7 commits into
troycomi:mainfrom
mpinb:feat/jobstats-fallback
Open

Feat/jobstats fallback#94
ovalerio wants to merge 7 commits into
troycomi:mainfrom
mpinb:feat/jobstats-fallback

Conversation

@ovalerio

@ovalerio ovalerio commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

This feature fixes a silent break that occurs in the more recent versions of jobstats. Originally, reportseff uses the AdminComment field in sacct to obtain the job's GPU performance metrics (GpuEff, GpuMemEff). But that field has been removed in favor of using an external database. The jobstats project already provides a fix which involves mirroring that information in slurm's db AdminComment field. I'm also the one who proposed that fix.

In some jobstats cluster deployments, the cluster admin might decide not to apply the fix. In those cases this pull request is providing a last resort fallback, to obtain the GPU metrics using jobstats public API instead. I've first got the idea for this workaround from a developer's comment on the jobstats issue discussion, where the silent break was highlighted.

It's important to stress that the AdminComment mirror is in my opinion and from a reportseff user's egoistic perspective, the preferred and faster fix. In any case, reportseff users can decide to disable the fallback by passing a command line option to avoid the additional time penalty.

I've used a Coding Agent website (claude.ai/Sonnet 4.6) to engineer and implement this feature.

…able

Implements a best-effort GPU metrics recovery mechanism that activates when
Slurm job records lack AdminComment data (e.g., when jobstats' optional
mirror_to_admin_comment flag is disabled).

Changes:
- Added _check_jobstats_available() to detect jobstats binary and -b flag support
- Added augment_with_jobstats() to batch jobstats queries for missing GPU metrics
- Integrated fallback into console.py with --no-jobstats-fallback CLI flag
- Added comprehensive test coverage (14 new tests, all passing)

Design:
- Batching: All missing jobs sent to jobstats in single subprocess call
- Opt-out: Fallback enabled by default if jobstats is available
- Graceful: Partial failures handled, subprocess errors caught
- Transparent: Existing parsing logic reused without modification
- Array jobs: Efficiently handled with single batched query per array

Motivation:
Jobstats is migrating GPU metrics to Prometheus + MariaDB (PR#55).
The optional mirror_to_admin_comment config preserves AdminComment data.
Without it, reportseff's GPU columns would show "---" (broken functionality).
This fallback enables automatic GPU metric recovery when jobstats is available.

Related:
PrincetonUniversity/jobstats#55

Testing:
All 136 tests pass (122 existing + 14 new)
@ovalerio

ovalerio commented Aug 4, 2026

Copy link
Copy Markdown
Contributor Author

@troycomi Sorry, I noticed the coverage test is not passing.
I will have a look and try to fix it.
Can I leave the PR open in the meantime?

…e a versions of click that were triggering an error during the audit as they have been reported as unsafe. The versions are marked as so both in the pyproject.toml and the uv.lock project files.
@troycomi

Copy link
Copy Markdown
Owner

Thanks for your patience, I'm getting back from vacation and slowly catching back up.

This looks like a solid PR that address the jobstats issue I was hoping to just ignore! A few changes I'd prefer but am open to discussion.

I think the option should probably be a pair, like --node/--no-node to make it clearer what option is set and what the default means.

I would also like it to be off by default. My concern is cases when jobstats is available but writes SHORT to the admin comment, causing extra overhead. Is that possible? Perhaps an alternative is to only enable that when gpu or multinode reporting is also set? Curious on your thoughts here.

@ovalerio

Copy link
Copy Markdown
Contributor Author

Hello @troycomi,👋

I understand your concerns although perhaps not fully.

After reading your comment I started thinking that instead of second guessing the reportseff users intent or preference, both methods can be explicitly set using a parameter with few options:

--read-gpu-perf:

  1. jobstats (only from)
  2. admincomment (only from)
  3. jobstats,admincomment (jobstats first, admin comment if no available)
  4. admincomment, jobstats (first admincomment, fallback to jobstats)

@troycomi

Copy link
Copy Markdown
Owner

That could be a nice interface. Let me think out loud for a minute.
Most of the benefit of jobstats/admincomment is for multi-node and gpu outputs, which doesn't get recorded well by sacct, but it also has better measurements of memory usage which is used if available. My concern is calling out to jobstats for every job, every time, would add onto the runtime unnecessarily. Giving the user the option is a nice compromise. Overall I would say we should:

  • Profile the runtime of a fairly large reportseff call without any additional jobstats parsing, admincomment only and jobstats only so we can gauge if the added runtime is significant vs sacct calls and other python overhead. I would say this would be nice to include as a CI check, but that would probably require mocking all the system calls.
  • Think on the option name. It's not just gpu jobs so maybe something like augment-with?
  • Support single letter abbreviations as well as full names (a for admincomment and j for jobstats) so you can say --option ja or --option aj for interactive shell calls. Also include an unset option (none?) to fully skip any additional parsing.
  • Based on the profiling, we should decide what a reasonable default is and if it should be changed for gpu jobs. E.g. if either additional call adds runtime maybe we set the default to none but have it activate aj if node or gpu is set.

No rush, enjoy your vacation!

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