feat: use original cuda scan from linear RNN#22
Merged
yoyolicoris merged 12 commits intomainfrom May 4, 2025
Merged
Conversation
… for scan and lpc functions
…y and maintainability
There was a problem hiding this comment.
Pull Request Overview
This PR reintroduces the original CUDA scan implementation for linear RNN recurrence computation while also cleaning up and reorganizing the recurrence functions and extension API. Key changes include:
- Splitting recurrence functionality into separate _cuda_recurrence and _cpu_recurrence functions.
- Renaming and re-registering C++ extension functions from “scan_cpu”/“lpc_cpu” to “scan”/“lpc”.
- Updating tests and setup configuration to support the new extension API and parameterizations.
Reviewed Changes
Copilot reviewed 8 out of 9 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| torchlpc/recurrence.py | Refactored recurrence functions with separate CPU/CUDA paths. |
| torchlpc/csrc/scan_cpu.cpp | Updated API registration and const/mutable data pointer usage. |
| torchlpc/csrc/cuda/LICENSE.txt | Added license text for CUDA code. |
| torchlpc/core.py | Updated operator calls to reflect new API names. |
| torchlpc/init.py | Changed extension loading logic using try-except for _C import. |
| tests/test_grad.py | Added parameterization for complex data tests. |
| tests/test_extension.py | Updated tests to use new operator names and added device parameter. |
| setup.py | Revised extension build configuration and source file discovery. |
Files not reviewed (1)
- torchlpc/csrc/cuda/linear_recurrence.cu: Language not supported
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The results on a 5060 ti GPU with linux machine:
It's roughly the same as before.