Skip to content

Latest commit

 

History

2 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 

Repository files navigation

megakernel-profiling-feasibility

这个仓库是一份可行性审查笔记,讨论一个还没有动手实现的研究设想:能不能给 GPU 巨核(megakernel)做一个 Coz 式的因果剖析工具

先解释这句话里的两个名字。

Coz 是 2015 年发表的一个 CPU 性能分析工具。传统的性能分析工具回答的是「程序的时间花在哪一行」,Coz 回答的是另一个问题:「如果我把这一行代码加速 20%,整个程序会快多少」。它的办法是:既然没法真的把目标代码变快,那就在目标代码运行的时候,让其他线程暂停一小会儿——目标代码相对于程序其余部分的进度就提前了,效果与真的加速它相当。

megakernel(巨核) 是一种 GPU 程序结构。GPU 上一段交给硬件执行的函数叫核函数(kernel),CPU 把它交给 GPU 去跑叫一次启动。传统做法是一个运算对应一次启动,跑一次模型要启动成百上千次;megakernel 反过来,把整个模型的所有运算、通信和调度逻辑塞进一个长期运行的核函数里,启动一次就一直跑下去。

这个仓库里没有代码,也没有实验数据。它记录的是:这个设想有没有人做过、引用的材料是否属实、它可能在哪些地方站不住,以及审查过程中有哪些结论被后续核实推翻了。

材料来源

起点是一次 ChatGPT 对话(由合作者提供),内容是这个设想有没有价值、有没有人做过、难点在哪里。那次回答没有跑任何实验、没有读任何代码,只做了两批网页检索,所以它在这里的用法是提纲和问题清单,不是事实来源。

此后每一处引用都回到原始出处核实过,包括:论文正文(不只是摘要)、NVIDIA 官方文档(CUDA C++ Programming Guide、PTX ISA、Nsight Compute 文档),以及 Coz(GitHub 上的 plasma-umass/coz)和 MPK(GitHub 上的 mirage-project/mirage,mpk 分支)两个系统的源码。

仓库里的结论分三类,并且逐处标注属于哪一类:

  • 已核实的事实:有论文原文、官方文档或源码可以对照,引文一律照抄。
  • 推理:从已核实的前提推出来的判断,在原处明确标注为推理。
  • 假设的示例数字:为把问题讲明白而假设的一组数字,在原处明确标注,不是实测结果。

文件导航

  • docs/01-conversation-and-terms.md — 那次对话的逐节复述,以及其中每一个术语的大白话解释。
  • docs/02-verification-of-citations.md — 引用核实:哪些说法核实为真、哪一处要修正、哪一条没能核实;并交代这次检索查了什么、没查什么。
  • docs/03-risks.md — 风险分析:这个设想可能在哪些地方站不住,从结构性问题到实验设计上的具体障碍。
  • docs/04-reviewer-questions.md — 审查过程中提出的五条质疑,以及每一条最后怎么收场。
  • docs/05-chatgpt-answer-audit.md — 对那次 ChatGPT 回答的逐条对照:说准了什么、没说到什么、哪里说得不准。
  • docs/06-revision-log.md — 修订记录:审查过程中被推翻的四条说法,以及推翻它们的证据。

如果是第一次读,建议的顺序是:先读 01 把术语和对话内容过一遍,再读 03 看主要结论;02、05、06 是支撑材料,04 记录了这些结论是被什么问题逼出来的。

怎么读这些结论

有两点限定,读之前需要知道。

所有「没有人做过」性质的判断,强度只到「在已交代的检索范围内没有找到」为止。 这次查过什么、没查什么,写在 docs/02-verification-of-citations.md 里;明确没有覆盖的包括中文文献库、各公司内部未公开的实现、各 GPU 厂商未公开的内部工具,以及 dblp 不收录的一部分会议。「这次没有找到」不等于「不存在」。

文中出现的一组数字是为了说明问题而假设的,不能当作实测结果引用。 那组数字在 docs/03-risks.md 里,用来说明三类优化在结构上的差别;原处已经标注它是假设值,并且为了让算式一眼看懂,还额外假设了一种理想的线性关系(某个阶段的 warp 数变成原来的多少倍,这个阶段的耗时就按同样比例缩短),真实硬件不会这么理想。其余数字都注明了出处,来自论文正文、官方文档或源码。

English summary

This repository holds feasibility-review notes for a research idea that has not been implemented: whether a Coz-style causal profiler can be built for GPU megakernels. Coz (SOSP 2015) answers "how much faster would the whole program run if this line were 20% faster" by pausing the other threads while the target code runs. A megakernel packs an entire model's computation, communication and scheduling into one long-running GPU kernel instead of launching one kernel per operator.

The notes start from a ChatGPT conversation supplied by a collaborator and then re-verify every citation against primary sources: paper bodies rather than abstracts, NVIDIA's CUDA C++ Programming Guide, PTX ISA and Nsight Compute documentation, and the source code of Coz (plasma-umass/coz) and MPK (mirage-project/mirage, mpk branch). The contents are: a restatement of the conversation with plain-language explanations of every term, a citation audit, a risk analysis, the review questions raised and how each was settled, a point-by-point audit of the ChatGPT answer, and a log of four earlier claims that later evidence overturned.

Two limits on how strongly the conclusions should be read: every "nobody has done this" statement holds only as "not found within the search scope stated in docs/02", and one set of illustrative numbers is hypothetical and labelled as such where it appears.

About

Feasibility notes on Coz-style causal profiling inside GPU megakernels: source-verified citations, risk analysis, and a revision log.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors