{"owner":"liguodongiot","repo":"llm-action","hasSkills":true,"totalSkillsCount":3,"totalTokensCount":1726,"categories":["plugin-manifest","root-instruction"],"hasMcp":false,"mcpConfig":null,"found":["llm-tools/nsight/README.md","llm-tools/README.md","llm-inference/openai.md"],"skills":{"llm-tools/nsight/README.md":"\n\n\n\nNVIDIA性能分析工具Nsight Systems/Compute 的使用介绍: https://www.bilibili.com/video/BV15P4y1R7VG （简介及分析案例）\n\n\n\n---\n\nchecklist：可以帮助快速判断模型存在的问题：\n\n数据加载阶段：\n\n小文件是否太多，导致文件 io 耗时太长，读取会浪费很多时间在寻道上。\n\n存储介质是否已达到瓶颈，可以监控存储介质的繁忙度，如果达到瓶颈可以增加存储介质缓解读取性能；\n\n是否启用多进程并行读取数据，另外可以注意线程争用问题，监控线程等待时候是否过长，可以采用私有线程池进行环境；\n\n是否启用提前加载机制来实现 CPU 和 GPU 的并行；\n\n数据预处理阶段：\n\n是否设置开启共享内存 pin_memory，可以直接将数据放置在pin_memory中；\n\n优化 I/O 和网络操作，确保数据以与其计算相匹配的速率馈送到 GPU；\n\n如果是A100或以上的机器，可以考虑开启numa绑定，缓解争用，提升性能；\n\n模型训练阶段：\n\n是否存在大量的CPU运算，可以通过实现GPU实现或去除指定CPU设备，尽可能的让模型运行在GPU上；\n\n模型是否存在GPU利用率不均的情况，尽可能得不在代码里指定GPU运行的卡；\n\n对于比较复杂运行效率较低的模块，可以通过实现融合的大GPU算子提升训练速度；\n\n避免指标和日志打印太频繁，CPU 和 GPU 频繁切换导致 GPU 利用率低；\n\n是否开启AMP来提升模型的训练性能；\n\n使用最新的高性能库和 GPU 驱动程序，cuda是否升级到最新版本；\n\n---\n\n\n\n优化策略\n\n1. 减少不必要的同步:\n\n尽量减少显式的同步调用，如 cudaDeviceSynchronize。\n\n使用 cudaStreamWaitEvent 等事件机制来实现更细粒度的同步控制。\n\n2. 使用多个流:\n\n将独立的CUDA操作分配到不同的流中，以实现并行执行。\n\n确保内核启动和内存拷贝操作尽可能在不同流中并行执行。\n\n3. 优化内存拷贝:\n\n使用异步内存拷贝函数（如 cudaMemcpyAsync ）并将其分配到不同的流中。尽量减少Host与Device之间的内存拷贝次数，使用统一内存（Unified Memory）或零拷贝（Zero Copy）技术。\n\n\n---\n\n\n\n\n\nexport CUDA_VISIBLE_DEVICES=2\n\nnsys profile -w true \\\n-t cuda,nvtx,osrt,cudnn,cublas \\\n-s cpu \\\n--capture-range=cudaProfilerApi \\\n--capture-range-end=stop \\\n--cudabacktrace=true -x true --force-overwrite true -o nsys-sglang-046-14 python3  qwen25_sys.py\n","llm-tools/README.md":"\n\n\n\n- [LLM-Viewer](https://github.com/hahnyuan/LLM-Viewer.git) : 可视化大语言模型 (LLMs) 并分析不同硬件平台上性能\n- [llm-analysis](https://github.com/cli99/llm-analysis) : 对 Transformer 模型的训练和推理进行延迟和内存分析\n- [llm_profiler](https://github.com/harleyszhang/llm_counts) : 大模型理论性能分析工具\n\n\n- [vLLM 性能分析](https://vllm.hyper.ai/docs/contributing/profiling_index/)\n\t- https://docs.vllm.ai/en/stable/contributing/profiling/profiling_index.html\n\t- PyTorch Profiler\n\t- NVIDIA Nsight Systems \n\t\t\n\n- [SGLang Benchmark and Profiling](https://docs.sglang.ai/references/benchmark_and_profiling.html)\n\n\n\n--json-model-override-args\n\n\n--load-format dummy\n\n\n\n\n\n## Pytorch Profiler\n\n- https://pytorch.org/tutorials/beginner/profiler.html\n- https://pytorch.org/tutorials/recipes/recipes/profiler_recipe.html\n- https://pytorch.org/tutorials/intermediate/tensorboard_profiler_tutorial.html\n\n教程：\n\n1. https://pytorch.org/tutorials/prototype/numeric_suite_tutorial.html\n2. https://pytorch.org/tutorials/intermediate/fx_profiling_tutorial.html\n\n\n\n\n\n\n## NVIDIA Nsight Systems \n\n\n\n参考资料：\n- https://help.aliyun.com/zh/ack/cloud-native-ai-suite/use-cases/using-nsight-system-to-realize-performance-analysis?spm=a2c4g.11186623.help-menu-85222.d_3_0_1.77d64381Fe4MY6&scm=20140722.H_2710010._.OR_help-T_cn~zh-V_1\n- https://zhuanlan.zhihu.com/p/718956195\n\n\n属于系统级性能分析工具，提供从全局视角对整个系统的性能进行监控和分析，包括 CPU、GPU、内存、IO 等多种硬件资源的使用情况，以及它们之间的交互信息。\n\n\n使用 --python-backtrace=cuda 查看所有 CUDA 内核的 python 调用堆栈，就像在 PyTorch Profiler 中一样。（注意：这可能会导致基于 CUDA 事件的计时的内核运行时间不准确）\n\n\n\nchrome://tracing\n\n\npython -m sglang.bench_serving --backend sglang --model meta-llama/Llama-3.1-8B-Instruct --num-prompts 2 --sharegpt-output-len 100 --profile\n\n\n\n## NVIDIA Nsight Compute\n\n专注于 GPU 内核级的性能分析，主要针对 CUDA 应用程序，深入到 GPU 内部，分析 CUDA 内核的执行情况。\n\n\n\n\n\n## NVIDIA Tools Extension Library（NVTX）\n\n通过使用NVTX，开发者可以在代码中添加注释，这些注释可以被NVIDIA的开发工具识别，从而在性能分析和调试过程中提供帮助。\n\n```\npip install nvtx\n```\n\n\n```\n# example_lib.py\n\nimport time\nimport nvtx\n\n\ndef sleep_for(i):\n    time.sleep(i)\n\n@nvtx.annotate()\ndef my_func():\n    time.sleep(1)\n\nwith nvtx.annotate(\"for_loop\", color=\"green\"):\n    for i in range(5):\n        sleep_for(i)\n        my_func()\n\n```\n\n```\nnsys profile python demo.py\n```\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n","llm-inference/openai.md":"\n\n\n\n\n\n\nAsyncOpenAI:\n\n\nConnectionError 问题：\n\n- https://github.com/openai/openai-python/issues/\n\n\n\n"},"files":{"llm-tools/nsight/README.md":"\n\n\n\nNVIDIA性能分析工具Nsight Systems/Compute 的使用介绍: https://www.bilibili.com/video/BV15P4y1R7VG （简介及分析案例）\n\n\n\n---\n\nchecklist：可以帮助快速判断模型存在的问题：\n\n数据加载阶段：\n\n小文件是否太多，导致文件 io 耗时太长，读取会浪费很多时间在寻道上。\n\n存储介质是否已达到瓶颈，可以监控存储介质的繁忙度，如果达到瓶颈可以增加存储介质缓解读取性能；\n\n是否启用多进程并行读取数据，另外可以注意线程争用问题，监控线程等待时候是否过长，可以采用私有线程池进行环境；\n\n是否启用提前加载机制来实现 CPU 和 GPU 的并行；\n\n数据预处理阶段：\n\n是否设置开启共享内存 pin_memory，可以直接将数据放置在pin_memory中；\n\n优化 I/O 和网络操作，确保数据以与其计算相匹配的速率馈送到 GPU；\n\n如果是A100或以上的机器，可以考虑开启numa绑定，缓解争用，提升性能；\n\n模型训练阶段：\n\n是否存在大量的CPU运算，可以通过实现GPU实现或去除指定CPU设备，尽可能的让模型运行在GPU上；\n\n模型是否存在GPU利用率不均的情况，尽可能得不在代码里指定GPU运行的卡；\n\n对于比较复杂运行效率较低的模块，可以通过实现融合的大GPU算子提升训练速度；\n\n避免指标和日志打印太频繁，CPU 和 GPU 频繁切换导致 GPU 利用率低；\n\n是否开启AMP来提升模型的训练性能；\n\n使用最新的高性能库和 GPU 驱动程序，cuda是否升级到最新版本；\n\n---\n\n\n\n优化策略\n\n1. 减少不必要的同步:\n\n尽量减少显式的同步调用，如 cudaDeviceSynchronize。\n\n使用 cudaStreamWaitEvent 等事件机制来实现更细粒度的同步控制。\n\n2. 使用多个流:\n\n将独立的CUDA操作分配到不同的流中，以实现并行执行。\n\n确保内核启动和内存拷贝操作尽可能在不同流中并行执行。\n\n3. 优化内存拷贝:\n\n使用异步内存拷贝函数（如 cudaMemcpyAsync ）并将其分配到不同的流中。尽量减少Host与Device之间的内存拷贝次数，使用统一内存（Unified Memory）或零拷贝（Zero Copy）技术。\n\n\n---\n\n\n\n\n\nexport CUDA_VISIBLE_DEVICES=2\n\nnsys profile -w true \\\n-t cuda,nvtx,osrt,cudnn,cublas \\\n-s cpu \\\n--capture-range=cudaProfilerApi \\\n--capture-range-end=stop \\\n--cudabacktrace=true -x true --force-overwrite true -o nsys-sglang-046-14 python3  qwen25_sys.py\n","llm-tools/README.md":"\n\n\n\n- [LLM-Viewer](https://github.com/hahnyuan/LLM-Viewer.git) : 可视化大语言模型 (LLMs) 并分析不同硬件平台上性能\n- [llm-analysis](https://github.com/cli99/llm-analysis) : 对 Transformer 模型的训练和推理进行延迟和内存分析\n- [llm_profiler](https://github.com/harleyszhang/llm_counts) : 大模型理论性能分析工具\n\n\n- [vLLM 性能分析](https://vllm.hyper.ai/docs/contributing/profiling_index/)\n\t- https://docs.vllm.ai/en/stable/contributing/profiling/profiling_index.html\n\t- PyTorch Profiler\n\t- NVIDIA Nsight Systems \n\t\t\n\n- [SGLang Benchmark and Profiling](https://docs.sglang.ai/references/benchmark_and_profiling.html)\n\n\n\n--json-model-override-args\n\n\n--load-format dummy\n\n\n\n\n\n## Pytorch Profiler\n\n- https://pytorch.org/tutorials/beginner/profiler.html\n- https://pytorch.org/tutorials/recipes/recipes/profiler_recipe.html\n- https://pytorch.org/tutorials/intermediate/tensorboard_profiler_tutorial.html\n\n教程：\n\n1. https://pytorch.org/tutorials/prototype/numeric_suite_tutorial.html\n2. https://pytorch.org/tutorials/intermediate/fx_profiling_tutorial.html\n\n\n\n\n\n\n## NVIDIA Nsight Systems \n\n\n\n参考资料：\n- https://help.aliyun.com/zh/ack/cloud-native-ai-suite/use-cases/using-nsight-system-to-realize-performance-analysis?spm=a2c4g.11186623.help-menu-85222.d_3_0_1.77d64381Fe4MY6&scm=20140722.H_2710010._.OR_help-T_cn~zh-V_1\n- https://zhuanlan.zhihu.com/p/718956195\n\n\n属于系统级性能分析工具，提供从全局视角对整个系统的性能进行监控和分析，包括 CPU、GPU、内存、IO 等多种硬件资源的使用情况，以及它们之间的交互信息。\n\n\n使用 --python-backtrace=cuda 查看所有 CUDA 内核的 python 调用堆栈，就像在 PyTorch Profiler 中一样。（注意：这可能会导致基于 CUDA 事件的计时的内核运行时间不准确）\n\n\n\nchrome://tracing\n\n\npython -m sglang.bench_serving --backend sglang --model meta-llama/Llama-3.1-8B-Instruct --num-prompts 2 --sharegpt-output-len 100 --profile\n\n\n\n## NVIDIA Nsight Compute\n\n专注于 GPU 内核级的性能分析，主要针对 CUDA 应用程序，深入到 GPU 内部，分析 CUDA 内核的执行情况。\n\n\n\n\n\n## NVIDIA Tools Extension Library（NVTX）\n\n通过使用NVTX，开发者可以在代码中添加注释，这些注释可以被NVIDIA的开发工具识别，从而在性能分析和调试过程中提供帮助。\n\n```\npip install nvtx\n```\n\n\n```\n# example_lib.py\n\nimport time\nimport nvtx\n\n\ndef sleep_for(i):\n    time.sleep(i)\n\n@nvtx.annotate()\ndef my_func():\n    time.sleep(1)\n\nwith nvtx.annotate(\"for_loop\", color=\"green\"):\n    for i in range(5):\n        sleep_for(i)\n        my_func()\n\n```\n\n```\nnsys profile python demo.py\n```\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n","llm-inference/openai.md":"\n\n\n\n\n\n\nAsyncOpenAI:\n\n\nConnectionError 问题：\n\n- https://github.com/openai/openai-python/issues/\n\n\n\n"},"items":[{"name":"openai.md","path":"llm-inference/openai.md","rawUrl":"https://raw.githubusercontent.com/liguodongiot/llm-action/HEAD/llm-inference/openai.md","title":"llm-inference - OpenAI Codex & System Instructions","category":"root-instruction","format":"markdown","content":"\n\n\n\n\n\n\nAsyncOpenAI:\n\n\nConnectionError 问题：\n\n- https://github.com/openai/openai-python/issues/\n\n\n\n","isInternal":false,"tokens":22,"sizeBytes":102},{"name":"README.md","path":"llm-tools/nsight/README.md","rawUrl":"https://raw.githubusercontent.com/liguodongiot/llm-action/HEAD/llm-tools/nsight/README.md","title":"nsight Documentation","category":"plugin-manifest","format":"markdown","content":"\n\n\n\nNVIDIA性能分析工具Nsight Systems/Compute 的使用介绍: https://www.bilibili.com/video/BV15P4y1R7VG （简介及分析案例）\n\n\n\n---\n\nchecklist：可以帮助快速判断模型存在的问题：\n\n数据加载阶段：\n\n小文件是否太多，导致文件 io 耗时太长，读取会浪费很多时间在寻道上。\n\n存储介质是否已达到瓶颈，可以监控存储介质的繁忙度，如果达到瓶颈可以增加存储介质缓解读取性能；\n\n是否启用多进程并行读取数据，另外可以注意线程争用问题，监控线程等待时候是否过长，可以采用私有线程池进行环境；\n\n是否启用提前加载机制来实现 CPU 和 GPU 的并行；\n\n数据预处理阶段：\n\n是否设置开启共享内存 pin_memory，可以直接将数据放置在pin_memory中；\n\n优化 I/O 和网络操作，确保数据以与其计算相匹配的速率馈送到 GPU；\n\n如果是A100或以上的机器，可以考虑开启numa绑定，缓解争用，提升性能；\n\n模型训练阶段：\n\n是否存在大量的CPU运算，可以通过实现GPU实现或去除指定CPU设备，尽可能的让模型运行在GPU上；\n\n模型是否存在GPU利用率不均的情况，尽可能得不在代码里指定GPU运行的卡；\n\n对于比较复杂运行效率较低的模块，可以通过实现融合的大GPU算子提升训练速度；\n\n避免指标和日志打印太频繁，CPU 和 GPU 频繁切换导致 GPU 利用率低；\n\n是否开启AMP来提升模型的训练性能；\n\n使用最新的高性能库和 GPU 驱动程序，cuda是否升级到最新版本；\n\n---\n\n\n\n优化策略\n\n1. 减少不必要的同步:\n\n尽量减少显式的同步调用，如 cudaDeviceSynchronize。\n\n使用 cudaStreamWaitEvent 等事件机制来实现更细粒度的同步控制。\n\n2. 使用多个流:\n\n将独立的CUDA操作分配到不同的流中，以实现并行执行。\n\n确保内核启动和内存拷贝操作尽可能在不同流中并行执行。\n\n3. 优化内存拷贝:\n\n使用异步内存拷贝函数（如 cudaMemcpyAsync ）并将其分配到不同的流中。尽量减少Host与Device之间的内存拷贝次数，使用统一内存（Unified Memory）或零拷贝（Zero Copy）技术。\n\n\n---\n\n\n\n\n\nexport CUDA_VISIBLE_DEVICES=2\n\nnsys profile -w true \\\n-t cuda,nvtx,osrt,cudnn,cublas \\\n-s cpu \\\n--capture-range=cudaProfilerApi \\\n--capture-range-end=stop \\\n--cudabacktrace=true -x true --force-overwrite true -o nsys-sglang-046-14 python3  qwen25_sys.py\n","isInternal":false,"tokens":854,"sizeBytes":2485},{"name":"README.md","path":"llm-tools/README.md","rawUrl":"https://raw.githubusercontent.com/liguodongiot/llm-action/HEAD/llm-tools/README.md","title":"llm-tools Documentation","category":"plugin-manifest","format":"markdown","content":"\n\n\n\n- [LLM-Viewer](https://github.com/hahnyuan/LLM-Viewer.git) : 可视化大语言模型 (LLMs) 并分析不同硬件平台上性能\n- [llm-analysis](https://github.com/cli99/llm-analysis) : 对 Transformer 模型的训练和推理进行延迟和内存分析\n- [llm_profiler](https://github.com/harleyszhang/llm_counts) : 大模型理论性能分析工具\n\n\n- [vLLM 性能分析](https://vllm.hyper.ai/docs/contributing/profiling_index/)\n\t- https://docs.vllm.ai/en/stable/contributing/profiling/profiling_index.html\n\t- PyTorch Profiler\n\t- NVIDIA Nsight Systems \n\t\t\n\n- [SGLang Benchmark and Profiling](https://docs.sglang.ai/references/benchmark_and_profiling.html)\n\n\n\n--json-model-override-args\n\n\n--load-format dummy\n\n\n\n\n\n## Pytorch Profiler\n\n- https://pytorch.org/tutorials/beginner/profiler.html\n- https://pytorch.org/tutorials/recipes/recipes/profiler_recipe.html\n- https://pytorch.org/tutorials/intermediate/tensorboard_profiler_tutorial.html\n\n教程：\n\n1. https://pytorch.org/tutorials/prototype/numeric_suite_tutorial.html\n2. https://pytorch.org/tutorials/intermediate/fx_profiling_tutorial.html\n\n\n\n\n\n\n## NVIDIA Nsight Systems \n\n\n\n参考资料：\n- https://help.aliyun.com/zh/ack/cloud-native-ai-suite/use-cases/using-nsight-system-to-realize-performance-analysis?spm=a2c4g.11186623.help-menu-85222.d_3_0_1.77d64381Fe4MY6&scm=20140722.H_2710010._.OR_help-T_cn~zh-V_1\n- https://zhuanlan.zhihu.com/p/718956195\n\n\n属于系统级性能分析工具，提供从全局视角对整个系统的性能进行监控和分析，包括 CPU、GPU、内存、IO 等多种硬件资源的使用情况，以及它们之间的交互信息。\n\n\n使用 --python-backtrace=cuda 查看所有 CUDA 内核的 python 调用堆栈，就像在 PyTorch Profiler 中一样。（注意：这可能会导致基于 CUDA 事件的计时的内核运行时间不准确）\n\n\n\nchrome://tracing\n\n\npython -m sglang.bench_serving --backend sglang --model meta-llama/Llama-3.1-8B-Instruct --num-prompts 2 --sharegpt-output-len 100 --profile\n\n\n\n## NVIDIA Nsight Compute\n\n专注于 GPU 内核级的性能分析，主要针对 CUDA 应用程序，深入到 GPU 内部，分析 CUDA 内核的执行情况。\n\n\n\n\n\n## NVIDIA Tools Extension Library（NVTX）\n\n通过使用NVTX，开发者可以在代码中添加注释，这些注释可以被NVIDIA的开发工具识别，从而在性能分析和调试过程中提供帮助。\n\n```\npip install nvtx\n```\n\n\n```\n# example_lib.py\n\nimport time\nimport nvtx\n\n\ndef sleep_for(i):\n    time.sleep(i)\n\n@nvtx.annotate()\ndef my_func():\n    time.sleep(1)\n\nwith nvtx.annotate(\"for_loop\", color=\"green\"):\n    for i in range(5):\n        sleep_for(i)\n        my_func()\n\n```\n\n```\nnsys profile python demo.py\n```\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n","isInternal":false,"tokens":850,"sizeBytes":2715}],"systemPromptSnippet":"<yakaai_skills repo=\"liguodongiot/llm-action\">\n<!-- File: llm-inference/openai.md (Tokens: ~22 | Category: root-instruction) -->\nAsyncOpenAI:\n\n\nConnectionError 问题：\n\n- https://github.com/openai/openai-python/issues/\n\n<!-- File: llm-tools/nsight/README.md (Tokens: ~854 | Category: plugin-manifest) -->\nNVIDIA性能分析工具Nsight Systems/Compute 的使用介绍: https://www.bilibili.com/video/BV15P4y1R7VG （简介及分析案例）\n\n\n\n---\n\nchecklist：可以帮助快速判断模型存在的问题：\n\n数据加载阶段：\n\n小文件是否太多，导致文件 io 耗时太长，读取会浪费很多时间在寻道上。\n\n存储介质是否已达到瓶颈，可以监控存储介质的繁忙度，如果达到瓶颈可以增加存储介质缓解读取性能；\n\n是否启用多进程并行读取数据，另外可以注意线程争用问题，监控线程等待时候是否过长，可以采用私有线程池进行环境；\n\n是否启用提前加载机制来实现 CPU 和 GPU 的并行；\n\n数据预处理阶段：\n\n是否设置开启共享内存 pin_memory，可以直接将数据放置在pin_memory中；\n\n优化 I/O 和网络操作，确保数据以与其计算相匹配的速率馈送到 GPU；\n\n如果是A100或以上的机器，可以考虑开启numa绑定，缓解争用，提升性能；\n\n模型训练阶段：\n\n是否存在大量的CPU运算，可以通过实现GPU实现或去除指定CPU设备，尽可能的让模型运行在GPU上；\n\n模型是否存在GPU利用率不均的情况，尽可能得不在代码里指定GPU运行的卡；\n\n对于比较复杂运行效率较低的模块，可以通过实现融合的大GPU算子提升训练速度；\n\n避免指标和日志打印太频繁，CPU 和 GPU 频繁切换导致 GPU 利用率低；\n\n是否开启AMP来提升模型的训练性能；\n\n使用最新的高性能库和 GPU 驱动程序，cuda是否升级到最新版本；\n\n---\n\n\n\n优化策略\n\n1. 减少不必要的同步:\n\n尽量减少显式的同步调用，如 cudaDeviceSynchronize。\n\n使用 cudaStreamWaitEvent 等事件机制来实现更细粒度的同步控制。\n\n2. 使用多个流:\n\n将独立的CUDA操作分配到不同的流中，以实现并行执行。\n\n确保内核启动和内存拷贝操作尽可能在不同流中并行执行。\n\n3. 优化内存拷贝:\n\n使用异步内存拷贝函数（如 cudaMemcpyAsync ）并将其分配到不同的流中。尽量减少Host与Device之间的内存拷贝次数，使用统一内存（Unified Memory）或零拷贝（Zero Copy）技术。\n\n\n---\n\n\n\n\n\nexport CUDA_VISIBLE_DEVICES=2\n\nnsys profile -w true \\\n-t cuda,nvtx,osrt,cudnn,cublas \\\n-s cpu \\\n--capture-range=cudaProfilerApi \\\n--capture-range-end=stop \\\n--cudabacktrace=true -x true --force-overwrite true -o nsys-sglang-046-14 python3  qwen25_sys.py\n\n<!-- File: llm-tools/README.md (Tokens: ~850 | Category: plugin-manifest) -->\n- [LLM-Viewer](https://github.com/hahnyuan/LLM-Viewer.git) : 可视化大语言模型 (LLMs) 并分析不同硬件平台上性能\n- [llm-analysis](https://github.com/cli99/llm-analysis) : 对 Transformer 模型的训练和推理进行延迟和内存分析\n- [llm_profiler](https://github.com/harleyszhang/llm_counts) : 大模型理论性能分析工具\n\n\n- [vLLM 性能分析](https://vllm.hyper.ai/docs/contributing/profiling_index/)\n\t- https://docs.vllm.ai/en/stable/contributing/profiling/profiling_index.html\n\t- PyTorch Profiler\n\t- NVIDIA Nsight Systems \n\t\t\n\n- [SGLang Benchmark and Profiling](https://docs.sglang.ai/references/benchmark_and_profiling.html)\n\n\n\n--json-model-override-args\n\n\n--load-format dummy\n\n\n\n\n\n## Pytorch Profiler\n\n- https://pytorch.org/tutorials/beginner/profiler.html\n- https://pytorch.org/tutorials/recipes/recipes/profiler_recipe.html\n- https://pytorch.org/tutorials/intermediate/tensorboard_profiler_tutorial.html\n\n教程：\n\n1. https://pytorch.org/tutorials/prototype/numeric_suite_tutorial.html\n2. https://pytorch.org/tutorials/intermediate/fx_profiling_tutorial.html\n\n\n\n\n\n\n## NVIDIA Nsight Systems \n\n\n\n参考资料：\n- https://help.aliyun.com/zh/ack/cloud-native-ai-suite/use-cases/using-nsight-system-to-realize-performance-analysis?spm=a2c4g.11186623.help-menu-85222.d_3_0_1.77d64381Fe4MY6&scm=20140722.H_2710010._.OR_help-T_cn~zh-V_1\n- https://zhuanlan.zhihu.com/p/718956195\n\n\n属于系统级性能分析工具，提供从全局视角对整个系统的性能进行监控和分析，包括 CPU、GPU、内存、IO 等多种硬件资源的使用情况，以及它们之间的交互信息。\n\n\n使用 --python-backtrace=cuda 查看所有 CUDA 内核的 python 调用堆栈，就像在 PyTorch Profiler 中一样。（注意：这可能会导致基于 CUDA 事件的计时的内核运行时间不准确）\n\n\n\nchrome://tracing\n\n\npython -m sglang.bench_serving --backend sglang --model meta-llama/Llama-3.1-8B-Instruct --num-prompts 2 --sharegpt-output-len 100 --profile\n\n\n\n## NVIDIA Nsight Compute\n\n专注于 GPU 内核级的性能分析，主要针对 CUDA 应用程序，深入到 GPU 内部，分析 CUDA 内核的执行情况。\n\n\n\n\n\n## NVIDIA Tools Extension Library（NVTX）\n\n通过使用NVTX，开发者可以在代码中添加注释，这些注释可以被NVIDIA的开发工具识别，从而在性能分析和调试过程中提供帮助。\n\n```\npip install nvtx\n```\n\n\n```\n# example_lib.py\n\nimport time\nimport nvtx\n\n\ndef sleep_for(i):\n    time.sleep(i)\n\n@nvtx.annotate()\ndef my_func():\n    time.sleep(1)\n\nwith nvtx.annotate(\"for_loop\", color=\"green\"):\n    for i in range(5):\n        sleep_for(i)\n        my_func()\n\n```\n\n```\nnsys profile python demo.py\n```\n</yakaai_skills>"}