Skip to content
Closed
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
3 changes: 2 additions & 1 deletion nemo_reinforcer/algorithms/grpo.py
Original file line number Diff line number Diff line change
Expand Up @@ -277,9 +277,10 @@ def refit_policy_generation(
"""Refit the policy generation interface with the latest policy weights."""
policy.offload_before_refit()
ipc_handles = policy.get_weights_ipc_handles()
policy_generation.prepare_for_generation()
policy_generation.prepare_for_generation(tags=["weights"])
policy_generation.update_weights(ipc_handles)
policy.offload_after_refit()
policy_generation.prepare_for_generation(tags=["kv_cache"])


def generate_responses(
Expand Down
10 changes: 7 additions & 3 deletions nemo_reinforcer/models/generation/vllm.py
Original file line number Diff line number Diff line change
Expand Up @@ -410,8 +410,12 @@ def sleep(self):
gc.collect()
torch.cuda.empty_cache()

def wake_up(self):
self.llm.wake_up()
def wake_up(self, **kwargs):
# tags like ["weights", "kv_cache"]
if "tags" in kwargs:
self.llm.wake_up(tags=kwargs["tags"])
else:
self.llm.wake_up()


class VllmGeneration(GenerationInterface):
Expand Down Expand Up @@ -580,7 +584,7 @@ def prepare_for_generation(self, *args, **kwargs):
try:
# Use run_all_workers_single_data for methods that don't need data
futures = self.worker_group.run_all_workers_single_data(
"wake_up", respect_tied_workers=True
"wake_up", respect_tied_workers=True, **kwargs
)
# Wait for all futures to complete
results = ray.get(futures)
Expand Down