Skip to content

[config] Reject a non-positive training.gc_freq - #5011

Merged
tianyu-l merged 7 commits into
pytorch:mainfrom
YeonwooSung:pr/validate-gc-freq
Oct 2, 2026
Merged

tianyu-l merged 7 commits into
pytorch:mainfrom
YeonwooSung:pr/validate-gc-freq

Conversation

@YeonwooSung

Copy link
Copy Markdown
Contributor

GarbageCollection.__init__ rejected a non-positive gc_freq with assert. training.gc_freq is user config. That assert disappears under python -O, and gc_freq=0 then dies as ZeroDivisionError on step_count % self.gc_freq during training. A negative value still collects.

Raise ValueError in the constructor instead. The message includes the bad value and says training.gc_freq must be a positive integer. The default stays 1000, and when GC runs is unchanged. The check stays in the constructor (not TrainingEngine or configs.py) because #4907 rewrites the config layout.

Test plan

  • pytest tests/unit_tests/cpu/test_gc_freq.py -q
  • GarbageCollection(0) and GarbageCollection(-1) raise ValueError whose message mentions gc_freq
  • GarbageCollection(1) and GarbageCollection(1000) still construct, and periodic collection still runs only when step_count > 1 and step_count % gc_freq == 0

@pytorch-bot pytorch-bot Bot added the ciflow/fake-pg Run 1-GPU Fake PG integration tests label Oct 2, 2026
@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Oct 2, 2026
@pytorch-bot

pytorch-bot Bot commented Oct 2, 2026 •

Copy link
Copy Markdown

Workflows were awaiting approval. CI has now been triggered for the ciflow labels on this PR.

Comment thread torchtitan/tools/utils.py Resolved
@pytorch-bot pytorch-bot Bot added the ciflow/rl label Oct 2, 2026

@tianyu-l tianyu-l left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

one comment

Comment thread torchtitan/training_engine.py Resolved
@YeonwooSung

Copy link
Copy Markdown
Contributor Author

There is a CI errror (lint errror), will fix it right now

@tianyu-l
tianyu-l merged commit 6f716fe into pytorch:main Oct 2, 2026
@YeonwooSung
YeonwooSung deleted the pr/validate-gc-freq branch October 2, 2026 09:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ciflow/fake-pg Run 1-GPU Fake PG integration tests ciflow/rl CLA Signed This label is managed by the Meta Open Source bot.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants