• <xmp id="om0om">
  • <table id="om0om"><noscript id="om0om"></noscript></table>
  • Development & Optimization

    DeepSeek-R1 ? ?? ?? ????? ?? GPU ?? ?? ???

    Reading Time: 4 minutes

    AI ??? ?? ? ??? ??? ???? ?? ??? ?????, ??? ?? ?? ?? ?? ?? ????? ??? ???? ????. ? ??? AI? ?? ?? ???? ??? ???? ???? ?? ?? ??? ??? ??? ?, ?? ??? ???? ?????? ??? ??? ????? ?????. ?? ?? AI? ??? ??? ??? ???? ???? ??? ????, ????? ???? ???? ?? ? ????.

    ? ???? NVIDIA ?????? ?? ?? ?? ?? ? ??? DeepSeek-R1 ??? ?? ???? ?? ??? ??? ?? ??? ??? ??? ??? ??? ?? ??????. ? ??? ??? ???? ????? ??? ????? ???? ??? ??? ??? ???? GPU ??? ??? ???? ???? ??????.

    ? ??, ??? ?? ??? ????? ??? ???? ???? ? ?? ??? ??????.

    ???? ??? ??? ??? ? ?? ??

    ???? ?? ?? ??(LLM) ??? ??? ??? ?? ?????. AI ??? ??? ??? ? ?? ? ?? ???? ?? ??? ????? ????? ???? ??? ??????, ??? ??? ?????? ? ??? ??? ?? ??? ? ?? ??? ????? ??? ? ????.

    ??? ??? ?? ???? ?? ??? ??? ?? 4???? ?????. ??? ??? ?? ????? ??? ??(?: ??? ??)? ??? ? ??, ?? ???? ??? ?? ???? ??? ??(GPU ?? ?)? ?????.

    ????? ?? ??, ??? ?? ???, ???? ? ??? ??? ???, ????? ??? ??? ?? ??? ??? ??? ??? ???? ???.

    ?? ?? ??(?: ?? ?????)? ??? ???? ??? ?? ???? ??? ??? ???? ?? ??? ??, ?? ?? ???(Spatial Neighborhood Attention) ?? ??? ??? ????? ?????. ?? ?? ???? ??? ??? ???? ???.

    ?? 1. 2D ??? ?? ?? ???

    ???? ???? GPU ??? ????? ??? ????? ?????? ?? ??? ??? ?????.

    DeepSeek-R1? ?? ?? LLM? ?? ???? ?? ???? ??????, ? ????? ???? ??? ???? ?? ?????. ??? ?? ???? ?? ??? ??? ? ???? ??? ???? ??? ?????.

    ?? ????? ?? ?? ??? ??? ??? ?? ?? ??? ?????.

    Please write a GPU attention kernel to support relative position encodings. Implement the relative positional encoding on the fly within the kernel. The complete code should be returned, including the necessary modifications.
     
    Use the following function to compute the relative positional encoding:
     
    def relative_positional(score, b, h, q_idx, kv_idx):
     
        return score + (q_idx - kv_idx)
     
    When implementing the kernel, keep in mind that a constant scaling factor 1.44269504 should be applied to the relative positional encoding due to qk_scale = sm_scale * 1.44269504. The PyTorch reference does not need to scale the relative positional encoding, but in the GPU kernel, use:
     
    qk = qk * qk_scale + rel_pos * 1.44269504
     
    Please provide the complete updated kernel code that incorporates these changes, ensuring that the relative positional encoding is applied efficiently within the kernel operations.

    LLM? ??? ?? ??? ????? ?? ?? ?? ?????? ??? ???? ???? ?? ?? ?? ????? ??? ? ????. ??? GPU ??? ??? ???? ?? ???? ?? ???? ????, ???? ???? ??? ?? ?? ???? ??? ??? ??? ????

    ???? GPU ?? ??? ?? ?? ?? ????

    ???? ??? ???? ??? ??? ?? ??, NVIDIA ?????? ?? ?? ?? ??? ???? ????? DeepSeek-R1 ??? ?? ?? ???? ???? ??? ?????? ??????.

    ?? 2. NVIDIA Hopper ????? DeepSeek-R1? ??? ?? ?? ??

    ?????? ?? ?? ????? ?? ????? DeepSeek-R1 ??? ? ?? ???? GPU ??(?, ??)? ?????. ???? NVIDIA H100 GPU?? ?????. ? ???? ??? ??? ???? ??? ????? ???? DeepSeek-R1 ??? ???? ?????.

    ? ?? ?? ?? ??? ?? ?? ???? ??? ????? ???? ?? ?? ????? ?????. ???? ? ????? 15? ?? ?? ???? ??? ??? ????? ??? ??????.

    ?? 3. ??? ????? ?? ??? ???? ??? ??? ??

    ? ???????? ????? KernelBench ?????? ???? ?? ?? 1 ??? 100%, ?? 2 ??? 96%? ?? ????? ??? ??? ??????.

    KernelBench? ?? 1 ???? ?? ?? ??? ?? ???? GPU ??? ???? LLM? ??? ???? ? ???? ???? ??? ??? ?????. ? ???? GPU ??????? ?? LLM? ??? ????? ?? ??? ?? ? ?????.

    ?? 4? ?? ?? ??? ????? ?? ??? ?? ??? ???? ?????. ?? 1 ?????? ??? 10? ??? ???? ??????? 100?? ?? ???? ?? ????? ??? ??? ??? ? ????.

    ?? 4. ?? ?? ??? ?? ???? GPU ?? ?? ??

    DeepSeek-R1?? ???? GPU ??

    ? ??? ?? DeepSeek-R1 ??? ??? ?? ?? ?? ? ?? ??? ??? ?????? ??? GPU ??? ???? ??? ?????. ?? ??? ?? ?????, ???? ??? ??? ???? ???? ??? ?? ??? ?? ?? ??? ??? ????.

    ?? ??? ????, ? ??? ???? ???? ??? ??? ???? ???? ??? ??? ?????. ?? DeepSeek-R1? ??? ? ???? ?? ??? ???.

    ??? ??? ????? ????? ?? build.nvidia.com?? ???? DeepSeek-R1 NIM ???????? ??? ???.

    ?? ???

    Discuss (0)
    0

    Tags

    人人超碰97caoporen国产