← Về thư mục
verl/utils/torch_functional.py
- gather_from_labels · function · L34-L46 — def gather_from_labels(data, label)
- logprobs_from_logits · function · L49-L62 — def logprobs_from_logits(logits, labels)
- logprobs_from_logits_flash_attn · function · L65-L67 — def logprobs_from_logits_flash_attn(logits, labels)
- logprobs_from_logits_naive · function · L70-L73 — def logprobs_from_logits_naive(logits, labels)
- logprobs_of_labels_v2 · function · L76-L83 — def logprobs_of_labels_v2(logits: torch.FloatTensor, labels)
- clip_by_value · function · L86-L92 — def clip_by_value(x, tensor_min, tensor_max)
- entropy_from_logits · function · L95-L99 — def entropy_from_logits(logits: torch.Tensor)
- masked_sum · function · L102-L104 — def masked_sum(values, mask, axis=None)
- masked_mean · function · L107-L109 — def masked_mean(values, mask, axis=None)
- masked_var · function · L112-L127 — def masked_var(values, mask, unbiased=True)
- masked_whiten · function · L130-L136 — def masked_whiten(values, mask, shift_mean=True)
- get_eos_mask · function · L139-L148 — def get_eos_mask(response_id: torch.Tensor, eos_token: int = 2, dtype=torch.int64)
- compute_grad_norm · function · L151-L157 — def compute_grad_norm(model: nn.Module)
- broadcast_dict_tensor · function · L160-L166 — def broadcast_dict_tensor(tensors: Union[Dict[str, torch.Tensor], TensorDict], src, group)
- allgather_dict_tensors · function · L169-L200 — def allgather_dict_tensors(tensors: Union[Dict[str, torch.Tensor], TensorDict], size, group, dim=0)
- split_dict_tensor_into_batches · function · L203-L206 — def split_dict_tensor_into_batches(tensors: TensorDict, batch_size) -> List[TensorDict]
- pad_sequence_to_length · function · L209-L219 — def pad_sequence_to_length(tensors, max_seq_len, pad_token_id, left_pad=False)
- tokenize_and_postprocess_data · function · L225-L266 — def tokenize_and_postprocess_data(prompt: str, tokenizer: PreTrainedTokenizer, max_length: int, pad_token_id: int, left_pad=True, truncation='error')
- remove_pad_token · function · L269-L281 — def remove_pad_token(input_ids: torch.Tensor, attention_mask: torch.Tensor)
- log_probs_from_logits_response · function · L284-L297 — def log_probs_from_logits_response(input_ids, logits, response_length)
- log_probs_from_logits_response_rmpad · function · L300-L325 — def log_probs_from_logits_response_rmpad(input_ids, attention_mask, logits_rmpad, response_length)
- log_probs_from_logits_all_rmpad · function · L328-L353 — def log_probs_from_logits_all_rmpad(input_ids_rmpad, logits_rmpad, indices, batch_size, seqlen, response_length)
- post_process_logits · function · L359-L367 — def post_process_logits(input_ids, logits, temperature, top_k, top_p)
- get_cosine_schedule_with_warmup · function · L379-L419 — def get_cosine_schedule_with_warmup( optimizer: Optimizer, num_warmup_steps: int, num_training_steps: int, min_lr_ratio: float = 0.0, num_cycles: float = 0.5, last_epoch: int = -1, )
- lr_lambda · function · L412-L417 — def lr_lambda(current_step)
- get_constant_schedule_with_warmup · function · L422-L431 — def get_constant_schedule_with_warmup( optimizer: Optimizer, num_warmup_steps: int, last_epoch: int = -1, )
- lr_lambda · function · L428-L429 — def lr_lambda(current_step)
- prepare_decoder_attention_mask · function · L434-L452 — def prepare_decoder_attention_mask(attention_mask, input_shape, inputs_embeds): # create causal mask # [bsz, seq_len] -> [bsz, 1, tgt_seq_len, src_seq_len]
- _make_causal_mask · function · L456-L465 — def _make_causal_mask(input_ids_shape: torch.Size, dtype: torch.dtype, device: torch.device)
- _expand_mask · function · L469-L480 — def _expand_mask(mask: torch.Tensor, dtype: torch.dtype, tgt_len: Optional[int] = None)
- get_unpad_data · function · L483-L492 — def get_unpad_data(attention_mask)