콘텐츠로 이동

Python Sampling API

함수 시그니처
set_sampling_params (core_id: int, entry_index: int, entry_num: int, top_p: float, top_k: int, temperature: float, repetition_penalty: float, pseudo_random: float) -> None
set_sampling_params_async (core_id: int, entry_index: int, entry_num: int, top_p: float, top_k: int, temperature: float, repetition_penalty: float, pseudo_random: float, stream: int = HA_STREAM_DEFAULT) -> None

예제

set_sampling_params

디바이스에 캐싱되므로 안 바뀐 값을 매 스텝 다시 넣는 것은 낭비입니다.

예제
1
2
3
4
5
6
import hart

hart.set_sampling_params(
    core_id, entry_index, entry_num,
    top_p=0.9, top_k=50, temperature=0.8, repetition_penalty=1.1, pseudo_random=0.0,
)

set_sampling_params_async

설정을 스트림에 넣고 바로 반환합니다. 같은 스트림에서 이후에 넣은 실행보다 먼저 적용됩니다. 완료는 stream_synchronize()로 확인합니다.

예제
1
2
3
4
5
6
hart.set_sampling_params_async(
    core_id, entry_index, entry_num,
    top_p=0.9, top_k=50, temperature=0.8, repetition_penalty=1.1, pseudo_random=0.0,
    stream=stream,
)
hart.launch_kernel_async_with_binary_path(kernel_path, args, stream)

함께 보기