Skip to content

Latest commit

 

History

2 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

nano-vllm-reading

这是对 nano-vllm 的阅读版整理,保留原始代码结构,并加入了面向学习的中文注释和阅读笔记。

内容

  • example.py:最小调用入口。
  • nanovllm/llm.py:外部 API 封装。
  • nanovllm/engine/llm_engine.py:主执行循环,核心入口是 LLMEngine.step()
  • nanovllm/engine/scheduler.py:请求调度、prefill、decode 和抢占逻辑。
  • nanovllm/engine/block_manager.py:KV cache block 分配与 prefix cache。
  • nanovllm/engine/model_runner.py:模型输入构造、CUDA graph、推理执行。
  • nanovllm/layers/attention.py:prefill/decode attention 与 KV cache 读写。
  • reading.md:按执行链路整理的阅读笔记。

主线

LLM.generate
-> LLMEngine.add_request
-> LLMEngine.step
-> Scheduler.schedule
-> ModelRunner.run
-> Attention
-> postprocess

理解这条链路后,再分别看 SequenceSchedulerBlockManagerModelRunnerAttention 会更清楚。

运行

pip install -e .
python example.py

example.py 中的模型路径需要改成本地实际路径。

Star History

Star History Chart

About

No description, website, or topics provided.

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages