Skip to content
Merged
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
8 changes: 4 additions & 4 deletions xtuner/v1/rl/base/worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@
from xtuner.v1.ray.config import RolloutConfig
from xtuner.v1.ray.utils import free_object_refs
from xtuner.v1.rl.base.loss import BaseRLLossContext
from xtuner.v1.rl.utils import gather_logprobs
from xtuner.v1.train.trainer import LoadCheckpointConfig
from xtuner.v1.utils import (
XTUNER_DETERMINISTIC,
Expand Down Expand Up @@ -391,9 +390,10 @@ def compute_ref_logprobs(
ref_logprobs_list: list[torch.Tensor] = []
for seq_ctx, shifted_labels in zip(seq_ctx_list, shifted_labels_list):
with torch.no_grad():
ref_output = self._ref_model(seq_ctx=seq_ctx, loss_ctx=None)
ref_logprobs = gather_logprobs(ref_output["logits"], shifted_labels)
ref_logprobs_list.append(ref_logprobs)
loss_ctx = self.logprob_cfg.build(data={"shifted_labels": shifted_labels})
assert loss_ctx is not None
ref_output = self._ref_model(seq_ctx=seq_ctx, loss_ctx={"lm": loss_ctx})
ref_logprobs_list.append(ref_output["loss"])
Comment thread
hhaAndroid marked this conversation as resolved.
self._ref_model.to_device("cpu")
return ref_logprobs_list

Expand Down
Loading