Python
LeetCode: 242-Valid Anagram 解題紀錄
題目
Given two strings s
and t
, return true
if t
is an anagram of s
, and false
otherwise.
LeetCode: 1436-Destination City 解題紀錄
題目
You are given the array paths
, where paths[i] = [cityAi, cityBi]
means there exists a direct path going from cityAi
to cityBi
. Return the destination city, that is, the city without any path outgoing to another city.
LeetCode: 2482-Difference Between Ones and Zeros in Row and Column 解題紀錄
題目
You are given a 0-indexed m x n
binary matrix grid
.
A 0-indexed m x n
difference matrix diff
is created with the following procedure:
[PyTorch] 將模型刪除後,釋放 GPU / CPU 的記憶體空間
問題描述
昨晚,我在改進一段將模型融合的程式碼時,由於個人設備資源不足,我採取分層合併的方法,一次只取一層的記憶體進行合併,以此減少系統同時保存的模型記憶體大小。然而,我發現模型雖然在 GPU 中的記憶體很容易被刪除、但是 CPU 中的記憶體被回收是十分不容易的。這涉及到了 Python 的資源回收器的設計。
Read More »[PyTorch] 將模型刪除後,釋放 GPU / CPU 的記憶體空間[Python] 使用 tempfile 模組建立臨時工作目錄,並在工作流程結束後自動刪除
介紹
今天在閱讀 DreamBooth 訓練原始碼時,發現了 tempfile
這個模組;剛巧手邊又在做一個模型分層合併的的腳本改寫,頓時想到使用這個模組的話能夠讓程式碼優雅一些,便順手做了個紀錄。
使用 vLLM 進行大型語言模型(LLM)的高速推理
介紹
vLLM 是加州柏克萊分校所開發的一種大型語言模型(Large Language Model, LLM)加速推理框架。它主要是利用 PagedAttention 機制提高了 GPU VRAM 的使用率,並且這一方法無須更改模型的架構。
Read More »使用 vLLM 進行大型語言模型(LLM)的高速推理LeetCode: 606-Construct String from Binary Tree 解題紀錄
題目
Given the root
of a binary tree, construct a string consisting of parenthesis and integers from a binary tree with the preorder traversal way, and return it.
LeetCode: 1903-Largest Odd Number in String 解題紀錄
題目
You are given a string num
, representing a large integer. Return the largest-valued odd integer (as a string) that is a non-empty substring of num
, or an empty string ""
if no odd integer exists.
[已解決][PyTorch] 編譯(compile)後模型權重多出 "_orig_mod" 的前綴問題
問題描述
在 2023 年初,PyTorch 的 2.0 版本新增了一個 torch.compile()
的新功能,讓我們能夠在模型訓練/推理時能夠進一步提昇速度。與混合精度訓練的協同工作,經常能使我的訓練速度提昇一倍左右。