Skip to content

[stat-cl] Add --attach-job in stat-cl for sampling Slurm and Flux jobs by ID - #94

Merged
lee218llnl merged 2 commits into
llnl:developfrom
pramodk:pramodk/stat-cl-sample-job
Nov 30, 2026
Merged

lee218llnl merged 2 commits into
llnl:developfrom
pramodk:pramodk/stat-cl-sample-job

Conversation

@pramodk

@pramodk pramodk commented Nov 28, 2026

Copy link
Copy Markdown
Collaborator

Summary

Remote Connect already supports sampling a running job by ID with stat-gui-remote-cli sample-job JOBID.
This PR brings that workflow to the native CLI with stat-cl --attach-job JOBID.

For Slurm, STAT looks up the launcher PID and lists the candidates when several launchers match. For Flux,
STAT starts the debug helper and cleans it up after sampling. Passing --flux-allocation selects Flux scheduler explicitly.

Examples

Collect one sample from a running Slurm job with a single launcher.

stat-cl --attach-job JOBID --scheduler slurm -t 1

Sample a Flux application from inside its instance, or from the login node using the outer allocation ID.

stat-cl --attach-job APPLICATION_JOB_ID --scheduler flux -t 1
stat-cl --attach-job APPLICATION_JOB_ID --flux-allocation ALLOCATION_ID -t 1

For a nested Flux job, use the existing Remote Connect command from desktop. Put --flux-allocation ALLOCATION_ID before sample-job to select the outer allocation:

stat-gui-remote-cli --remote-login user@login-host --remote-prefix /opt/stat \
  --flux-allocation ALLOCATION_ID sample-job APPLICATION_JOB_ID

Notes / Disclaimer

  • Tested both using stat-cl on a test cluster and the standalone GUI over SSH.
  • A coding agent has been used to help with refactoring code, implementation, testing, and documentation.

- Resolve a Slurm launcher or manage a Flux debug helper and forward native sampling options to STATbin.
- Install the resolver with headless builds and document scheduler selection for local and remote sampling.
@pramodk pramodk changed the title [stat-cl] Add job-ID sampling for Slurm and Flux to the native CLI [stat-cl] Add --attach-job in stat-cl for sampling Slurm and Flux jobs by ID Nov 28, 2026
@lee218llnl

Copy link
Copy Markdown
Collaborator

Can you please change stat-gui-remote-cli to stat-remote-cl? It's not the GUI, so we should remove that from the name. And minor issue, but to be consistent with stat-cl, remove the trailing "i". This may be a moot point depending on what you think about my next request.

There is an inconsistency with the remote GUI and the CLI commands. The remote GUI still uses the old stat-gui command, just requiring certain options to make it clear that it is operating remotely. Currently the local and remote CLIs are separate commands. Would it make sense to also unify remote and local within the stat-cl command?

Comment thread doc/remote-connect.md Resolved
@pramodk

pramodk commented Nov 30, 2026 •

Copy link
Copy Markdown
Collaborator Author

There is an inconsistency with the remote GUI and the CLI commands. The remote GUI still uses the old stat-gui command, just requiring certain options to make it clear that it is operating remotely. Currently the local and remote CLIs are separate commands. Would it make sense to also unify remote and local within the stat-cl command?

@lee218llnl - this is good point. Actually, few days ago I was thinking if stat-gui-remote-cli should be merged with stat-gui. But agree that merge with stat-cl makes more sense. (Initially I wasn't sure due to compiled module dependency, etc but it's not a big issue).

This could be a separate issue/PR discussion but let me write here details anyway:

stat-cl and stat-remote-cl

By keeping stat-cl only, at high level, I assume we want to support largely same CLI options and their defaults like native usage. Native stat-cl defines the options and sampling defaults for both local and remote SSH use. A user can take a local sampling command and add --remote-login USER@HOST to run it on the cluster.

I was also thinking of changes I did/proposed in #95 with -w (host) and -W (device). Let me write about that part as well:

GDB and CUDA-GDB

Today, -G -w with CUDA-GDB collects both host and device threads. I am thinking the host and device selections should be independent: -w (--withthreads) adds host threads, -W (--with-device-threads) adds device threads. An explicit --gdb-path selects the executable in the sampling environment.

Here is the summary table. The Change in behaviour column summaries change in behavior compared to what is provided today. An invalid combination produces no sample.

Debugger Options Host Device Change in behaviour?
CUDA-GDB -G First host thread per rank None No. Same host-only sample.
CUDA-GDB -G -w All sampled host threads None Yes. Previously included device stacks. Add -W to include them.
CUDA-GDB -G -Q None None Yes. Error: --cudaquick requires --with-device-threads (-W). Previously produced host output.
CUDA-GDB -G -w -Q None None Yes. Error: --cudaquick requires --with-device-threads (-W). Previously also produced quick device locations.
CUDA-GDB -G -W First host thread per rank Full stacks Yes. New selection for GPU stacks with one host stack per rank.
CUDA-GDB -G -w -W All sampled host threads Full stacks Yes. Explicit form of the former -G -w result.
CUDA-GDB -G -W -Q First host thread per rank Quick locations Yes. New selection for quick GPU sampling with one host stack per rank.
CUDA-GDB -G -w -W -Q All sampled host threads Quick locations Yes. Explicit form of the former -G -w -Q result.
GDB -G First host thread per rank None No. Same host-only sample.
GDB -G -w All sampled host threads None No. Same host-thread sample.
GDB -G -Q None None Yes. Error: --cudaquick requires --with-device-threads (-W). Omit -Q for host sampling.
GDB -G -w -Q None None Yes. Error: --cudaquick requires --with-device-threads (-W). Omit -Q for host-thread sampling.
GDB -G -W, optionally with -w or -Q None None Yes. Error: Selected debugger gdb does not support CUDA device sampling.

A GDB-enabled build accepts --backend gdb as an alias for the existing -G option.

Does this make sense?

I have renamed command in d87060e. I can do whole unification changes in a separate PR shortly as it would involve a bit of refactoring of the existing CLI parsing. But if you prefer, happy to push it here.

@pramodk

pramodk commented Nov 30, 2026

Copy link
Copy Markdown
Collaborator Author

By the way, as I am looking through the existing options and thinking about new ones, what do you think about using hyphens in multiword option names? I find --sample-individual easier to read than --sampleindividual and follows a common CLI convention.

We could follow that convention for new options and add aliases for existing ones over time so current scripts keep working for near future (until / beyond v5.0).

@lee218llnl

Copy link
Copy Markdown
Collaborator

I think those sample options make sense. I'm not going to put you on the hook, but some of the same logic applies for gdb-oneapi and roc-gdb. I can take care of any of those if they don't align with the cuda-gdb implementation. Obviously cudaquick (or perhaps cuda-quick) is unique to cuda-gdb. I don't recall if there are equivalents.

The --sample-individual flags looks better to me too.

Both can be done in a separate PR.

Let me know if you want to do to the stat-gui-remote-cli -> stat-cl merge here or in another PR. If that too is another PR, please let me know if this one is good and then I can merge this PR.

Thanks!

@pramodk

pramodk commented Nov 30, 2026

Copy link
Copy Markdown
Collaborator Author

but some of the same logic applies for gdb-oneapi and roc-gdb. I can take care of any of those if they don't align with the cuda-gdb implementation

Certainly make sense! I just don't have a way/dev environment to test those. During the review process if you could check/provide feedback, happy to make changes accordingly. No problem!

The --sample-individual flags looks better to me too.

Ok, I will use this style and keep backward compatibility.

If that too is another PR, please let me know if this one is good and then I can merge this PR.

I am looking into this and considering overall, I think better to do that as a separate PR. Also easy to track issues later. So let's merge this. Thanks!

@lee218llnl
lee218llnl merged commit 018c398 into llnl:develop Nov 30, 2026
2 checks passed
@pramodk
pramodk deleted the pramodk/stat-cl-sample-job branch November 30, 2026 23:01
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