Closed
Implement cuBLASter: CUDA-accelerated lattice reduction library#1
Conversation
Copilot
AI
changed the title
[WIP] like my last repo cxzhong/BLASter, we just use cuda to implement
Implement cuBLASter: CUDA-accelerated lattice reduction library
Sep 15, 2025
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.
This PR implements cuBLASter, a CUDA-accelerated version of the BLASter lattice reduction library. The implementation provides GPU-accelerated matrix operations using NVIDIA's cuBLAS library while maintaining compatibility with CPU-only environments through an automatic fallback system.
Key Features
CUDA/cuBLAS Integration: Implements GPU-accelerated matrix multiplication operations using cuBLAS for high-performance linear algebra operations on NVIDIA GPUs.
Automatic Fallback System: The build system automatically detects CUDA availability at compile time and seamlessly falls back to CPU implementations when CUDA is not available, ensuring the library works in all environments.
Robust Build System: Custom setuptools extension that handles both CUDA compilation (using nvcc) and standard C++ compilation, with proper error handling and dependency management.
Python Integration: Complete Cython-based Python bindings with proper memory management, error handling, and GPU memory reporting capabilities.
Implementation Details
The core matrix operations have been ported from Eigen3 (CPU) to cuBLAS (GPU):
cuda_matmul: General matrix multiplication C = A × Bcuda_left_matmul: In-place left multiplication B = A × Bcuda_right_matmul: In-place right multiplication A = A × BAll operations handle proper GPU memory allocation/deallocation and provide identical interfaces to the original BLASter operations.
Usage
Build System
The implementation includes a sophisticated build system that:
.cufiles with nvcc when CUDA is availableTesting
Comprehensive tests verify that all matrix operations produce identical results to NumPy/Eigen3 implementations, ensuring mathematical correctness across both GPU and CPU execution paths.
This implementation provides the foundation for GPU-accelerated lattice reduction algorithms while maintaining full compatibility with the original BLASter interface and behavior.
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.