Skip to content

Assignment #4: CUDA integration for NVIDIA RTX 4090 and MetaX C500 - #61

Open
kadadsns wants to merge 9 commits into
InfiniTensor:mainfrom
kadadsns:main
Open

kadadsns wants to merge 9 commits into
InfiniTensor:mainfrom
kadadsns:main

Conversation

@kadadsns

Copy link
Copy Markdown

总结

本 PR 完成作业 #4:为 LLAISYS 集成 CUDA。

实现内容:

  • CUDA Runtime API 与设备资源管理
  • 全部作业算子的 CUDA 实现:add、argmax、embedding、linear、rearrange、rms_norm、rope、self_attention、swiglu
  • Qwen2 模型 CUDA 推理
  • MetaX 独立构建:Makefile.metax
  • 作业 推理时间过长,超出 CI 时长 #4 报告(中文版与英文版)

CI 状态

CI 在 Windows 和 Ubuntu 上均通过,Assignment #0-#3 全部通过。

最新运行:https://github.com/kadadsns/llaisys/actions/runs/31293416784

支持平台与状态

平台 状态
CPU 通过
NVIDIA RTX 4090 通过:Runtime、全部算子测试、完整模型推理
曦云 C500 通过:Runtime、全部算子测试、完整模型推理

复现流程

详细复现步骤与结果见 ASSIGNMENT_REPORT.md 和 ASSIGNMENT_REPORT_ZH.md。

主要改动

…iniTensor#2 (Operators)

- Tensor: implement load, isContiguous, view, permute, slice
- Operators: implement argmax, embedding, linear, rms_norm, rope, self_attention, swiglu
- All CPU implementations support F32, F16, BF16 data types
- All tests pass
- Add Qwen2 model C++ implementation with KV Cache support
- Add Python bindings for model inference
- Add rearrange operator for KV cache management
- Implement weight loading from safetensors files
- Note: Full testing requires more system memory (model is ~3.5GB)
- Implement chunked reading for large tensors (4MB chunks)
- Avoid data type conversion (keep bfloat16 as uint16)
- Add proper memory cleanup with gc.collect()
- Add C++ side weight loading function declaration
- Model loading now works successfully
- Create CUDA Runtime API implementation
- Add CUDA resource management (cuBLAS, cuDNN)
- Implement CUDA kernels for all operators
- Add NVIDIA compilation configuration
- Create comprehensive CUDA documentation
Implement CUDA runtime APIs and operators for NVIDIA/MetaX. Fix cuBLAS F16/BF16 accumulation, causal attention mask offset, and argmax reduction for large vocab sizes. Add CUDA device link for the shared library.
Sign up for free to 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.

1 participant