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

Add FuseMLP to NPU Llama #11565

Closed
wants to merge 4 commits into from
Closed

Conversation

hkvision
Copy link
Contributor

No description provided.

@@ -0,0 +1,163 @@
from intel_npu_acceleration_library.backend.factory import NNFactory
Copy link
Contributor

Choose a reason for hiding this comment

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

change to lowbitmlp.py

Copy link
Contributor Author

Choose a reason for hiding this comment

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

sure.

import uuid


class QuantizedMLP(NNFactory):
Copy link
Contributor

Choose a reason for hiding this comment

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

change to LowBitMLP


# TODO: separate it into a single file
@torch.no_grad()
def run_factory(
Copy link
Contributor

Choose a reason for hiding this comment

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

change to run_model

backend_cls: Any,
op_id: Optional[str] = None,
) -> torch.Tensor:
"""Run a factory operation. Depending on the datatype of the weights it runs a float or quantized operation.
Copy link
Contributor

Choose a reason for hiding this comment

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

Run an NPU model


input_shapes = [elem.shape for elem in x_np]
if models is None:
_model_cache[key] = deque([backend_cls(*input_shapes) for i in range(4)])
Copy link
Contributor

Choose a reason for hiding this comment

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

make 4 configurable

@hkvision hkvision marked this pull request as ready for review July 12, 2024 11:06
@hkvision
Copy link
Contributor Author

Currently bias is not considered.
In the sample implementation, bias is not included in the op, just directly added to the output when the op finishes. For the fused mlp, may need to add bias into the overall graph as well.

@hkvision hkvision closed this Nov 4, 2024
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.

2 participants