sysprog
      • Sharing URL Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Customize slides
      • Note Permission
      • Read
        • Owners
        • Signed-in users
        • Everyone
        Owners Signed-in users Everyone
      • Write
        • Owners
        • Signed-in users
        • Everyone
        Owners Signed-in users Everyone
      • Engagement control Commenting, Suggest edit, Emoji Reply
    • Invite by email
      Invitee

      This note has no invitees

    • Publish Note

      Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

      Your note will be visible on your profile and discoverable by anyone.
      Your note is now live.
      This note is visible on your profile and discoverable online.
      Everyone on the web can find and read all notes of this public team.
      See published notes
      Unpublish note
      Please check the box to agree to the Community Guidelines.
      View profile
    • Commenting
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
      • Everyone
    • Suggest edit
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
    • Emoji Reply
    • Enable
    • Versions and GitHub Sync
    • Note settings
    • Note Insights New
    • Engagement control
    • Transfer ownership
    • Delete this note
    • Insert from template
    • Import from
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
    • Export to
      • Dropbox
      • Google Drive
      • Gist
    • Download
      • Markdown
      • HTML
      • Raw HTML
Menu Note settings Note Insights Versions and GitHub Sync Sharing URL Help
Menu
Options
Engagement control Transfer ownership Delete this note
Import from
Dropbox Google Drive Gist Clipboard
Export to
Dropbox Google Drive Gist
Download
Markdown HTML Raw HTML
Back
Sharing URL Link copied
/edit
View mode
  • Edit mode
  • View mode
  • Book mode
  • Slide mode
Edit mode View mode Book mode Slide mode
Customize slides
Note Permission
Read
Owners
  • Owners
  • Signed-in users
  • Everyone
Owners Signed-in users Everyone
Write
Owners
  • Owners
  • Signed-in users
  • Everyone
Owners Signed-in users Everyone
Engagement control Commenting, Suggest edit, Emoji Reply
  • Invite by email
    Invitee

    This note has no invitees

  • Publish Note

    Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

    Your note will be visible on your profile and discoverable by anyone.
    Your note is now live.
    This note is visible on your profile and discoverable online.
    Everyone on the web can find and read all notes of this public team.
    See published notes
    Unpublish note
    Please check the box to agree to the Community Guidelines.
    View profile
    Engagement control
    Commenting
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    • Everyone
    Suggest edit
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    Emoji Reply
    Enable
    Import from Dropbox Google Drive Gist Clipboard
       Owned this note    Owned this note      
    Published Linked with GitHub
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    ## 演講簡記 許秉倫畢業於台灣大學電機系,之後前往美國加州大學柏克萊分校就讀一年制的MEng課程,該課程以求職為導向。畢業後加入 LinkedIn,並在 Liger Kernel 專案之前參與三個知名專案,分別是 Apache Foundation 的 Submarine、Linux Foundation 的 Flyte,及 LMSYS Org 的SGLang。 > "Talk is cheap. Show me the code" -- Linus Torvalds GPT 本質的限制,至今仍無法寫好 CUDA kernel Mitchell Hashimoto: 不要迷失於 10x 工程師,真正解決問題才是關鍵 為何要投入 open source?高度的 impact 是關鍵,且過程中學習到的技術,是可不受公司限制,到了其他地方依舊適用 軟體工程師的職責不僅僅是解題平台的考題準備,那些技能可能只是在求職初期需要,而在職涯中後期,專案背景的累積顯得更加重要。他認為參與開源專案是一個加分項,因為開源專案的程式碼與貢獻可以公開展示,而公司內部專案常因保密需求而受限。此外,他指出在人工智慧時代,工程師的程式能力將愈加受到重視。 對於企業開源專案的價值,以 Meta 的 PyTorch 和 Google 的TensorFlow 為例,指出這些專案不僅吸引專家加入,也有助於企業的招聘工作。例如 LinkedIn 的 Liger Kernel 專案,內部僅有五名工程師參與,但透過開源社群,參與者總數達五十人以上。開源專案還讓工程師的技能具備更高的可轉移性,這是內部專案無法提供的。 在談論AI的發展時,以一張冰山圖為例,指出目前顯露在外的技術多是 CoT 和 RAG,但隱藏在水面下的包括 PDF 解析、Liger Kernel、GPU 工具等數十個專案,這些才是 AI 真正的競爭力所在。 以 LORA 來說,是知名的訓練框架,但有其限制 在矽谷,任何一個作基礎建設的公司,都會移往 ML 及其大規模的系統架構。 目前 GPU 遇到的技術挑戰: * GPU scarcity * Low Utilization: 如果沒有經過特別優化通常使用率只有 20% * Scaling Challenges: Out of Memory GPU 的效能議題 (GPU 運算可以簡化成以下三個步驟): 1. CPU -> GPU DRAM (HBM) (e.g. pytorch dispatcher) 2. GPU DRAM (HBM) -> GPU SRAM 3. GPU compute 從高階觀點來看: PyTorch dispatcher -> HBM (高速記憶體) -> compute (真正計算的單元和機制) ![image](https://hackmd.io/_uploads/SJ_1nZdBye.png) 效能瓶頸: * overhead bound : CPU-> HBM (例如小的 tensor 運算) * bandwidth bound : HBM -> GPU SRAM (例如 element-wise ops) * compute bound : 例如矩陣乘法 (通常這是最想看到的,這代表 GPU 的運算資源真的用滿了) kernel fusion 的示範 將 `b = a * a * a * a` 轉換為 `b = mul3(a)`,前者會因為 GPU 的機制,每次都將 SRAM 得到的結果寫回 HBM,後者是客製化的 kernel,可省下記憶體傳輸的時間,後者佔用大量的成本 搭配 profiler 找出值得 fusion 的操作,避免每次都將結果寫回 HBM MFU 是衡量 GPU 效益的指標,例如在大語言模型訓練的過程平均 20-30% 就沒效益 改進方案: CPU offloading, gradient checkpointing, paged optimizer 以 Llama 3 訓練為例,區分記憶體和運算操作 Liger Kernel 的底層語言使用 Triton (跟 NVIDIA 的 Triton server 無關,而來自 OpenAI),而 Triton 並不是生成 CUDA code 而是直接生成 GPU 的機械碼,這是種能直接操作 GPU 並自動改善底層表現的開放原始碼程式語言,其設計簡潔且與 Python 相容,適合大規模運算。在 Liger Kernel 的運算模型中,GPU的效能挑戰主要來自三個階段:CPU到GPU的傳輸、GPU 記憶體到運算單元的資料傳輸,及 GPU 運算本身。其中,資料傳輸階段最常形成瓶頸,解決方案則是採用 **Kernel Fusion** 策略,將多次運算合併為單次執行,顯著提高效率。 Triton 的優點: 1. 可自動最佳化,降低對 GPU 使用的難度 2. 可用類似 NumPy 的方式操作 GPU 3. Python-native,不用依賴 C/C++ 或其他程式語言來建構,支援 JIT 編譯 4. 通常 NVIDIA GPU 安裝好之後即可使用 運算時期效率與記憶體使用量的最佳化是一大挑戰。例如,處理大型詞彙表時,僅 **Cross Entropy** 階段就可能消耗 32GB 記憶體。Liger Kernel 透過 Kernel fusion、分塊技術和線性運算,成功提升運算效率並將記憶體使用量降低到 1GB 左右,並省略 CPU offloading 等傳統技巧。 ![profiling](https://hackmd.io/_uploads/SJ-ZGMurye.png) 一次的梯度下降總共啟動了 6 次 kernel,linear fwd -> log softmax fwd -> NLL loss fwd -> NLL loss bwd -> log softmax bwd -> linear bwd。其中 fwd 代表 forward pass;bwd 代表 backward pass。其中 forward pass 的運算結果必須存起來以利後續的運算。因此記憶體使用量在 NLL loss bwd 階段時最高。 以 Gemma-2 9B 為例,詞彙表的大小為 256K。若使用 fp32 格式,序列長度 (seq len) 為 4096,批次大小 (batch size) 為 8,則記憶體使用量為 32 GB。 因此 Liger Kernel 首先使用了 Kernel fusion 的技術來減少 kernel 的啟動次數,在 Kernel fusion 中除了將不同的階段進行合併,同時也簡化運算過程以此達到提升運算效率的同時減少記憶體使用量。 此時的記憶體使用量已從原本的 32 GB 縮減至 16 GB,為了更進一步的減少記憶體的開銷,Liger Kernel 還採用了分塊技術,將一次的梯度更新分成多次進行,以此大幅的降低記憶體使用量。 經過上述施加一系列最佳化之後,記憶體的使用量從原本的 4N 下降至 2*N/(V/H)。 ![optimization](https://hackmd.io/_uploads/HJLz7zOSJl.png) 原本: ![original](https://hackmd.io/_uploads/ryerlzOB1g.png =50%x) 調整後: ![tuned](https://hackmd.io/_uploads/HJ_wgGOBye.png =50%x) Liger Kernel 團隊著眼於可靠性、數值穩定性、收斂性及易用性。他們的測試流程涵蓋正確性測試、效能測試、小模型收斂測試,以及產品測試,確保系統能在各種情境下穩定運行。 ![OOM](https://hackmd.io/_uploads/B1G8bMOr1l.png =50%x) HuggingFace 的訓練,會因 embedding 空間導致 OOM,即 large vocab size 議題 Liger Kernel 在開發時驗證的四個流程 1. Correctness Test: 使用各種不同的輸入來檢測結果皆正確。(fp32, bf16)。 2. Performance Test: 使用真的 input 的格式與型態進行測試。 3. Convergence Test: 使用縮小過後的模型檢查使用 Liger Kernel 與沒有使用 Liger Kernel 訓練時模型收斂的結果是否相同。 4. Production Test: 實際跑在產品上 **Liger** 的命名隱含 **Li**nkedIn **G**PU **E**fficient **R**untime {%youtube gWble4FreV4 %} ## 2024-12-24 問答 > 歡迎在活動前或進行中提交你的疑惑,與談者將嘗試予以回覆 $\to$ [請編輯 **HackMD 頁面**](https://hackmd.io/Qt1iJxGEQOe5xdpWrTvJvw) 1. 我有問題: Byron您好,在現今AI高速發展的情況下,你會建議該如何踏進大語言模型與GPU 訓練的領域呢?因為工作上可能跟這一塊也沒有相關,雖然有去了解相關議題,但不知道如何利用工作以外的時間來摸索這一塊,不知道你會如何建議,謝謝。 - A: Mind set 很重要,不要認為這些事情跟自己沒有關係,不要當理由伯。學習資源:programming massively parallel processing(ppmp),Andrej Karpathy 2. 我有問題: Byron您好,請問您之前面試時,您覺得面試公司除了注重您的個人技術以外,還會比較注重哪一部分呢?例如開源專案的參與度?或是什麼呢 - A: 以 Google 面試的經驗,除了寫 code 以外,溝通很重要。有時候題目沒有答出來沒問題,但可以透過溝通完成面試,參與開源專案是一個練習溝通的方式。 3. 我有問題: Byron您好,你在第一線軟體公司工作,好奇您在一開始工作時有遇到什麼困難嗎?或是讓您很驚訝的事情呢?另外公司是很注重個人工作效率嗎?還是比較注重哪一部分呢?謝謝。 A: 做開源有很大的幫助,在做開源時累積了很多技能。很驚訝的事情,午餐是免費的;很注重 documentation,自己做過的所有東西都需要紀錄下來,盡量使用英文。 4. 我有問題: Byron您好,請問在現今硬體需求快速提升的背景下,新創公司或學術工作者在 LLM 領域除了本次演講主題的訓練框架外,是否有其他具有潛力的研究方向或機會,以避免和科技巨頭進行軍備競賽,謝謝。 A: inference optimization,因為 inference 就是要盡量使用較少的資源進行運算 ; 去接觸與GPU相關的領域。 5. 我有問題: Byron您好,請問要如何加入大型開源軟體的開發,感覺在上萬行的程式碼中很難直接找出程式的問題並做出貢獻,謝謝。 6. 我有問題: Byron您好,您提到參與開源專案能提高技能的可轉移性,但對於剛起步的工程師來說,對於相關技能都沒很熟悉的情景下,如何有效挑選適合自己的開源專案並快速上手,避免因項目複雜度而感到挫折呢?謝謝。 7. 我有問題: Byron您好,關於 Kernel Fusion 技術在提升 GPU 效率上的應用,想請教未來是否有其他可能的技術突破,例如在硬體架構或記憶體設計上的創新,能進一步提升大規模運算的效能?謝謝。 8. 我有問題: Byron您好,想請問對於一個剛接觸開源的人,有什麼建議入門的開源專案?以及您那時為何選擇submarine進行貢獻?謝謝。 A: 開源比較像是一個金礦銀礦,要自己去挖,初學者很難自己去挖,能做的事情就是"厚顏無恥"找開源社群中活躍的 maintainer 詢問,同時也要展現出自己的決心,並表現自己做了哪些功課。(詢問時說自己是學生很重要);可以選定一個目標,例如你想把 inference 學好,這樣就可以找與 inference 有關的開源專案 9. 我有問題: Byron您好,你身為資訊產業最前線的工程師,想問你對於未來資訊產業會如何發展有什麼看法,例如:市場對於哪些特定領域的人才需求會增加...?謝謝。 A: 如果你以後想在美國工作,你最好要有兩段實習經驗;找的到工作的同學也大多在台灣就有工作經驗(Google實習只要兩段面試);多找暑期實習(step實習也可參考);不要只會寫網頁或小的APP,很容易找不到工作,競爭太激烈。 找實習=先求有再求好。 10. 我有問題: Byron學長您好,請問可以加您的linkedin嗎?謝謝。恭喜破4000個星星⭐️了。(目前:4007) 11. 我有問題: 學長你好,聽完學長的介紹,我也想在開發liger kernel上做出貢獻,但以往沒有開發經驗,請問我可以從哪裡開始入門呢? A: 先了解 LLM 的知識;看懂 Triton 要怎麼寫;要有 GPU 資源(3080可能不夠喔) 12. 我有問題: 學長您好,我想請問當初怎麼會想選 Meng 的 program 而不是 MS,選擇 Meng 會對於在美國找工作會有影響嗎? A: 跟景氣相關,每一屆都不太一樣,看一下上一屆的學長姊怎麼選擇;你投身的領域一定要是AI很難做到的(GPU相關底層的優化,先去看你想去的公司的工作描述) 13. 我有問題: 學長您好,在剛剛對於input切NumChunks分批輸入時,是否會因為Model不同而有所影響 基於Attention的理論的話,Input會需要全部輸入並經由Attention layer去選擇各tokens的權重 那這樣對於input切NumChunks是否會有影響? 14. 我有問題: 學長你好,想請問在準備出國留學是,覺得最困難的部分是什麼? 15. 我有問題: 學長您好,前面大部分的問題是詢問該怎麼克服困難,但想知道是有什麼動機可以一直push學長前進?不論是以往的求學、現在的工作和開源專案等等,非常謝謝。 16. 我有問題 Byron您好,除了flash attention來優化softmax運算在記憶體搬運的次數,那是否還有其他方法來優化softmax運算提高運算速度? 17. 我有問題 如果我想去國外工作在不同國家當工程師,會建議去讀國外的二碩還是直接進到台灣的外商爭取輪調的機會?謝謝學長 18. 我有問題 如果想進Google等公司,碩班期間刷題、開源、實驗室計畫各自占比?或是應該怎麼管理這個時間分配 A: 可以將做過的 Project 列上去,如果 Project 不夠強用工作經驗補。刷題重質不重量,要選擇題目,建議可以一邊寫一邊講。占比還是要看自己的分配,建議還是每天都要刷。 19. 我有問題 Byron您好,目前llm大多針對linear運算做優化,包括量化、data reuse...這些,反而相對nonlinear運算的優化比較少,像是normalization,gelu,softmax運算。目前有人針對這些nolinear運算優化做相關研究嗎? A: non-linear 比較多的是用 kernel fusion 或是從數學的層面修改。 20. 我有問題: 學長們好,我常常覺得自己什麼都不會,什麼都學不好,有什麼解決辦法嗎,或怎麼增強自己的實力呢? 21. 我有問題 第九題卡Byron學長的分享 <!--有事必須先離席,希望會有好心人幫忙記錄回答嗚嗚,謝謝--> 22. 我有問題 學長們好,jserv老師好,想請問現在投資的 skill set 是越底層越不會被 AI 取代嗎?例如:專研 Linux Kernel 等。另外想請問,在資訊科技產業這樣高壓的環境中,怎麼兼顧身心健康? 23. 我有問題 學長好,請問 Liger Kernel 有沒有辦法處理多個模型的 pipeline 加速?例如:image raw -> "yolo" -> string and tag -> "RL" -> action。有沒有辦法能夠使中間產物不需要經過 CPU 與 GPU 之間的搬移? 24.我有問題 學長好 25. 如果此時此刻想要去美國,應該要做什麼準備? A: 不用只顧 GPA,盲目的追求,更重要的是自己的 skill set 的稀少性。以最標準的例子是做研究,就是想辦法建立與國外實驗室的 connection。如果是要做工程師,就是透過各種方式認識領域大神,想辦法把技能練強。 A: 最好的方式就是美國開職缺的時候剛好符合,直接剛好 match,所以工作經驗很重要,而且要學會包裝自己。但還是要看自己的規劃,如果是 MLE 通常需要讀博

    Import from clipboard

    Paste your markdown or webpage here...

    Advanced permission required

    Your current role can only read. Ask the system administrator to acquire write and comment permission.

    This team is disabled

    Sorry, this team is disabled. You can't edit this note.

    This note is locked

    Sorry, only owner can edit this note.

    Reach the limit

    Sorry, you've reached the max length this note can be.
    Please reduce the content or divide it to more notes, thank you!

    Import from Gist

    Import from Snippet

    or

    Export to Snippet

    Are you sure?

    Do you really want to delete this note?
    All users will lose their connection.

    Create a note from template

    Create a note from template

    Oops...
    This template has been removed or transferred.
    Upgrade
    All
    • All
    • Team
    No template.

    Create a template

    Upgrade

    Delete template

    Do you really want to delete this template?
    Turn this template into a regular note and keep its content, versions, and comments.

    This page need refresh

    You have an incompatible client version.
    Refresh to update.
    New version available!
    See releases notes here
    Refresh to enjoy new features.
    Your user state has changed.
    Refresh to load new user state.

    Sign in

    Forgot password

    or

    By clicking below, you agree to our terms of service.

    Sign in via Facebook Sign in via Twitter Sign in via GitHub Sign in via Dropbox Sign in with Wallet
    Wallet ( )
    Connect another wallet

    New to HackMD? Sign up

    Help

    • English
    • 中文
    • Français
    • Deutsch
    • 日本語
    • Español
    • Català
    • Ελληνικά
    • Português
    • italiano
    • Türkçe
    • Русский
    • Nederlands
    • hrvatski jezik
    • język polski
    • Українська
    • हिन्दी
    • svenska
    • Esperanto
    • dansk

    Documents

    Help & Tutorial

    How to use Book mode

    Slide Example

    API Docs

    Edit in VSCode

    Install browser extension

    Contacts

    Feedback

    Discord

    Send us email

    Resources

    Releases

    Pricing

    Blog

    Policy

    Terms

    Privacy

    Cheatsheet

    Syntax Example Reference
    # Header Header 基本排版
    - Unordered List
    • Unordered List
    1. Ordered List
    1. Ordered List
    - [ ] Todo List
    • Todo List
    > Blockquote
    Blockquote
    **Bold font** Bold font
    *Italics font* Italics font
    ~~Strikethrough~~ Strikethrough
    19^th^ 19th
    H~2~O H2O
    ++Inserted text++ Inserted text
    ==Marked text== Marked text
    [link text](https:// "title") Link
    ![image alt](https:// "title") Image
    `Code` Code 在筆記中貼入程式碼
    ```javascript
    var i = 0;
    ```
    var i = 0;
    :smile: :smile: Emoji list
    {%youtube youtube_id %} Externals
    $L^aT_eX$ LaTeX
    :::info
    This is a alert area.
    :::

    This is a alert area.

    Versions and GitHub Sync
    Get Full History Access

    • Edit version name
    • Delete

    revision author avatar     named on  

    More Less

    Note content is identical to the latest version.
    Compare
      Choose a version
      No search result
      Version not found
    Sign in to link this note to GitHub
    Learn more
    This note is not linked with GitHub
     

    Feedback

    Submission failed, please try again

    Thanks for your support.

    On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

    Please give us some advice and help us improve HackMD.

     

    Thanks for your feedback

    Remove version name

    Do you want to remove this version name and description?

    Transfer ownership

    Transfer to
      Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

        Link with GitHub

        Please authorize HackMD on GitHub
        • Please sign in to GitHub and install the HackMD app on your GitHub repo.
        • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
        Learn more  Sign in to GitHub

        Push the note to GitHub Push to GitHub Pull a file from GitHub

          Authorize again
         

        Choose which file to push to

        Select repo
        Refresh Authorize more repos
        Select branch
        Select file
        Select branch
        Choose version(s) to push
        • Save a new version and push
        • Choose from existing versions
        Include title and tags
        Available push count

        Pull from GitHub

         
        File from GitHub
        File from HackMD

        GitHub Link Settings

        File linked

        Linked by
        File path
        Last synced branch
        Available push count

        Danger Zone

        Unlink
        You will no longer receive notification when GitHub file changes after unlink.

        Syncing

        Push failed

        Push successfully