Skip to content

[Bugfix] Fix missing attribute from compile - #2675

Merged
Lucaskabela merged 1 commit into
pytorch:mainfrom
Lucaskabela:lucaskabela/named_children_fix
Mar 23, 2026
Merged

Lucaskabela merged 1 commit into
pytorch:mainfrom
Lucaskabela:lucaskabela/named_children_fix

Conversation

@Lucaskabela

Copy link
Copy Markdown
Contributor

Minor fix in #2568 to move apply_compile to distributed/compile caused a bug due to missing .named_children() in this integration. So, update to fix (avoid crashing) for compile on the trainer

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Mar 23, 2026
@Lucaskabela
Lucaskabela marked this pull request as ready for review March 23, 2026 18:33
Comment thread torchtitan/distributed/compile.py Outdated
# pyrefly: ignore [missing-attribute]
for transformer_block in model.layers.named_children.values():
# pyrefly: ignore [missing-attribute, not-callable]
for transformer_block in model.layers.values():

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.

can we use for layer_id, transformer_block in model.layers.named_children(): which is what it is before?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

layer_id won't be used so we can just use _ - named_children() should work though

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.

I see, for compile dense it was used for model.layers.register_module(layer_id, transformer_block), so does that mean model.compile here will change the module in place?

@Lucaskabela
Lucaskabela force-pushed the lucaskabela/named_children_fix branch from 90eb19f to bd0390e Compare March 23, 2026 20:13
@Lucaskabela
Lucaskabela merged commit 129b517 into pytorch:main Mar 23, 2026
19 of 29 checks passed
pytorch-bot Bot pushed a commit that referenced this pull request Mar 27, 2026
Minor fix in #2568 to move
apply_compile to distributed/compile caused a bug due to missing
`.named_children()` in this integration. So, update to fix (avoid
crashing) for compile on the trainer
TXacs pushed a commit to McmillanTAC/torchtitan that referenced this pull request Apr 13, 2026
Minor fix in pytorch#2568 to move
apply_compile to distributed/compile caused a bug due to missing
`.named_children()` in this integration. So, update to fix (avoid
crashing) for compile on the trainer
ACharacterInASimulation pushed a commit to ACharacterInASimulation/torchtitan that referenced this pull request Apr 21, 2026
Minor fix in pytorch#2568 to move
apply_compile to distributed/compile caused a bug due to missing
`.named_children()` in this integration. So, update to fix (avoid
crashing) for compile on the trainer
@Lucaskabela
Lucaskabela deleted the lucaskabela/named_children_fix branch May 6, 2026 19:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ciflow/8gpu 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.

3 participants