Skip to content

Refactor scheduler and engine.py#4163

Merged
lvhan028 merged 17 commits intoInternLM:mainfrom
grimoire:refactor-scheduler-states
Dec 15, 2025
Merged

Refactor scheduler and engine.py#4163
lvhan028 merged 17 commits intoInternLM:mainfrom
grimoire:refactor-scheduler-states

Conversation

@grimoire
Copy link
Copy Markdown
Collaborator

@grimoire grimoire commented Nov 28, 2025

  • refactor sequence states with state pattern
  • rename status RUNNING->READY LOCKED->RUNNING
  • split engine.py

@grimoire grimoire marked this pull request as ready for review December 5, 2025 03:05
@grimoire grimoire changed the title [WIP]Refactor scheduler states Refactor scheduler and engine.py Dec 5, 2025
Comment on lines +101 to +104
def activate(self):
"""From STOPPED to WAITING."""
assert self.seq.num_token_ids > 0
self.to_state(WaitingState)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

In what case a stopped seq can be activate again?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

second round chat

self.seq = seq
self.scheduler = scheduler

def to_state(self, new_state):
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

For better readability, consider using state_cls instead of new_state since it's a class, not an instance.

Copy link
Copy Markdown
Collaborator

@RunningLeon RunningLeon left a comment

Choose a reason for hiding this comment

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

LGTM

@lvhan028 lvhan028 merged commit c5a05c1 into InternLM:main Dec 15, 2025
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants