MCPcopy Create free account
hub / github.com/RL-Align/RL-Kernel / _run_sampling_native_workload

Function _run_sampling_native_workload

benchmarks/profiler.py:684–718  ·  view source on GitHub ↗
(
    profiler: PerformanceProfiler,
    args: argparse.Namespace,
    device: torch.device,
    dtype: torch.dtype,
    batch_size: int,
    seq_len: int,
    vocab_size: int,
)

Source from the content-addressed store, hash-verified

682
683
684def _run_sampling_native_workload(
685 profiler: PerformanceProfiler,
686 args: argparse.Namespace,
687 device: torch.device,
688 dtype: torch.dtype,
689 batch_size: int,
690 seq_len: int,
691 vocab_size: int,
692) -> BenchmarkMetrics:
693 try:
694 fn = _sampling_fn(
695 batch_size=batch_size,
696 vocab_size=vocab_size,
697 dtype=torch.float32 if device.type == "cpu" else dtype,
698 device=device,
699 seed=args.seed + 2,
700 top_k=args.top_k,
701 top_p=args.top_p,
702 )
703 return profiler.profile_sampling(
704 fn,
705 batch_size=batch_size,
706 seq_len=seq_len,
707 vocab_size=vocab_size,
708 benchmark_name="sampling_native",
709 )
710 except Exception as exc:
711 return _blocked_metric(
712 profiler=profiler,
713 benchmark_name="sampling_native",
714 batch_size=batch_size,
715 seq_len=seq_len,
716 vocab_size=vocab_size,
717 exc=exc,
718 )
719
720
721WORKLOAD_REGISTRY: dict[str, WorkloadRunner] = {

Callers

nothing calls this directly

Calls 3

_sampling_fnFunction · 0.85
_blocked_metricFunction · 0.85
profile_samplingMethod · 0.80

Tested by

no test coverage detected