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

[DRAFT] Feat cailey sgd #1127

Draft
wants to merge 9 commits into
base: dev
Choose a base branch
from
Draft

Conversation

pablomlago
Copy link
Collaborator

Reason for this PR

Changes Made in this PR

Testing Summary

Risk Highlight

  • This PR includes code from another work (please detail).
  • This PR contains API-breaking changes.
  • This PR depends on work in another PR (please provide links/details).
  • This PR introduces new dependencies (please detail).
  • There are coverage gaps not covered by tests.
  • Documentation updates required in subsequent PR.

Checklist

  • Code comments added to any hard-to-understand areas, if applicable.
  • Changes generate no new warnings.
  • Updated any relevant tests, if applicable.
  • No conflicts with destination dev branch.
  • I reviewed my own code changes.
  • Initial CI/CD passing.
  • 1+ reviews given, and any review issues addressed and approved.
  • Post-review full CI/CD passing.

@pablomlago pablomlago changed the title [WIP] Feat cailey sgd [DRAFT] Feat cailey sgd Dec 13, 2024
@@ -166,3 +183,86 @@ def apply_exact_had_to_linear(module, had_dim=-1, output=False):

def is_pow2(n):
return (n & (n - 1) == 0) and (n > 0)


hadamard_string_16 = """++++++++++++++++
Copy link
Collaborator

Choose a reason for hiding this comment

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

?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This is temporal code. These matrices will be included in hadamard.pt, when the PR is in merge state.

regions: List[Region] = []
self.find_module(model, regions)
if len(regions) > 0:
_apply_rotate(model, regions)
return model


def _apply_rotate_fused_rotations(
Copy link
Collaborator

Choose a reason for hiding this comment

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

We don't need an entire new function

@@ -0,0 +1,197 @@
# coding=utf-8
# Copyright (c) Meta Platforms, Inc. and affiliates.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Add a reference to the code origin

@@ -49,7 +53,7 @@ def set_seed(seed):
torch.random.manual_seed(seed)


def fused_rotation_no_fx(model, calibration_loader, args):
def fused_rotation_no_fx(model, calibration_loader, args, fuse_rotations: bool = False):
Copy link
Collaborator

Choose a reason for hiding this comment

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

fuse_rotation -> optimize_rotation

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The matrices can be kept unfused, even if they are no optimized (even if this is not leveraged at any point), so this name seems more general.

@pablomlago pablomlago marked this pull request as draft December 13, 2024 15:30
@Giuseppe5 Giuseppe5 linked an issue Dec 18, 2024 that may be closed by this pull request
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.

Optimized rotation matrix
2 participants