mirror of
https://github.com/harvard-edge/cs249r_book.git
synced 2026-07-24 08:47:40 -05:00
Closed
opened 2026-04-21 21:41:14 -05:00 by GiteaMirror
·
5 comments
No Branch/Tag Specified
dev
dependabot/npm_and_yarn/socratiq/linkify-it-5.0.2
audit/mlperf-edu-readiness
feat/mlperf-edu-precondition
gh-pages
vol1/all-final
main
vol1/appendices-final
vol1/ch16-final
vol1/ch15-final
vol1/ch14-final
vol1/ch13-final
vol1/ch11-final
vol1/ch12-final
vol1/ch10-final
vol1/ch9-final
vol1/ch8-final
vol1/ch7-final
vol1/ch6-final
vol1/ch5-final
vol1/ch4-final
vol1/ch3-final
vol1/ch2-final
vol1/frontmater-final
kai/fixing-profile-setting-and-map
chore/staffml-ci-path
fix/callout-flow
vol1/ch10-pass4
vol1/ch9-pass4
vol1/ch8-pass4
vol1/ch7-pass4
vol1/ch6-pass4
vol1/ch5-pass4
vol1/apC-pass3
vol1/ch4-pass4
vol1/ch3-pass4
vol1/ch2-pass4
vol1/ch1-pass4
vol1/frontmatter
vol1/apE-pass3
vol1/apD-pass3
fmt-fix
vol1/ch14-pass3
kai/clarify-community-map-totals
vol1/ch13-pass3
vol1/ch12-pass3
vol1/ch11-pass3
vol1/ch10-pass3
vol1/ch7-pass3
vol1/ch9-pass3
vol1/ch8-pass3
vol1/ch6-pass3
vol1/ch5-pass3
vol1/ch4-pass3
vol1/ch3-pass3
vol1/ch2-pass3
vol1/ch1-pass3
vol1/ch6-pass2
vol1/ch5-pass2
vol1/ch4-pass2
vol1/ch3-pass2
vol1/ch2-pass2
fix/badge-fixes
chore/precommit-cleanup
cleanup/book-validate-paths
fix/staffml-trigger-on-workflow-edits
fix/staffml-reusable-concurrency
feat/container-preflight-urls
instructors-v0.1.1
vol1-pr1957-merged
vol2-v0.2.1
vol1-v0.7.1
vol1-v0.7.0+vol2-v0.2.0
slides-v0.1.0
vol2-v0.2.0
vol1-v0.7.0
tinytorch-v0.1.13
mlsysim-v0.2.0
vol2-v0.1.2
vol1-v0.6.2
tinytorch-v0.1.12
vol2-v0.1.1
vol1-v0.6.1
mlsysim-v0.1.3
vol2-v0.1.0
vol1-v0.6.0
mlsysim-v0.1.2
staffml-v0.1.1
tinytorch-v0.1.11
labs-v0.1.0
kits-v0.1.0
slides-latest
instructors-v0.1.0
staffml-v0.1.0
mlsysim-v0.1.1
mlsysim-v0.1.0
tinytorch-v0.1.10
build-verified-windows-v1
tinytorch-v0.1.9
tinytorch-v0.1.8
mit-submission-v1
tinytorch-v0.1.7
tinytorch-v0.1.6
tinytorch-v0.1.5
tinytorch-slides-v0.1.0
tinytorch-v0.1.3
tinytorch-v0.1.4
tinytorch-v0.1.2
tinytorch-v0.1.1
tinytorch-v0.1.0
book-v0.5.1
tinytorch-audio-v0.1.1
tinytorch-audio-assets-v0.1
book-v0.5.0
book-v0.4.2
book-v0.4.1
book-v0.4.0
book-v0.3.0
book-v0.2.0
book-v0.1.0
Labels
Clear labels
area: book
area: collabs
area: kits
area: labs
area: socratiq
area: staffml
area: tinytorch
area: tools
area: website
bug
dependencies
format: epub
format: pdf
javascript
link-health
link-rot
priority-high
pull-request
staffml
type: bug
type: citation
type: code
type: errata
type: improvement
type: new
type: question
vault-sli
Mirrored from GitHub Pull Request
Milestone
No items
No Milestone
Projects
Clear projects
No projects
No Assignees
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: github-starred/cs249r_book#5678
Reference in New Issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Originally created by @ngbolin on GitHub (Feb 11, 2026).
Original GitHub issue: https://github.com/harvard-edge/cs249r_book/issues/1168
Hi,
In the function
measure_sparsity()of Module 16, we set total_params=0.0 if there are no parameters present in the model. In the following division, wouldn't that raise a ValueError?Should we have set total_params=eps in this case to prevent this, where eps can be 1e-9?
@ngbolin commented on GitHub (Feb 11, 2026):
In addition, for the example below, 0.1 seems to be the 44th percentile instead of the 70th percentile. Hence, when setting the threshold at 0.1, 44% of the values (or 8/18 of all values) are set to 0.
@ngbolin commented on GitHub (Feb 11, 2026):
In the function
demo_compression_with_profiler, the sparsity increased from 0 to 70%, not 7000%. I think this was a result of themeasure_sparsityfunction, which already converted the fraction to a percentage.@profvjreddi commented on GitHub (Feb 11, 2026):
Hi @ngbolin — great catches, all three! Here's what we found and fixed:
Bug 1:
measure_sparsity()divide-by-zeroThere's actually already a guard for this:
It returns early before the division, so no
ZeroDivisionErroris raised. But you're right that the screenshot makes it look like the division would happen unconditionally — appreciate flagging it.Bug 2: Incorrect percentile in the pruning diagram
You're exactly right. With 18 values, a threshold of 0.1 zeroes out 8/18 ≈ 44% — not the 70% claimed. We rewrote the ASCII art example to use 20 values with a clean 50th percentile threshold (0.4), which zeroes out exactly 10/20 values. The math now checks out.
Bug 3: 7000% sparsity display
Spot on —
measure_sparsity()already returns a percentage (0–100), so the extra* 100indemo_compression_with_profiler()was double-multiplying. We fixed all 6 occurrences in that function:* 100from display strings (e.g.,{sparsity_after:.1f}%instead of{sparsity_after*100:.1f}%)1 - sparsity / 100instead of1 - sparsity)sparsity_gainto be a simple difference of percentages instead of re-multiplyingAll fixes are in commit
0630674a7. Thanks for the thorough report — this kind of attention to detail really helps improve the modules! 🙏@profvjreddi commented on GitHub (Feb 12, 2026):
@all-contributors please add @ngbolin as a contributor for ✍️ Doc,Bug in tinytorch
@github-actions[bot] commented on GitHub (Feb 12, 2026):
I've added @ngbolin as a contributor to tinytorch! 🎉
Recognized for: doc
Project: tinytorch (explicitly mentioned in comment)
Based on: @all-contributors please add @ngbolin as a contributor for ✍️ Doc,Bug in tinytorch
The contributor list has been updated in:
tinytorch/.all-contributorsrctinytorch/README.mdREADME.mdWe love recognizing our contributors! ❤️