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

Weight Stripping #3207

Open
hgaspar opened this issue Jun 21, 2024 · 7 comments · May be fixed by #3416
Open

Weight Stripping #3207

hgaspar opened this issue Jun 21, 2024 · 7 comments · May be fixed by #3416
Assignees
Labels
enhancement New feature or request

Comments

@hgaspar
Copy link

hgaspar commented Jun 21, 2024

Enable creating engines (currently, MXR files, eventually perhaps dynamic objects) without embedding the weights in the engine.

Use cases:
(1) Support compilation for various batch sizes without duplicating the weights.
(2) Support multiple execution configurations with different quantization options (including mixed precision), without necessarily having to embed the weights in all the created engines.
(3) multi-GPU execution may benefit from this also, especially when it comes to creating multiple multiGPU execution configurations (partitions, execution schedules)

Technical considerations:
How do we treat literals?
Perhaps we need to have the MXR files contain the steps required to recreate the literals from the weights' file, and that may require a new type ( finalized lliterals vs future literal or meta-literal) 

@hgaspar hgaspar added the enhancement New feature or request label Jun 21, 2024
@eddieliao eddieliao self-assigned this Jul 10, 2024
@eddieliao
Copy link
Contributor

Looking to work on this as an extension of weight streaming; do we have a specific format already for a weights file or is that something that needs to be decided?

@eddieliao
Copy link
Contributor

eddieliao commented Jul 31, 2024

List of items for basic proof of concept:

  • Remove weights from .mxr files
  • Save weights to separate file(s)
  • Load in weights during runtime

@eddieliao
Copy link
Contributor

Replaced current literals with a fetch_literals dummy instruction that contains no data. Greatly reduces .mxr size, although still need to investigate why read of the model fails.

@eddieliao
Copy link
Contributor

Added the ability to write and save weights in the strip_weights pass. Need to figure out how to pass output location to the pass (remove hard-coded location).

@simberg-amd simberg-amd self-assigned this Aug 23, 2024
@simberg-amd
Copy link

simberg-amd commented Aug 23, 2024

Fixed issue with writing weights and added test that successfully reads weights from file and adds weight back to MXR file

@simberg-amd
Copy link

  • Might look into taking the extra pass out of target.cpp and moving things into write_literals. This way instead of adding the literal first and then removing it, just add the dummy instruction in there and save the weights to the file if want to strip_weights. This would make it so no time is added during compilation and don't have to do MIGRAPHX_COPY_LITERALS{}

  • Also could put in a check to see if weight file is already available for model compiling, and then don't write weights again for new compiled MXR file.

@simberg-amd
Copy link

Finished above, going to look into different quantization options.

@simberg-amd simberg-amd linked a pull request Sep 4, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants