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

[sharktank] Add common model config, export and compile #1013

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

sogartar
Copy link
Contributor

@sogartar sogartar commented Feb 27, 2025

We don't have a standard way to configure, export and compile sharktank models.

Here is introduced such mechanism and for demonstration the CLIP text model is refactored to utilize this new approach.

config.json:

{
    "model_type": "my_package.MyModel",
    "mlir_path": "model.mlir",
    "parameters_path": "model.irpa",
    "iree_module_path": "model.vmfb",
    "compile_args": ["--iree-hal-target-device=local"],
    "export_functions": [
        {
            "function": "forward",
            "batch_sizes": [1, 2, 3]
        }
    ]
    "my_model_arg": 5,
}

usage

model = create_model("config.json")
model.export()
model.compile()

@sogartar sogartar force-pushed the model-config branch 2 times, most recently from 5f8d32b to f2850be Compare February 27, 2025 22:51
We don't have a standard way to configure, export and compile sharktank
models.

Here is introduced such mechanism and for demonstration the CLIP text
model is refactored to utilize this new approach.

`config.json`:
```
{
    "model_type": "MyModel",
    "mlir_path": "model.mlir",
    "parameters_path": "model.irpa",
    "iree_module_path": "model.vmfb",
    "compile_args": ["--iree-hal-target-device=local"],
    "export_functions": [
        {
            "function": "forward",
            "batch_sizes": [1, 2, 3]
        }
    ]
}
```

usage
```
model = create_model("config.json")
model.export()
model.compile()
```
@sogartar sogartar marked this pull request as ready for review February 27, 2025 23:31
Copy link
Member

Choose a reason for hiding this comment

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

I'll need to set up some time aside to review this in detail. Can you tag related issues on this PR and connect this back to the overall goals? Bonus points if you could also comment on the issues and help coordinate their full resolution. Cross-cutting work like this goes more smoothly if the plans are communicated ahead of time, before jumping straight to code.

These issues appear related:

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes the are related issues.

@sogartar
Copy link
Contributor Author

sogartar commented Feb 28, 2025

This PR requires some modification to make it more interoperable with IREE build pipeline tooling.

@sogartar sogartar marked this pull request as draft February 28, 2025 18:01
@sogartar sogartar marked this pull request as ready for review March 3, 2025 16:40
@sogartar
Copy link
Contributor Author

sogartar commented Mar 3, 2025

I added an export function to be used in an IREE build pipeline.

@renxida
Copy link
Contributor

renxida commented Mar 5, 2025

I have some py functions / classes for managing LLMs in app_tests/integration_tests/llm/model_management.py.

I like the class / function structure currently in there, but they use a very hacky bash-script-in-python-script kind of solution to call into sharktank and IREE to shard / export / compile models.

Would be very cool if I could switch to using this instead.

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.

3 participants