廖永誠
    • Create new note
    • Create a note from template
      • Sharing URL Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Customize slides
      • Note Permission
      • Read
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Write
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Engagement control Commenting, Suggest edit, Emoji Reply
    • Invite by email
      Invitee

      This note has no invitees

    • Publish Note

      Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

      Your note will be visible on your profile and discoverable by anyone.
      Your note is now live.
      This note is visible on your profile and discoverable online.
      Everyone on the web can find and read all notes of this public team.
      See published notes
      Unpublish note
      Please check the box to agree to the Community Guidelines.
      View profile
    • Commenting
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
      • Everyone
    • Suggest edit
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
    • Emoji Reply
    • Enable
    • Versions and GitHub Sync
    • Note settings
    • Note Insights New
    • Engagement control
    • Make a copy
    • Transfer ownership
    • Delete this note
    • Save as template
    • Insert from template
    • Import from
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
    • Export to
      • Dropbox
      • Google Drive
      • Gist
    • Download
      • Markdown
      • HTML
      • Raw HTML
Menu Note settings Note Insights Versions and GitHub Sync Sharing URL Create Help
Create Create new note Create a note from template
Menu
Options
Engagement control Make a copy Transfer ownership Delete this note
Import from
Dropbox Google Drive Gist Clipboard
Export to
Dropbox Google Drive Gist
Download
Markdown HTML Raw HTML
Back
Sharing URL Link copied
/edit
View mode
  • Edit mode
  • View mode
  • Book mode
  • Slide mode
Edit mode View mode Book mode Slide mode
Customize slides
Note Permission
Read
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Write
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Engagement control Commenting, Suggest edit, Emoji Reply
  • Invite by email
    Invitee

    This note has no invitees

  • Publish Note

    Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

    Your note will be visible on your profile and discoverable by anyone.
    Your note is now live.
    This note is visible on your profile and discoverable online.
    Everyone on the web can find and read all notes of this public team.
    See published notes
    Unpublish note
    Please check the box to agree to the Community Guidelines.
    View profile
    Engagement control
    Commenting
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    • Everyone
    Suggest edit
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    Emoji Reply
    Enable
    Import from Dropbox Google Drive Gist Clipboard
       Owned this note    Owned this note      
    Published Linked with GitHub
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    # Parallel Programming Final Project Proposal Draft ### Title Sparse Matrix Parallelization for Optimizing Deep Learning on Edge Devices ### The participant(s) - Yong Cheng Liaw yongchengliaw.ii12@nycu.edu.tw - 312581014 陳禹勳 - Shih Chi Cheng eziotiar@gmail.com ### Introduction/motivation #### Introduction In recent years, the scale of deep learning models has witnessed a staggering increase. Transitioning from foundational models of the past to the advanced architectures of today, a marked surge in the number of parameters is evident. This evolution, while capturing academia's interest, also garners significant attention in the industrial sector. A pressing concern that emerges is the rate at which model scales are outpacing the advancements in computational resources. Even with state-of-the-art hardware, we're presented with challenges in efficiently training and deploying these large-scale models. Take GPT-3 as an illustrative example. With over 175 billion parameters, operating it on standard computational devices becomes a formidable challenge. Training such a model on even high-performance servers necessitates significant time and resource commitments, rendering it nearly impossible for average PCs and mobile devices. Furthermore, similar challenges persist in other domains, such as recommendation systems and image processing. Consequently, researchers and engineers are exploring quantization and other methods to mitigate model size and computational requirements. This not only facilitates easier model deployment across devices but also ensures commendable performance within constrained computational environments. Indeed, when considering edge computing devices like IoT gadgets and smartphones, the challenge intensifies. Typically devoid of GPU accelerators, finding efficient ways to run neural network models on these platforms becomes paramount. Historically, the community leaned towards quantization techniques, transitioning from float32 to representations like int8 or 4 bits. However, this often resulted in a trade-off with precision. Yet, Prunning emerges as a promising technique. Studies, such as these Prunning-related papers, reveal that a substantial number of neural network parameters have values close to zero. By employing Prunning, these negligible values can be set to zero, substantially reducing model size and memory demands. This approach not only diminishes storage requirements but also retains model accuracy, paving a novel direction for future neural network model deployments. #### Motivation In recent studies, we have observed that the application of Prunning techniques can transform a significant portion of parameters in large models to zero. By utilizing Sparse Matrix storage methods, we can bypass the necessity to store all parameters, thereby conservatively using memory resources. In contrast, if we continue to store these Prunned models in a Dense Matrix format, we won't truly reap the benefits of memory savings, as even the zero values remain stored. Therefore, to genuinely save on memory, it is crucial to employ Sparse Matrix formats, focusing only on storing non-zero values. This highlights the significance of Sparse Matrix in scenarios where memory savings through Prunning is desired. However, based on our empirical observations, the prevalent PyTorch framework, when handling Sparse Matrix Multiplication, predominantly adopts the CSR Format for Sparse Matrix storage and resorts to Serial algorithms for computation. Through comparative analysis with Dense Matrix Multiplication, a noteworthy finding is that computational efficiency of Sparse Matrix operations tends to exponentially decrease as the size of the Matrix grows. This sheds light on the current suboptimal performance of Sparse Matrix Multiplication in neural network applications: while it indeed saves memory, the trade-off in computational efficiency is substantial. Consequently, exploring avenues to optimize Sparse Matrix Multiplication and enhance its computational performance has emerged as a pivotal research concern. ### Statement of the problem (Which application did you choose for this project? Why did you choose this problem?) The primary concern of this study revolves around the execution of neural networks and related applications on edge devices. With the contemporary growth in the size of neural network models, we are challenged with the task of efficiently running these vast models on devices devoid of GPUs and with limited DRAM. We propose that transforming matrices into Sparse Matrix through the technique of Prunning could be a viable solution. However, based on the current architecture of Pytorch, directly applying its existing framework results in a notable setback: the inherent computation speed for Sparse Matrix in Pytorch is considerably slow, hindering its practical applicability. Consequently, our approach emphasizes on speeding up Sparse Matrix Multiplication by leveraging parallel computation. Importantly, our investigation specifically delves into the scenario of Dense multiplied by Sparse Matrix. This is primarily because, in neural networks, model input features are often in a Dense format. Our main objective in Prunning targets the model weights, aiming to convert them into a Sparse Matrix. Given that the predominant operations in neural networks involve multiplication of the Input and Weight, we believe that accelerating the multiplication in the Dense-to-Sparse context is pivotal. If we can achieve optimized multiplication between Dense and Sparse matrices, it promises to greatly enhance the feasibility of running neural network models on edge devices. ### Proposed approaches, which include the block diagram (or architecture) of you system. Please describe the function of each components, and the interaction among these components. 1. block diagram / flow chart ![](https://hackmd.io/_uploads/H1HIdiAfp.png) 2. description We will implement a operator of multiplication between sparse matrix and dense matrix by pytorch C++ extension, allowing for fine-grained control, optimization, and integration with the existing PyTorch ecosystem. For easier use, we will wrap this operator into a separate Python package. ### Language selection (What parallel language do you use? Why do you use this parallel language?) In the implementation of the operator for multiplying a sparse matrix by a dense matrix, we utilize C++ standard threading library, std::thread, for parallelization. The reason why we use std::thread to implement it is due to : 1. Ease of Integration: Since we are implementing the operator as a PyTorch C++ extension, it is beneficial to use a threading library that easily integrates with C++ and does not introduce additional dependencies. std::thread fulfills this requirement as it is natively supported by C++. 2. Efficient Utilization of Resources: By parallelizing the sparse-dense matrix multiplication operation using std::thread, we can efficiently utilize available CPU cores. This is particularly important for large-scale matrix operations, where the computational load can be distributed across multiple threads to achieve faster execution times. 3. Granular Control: std::thread provides a low-level interface for thread management, giving the developer granular control over thread creation, synchronization, and termination. This is crucial for performance-critical applications like matrix multiplication, where optimizing thread utilization and minimizing overhead can lead to significant performance gains. This is the main difference with OpenMP. ### Related work 1. PyTorch: PyTorch is a popular deep learning framework that provides powerful tools and libraries for building and training neural network models. It is widely used in research and applications, particularly for deep learning tasks. 2. Edge Device: An edge device refers to a computing device located at the network's edge, close to data sources or end-users. These devices are typically used for data processing and decision-making to reduce data transmission and latency. - dram limitation : DRAM stands for Dynamic Random-Access Memory, which is a type of memory used in computer systems for storing data and programs. DRAM limitation indicates that a computing device has limited memory capacity, which may result in memory constraints affecting performance or application execution. 3. Pruning: Pruning is an optimization technique for deep learning models. It involves removing unnecessary neurons or weights to reduce the model's complexity and memory footprint while striving to maintain model performance. This helps accelerate the inference process and reduce model storage requirements. 4. Sparse Matrix Characteristics: Sparse matrices are matrices in which the majority of elements are zero. Sparse matrices exhibit specific characteristics that can be utilized for optimizing storage and computations. - COO and CSR Formats: COO (Coordinate Format) and CSR (Compressed Sparse Row Format) are two common formats used to represent sparse matrices. The COO format uses coordinates to represent the positions of non-zero elements, while the CSR format reduces memory usage by efficiently encoding the values and positions of non-zero elements. These formats are valuable in sparse matrix operations. ### Statement of expected results While striving to conserve memory through the utilization of sparse data characteristics, we anticipate achieving a significant reduction in memory usage without compromising performance to a significant extent. This implies that we aim to efficiently store and process extensive datasets while minimizing the system's memory requirements. By employing effective strategies for handling sparse data, such as zero values and repetitiveness, we seek to reduce memory footprint. The desired outcomes encompass the implementation of various optimization techniques in data processing to make full use of the sparsity of the data, ensuring that these optimizations do not significantly impact the speed and quality of data processing, meeting the requirements of applications or tasks. By successfully implementing these memory optimization measures, we aim to reduce memory demands while maintaining satisfactory performance, enhancing the scalability of applications, reducing hardware costs, and facilitating larger-scale data processing and analysis. In summary, our expectation is to strike an ideal balance between memory and performance by capitalizing on data sparsity, resulting in more efficient computations and resource utilization. ### A timetable ![](https://hackmd.io/_uploads/SJyouuAzp.png) ### References - A Systematic Survey of General Sparse Matrix-Matrix Multiplication. https://arxiv.org/pdf/2007.03179.pdf - GE-SpMM: General-purpose Sparse Matrix-Matrix Multiplication on GPUs for Graph Neural Networks. https://arxiv.org/pdf/2002.11273.pdf - Pytorch https://github.com/pytorch

    Import from clipboard

    Paste your markdown or webpage here...

    Advanced permission required

    Your current role can only read. Ask the system administrator to acquire write and comment permission.

    This team is disabled

    Sorry, this team is disabled. You can't edit this note.

    This note is locked

    Sorry, only owner can edit this note.

    Reach the limit

    Sorry, you've reached the max length this note can be.
    Please reduce the content or divide it to more notes, thank you!

    Import from Gist

    Import from Snippet

    or

    Export to Snippet

    Are you sure?

    Do you really want to delete this note?
    All users will lose their connection.

    Create a note from template

    Create a note from template

    Oops...
    This template has been removed or transferred.
    Upgrade
    All
    • All
    • Team
    No template.

    Create a template

    Upgrade

    Delete template

    Do you really want to delete this template?
    Turn this template into a regular note and keep its content, versions, and comments.

    This page need refresh

    You have an incompatible client version.
    Refresh to update.
    New version available!
    See releases notes here
    Refresh to enjoy new features.
    Your user state has changed.
    Refresh to load new user state.

    Sign in

    Forgot password

    or

    By clicking below, you agree to our terms of service.

    Sign in via Facebook Sign in via Twitter Sign in via GitHub Sign in via Dropbox Sign in with Wallet
    Wallet ( )
    Connect another wallet

    New to HackMD? Sign up

    Help

    • English
    • 中文
    • Français
    • Deutsch
    • 日本語
    • Español
    • Català
    • Ελληνικά
    • Português
    • italiano
    • Türkçe
    • Русский
    • Nederlands
    • hrvatski jezik
    • język polski
    • Українська
    • हिन्दी
    • svenska
    • Esperanto
    • dansk

    Documents

    Help & Tutorial

    How to use Book mode

    Slide Example

    API Docs

    Edit in VSCode

    Install browser extension

    Contacts

    Feedback

    Discord

    Send us email

    Resources

    Releases

    Pricing

    Blog

    Policy

    Terms

    Privacy

    Cheatsheet

    Syntax Example Reference
    # Header Header 基本排版
    - Unordered List
    • Unordered List
    1. Ordered List
    1. Ordered List
    - [ ] Todo List
    • Todo List
    > Blockquote
    Blockquote
    **Bold font** Bold font
    *Italics font* Italics font
    ~~Strikethrough~~ Strikethrough
    19^th^ 19th
    H~2~O H2O
    ++Inserted text++ Inserted text
    ==Marked text== Marked text
    [link text](https:// "title") Link
    ![image alt](https:// "title") Image
    `Code` Code 在筆記中貼入程式碼
    ```javascript
    var i = 0;
    ```
    var i = 0;
    :smile: :smile: Emoji list
    {%youtube youtube_id %} Externals
    $L^aT_eX$ LaTeX
    :::info
    This is a alert area.
    :::

    This is a alert area.

    Versions and GitHub Sync
    Get Full History Access

    • Edit version name
    • Delete

    revision author avatar     named on  

    More Less

    Note content is identical to the latest version.
    Compare
      Choose a version
      No search result
      Version not found
    Sign in to link this note to GitHub
    Learn more
    This note is not linked with GitHub
     

    Feedback

    Submission failed, please try again

    Thanks for your support.

    On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

    Please give us some advice and help us improve HackMD.

     

    Thanks for your feedback

    Remove version name

    Do you want to remove this version name and description?

    Transfer ownership

    Transfer to
      Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

        Link with GitHub

        Please authorize HackMD on GitHub
        • Please sign in to GitHub and install the HackMD app on your GitHub repo.
        • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
        Learn more  Sign in to GitHub

        Push the note to GitHub Push to GitHub Pull a file from GitHub

          Authorize again
         

        Choose which file to push to

        Select repo
        Refresh Authorize more repos
        Select branch
        Select file
        Select branch
        Choose version(s) to push
        • Save a new version and push
        • Choose from existing versions
        Include title and tags
        Available push count

        Pull from GitHub

         
        File from GitHub
        File from HackMD

        GitHub Link Settings

        File linked

        Linked by
        File path
        Last synced branch
        Available push count

        Danger Zone

        Unlink
        You will no longer receive notification when GitHub file changes after unlink.

        Syncing

        Push failed

        Push successfully