Skip to content

feat: mx integration#110

Merged
chichun-charlie-liu merged 47 commits intofoundation-model-stack:mainfrom
chichun-charlie-liu:mx_impl
May 28, 2025
Merged

feat: mx integration#110
chichun-charlie-liu merged 47 commits intofoundation-model-stack:mainfrom
chichun-charlie-liu:mx_impl

Conversation

@chichun-charlie-liu
Copy link
Copy Markdown
Collaborator

Description of the change

Support mx formats by integrating mx package's functionalities. Triggered by mx_ prefix in config's qw_mode, qa_mode,...

Related issue number

part #105 but need two more PRs

  1. use diff/patch file to resolve microxcaling's dependency/installation issue
  2. add supports to fp8e4m3, e5m2 format for scales.
    (see Issue 105 for more details)

How to verify the PR

New unit tests are added, including config and toy model tests.

Was the PR tested

  • I have added >=1 unit test(s) for every new method I have added.
  • I have ensured all unit tests pass

chichun-charlie-liu and others added 20 commits March 27, 2025 18:45
Signed-off-by: cliu-us <cliu@us.ibm.com>
Signed-off-by: cliu-us <cliu@us.ibm.com>
Signed-off-by: cliu-us <cliu@us.ibm.com>
Signed-off-by: cliu-us <cliu@us.ibm.com>
Signed-off-by: cliu-us <cliu@us.ibm.com>
Signed-off-by: cliu-us <cliu@us.ibm.com>
…. previously has to be all or none mx

Signed-off-by: cliu-us <cliu@us.ibm.com>
…-existing quantizer "mx_abc", force nbits=32 for QBmm init to avoid getting quantizers. QBmmMX simply relies on qa_mode, not nbits

Signed-off-by: cliu-us <cliu@us.ibm.com>
Signed-off-by: Brandon Groth <brandon.m.groth@gmail.com>
Signed-off-by: Brandon Groth <brandon.m.groth@gmail.com>
Signed-off-by: Brandon Groth <brandon.m.groth@gmail.com>
Signed-off-by: Brandon Groth <brandon.m.groth@gmail.com>
Signed-off-by: Brandon Groth <brandon.m.groth@gmail.com>
Signed-off-by: chichun-charlie-liu <57839396+chichun-charlie-liu@users.noreply.github.com>
Copy link
Copy Markdown
Collaborator

@tharapalanivel tharapalanivel left a comment

Choose a reason for hiding this comment

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

Did a quick review and looks like lint and some of the tests are failing sadly but great PR @chichun-charlie-liu and the docs particularly look great 😄 Thank you!

Comment thread pyproject.toml Outdated
Comment thread tests/models/conftest.py
Comment thread examples/MX/ffn_tmp.py Outdated
Comment thread examples/MX/ffn_tmp.py Outdated
Comment thread fms_mo/modules/linear.py Outdated
Comment thread fms_mo/utils/torchscript_utils.py Outdated
Comment thread fms_mo/utils/qconfig_utils.py
Comment thread examples/MX/ffn_tmp.py
Signed-off-by: cliu-us <cliu@us.ibm.com>
@chichun-charlie-liu chichun-charlie-liu marked this pull request as draft April 29, 2025 20:34
chichun-charlie-liu and others added 9 commits May 14, 2025 17:31
Signed-off-by: cliu-us <cliu@us.ibm.com>
Signed-off-by: cliu-us <cliu@us.ibm.com>
Signed-off-by: cliu-us <cliu@us.ibm.com>
…ings

Signed-off-by: Brandon Groth <brandon.m.groth@gmail.com>
Signed-off-by: Brandon Groth <brandon.m.groth@gmail.com>
Signed-off-by: Brandon Groth <brandon.m.groth@gmail.com>
Signed-off-by: Brandon Groth <brandon.m.groth@gmail.com>
Signed-off-by: Brandon Groth <brandon.m.groth@gmail.com>
fix: Setting mx_specs outside qconfig_init
Comment thread examples/MX/README.md Outdated
Signed-off-by: Brandon Groth <brandon.m.groth@gmail.com>
…bugs

Signed-off-by: cliu-us <cliu@us.ibm.com>
@chichun-charlie-liu chichun-charlie-liu marked this pull request as ready for review May 27, 2025 17:11
Signed-off-by: chichun-charlie-liu <57839396+chichun-charlie-liu@users.noreply.github.com>
Comment thread examples/MX/README.md
chichun-charlie-liu and others added 3 commits May 27, 2025 17:51
Signed-off-by: cliu-us <cliu@us.ibm.com>
Signed-off-by: Brandon Groth <brandon.m.groth@gmail.com>
Signed-off-by: Brandon Groth <brandon.m.groth@gmail.com>
Signed-off-by: Brandon Groth <brandon.m.groth@gmail.com>
Signed-off-by: cliu-us <cliu@us.ibm.com>
Comment thread .gitignore Outdated
@@ -46,3 +46,4 @@ data*_train/
data*_test/
act_scales/
examples/
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I'm not sure why we're ignoring examples dir since we actually have example docs there, can we get rid of it?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

adjusted, now we will ignore generated files such as .pt, .json, .safetensors, .arrow but allow others, such as .md and .py

Comment thread fms_mo/dq.py Outdated
Comment thread fms_mo/fx/dynamo_utils.py
if qcfg.get("QBmm"): # see Note 4
# Local
from fms_mo.modules import QBmm
QBmm = qcfg["mapping"]["matmul_or_bmm"]
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Should this be lower case variable name?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This is a class pointer disguised as a variable and used as QBmm(args) below. I think it is fine as is.

Comment thread fms_mo/fx/utils.py Outdated
Comment thread fms_mo/utils/qconfig_utils.py Outdated
Comment thread fms_mo/utils/qconfig_utils.py Outdated
Comment thread tests/models/conftest.py Outdated
BrandonGroth and others added 2 commits May 28, 2025 01:02
Signed-off-by: Brandon Groth <brandon.m.groth@gmail.com>
Signed-off-by: cliu-us <cliu@us.ibm.com>
@chichun-charlie-liu chichun-charlie-liu merged commit 05bb442 into foundation-model-stack:main May 28, 2025
12 checks passed
@chichun-charlie-liu chichun-charlie-liu deleted the mx_impl branch May 28, 2025 16:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add MX (microxcaling) support

3 participants