Digitala Vetenskapliga Arkivet

Change search
CiteExportLink to record
Permanent link

Direct link
Cite
Citation style
  • apa
  • ieee
  • modern-language-association-8th-edition
  • vancouver
  • Other style
More styles
Language
  • de-DE
  • en-GB
  • en-US
  • fi-FI
  • nn-NO
  • nn-NB
  • sv-SE
  • Other locale
More languages
Output format
  • html
  • text
  • asciidoc
  • rtf
Micrograd-rs: An analysis of Rust’s memory allocation in neural networks
KTH, School of Electrical Engineering and Computer Science (EECS).
2025 (English)Independent thesis Basic level (degree of Bachelor), 10 credits / 15 HE creditsStudent thesis
Abstract [en]

As machine learning frameworks grow, it becomes more important to balance the computational power and memory efficiency of these systems. This paper explores Rust’s memory allocation in neural networks by rewriting Micrograd, a minimalist autograd engine, into Micrograd-rs. We show that the over utilization of vectors, which are optimized by the Python backend, negatively affects Rust’s performance and memory efficiency effectively allocating the program to the heap. This paper serves as a guide for future software and hardware engineers who want to have a better understanding of the Rust borrow checker and discusses how Micrograd-rs and other machine learning frameworks could be improved in Rust allowing the program to allocate more bytes to the stack safely.

Abstract [sv]

I takt med att ramverk för maskininlärning växer blir det viktigare att balansera beräkningskraften och minneseffektiviteten hos dessa system. Denna uppsats utforskar Rusts minnesallokering i neurala nätverk genom att skriva om Micrograd, en minimalistisk autogradmotor, till Micrograd-rs. Vi visar att överanvändning av vektorer, som är optimerade av Python-backenden, negativt påverkar Rusts prestanda och minneseffektivitet som i praktiken allokerar programmet till heapen. Denna uppsats fungerar som en guide för framtida mjukvaru- och hårdvaruingenjörer som vill ha en bättre förståelse av Rusts borrow checker och diskuterar hur Micrograd-rs och andra ramverk för maskininlärning kan förbättras i Rust, vilket gör att programmet kan allokera fler byte till stacken på ett säkert sätt.

Place, publisher, year, edition, pages
2025. , p. 37
Series
TRITA-EECS-EX ; 2025:363
Keywords [en]
Rust, Machine Learning, Memory Allocation, Memory Safety, Neural Network, Micrograd
National Category
Computer and Information Sciences
Identifiers
URN: urn:nbn:se:kth:diva-367696OAI: oai:DiVA.org:kth-367696DiVA, id: diva2:1985858
Supervisors
Examiners
Available from: 2025-08-06 Created: 2025-07-28 Last updated: 2025-08-06Bibliographically approved

Open Access in DiVA

fulltext(1013 kB)312 downloads
File information
File name FULLTEXT01.pdfFile size 1013 kBChecksum SHA-512
2eeff119a064187125711658d130db5b78d9848ba9e9b8a0ca023a518b225c2470b7c994eec0b3cd4444b08e7d1ec67374e9cca13396b84313bfab74c77cc9c1
Type fulltextMimetype application/pdf

By organisation
School of Electrical Engineering and Computer Science (EECS)
Computer and Information Sciences

Search outside of DiVA

GoogleGoogle Scholar
Total: 314 downloads
The number of downloads is the sum of all downloads of full texts. It may include eg previous versions that are now no longer available

urn-nbn

Altmetric score

urn-nbn
Total: 581 hits
CiteExportLink to record
Permanent link

Direct link
Cite
Citation style
  • apa
  • ieee
  • modern-language-association-8th-edition
  • vancouver
  • Other style
More styles
Language
  • de-DE
  • en-GB
  • en-US
  • fi-FI
  • nn-NO
  • nn-NB
  • sv-SE
  • Other locale
More languages
Output format
  • html
  • text
  • asciidoc
  • rtf