Skip to content

feat: pmix v2#421

Open
huerni wants to merge 5 commits intomasterfrom
dev/pmix
Open

feat: pmix v2#421
huerni wants to merge 5 commits intomasterfrom
dev/pmix

Conversation

@huerni
Copy link
Copy Markdown
Collaborator

@huerni huerni commented Mar 30, 2026

Summary by CodeRabbit

  • New Features

    • Added a new --mpi command-line option for interactive jobs.
    • Interactive job metadata now includes an MPI field so MPI values are persisted with runs.
    • MPI value is propagated to interactive steps so tooling and logs receive the configured MPI.
  • Bug Fixes / Behavior

    • Invalid MPI values are now rejected; only supported MPI types (e.g., "pmix") are accepted.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Mar 30, 2026

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

Added package-level FlagMpi, registered a --mpi CLI flag, validated and propagated MPI value into interactive job metadata in MainCrun, and extended InteractiveJobAdditionalMeta protobuf with string mpi = 9.

Changes

Cohort / File(s) Summary
Flag Declaration
internal/calloc/cmd.go
Introduced package-level string FlagMpi.
CLI Flag Registration
internal/crun/cmd.go
Bound a new --mpi CLI flag to FlagMpi.
Metadata & Validation
internal/crun/crun.go
Added supported MPI constant (pmix), validated FlagMpi against it, and set iaMeta.Mpi = FlagMpi in MainCrun.
Proto Definition
protos/PublicDefs.proto
Added string mpi = 9; to InteractiveJobAdditionalMeta schema.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  participant User as User
  participant CLI as CLI (crun)
  participant Main as MainCrun
  participant Proto as InteractiveJobAdditionalMeta
  participant Server as Server

  User->>CLI: run `crun --mpi="<value>"`
  CLI->>CLI: parse flags (sets FlagMpi)
  CLI->>Main: invoke MainCrun (reads FlagMpi)
  Main->>Main: validate FlagMpi == "pmix"
  Main->>Proto: set iaMeta.Mpi = FlagMpi
  Main->>Server: send serialized InteractiveJobAdditionalMeta (includes mpi)
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Suggested reviewers

  • L-Xiafeng
  • Nativu5

Poem

🐇
I nudge a flag beneath the log,
A tiny hop, a quiet pog.
From CLI burrow to proto hill,
MPI snug — my task is still. 🥕

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (1 warning, 1 inconclusive)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Title check ❓ Inconclusive The title 'feat: pmix v2' is vague and does not clearly convey the actual change. While it mentions 'pmix', it doesn't explain what functionality is being added—whether it's support for PMIx, configuration handling, validation, or something else. Consider a more descriptive title such as 'feat: add MPI type validation and metadata support for PMIx' or 'feat: add PMIx MPI configuration support' to better clarify the main change.
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch dev/pmix

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@internal/calloc/cmd.go`:
- Line 54: The file contains a gofmt formatting issue around the FlagMpi
declaration; run gofmt -w on the source file that declares FlagMpi to fix
formatting (or use your editor's Go formatting) so the file compiles cleanly and
the pipeline passes; ensure the FlagMpi line and surrounding code are properly
formatted by gofmt.
- Line 126: The --mpi flag (FlagMpi) is registered but never copied into the job
metadata before submit: in the calloc command flow where InteractiveMeta is
initialized to nil (function calloc / variable iaMeta), retrieve or create the
InteractiveMeta struct and set iaMeta.Mpi = FlagMpi (same as crun does) before
calling the submission routine so the value is propagated to the job controller;
ensure you update the same variable used downstream (iaMeta / InteractiveMeta)
so the metadata contains the FlagMpi value.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: e310a670-e045-467d-8cf0-4ea50cde4d13

📥 Commits

Reviewing files that changed from the base of the PR and between 6a63477 and 7450171.

📒 Files selected for processing (4)
  • internal/calloc/cmd.go
  • internal/crun/cmd.go
  • internal/crun/crun.go
  • protos/PublicDefs.proto

Comment thread internal/calloc/cmd.go Outdated
Comment thread internal/calloc/cmd.go Outdated
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@internal/calloc/cmd.go`:
- Line 54: Add a CLI flag binding for the previously declared FlagMpi in
calloc's init() so the --mpi option actually works: in the init() function of
the calloc command register FlagMpi with the root command flags (e.g.,
rootCmd.Flags().StringVar(&FlagMpi, "mpi", <default>, "<help>") analogous to how
FlagMpi is registered in crun's init), ensuring you use the same variable name
FlagMpi and an appropriate default and help string.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 54149446-47b7-49ef-95e7-2ca8d143e77d

📥 Commits

Reviewing files that changed from the base of the PR and between 7450171 and 5a0a33d.

📒 Files selected for processing (1)
  • internal/calloc/cmd.go

Comment thread internal/calloc/cmd.go
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

♻️ Duplicate comments (1)
internal/calloc/cmd.go (1)

53-53: ⚠️ Potential issue | 🟠 Major

Register FlagMpi in init() so calloc --mpi is usable.

Line 53 introduces FlagMpi, but init() never binds it via RootCmd.Flags().StringVar...; as a result, calloc --mpi will not be recognized.

Suggested fix
 func init() {
@@
 	RootCmd.Flags().StringVarP(&FlagDependency, "dependency", "d", "", "Conditions for job to execute")
+	RootCmd.Flags().StringVar(&FlagMpi, "mpi", "", "MPI type/version for interactive job")
 	RootCmd.Flags().StringVarP(&FlagSignal, "signal", "s", "", "Send signal when time limit within time seconds, format: [{R}:]<sig_num>[`@sig_time`]")
 }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@internal/calloc/cmd.go` at line 53, The new package-level variable FlagMpi is
never registered with the CLI, so the --mpi flag is not recognized; in init()
register it by calling RootCmd.Flags().StringVar(&FlagMpi, "mpi", "",
"enable/use MPI implementation (e.g. mpich|openmpi)") (or StringVarP if a short
option is desired), ensuring the binding uses the FlagMpi variable and
RootCmd.Flags() so calloc --mpi is parsed.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Duplicate comments:
In `@internal/calloc/cmd.go`:
- Line 53: The new package-level variable FlagMpi is never registered with the
CLI, so the --mpi flag is not recognized; in init() register it by calling
RootCmd.Flags().StringVar(&FlagMpi, "mpi", "", "enable/use MPI implementation
(e.g. mpich|openmpi)") (or StringVarP if a short option is desired), ensuring
the binding uses the FlagMpi variable and RootCmd.Flags() so calloc --mpi is
parsed.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: ad5406f2-7d17-4007-927c-a44756dc7fcf

📥 Commits

Reviewing files that changed from the base of the PR and between 5a0a33d and 8c9cd01.

📒 Files selected for processing (4)
  • internal/calloc/cmd.go
  • internal/crun/cmd.go
  • internal/crun/crun.go
  • protos/PublicDefs.proto
✅ Files skipped from review due to trivial changes (2)
  • internal/crun/cmd.go
  • internal/crun/crun.go
🚧 Files skipped from review as they are similar to previous changes (1)
  • protos/PublicDefs.proto

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
internal/crun/crun.go (1)

1880-1880: Consider validating FlagMpi against supported MPI types before accepting it.

iaMeta.Mpi = FlagMpi forwards the raw CLI string without validation. If specific values (e.g., pmix, pmi2, none) are supported, validating here enables fast-fail with a clear CLI error instead of deferring to backend rejection. Note that the --mpi flag is currently marked as unsupported in the slurm wrapper (internal/cwrapper/slurm.go:1299-1300), so validation can be added when this feature is fully enabled.

Regarding calloc: FlagMpi exists in internal/calloc/cmd.go but is not exposed as a CLI flag, so there's no inconsistency—only crun has the flag wired up.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@internal/crun/crun.go` at line 1880, The assignment iaMeta.Mpi = FlagMpi
accepts the raw CLI string without validation; update the code around the
iaMeta.Mpi assignment to validate FlagMpi against the allowed MPI types (e.g.,
"pmix", "pmi2", "none" or your project's canonical list) and return a clear CLI
error if the value is unsupported; specifically, in the block that sets
iaMeta.Mpi and references FlagMpi, check membership in the allowed set,
normalize/case-fold as needed, and abort with a user-facing error message when
invalid to fail fast before backend submission.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@internal/crun/crun.go`:
- Line 1880: The assignment iaMeta.Mpi = FlagMpi accepts the raw CLI string
without validation; update the code around the iaMeta.Mpi assignment to validate
FlagMpi against the allowed MPI types (e.g., "pmix", "pmi2", "none" or your
project's canonical list) and return a clear CLI error if the value is
unsupported; specifically, in the block that sets iaMeta.Mpi and references
FlagMpi, check membership in the allowed set, normalize/case-fold as needed, and
abort with a user-facing error message when invalid to fail fast before backend
submission.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: e115dafd-a1ff-49c6-b1e0-630152e4191d

📥 Commits

Reviewing files that changed from the base of the PR and between 8c9cd01 and ba078c9.

📒 Files selected for processing (4)
  • internal/calloc/cmd.go
  • internal/crun/cmd.go
  • internal/crun/crun.go
  • protos/PublicDefs.proto
✅ Files skipped from review due to trivial changes (2)
  • internal/crun/cmd.go
  • internal/calloc/cmd.go

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
internal/crun/crun.go (1)

71-73: Consider a set of supported MPI types for extensibility.

If additional MPI implementations (e.g. pmi2, openmpi) are likely to be supported later, a single constant plus a hard-coded equality check will not scale cleanly. A small set/slice would also let you surface the supported list in the error message.

♻️ Sketch
-	MpiTypePmix string = "pmix"
+	MpiTypePmix string = "pmix"
+)
+
+var SupportedMpiTypes = map[string]struct{}{
+	MpiTypePmix: {},
+}
+
+const (
+	_mpiTypesEnd = ""

(or simply keep the constant and switch the check to a map lookup.)

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@internal/crun/crun.go` around lines 71 - 73, The code currently defines only
a single MPI constant (MpiTypePmix) which doesn't scale; replace the
single-constant check with a reusable collection of supported types (e.g. a
slice var SupportedMpiTypes = []string{"pmix"} or a map var supportedMpiTypes =
map[string]struct{}{"pmix":{}}) and update any validation logic to check
membership against that collection (instead of equality to MpiTypePmix) and to
use the collection to construct clearer error messages listing supported MPI
types; look for uses of MpiTypePmix in internal/crun/crun.go
(validation/selection logic) and change them to consult the new
SupportedMpiTypes/supportedMpiTypes.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@internal/crun/crun.go`:
- Around line 1882-1886: The current check treats the empty default FlagMpi as
invalid and forces MPI to be required; update the validation so it only runs
when the user explicitly set the --mpi flag: either skip validation when FlagMpi
== "" (leave iaMeta.Mpi unset) or use the command flag state
(cmd.Flags().Changed("mpi")) before comparing FlagMpi to MpiTypePmix; only
assign iaMeta.Mpi when the flag was provided and validated.

---

Nitpick comments:
In `@internal/crun/crun.go`:
- Around line 71-73: The code currently defines only a single MPI constant
(MpiTypePmix) which doesn't scale; replace the single-constant check with a
reusable collection of supported types (e.g. a slice var SupportedMpiTypes =
[]string{"pmix"} or a map var supportedMpiTypes =
map[string]struct{}{"pmix":{}}) and update any validation logic to check
membership against that collection (instead of equality to MpiTypePmix) and to
use the collection to construct clearer error messages listing supported MPI
types; look for uses of MpiTypePmix in internal/crun/crun.go
(validation/selection logic) and change them to consult the new
SupportedMpiTypes/supportedMpiTypes.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 45a1beb8-c11d-4932-9891-db3f57b059e6

📥 Commits

Reviewing files that changed from the base of the PR and between ba078c9 and 39aebcc.

📒 Files selected for processing (1)
  • internal/crun/crun.go

Comment thread internal/crun/crun.go
Comment on lines +1882 to +1886
if FlagMpi != MpiTypePmix {
return util.NewCraneErr(util.ErrorCmdArg, fmt.Sprintf("Invalid argument: unsupported MPI type %s.", FlagMpi))
}

iaMeta.Mpi = FlagMpi
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.

⚠️ Potential issue | 🔴 Critical

Critical: default (no --mpi) now rejects every crun invocation.

FlagMpi is registered with an empty-string default (internal/crun/cmd.go line 169). With the current check, any crun run without --mpi fails with Invalid argument: unsupported MPI type . (note the empty value interpolated), i.e. the MPI feature is no longer opt-in — it is mandatory. This breaks all existing non-MPI interactive workloads.

Validate only when the user explicitly set the flag, e.g.:

🐛 Proposed fix
-	if FlagMpi != MpiTypePmix {
-		return util.NewCraneErr(util.ErrorCmdArg, fmt.Sprintf("Invalid argument: unsupported MPI type %s.", FlagMpi))
-	}
-
-	iaMeta.Mpi = FlagMpi
+	if FlagMpi != "" {
+		if FlagMpi != MpiTypePmix {
+			return util.NewCraneErr(util.ErrorCmdArg,
+				fmt.Sprintf("Invalid argument: unsupported MPI type %q (supported: %s).", FlagMpi, MpiTypePmix))
+		}
+		iaMeta.Mpi = FlagMpi
+	}

Alternatively, gate on cmd.Flags().Changed("mpi") which is the pattern used elsewhere in MainCrun.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
if FlagMpi != MpiTypePmix {
return util.NewCraneErr(util.ErrorCmdArg, fmt.Sprintf("Invalid argument: unsupported MPI type %s.", FlagMpi))
}
iaMeta.Mpi = FlagMpi
if FlagMpi != "" {
if FlagMpi != MpiTypePmix {
return util.NewCraneErr(util.ErrorCmdArg,
fmt.Sprintf("Invalid argument: unsupported MPI type %q (supported: %s).", FlagMpi, MpiTypePmix))
}
iaMeta.Mpi = FlagMpi
}
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@internal/crun/crun.go` around lines 1882 - 1886, The current check treats the
empty default FlagMpi as invalid and forces MPI to be required; update the
validation so it only runs when the user explicitly set the --mpi flag: either
skip validation when FlagMpi == "" (leave iaMeta.Mpi unset) or use the command
flag state (cmd.Flags().Changed("mpi")) before comparing FlagMpi to MpiTypePmix;
only assign iaMeta.Mpi when the flag was provided and validated.

Copy link
Copy Markdown
Collaborator

@L-Xiafeng L-Xiafeng left a comment

Choose a reason for hiding this comment

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

LGTM

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