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

Bug fix for the schedule after the update_optimizer #272

Merged
merged 6 commits into from
Nov 30, 2023
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/linters/.python-lint
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ max-line-length = 99
max-locals=100
max-statements=300
min-public-methods=1
max-branches=100
max-branches=120
max-module-lines=5000
max-args=20
max-returns=10
Expand Down
8 changes: 8 additions & 0 deletions train.py
Original file line number Diff line number Diff line change
Expand Up @@ -527,6 +527,14 @@ def main():
# Update the optimizer to reflect fused batchnorm layers
optimizer = ai8x.update_optimizer(model, optimizer)

# Update the compression scheduler to reflect the updated optimizer
for ep, _ in enumerate(compression_scheduler.policies):
for i, _ in enumerate(compression_scheduler.policies[ep]):
for attr_key in dir(compression_scheduler.policies[ep][i]):
attr = getattr(compression_scheduler.policies[ep][i], attr_key)
if hasattr(attr, 'optimizer'):
attr.optimizer = optimizer

# Switch model from unquantized to quantized for QAT
ai8x.initiate_qat(model, qat_policy)

Expand Down