↓ Skip to main content
  1. Categories/

Deep-Learning

2026

从 CS336 到 ML Infra:理解 Arithmetic Intensity、Accelerator Intensity,以及 Compute Bound / Memory Bound

起因 # 这是 CS336 系列的又一篇。 之前那篇讨论了 FLOPs 到 Latency 之间的鸿沟:FLOPs 相同的两个 GEMM,latency 可能差几倍甚至十几倍。那篇文章的核心结论是 FLOPs 是 workload metric,不是 performance metric,并且引入了 Arithmetic Intensity 和 Roofline Model 作为分析工具。

从线上模型切换问题理解 PyTorch CUDA Caching Allocator:为什么显存管理需要理解生命周期

起因 # 我们的线上推理系统中存在大量模型——MLP、GNN、MoE,以及它们的各种组合。这个 workload 有几个重要特点: 单张 GPU 上可能同时存在多个模型; 很多模型的 architecture 相同或者高度相似; 模型会随着业务时间轴不断上线、下线和切换; 模型切换过程对 latency 比较敏感。 随着模型数量增加以及动态上下线越来越频繁,我们逐渐观察到两个问题:GPU memory fragmentation,以及 model loading / switching latency。

从 CS336 的 xfail 看大型工程中的测试设计

·3497 words·7 mins
起因 # 最近在学 Stanford CS336(Language Modeling from Scratch),做 tokenizer 作业时,第一次在测试代码里见到了 pytest.mark.xfail。 具体是这段: 1@pytest.mark.xfail( 2 reason="Tokenizer.encode is expected to take more memory than allotted (1MB)." 3) 4def test_encode_memory_usage(): 5 """ 6 We expect this test to fail, since Tokenizer.encode is not expected to be memory efficient. 7 """ 8 tokenizer = get_tokenizer_from_vocab_merges_path( 9 vocab_path=VOCAB_PATH, 10 merges_path=MERGES_PATH, 11 ) 12 with open(FIXTURES_PATH / "tinystories_sample_5M.txt") as f: 13 contents = f.read() 14 _ = _encode(tokenizer, contents) 我当时第一反应是困惑:既然作者明确知道 encode 会超过 1MB,为什么不直接写成 assert memory > 1MB?或者干脆删掉?为什么要提交一个「预期会失败」的测试?

2023

2022

2021

【推荐系统】Toward the Next Generation of Recommender Systems: A Survey of the State-of-the-Art and Possible Extensions

·1797 words·4 mins
迫于生计,从今天开始学习推荐系统相关的内容,先来读一篇推荐系统领域的综述 Toward the next generation of recommender systems: a survey of the state-of-the-art and possible extensions 由于目前的工作其实偏向推荐系统的 serving、训练的开发,因此这些 paper 可能都是粗读,也不会把 paper 中的内容逐句翻译,而是找出我认为最为重要的一些概念加以记录。

2020

【施工中】torch2trt 学习笔记

·559 words·2 mins
前言 # 偶然发现了 torch2trt 的模型转换方案,思路是直接将pytorch op映射到TensorRT的python api. 在pytorch进行每个op forward的时候,tensorrt也相应往network上添加op. 这里会先涉及torch2trt的使用,后面会补充这个转换工具的代码学习

Jetson Nano踩坑记录

·3101 words·7 mins
写在前面 # 主要是需要在 jetson nano 上做模型转换,来记录下踩的坑。 目前有两条路径,一条是我们现有的转换路径,也就是 pytorch->onnx(->caffe)->trt 的路径。 在这条路径上踩了比较多的坑,最终暂时放弃,最直接的原因是 cudnn8.0 升级接口发生改动,编译 caffe 遇到较多问题。 这里其实仍然采用了两条平行的路径,一条是直接在 nano 上构建环境,另外一种是基于 docker(包括构建交叉编译环境用于加快编译速度)。