Skip to content

fix(mlsysim): surface load errors via last_load_error on DesignLedger - #2007

Closed
ShivtejG236 wants to merge 4 commits into
harvard-edge:devfrom
ShivtejG236:fix/1994-designledger-load-error-handling
Closed

fix(mlsysim): surface load errors via last_load_error on DesignLedger#2007
ShivtejG236 wants to merge 4 commits into
harvard-edge:devfrom
ShivtejG236:fix/1994-designledger-load-error-handling

Conversation

@ShivtejG236

Copy link
Copy Markdown
Contributor

Summary

Fixes #1994. DesignLedger.load()/load_async() previously reset silently
to a blank LedgerState() on any read failure (missing file, corrupt JSON,
IndexedDB error), with no way for calling code to distinguish "first run,
nothing saved yet" from "a save exists but couldn't be read" — a silent
data-loss bug on the read path. Adds last_load_error, mirroring the
last_save_error pattern #1988 established on the write path.

Area

  • Book (textbook content, figures, exercises)
  • TinyTorch (modules, tests, milestones)
  • StaffML (interview questions, challenges)
  • Kits (hardware labs)
  • Infrastructure (CI/CD, scripts, config)

(No box above quite fits mlsysim/Co-Labs specifically — checking
Infrastructure as the closest match. Actual area: mlsysim/mlsysim/labs/
and labs/tests/.)

Changes

  • mlsysim/mlsysim/labs/state.py: add _last_load_error + read-only
    last_load_error property; set it in load() and load_async()'s
    except blocks instead of discarding the exception.
  • mlsysim/tests/test_state.py: add native-path regression tests
    (missing file is not an error, corrupt file sets last_load_error and
    falls back to blank state, error clears on next successful load).
  • labs/tests/test_wasm_persistence.py: add two real-browser
    (Playwright + Chromium + Pyodide) regression tests for load_async()
    corrupt IndexedDB record, and indexedDB.open() throwing synchronously —
    reusing the served_dir fixture fix(labs): stop silently dropping WASM DesignLedger saves (#1985) #1988 introduced.

Rebased cleanly onto dev after #1988 merged; no leftover conflicts.

Testing

  • Rendered the book locally (quarto render)
  • Ran tests (pytest tests/)
  • Ran tito module test NN for affected module(s)
  • Manual verification (describe below)

Ran explicitly:

python -m pytest mlsysim/tests/test_state.py -v      # 11 passed
python -m pytest labs/tests/test_wasm_persistence.py -v   # 3 passed (real Chromium)

@Shashank-Tripathi-07

This comment was marked as outdated.

@Shashank-Tripathi-07

Shashank-Tripathi-07 commented Aug 11, 2026

Copy link
Copy Markdown
Collaborator

lgtm. tagging professor for a review from his end.

@profvjreddi

Copy link
Copy Markdown
Contributor

Thanks @ShivtejG236, and welcome. Integrated into dev.

Your six new tests pass here alongside the existing five. Good first PR to pick, and thanks for the patience on the review.

I applied your commit onto a review branch off current dev rather than merging the PR head, so GitHub will show this as closed instead of merged. Authorship and credit are intact.

@all-contributors please add @ShivtejG236 for bug, code, test in mlsysim

@github-actions

Copy link
Copy Markdown
Contributor

I've added @ShivtejG236 as a contributor to mlsysim! 🎉

Recognized for: bug, code, test
Project(s): mlsysim (explicitly mentioned in comment)
Based on: @all-contributors please add @ShivtejG236 for bug, code, test in mlsysim

The contributor list has been updated in:

  • mlsysim/.all-contributorsrc, mlsysim/README.md
  • Main README.md

We love recognizing our contributors! ❤️

@ShivtejG236

ShivtejG236 commented Aug 31, 2026

Copy link
Copy Markdown
Contributor Author

Thanks @ShivtejG236, and welcome. Integrated into dev.

Your six new tests pass here alongside the existing five. Good first PR to pick, and thanks for the patience on the review.

I applied your commit onto a review branch off current dev rather than merging the PR head, so GitHub will show this as closed instead of merged. Authorship and credit are intact.

@all-contributors please add @ShivtejG236 for bug, code, test in mlsysim

Thank you, Professor!

Was an amazing experience working on this. As my first real OSS contribution, I learnt a lot, especially through the review process

@github-actions

Copy link
Copy Markdown
Contributor

I've added @ShivtejG236 as a contributor to mlsysim! 🎉

Recognized for: bug, code, test
Project(s): mlsysim (explicitly mentioned in comment)
Based on: > @all-contributors please add @ShivtejG236 for bug, code, test in mlsysim

The contributor list has been updated in:

  • mlsysim/.all-contributorsrc, mlsysim/README.md
  • Main README.md

We love recognizing our contributors! ❤️

1 similar comment
@github-actions

Copy link
Copy Markdown
Contributor

I've added @ShivtejG236 as a contributor to mlsysim! 🎉

Recognized for: bug, code, test
Project(s): mlsysim (explicitly mentioned in comment)
Based on: > @all-contributors please add @ShivtejG236 for bug, code, test in mlsysim

The contributor list has been updated in:

  • mlsysim/.all-contributorsrc, mlsysim/README.md
  • Main README.md

We love recognizing our contributors! ❤️

profvjreddi added a commit that referenced this pull request Aug 31, 2026
Land five verified contributor fixes from the open-PR triage:

  #2089 utf-8 encoding on all tito file I/O (Windows cp1252 crashes)
  #2093 Conv2d FLOP counting in the profiler (TypeError on real layers)
  #2022 --skip-profile no longer prompts for community registration
  #2071 setup survives a corrupted profile.json; atomic profile write
  #2007 DesignLedger.last_load_error surfaces swallowed load failures

Each was verified against the code rather than the PR description, and
authorship is preserved per commit. Unit suite matches the pre-merge dev
baseline exactly (641 passed / 3 pre-existing failures, 672 total).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: mlsysim Path mlsysim/ — auto-label type: bug bug in rendering

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug][Labs] DesignLedger.load()/load_async() silently swallow read failures and reset progress to blank

3 participants