Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cache AoT compilation result #927

Merged
merged 6 commits into from
Jan 16, 2025
Merged

Cache AoT compilation result #927

merged 6 commits into from
Jan 16, 2025

Conversation

hanzhi713
Copy link
Member

@hanzhi713 hanzhi713 commented Jan 16, 2025

This improves the step time of some models on v6e by 2x. See the comments of cache_compiled_train_step .

@hanzhi713 hanzhi713 requested review from ruomingp, markblee and a team as code owners January 16, 2025 00:52
# excessive recompilations. Note: this could introduce overhead to training due to
# pre-compilation checks (such as sharding check) that increases the step time for some
# models. Note that this cache is always disabled at steps when xsc is enabled.
disable_python_train_step_cache: Optional[bool] = None
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's avoid negative boolean fields, as enable_python_train_step_cache=True is more readable than disable_python_train_step_cache=False.

Suggested change
disable_python_train_step_cache: Optional[bool] = None
enable_python_train_step_cache: Optional[bool] = None

Copy link
Member Author

Choose a reason for hiding this comment

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

Done.

Comment on lines 1012 to 1013
self._compiled_train_step = compiled_jit_train_step_fn
return self._compiled_train_step
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we leave self._compiled_train_step unchanged when with_xsc is true?

Suggested change
self._compiled_train_step = compiled_jit_train_step_fn
return self._compiled_train_step
return compiled_jit_train_step_fn

Copy link
Member Author

Choose a reason for hiding this comment

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

Good point, yes.

@ruomingp ruomingp self-assigned this Jan 16, 2025
@hanzhi713 hanzhi713 requested a review from ruomingp January 16, 2025 02:51
axlearn/common/trainer.py Show resolved Hide resolved
axlearn/common/trainer.py Outdated Show resolved Hide resolved
axlearn/common/trainer.py Show resolved Hide resolved
@hanzhi713 hanzhi713 requested review from apghml and ruomingp January 16, 2025 04:15
Comment on lines 282 to 283
if cfg.cache_python_train_step is True:
raise ValueError("cache_python_train_step cannot be True when xsc is enabled.")
Copy link
Contributor

Choose a reason for hiding this comment

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

Actually cache_python_train_step is still useful even with XSC, since the non-XSC steps will be cached and only the XSC step needs to be recompiled. The XSC step does not run often, so maybe this is OK?

Copy link
Member Author

Choose a reason for hiding this comment

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

Agreed.

@hanzhi713 hanzhi713 requested a review from ruomingp January 16, 2025 18:34
# pre-compilation checks (such as sharding check) that increases the step time for some
# models. Note that this cache is always disabled at steps when xsc is enabled.
# Defaults to None which is interpreted as True.
cache_python_train_step: Optional[bool] = None
Copy link
Contributor

Choose a reason for hiding this comment

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

nit --

Suggested change
cache_python_train_step: Optional[bool] = None
cache_compiled_train_step: Optional[bool] = None

Copy link
Member Author

Choose a reason for hiding this comment

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

Done.

@hanzhi713 hanzhi713 requested a review from markblee January 16, 2025 18:55
@hanzhi713 hanzhi713 enabled auto-merge January 16, 2025 19:07
@hanzhi713 hanzhi713 added this pull request to the merge queue Jan 16, 2025
Merged via the queue into apple:main with commit 1e25e4a Jan 16, 2025
6 checks passed
@hanzhi713 hanzhi713 deleted the cache-aot branch January 16, 2025 19:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants