8000 Improve Mosaic memory profiling tutorial by basilwong · Pull Request #3753 · pytorch/tutorials · GitHub
[go: up one dir, main page]

Skip to content

Conversation

@basilwong
Copy link
Contributor
@basilwong basilwong commented Jan 28, 2026

Summary

This PR improves the Mosaic memory profiling tutorial with several enhancements:

  • Add GPT-2 memory profile images: Visual comparison of memory usage with and without activation checkpointing
  • Add Google Colab download instructions: Code block showing how to download generated snapshot/profile files
  • Fix subprocess output visibility: Mosaic CLI output is now captured and printed so users can see the analysis results
  • Split Mosaic analysis into separate code blocks: Better readability for the baseline vs buggy model comparison
  • Refactor GPT2WithDebugOverhead: Changed from subclassing to wrapper pattern, fixing transformers version compatibility
  • Update section formatting: Bold headers instead of RST section underlines for cleaner rendering

Test plan

  • Build tutorial locally with GALLERY_PATTERN="mosaic_memory_profiling_tutorial" make html-noplot
  • Verify new images render correctly
  • Verify subprocess output is visible in rendered tutorial
  • Verify GPT2WithDebugOverhead works with current transformers version

…buggy model

- Add GPT-2 memory profiling images (with/without activation checkpointing)
- Add Google Colab download instructions for generated files
- Fix subprocess.run to capture and print Mosaic CLI output
- Split Mosaic analysis into separate code blocks for readability
- Refactor GPT2WithDebugOverhead to use wrapper pattern instead of
  subclassing, fixing transformers version compatibility issues
- Remove try/except workaround that was bypassing the tutorial's purpose
- Update section formatting (bold headers instead of RST underlines)
@pytorch-bot
Copy link
pytorch-bot bot commented Jan 28, 2026

🔗 Helpful Links

🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/tutorials/3753

Note: Links to docs will display an error until the docs builds have been completed.

⏳ No Failures, 15 Pending

As of commit f26fe03 with merge base afcd23a (image):
💚 Looks good so far! There are no failures yet. 💚

This comment was automatically generated by Dr. CI and updates every 15 minutes.

evaluate
accelerate>=0.20.1
git+https://github.com/facebookresearch/mosaic.git
altair
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@basilwong basilwong force-pushed the mosaic-tutorial-improvements branch from 25d498d to f26fe03 Compare January 28, 2026 21:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

0