Add AscendC triangular inverse using AIC and AIV#366
Add AscendC triangular inverse using AIC and AIV#366gioelegott wants to merge 23 commits intosgl-project:mainfrom
Conversation
Summary of ChangesHello @gioelegott, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request significantly enhances the Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Changelog
Activity
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request introduces a new AscendC kernel for triangular matrix inversion using AI Cores (AIC) and AI Vectors (AIV), aiming for better performance on large batches. The changes span the C++ kernel implementation, host-side logic, PyTorch op registration, and associated Python wrappers and tests. While the performance gains are notable, my review has uncovered several critical correctness issues. There appears to be a bug in the core inversion algorithm in kernel_mat_gen.h where an iteration is missed. The Python wrapper fast_cube_inv_tril seems to pass a matrix with the wrong memory layout (lower triangular instead of upper triangular) to the new kernel. Furthermore, a critical issue in the test file test_triangular_inverse.py causes one of the main tests to be skipped due to function redefinition. I've also noted several medium-severity issues, including very high test tolerances that could mask bugs, and areas for code cleanup to improve maintainability. These critical issues should be addressed to ensure the correctness of this new high-performance kernel.
zouzias
left a comment
There was a problem hiding this comment.
Left a few minor comments.
This MR contributes an AscendC triangular inverse kernel that implements a column sweep algorithm using vector cores and cube core. This algorithms is based on @zouzias algorithm and takes advantage of all the NPU's resources.
This is joint work with @asobczyk , @zouzias and @learning-chip .
The users of
chunk_gated_delta_rule_nativecan use the new kernel by settingtri_inv_fn = sgl_kernel_npu.fla.chunk.fast_cube_inv_tril.The kernel
torch.ops.npu.tri_inv_cubeis tested on Ascend A2 and 910B4 (x86_64).The kernel supports onlyfp16due to the cube core limitations. This may impact e2e accuracy, but gives great performance improvements for large batch sizes.Performance