Skip to content

Finish project 03_nf4_dequant - #41

Open
xfarawayx wants to merge 2 commits into
InfiniTensor:2025-winter-projectfrom
xfarawayx:2025-winter-project
Open

Finish project 03_nf4_dequant#41
xfarawayx wants to merge 2 commits into
InfiniTensor:2025-winter-projectfrom
xfarawayx:2025-winter-project

Conversation

@xfarawayx

Copy link
Copy Markdown

No description provided.

CopilotAI review requested due to automatic review settings March 15, 2026 03:49

CopilotAI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a complete NF4 (double-quant) dequantization workflow: data generation via bitsandbytes, a CUDA kernel implementation + build/run automation, correctness verification and benchmarking, plus ports for several non-CUDA vendor stacks and an accompanying report.

Changes:

  • Add Python scripts to generate NF4 test vectors, verify CUDA output vs bitsandbytes, and benchmark bitsandbytes dequant performance.
  • Add CUDA implementation (kernel + host runner) with CMake build and helper profiling script.
  • Add non-CUDA vendor adaptations (MACA/MUSA/Iluvatar) with build/run/verify scripts and documentation; add project README + technical report.

Reviewed changes

Copilot reviewed 25 out of 27 changed files in this pull request and generated 11 comments.

Show a summary per file
FileDescription
03_nf4_dequant/scripts/generate_data.pyGenerates NF4-packed weights + reference outputs and writes custom binary format
03_nf4_dequant/scripts/verify.pyLoads outputs and reports elementwise error metrics with exit code
03_nf4_dequant/scripts/bench_bnb.pyBenchmarks bitsandbytes dequantize_4bit latency/bandwidth
03_nf4_dequant/kernel/nf4_dequant_kernel.cuhCUDA NF4 dequant kernel implementation (optimized)
03_nf4_dequant/kernel/main.cuCUDA host runner: loads binary, launches kernel, times, writes output
03_nf4_dequant/kernel/CMakeLists.txtCMake build with CUDA arch auto-detection and temp dir handling
03_nf4_dequant/kernel/run_test_ncu.shNsight Compute profiling helper
03_nf4_dequant/run.shEnd-to-end driver script (generate/build/test/bench/all)
03_nf4_dequant/kernel_noncuda/mutex/*MACA port (kernel + runner + Makefile + docs + runner script)
03_nf4_dequant/kernel_noncuda/moore/*MUSA port (kernel + runner + Makefile + docs + runner script)
03_nf4_dequant/kernel_noncuda/iluvatar/*Iluvatar CUDA-compatible port (kernel + runner + Makefile + docs + runner script)
03_nf4_dequant/docs/report.mdDetailed design + optimization report
03_nf4_dequant/README.mdTop-level usage/docs for running the project

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review. Take the survey.

Comment thread03_nf4_dequant/xfarawayx/scripts/generate_data.py
Comment thread03_nf4_dequant/xfarawayx/kernel/main.cu
Comment thread03_nf4_dequant/xfarawayx/kernel/main.cu
Comment thread03_nf4_dequant/xfarawayx/run.sh Outdated
Comment thread03_nf4_dequant/xfarawayx/kernel/main.cu
Comment thread03_nf4_dequant/xfarawayx/kernel/main.cu
Comment thread03_nf4_dequant/README.md Outdated
Comment thread03_nf4_dequant/xfarawayx/scripts/generate_data.py
Comment thread03_nf4_dequant/xfarawayx/kernel/main.cu
Comment thread03_nf4_dequant/xfarawayx/kernel/main.cu

CopilotAI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

该 PR 完成 03_nf4_dequant 项目:用 bitsandbytes 生成/对齐 NF4 双重量化数据格式,实现并基准测试 CUDA NF4 反量化 kernel,同时提供 MUSA/MACA/Iluvatar 平台的适配版本与一键脚本,便于验证正确性与对比性能。

Changes:

  • 新增数据生成、结果验证与 bitsandbytes 基准脚本,统一端到端流程脚本 run.sh
  • 新增 CUDA kernel(含构建系统、NCU profiling 脚本)以及国产 GPU 平台的移植版本(MUSA/MACA/Iluvatar)
  • 新增项目 README 与实现报告文档

Reviewed changes

Copilot reviewed 25 out of 28 changed files in this pull request and generated 11 comments.

Show a summary per file
FileDescription
03_nf4_dequant/xfarawayx/scripts/verify.py对比 CUDA 输出与 bitsandbytes 参考输出,输出误差指标并用退出码表示 PASS/FAIL
03_nf4_dequant/xfarawayx/scripts/generate_data.py生成随机权重并用 bitsandbytes 量化为 NF4(双重量化),导出自定义二进制权重与参考解量化输出
03_nf4_dequant/xfarawayx/scripts/bench_bnb.py基准测试 bitsandbytes dequantize_4bit 性能并计算带宽
03_nf4_dequant/xfarawayx/run.sh统一入口脚本:generate/build/test/bench/all 流程编排
03_nf4_dequant/xfarawayx/kernel_noncuda/mutex/run_mutex.shMACA 平台的一键 build/run/verify 脚本
03_nf4_dequant/xfarawayx/kernel_noncuda/mutex/nf4_dequant_kernel.macaMACA 平台 NF4 反量化 kernel(手写 half/bf16 位转换)
03_nf4_dequant/xfarawayx/kernel_noncuda/mutex/main.macaMACA 平台主程序:读取权重文件、启动 kernel、计时并写回输出
03_nf4_dequant/xfarawayx/kernel_noncuda/mutex/README.mdMACA 适配说明与用法
03_nf4_dequant/xfarawayx/kernel_noncuda/mutex/MakefileMACA 编译产物 nf4_dequant_maca 的 Makefile
03_nf4_dequant/xfarawayx/kernel_noncuda/moore/run_moore.shMUSA 平台的一键 build/run/verify 脚本
03_nf4_dequant/xfarawayx/kernel_noncuda/moore/nf4_dequant_kernel.muMUSA 平台 NF4 反量化 kernel(手写 half/bf16 位转换)
03_nf4_dequant/xfarawayx/kernel_noncuda/moore/main.muMUSA 平台主程序:读取权重文件、启动 kernel、计时并写回输出
03_nf4_dequant/xfarawayx/kernel_noncuda/moore/README.mdMUSA 适配说明与用法
03_nf4_dequant/xfarawayx/kernel_noncuda/moore/MakefileMUSA 编译产物 nf4_dequant_musa 的 Makefile
03_nf4_dequant/xfarawayx/kernel_noncuda/iluvatar/run_iluvatar.shIluvatar 平台的一键 build/run/verify 脚本
03_nf4_dequant/xfarawayx/kernel_noncuda/iluvatar/nf4_dequant_kernel.cuhIluvatar 平台 kernel 头文件(CUDA 兼容风格)
03_nf4_dequant/xfarawayx/kernel_noncuda/iluvatar/main.cuIluvatar 平台主程序(cuda* 兼容运行时)
03_nf4_dequant/xfarawayx/kernel_noncuda/iluvatar/README.mdIluvatar 适配说明与用法
03_nf4_dequant/xfarawayx/kernel_noncuda/iluvatar/MakefileIluvatar 编译产物 nf4_dequant_iluvatar 的 Makefile
03_nf4_dequant/xfarawayx/kernel/run_test_ncu.shNsight Compute profiling 脚本入口
03_nf4_dequant/xfarawayx/kernel/nf4_dequant_kernel.cuhCUDA NF4 双重量化反量化 kernel(shared 表、向量化读写、位移优化)
03_nf4_dequant/xfarawayx/kernel/main.cuCUDA 主程序:读取权重、启动 kernel、计时、写回输出
03_nf4_dequant/xfarawayx/kernel/CMakeLists.txtCUDA 构建系统(支持 GPU arch 自动检测与 TMPDIR 配置)
03_nf4_dequant/xfarawayx/docs/report.md项目实现报告、原理与性能实验结果
03_nf4_dequant/xfarawayx/README.md项目总览、目录结构与快速开始

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review. Take the survey.

Comment thread03_nf4_dequant/xfarawayx/scripts/bench_bnb.py
Comment thread03_nf4_dequant/xfarawayx/run.sh Outdated
Comment thread03_nf4_dequant/xfarawayx/scripts/generate_data.py
Comment thread03_nf4_dequant/xfarawayx/kernel/main.cu
Comment thread03_nf4_dequant/xfarawayx/kernel/main.cu
Comment thread03_nf4_dequant/xfarawayx/kernel/main.cu
Comment thread03_nf4_dequant/xfarawayx/kernel/nf4_dequant_kernel.cuh
Comment thread03_nf4_dequant/xfarawayx/scripts/generate_data.py
Comment thread03_nf4_dequant/xfarawayx/kernel/main.cu
Comment thread03_nf4_dequant/xfarawayx/kernel/nf4_dequant_kernel.cuh
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

@xfarawayx