Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(nn4k): add executor and invoker API for alignment #78

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 27 additions & 3 deletions python/nn4k/nn4k/executor/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,10 +152,34 @@ def execute_sft(self, args=None, callbacks=None, **kwargs):
"""
raise NotImplementedError(f"{self.__class__.__name__} does not support SFT.")

def execute_rl_tuning(self, args=None, callbacks=None, **kwargs):

class AlignExecutor(LLMExecutor):
"""An executor for X-Alignment"""

@classmethod
def from_config(cls, nn_config: Union[str, dict]) -> "NNExecutor":
return super().from_config(nn_config)

def execute_rm(self, args=None, callbacks=None, **kwargs):
"""
The entry point of SFT execution in a certain pod.
Execute reward model(rm) training.
"""
raise NotImplementedError(
f"{self.__class__.__name__} does not support execute_rm yet."
)

def execute_dpo(self, args=None, callbacks=None, **kwargs):
"""
Execute DPO training.
"""
raise NotImplementedError(
f"{self.__class__.__name__} does not support execute_dpo yet."
)

def execute_ppo(self, args=None, callbacks=None, **kwargs):
"""
Execute PPO training.
"""
raise NotImplementedError(
f"{self.__class__.__name__} does not support RL-Tuning."
f"{self.__class__.__name__} does not support execute_ppo yet."
)
43 changes: 35 additions & 8 deletions python/nn4k/nn4k/invoker/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,14 +138,6 @@ def submit_sft(self, submit_mode: SubmitMode = SubmitMode.K8s):
"""
raise NotImplementedError(f"{self.__class__.__name__} does not support SFT.")

def submit_rl_tuning(self, submit_mode: SubmitMode = SubmitMode.K8s):
"""
Submit remote RL-Tuning execution.
"""
raise NotImplementedError(
f"{self.__class__.__name__} does not support RL-Tuning."
)

def local_inference(self, data, **kwargs):
"""
Implement local inference for local invoker.
Expand Down Expand Up @@ -184,3 +176,38 @@ def from_config(cls, nn_config: dict) -> "LLMInvoker":
"""
invoker = cls(nn_config)
return invoker


class AlignInvoker(NNInvoker):
"""A invoker for X-Alignment tuning"""
@classmethod
def from_config(cls, nn_config: Union[str, dict]) -> "NNInvoker":
"""
Create an instance from `nn_config`.
"""
invoker = cls(nn_config)
return invoker

def submit_rm(self, submit_mode: SubmitMode = SubmitMode.K8s):
"""
Submit remote tuning execution for reward model(rm).
"""
raise NotImplementedError(
f"{self.__class__.__name__} does not support submit_rm yet."
)

def submit_dpo(self, submit_mode: SubmitMode = SubmitMode.K8s):
"""
Submit remote execution for DPO.
"""
raise NotImplementedError(
f"{self.__class__.__name__} does not support submit_dpo yet."
)

def submit_ppo(self, submit_mode: SubmitMode = SubmitMode.K8s):
"""
Submit remote execution for PPO.
"""
raise NotImplementedError(
f"{self.__class__.__name__} does not support submit_ppo yet."
)
Loading