[PR #1625] fix(labs): correct ESP32 SRAM field and OOM ratio in Lab 01 #9231

Open
opened 2026-05-03 01:29:37 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/harvard-edge/cs249r_book/pull/1625
Author: @Shashank-Tripathi-07
Created: 5/3/2026
Status: 🔄 Open

Base: devHead: fix/lab01-esp32-sram-oom-ratio


📝 Commits (1)

  • 145fc35 fix(labs): use ESP32 SRAM capacity for OOM ratio in lab 01

📊 Changes

1 file changed (+6 additions, -6 deletions)

View changed files

📝 labs/vol1/lab_01_ml_intro.py (+6 -6)

📄 Description

Bug

labs/vol1/lab_01_ml_intro.py line 67 reads ESP32.memory.capacity to get the ESP32's memory size, but memory.capacity returns the 8 MB flash storage, not SRAM.

The correct field is ESP32.memory.sram_capacity = 512 KiB.

Impact

ESP32_RAM_KB was 7812 (flash) instead of 512 (SRAM), making the OOM ratio compute as ~6x instead of the correct ~98x. Every downstream callout, badge, and answer reveal in Part C showed fabricated numbers.

Fix

  • Line 67: ESP32.memory.capacity.m_as("KiB")ESP32.memory.sram_capacity.m_as("KiB")
  • Badge: 200x Out of Memory~100x Out of Memory
  • Learning objective: "infeasible by 200x" → "infeasible by ~100x"
  • Part C question option C: ~200x over budget~100x over budget
  • Answer reveal text: updated hardcoded "200x" references to match actual ~98x ratio

Verification

from mlsysim import Hardware, Models
ESP32 = Hardware.Tiny.ESP32_S3
RESNET50_PARAMS = Models.ResNet50.parameters.m_as('count')
RESNET50_SIZE_MB = RESNET50_PARAMS * 2 / (1024*1024)  # FP16

# Before fix (wrong)
wrong_kb = ESP32.memory.capacity.m_as('KiB')        # 7812 KiB (flash)
print(RESNET50_SIZE_MB * 1024 / wrong_kb)            # ~6x -- wrong

# After fix (correct)
correct_kb = ESP32.memory.sram_capacity.m_as('KiB')  # 512 KiB (SRAM)
print(RESNET50_SIZE_MB * 1024 / correct_kb)          # ~98x -- correct

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/harvard-edge/cs249r_book/pull/1625 **Author:** [@Shashank-Tripathi-07](https://github.com/Shashank-Tripathi-07) **Created:** 5/3/2026 **Status:** 🔄 Open **Base:** `dev` ← **Head:** `fix/lab01-esp32-sram-oom-ratio` --- ### 📝 Commits (1) - [`145fc35`](https://github.com/harvard-edge/cs249r_book/commit/145fc359a0341070dabdf2d36ee39bea97accfd6) fix(labs): use ESP32 SRAM capacity for OOM ratio in lab 01 ### 📊 Changes **1 file changed** (+6 additions, -6 deletions) <details> <summary>View changed files</summary> 📝 `labs/vol1/lab_01_ml_intro.py` (+6 -6) </details> ### 📄 Description ## Bug `labs/vol1/lab_01_ml_intro.py` line 67 reads `ESP32.memory.capacity` to get the ESP32's memory size, but `memory.capacity` returns the **8 MB flash storage**, not SRAM. The correct field is `ESP32.memory.sram_capacity` = **512 KiB**. ## Impact `ESP32_RAM_KB` was 7812 (flash) instead of 512 (SRAM), making the OOM ratio compute as ~6x instead of the correct ~98x. Every downstream callout, badge, and answer reveal in Part C showed fabricated numbers. ## Fix - Line 67: `ESP32.memory.capacity.m_as("KiB")` → `ESP32.memory.sram_capacity.m_as("KiB")` - Badge: `200x Out of Memory` → `~100x Out of Memory` - Learning objective: "infeasible by 200x" → "infeasible by ~100x" - Part C question option C: `~200x over budget` → `~100x over budget` - Answer reveal text: updated hardcoded "200x" references to match actual ~98x ratio ## Verification ```python from mlsysim import Hardware, Models ESP32 = Hardware.Tiny.ESP32_S3 RESNET50_PARAMS = Models.ResNet50.parameters.m_as('count') RESNET50_SIZE_MB = RESNET50_PARAMS * 2 / (1024*1024) # FP16 # Before fix (wrong) wrong_kb = ESP32.memory.capacity.m_as('KiB') # 7812 KiB (flash) print(RESNET50_SIZE_MB * 1024 / wrong_kb) # ~6x -- wrong # After fix (correct) correct_kb = ESP32.memory.sram_capacity.m_as('KiB') # 512 KiB (SRAM) print(RESNET50_SIZE_MB * 1024 / correct_kb) # ~98x -- correct ``` --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2026-05-03 01:29:37 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/cs249r_book#9231