Skip to content

feat: unify jobs + mmt under jobs command - #68

Open
tejapulagam wants to merge 7 commits into
mainfrom
feat/unify-mmt-under-jobs
Open

feat: unify jobs + mmt under jobs command#68
tejapulagam wants to merge 7 commits into
mainfrom
feat/unify-mmt-under-jobs

Conversation

@tejapulagam

@tejapulagam tejapulagam commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

Unify standalone Jobs and multi-machine training (MMT) under a single Job resource, while keeping MMT and lightning mmt as a silent compatibility layer. I will setup a deprecation notice in a followup.

  • Job handles both single- and multi-machine work (standalone / multi backends).
  • Lookup tries a standalone job first, then multi-machine on 404.
  • Job.run(..., num_machines=N) creates a multi-machine job when N > 1.
  • Multi-machine jobs expose is_multi_machine, num_machines, and rank-sorted machines; stop/delete always target the parent.
  • MMT is a thin Job subclass for compatibility (no deprecation warnings yet).
  • teamspace.jobs lists both; teamspace.multi_machine_jobs is unchanged.
  • lightning job uses unified Job; lightning mmt still uses the MMT wrapper.
  • Pipeline JobStep accepts num_machines and creates an MMT step when > 1.

@tejapulagam tejapulagam changed the title feat: unify jobs + mmt under jobs command wip feat: unify jobs + mmt under jobs command Jul 30, 2026
@tejapulagam tejapulagam changed the title wip feat: unify jobs + mmt under jobs command feat: unify jobs + mmt under jobs command Jul 30, 2026
@tejapulagam
tejapulagam marked this pull request as draft July 30, 2026 22:27
@justusschock

Copy link
Copy Markdown
Member

This should match with the SDK though, so we'd need to merge both classes as well (which would be doable).

@tejapulagam
tejapulagam marked this pull request as ready for review July 31, 2026 18:06
@tejapulagam
tejapulagam requested a review from tchaton as a code owner July 31, 2026 18:06
@tejapulagam
tejapulagam force-pushed the feat/unify-mmt-under-jobs branch from 8cc205e to 55e8290 Compare July 31, 2026 19:14
@tejapulagam
tejapulagam force-pushed the feat/unify-mmt-under-jobs branch from e03aa9a to e4ac9b7 Compare July 31, 2026 21:03
Comment thread python/lightning_sdk/cli/utils/resource_resolution.py Outdated
"cloud_account_auth": cloud_account_auth,
"entrypoint": entrypoint,
"path_mappings": path_mappings_dict,
"num_machines": num_machines,

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.

Side note: In order to move LitData to use MMT, we need to support per rank env variables, so each rank can adapt its behaviour

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

happy to look into this as a next step when i get the time :)

@justusschock justusschock left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Nice!

class MMT(Job):
"""Compatibility interface for multi-machine jobs.

Multi-machine functionality is implemented by :class:`lightning_sdk.job.Job`.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

nice!

Comment thread python/lightning_sdk/job.py Outdated
self._cloud_account_api = CloudAccountApi()
self._job_api = JobApiV2()
self._standalone_job_api = JobApiV2()
self._mmt_job_api: Optional[MMTApiV2] = None

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

what's the issue with always instantiating it? Might make your typing a bit easier :)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

switched to always instantiate MMTApiV2()!

Comment thread python/lightning_sdk/job.py Outdated
if kind not in ("standalone", "multi"):
raise ValueError(f"Unknown job resource kind: {kind}")
self._resource_kind = kind
if kind == "multi":

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

what do we need kind for? Just the switch here? you could just make sure the job_api and mmt_api have the same public interface (they almost have i think).

And then just have a property that dynamically forwards based on num_machines or so?

This one works as well though :)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

just updated to this scheme in 3920403

Comment thread python/lightning_sdk/teamspace.py Outdated
job._job = j2
jobs.append(job)
for m2 in self._teamspace_api.list_mmts(teamspace_id=self.id):
job = Job(name=m2.name, teamspace=self, _fetch_job=False, _resource_kind="multi")

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

is this _resource_kind required? Would it resolve this automatically? I don't have strong objections here, i just think it'd be better to not expose this at all if we can avoid this :)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

removed, now listing uses _attach_job(proto), which detects multi from V1MultiMachineJob and syncs num_machines

@tejapulagam
tejapulagam force-pushed the feat/unify-mmt-under-jobs branch from 3920403 to 79f2fb7 Compare August 3, 2026 18:48
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