Skip to content
This repository was archived by the owner on Sep 9, 2025. It is now read-only.

ilab model engine proposal - #48

Merged
russellb merged 1 commit into
instructlab:mainfrom
cdoern:ilab-model-engine
May 23, 2024
Merged

ilab model engine proposal#48
russellb merged 1 commit into
instructlab:mainfrom
cdoern:ilab-model-engine

Conversation

@cdoern

@cdoern cdoern commented May 14, 2024

Copy link
Copy Markdown
Contributor

This enhancement introduces a new design for ilab. Primarily adding sub-parent commands, new modes of interactions with ilab, and clarity on what the source + sink of data are in this system we are building.

@cdoern
cdoern force-pushed the ilab-model-engine branch from 9496732 to 450d2df Compare May 14, 2024 19:52

@hickeyma hickeyma left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks @cdoern for pushing this design and for you perseverance in multiple redesigns. I like this overall and the direction your are proposing.

Some small nits and feedback to address.

Comment thread docs/ilab-model-engine.md Outdated
Comment thread docs/ilab-model-engine.md Outdated
Comment thread docs/ilab-model-engine.md Outdated
Comment thread docs/ilab-model-engine.md Outdated
Comment thread docs/ilab-model-engine.md Outdated
Comment thread docs/ilab-model-engine.md Outdated
Comment thread docs/ilab-model-engine.md Outdated
Comment thread docs/ilab-model-engine.md Outdated
Comment thread docs/ilab-model-engine.md Outdated
Comment thread docs/ilab-model-engine.md Outdated
@nathan-weinberg

Copy link
Copy Markdown
Contributor

@cdoern can you fix the Markdown Lint/Spellcheck errors?

@cdoern

cdoern commented May 17, 2024

Copy link
Copy Markdown
Contributor Author

@nathan-weinberg should be set

@cdoern
cdoern force-pushed the ilab-model-engine branch from 497c564 to e52c301 Compare May 17, 2024 14:38
@cdoern
cdoern requested a review from hickeyma May 17, 2024 14:39

@nathan-weinberg nathan-weinberg left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@cdoern Overall this proposal is very strong and I wholeheartedly agree with the approach - I have some minor requested changes but once they are addressed I will happily add my approval to the pile

Comment thread docs/ilab-model-engine.md Outdated
Comment thread docs/ilab-model-engine.md Outdated
| |____convert
| |____download
| |____train (--convert)
| |____serve (-i)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
| |____serve (-i)
| |____serve (-i)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Also, what is -i for @cdoern? Assume it's shorthand for interact or something of the like based on context clues elsewhere in the document (if I'm missing somewhere it's explicitly defined lmk)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I assume it implies a new default of ilab serve launching model serving in the background, while -i or --interactive would keep it in the foreground?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

yep, I think I specify it implicitly below but will add a note.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@cdoern spacing here still needs to be fixed

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

could just say [flags] for these

Comment thread docs/ilab-model-engine.md Outdated
Comment thread docs/ilab-model-engine.md Outdated
Comment thread docs/ilab-model-engine.md Outdated
Comment thread docs/ilab-model-engine.md Outdated

The primary focus here should be the `ilab model` group. The other ones should not be treated as blockers for launch, but would be nice to have.

Another key change that should be included is a switch to using `/var/lib/models` as a model store and `$HOME/.config/models/ilab.conf` for the new configuration path. Keeping config and models in the CWD does not map well to the importance of these two pieces. This will allow `ilab config` commands to act on a global level per-user. Models will be a system-wide directory as they are with most other applications of this type.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Agree with Charlie - I think we can start with a global config, but we can always enhance later for users to have options to create separate "projects" (there's some existing work for something like that here instructlab/instructlab#1022)

Comment thread docs/ilab-model-engine.md Outdated
Comment thread docs/ilab-model-engine.md Outdated
Comment thread docs/ilab-model-engine.md Outdated
Comment thread docs/ilab-model-engine.md

## Changes to Existing flow

The current `ilab` commands will still work. Users will be able to type commands like `ilab model train` or `ilab train` for the foreseeable future to ensure feature parity. Eventually, this alias should be removed, and only the sub-commands should probably exist.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

We should target an explicit release to do so (outside of this general proposal, in our usual planning meetings/channels)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

we'll have to revisit having 2 ways of doing everything for sure. I guess it is comforting to suggest we a dual path for transition.

@russellb
russellb self-requested a review May 17, 2024 16:28

@russellb russellb left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

posting a few comments before a meeting starts, though I'm not actually finished with reviewing it

Comment thread docs/ilab-model-engine.md Outdated
Comment thread docs/ilab-model-engine.md Outdated
| |____convert
| |____download
| |____train (--convert)
| |____serve (-i)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I assume it implies a new default of ilab serve launching model serving in the background, while -i or --interactive would keep it in the foreground?

Comment thread docs/ilab-model-engine.md Outdated
Comment thread docs/ilab-model-engine.md Outdated
The main point of this structure is to introduce a group hierarchy and to improve the usability of the existing `ilab` structure. Some key things missing in `ilab` currently are:

1. `ilab init` does too many things.
- We don't want "black box" commands. This creates bad UX and also ties too many processes together in which one might eventually need to be changed.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

It's not clear that the proposal changes this at all. ilab init is just ilab config init. It seems like a distraction.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Good point, this was an old reasoning anyway, will remove

Comment thread docs/ilab-model-engine.md Outdated
Comment thread docs/ilab-model-engine.md Outdated
Comment thread docs/ilab-model-engine.md Outdated
Comment thread docs/ilab-model-engine.md Outdated
Comment thread docs/ilab-model-engine.md Outdated
Comment thread docs/ilab-model-engine.md Outdated

The primary focus here should be the `ilab model` group. The other ones should not be treated as blockers for launch, but would be nice to have.

Another key change that should be included is a switch to using `/var/lib/models` as a model store and `$HOME/.config/models/ilab.conf` for the new configuration path. Keeping config and models in the CWD does not map well to the importance of these two pieces. This will allow `ilab config` commands to act on a global level per-user. Models will be a system-wide directory as they are with most other applications of this type.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I would prefer to remove this from this proposal. Changing the CLI command structure is not dependent on making this configuration management change.

Comment thread docs/ilab-model-engine.md Outdated
Comment thread docs/ilab-model-engine.md Outdated
Comment thread docs/ilab-model-engine.md Outdated
Comment thread docs/ilab-model-engine.md
vs. after:

```console
ilab

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

I would say we should have those on an API resource level with OpenAPI and then have swagger to generate the CLI according. Otherwise, it would be very hard to make it api driven in the future,

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

I'm also concerned we will want to restructure the CLI again once we have an API spec

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Maybe, but the API definition isn't going to happen quickly. This moves us much closer to what a resource-aligned command structure would look like that's more aligned with an API. I think it's a good move in the near term without APIs defined.

@n1hility

Copy link
Copy Markdown
Contributor

Overall I think this is a good proposal. It offers a good UX with lots of future expansion potential

@cdoern

cdoern commented May 22, 2024

Copy link
Copy Markdown
Contributor Author

@russellb (GH wont let me quote reply)

I would prefer to remove this from this proposal. Changing the CLI command structure is not dependent on making this configuration management change.

I think this EP is meant to cover the cmd redesign sure but also the way ilab is thought about and generally used. That is why initially had the title as "model engine". Sure, we are redesigning the cmds, but we are also redesigning how we think about using ilab, its scope, etc.

A lot of your comments seem to be removing some parts of that (the future structure, the ilab init stuff, etc). I think this is something I'd really like to leave, as well as the original title, and the future structure to be discussed in another EP as all of these things fit more with the mental model I was hoping to get across with this EP.

Pushing up a new set of changes but hoping to roll back some of them if possible! lmk what you think.

@cdoern
cdoern force-pushed the ilab-model-engine branch 2 times, most recently from 45af8e7 to cd101e4 Compare May 22, 2024 15:21

@nathan-weinberg nathan-weinberg left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I have a few outstanding comments but I agree with this document as a whole and personally am ready for us to move forward with implementation, so approving from my side

Comment thread docs/ilab-model-engine.md Outdated
| |____download
```

Note: -i will serve and start a chat process as opposed to the current flow which implicitly starts servers in certain commands

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
Note: -i will serve and start a chat process as opposed to the current flow which implicitly starts servers in certain commands
Note: `-i` will serve and start a chat process as opposed to the current flow which implicitly starts servers in certain commands

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

It's just a "Note:" which is fine but general thinking is that this -i feature for "serve" is a separate enhancement. Wouldn't want to pile on every to-do in this redesign.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Agree that this is a separate feature

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

sure, I can remove this

@markstur markstur left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

I went through and commented again on some of things that don't really jive with my way of thinking, but these are mostly just comments and not change requests. I know we are near the end of this. :)

But it is easier to comment critiques than bother noting the parts I agree with. To be clear... the argument might not be immediately compelling to me, but I do think we will benefit from the sub-command design eventually. So it's probably better to do it soon instead of using a bunch of flags (generate --data?) or commands like generate-data as work-arounds for subcommands. <-- that was me attempting to agree with you. :)

Comment thread docs/ilab-model-engine.md Outdated
| |____convert
| |____download
| |____train (--convert)
| |____serve (-i)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

could just say [flags] for these

Comment thread docs/ilab-model-engine.md Outdated
| |____download
```

Note: -i will serve and start a chat process as opposed to the current flow which implicitly starts servers in certain commands

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

It's just a "Note:" which is fine but general thinking is that this -i feature for "serve" is a separate enhancement. Wouldn't want to pile on every to-do in this redesign.

Comment thread docs/ilab-model-engine.md Outdated

The primary focus here should be the `ilab model` group. The other ones should not be treated as blockers for launch, but would be nice to have.

Another key change that should be included is a switch to using `/var/lib/models` as a model store and `$HOME/.config/models/ilab.conf` for the new configuration path. Keeping config and models in the CWD does not map well to the importance of these two pieces. This will allow `ilab config` commands to act on a global level per-user. Models will be a system-wide directory as they are with most other applications of this type.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

worth noting that our "models" dir can (and should) just be links to the HF cache when applicable.

Comment thread docs/ilab-model-engine.md Outdated

The primary focus here should be the `ilab model` group. The other ones should not be treated as blockers for launch, but would be nice to have.

Another key change that should be included is a switch to using `/var/lib/models` as a model store and `$HOME/.config/models/ilab.conf` for the new configuration path. Keeping config and models in the CWD does not map well to the importance of these two pieces. This will allow `ilab config` commands to act on a global level per-user. Models will be a system-wide directory as they are with most other applications of this type.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

re: global conf/models vs local dir -- I think ability to have a per-project conf and models is required and the ability to fallback to global is nice. So what that means is... we can add a global conf (default global models) but we have to have flags/config-settings to allow running independent projects in dirs. I suppose a config could have internal project sections, but I'm thinking more likely the local one is used first if it exists and the global is a fallback. Pretty common behavior.

Comment thread docs/ilab-model-engine.md

### Necessity of a input -> configuration -> result mental model

The commands uncovered by adding this structure resemble the typical architecture for an "engine". `ilab` is not complete without the mechanisms to create, list, delete, and inspect the models. Models, as container images do in container engines, act as the configuration for the end result: the chat process. The interesting thing about this analogy, is that there needs to be a pre-cursor to configuration as well. There is the container image, the container, and the `Containerfile`. The `Containerfile` is the raw user input that leads to an image.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

I still think references to "Containerfile" here are distracting and irrelevant to the discussion. Well-written, but less is more. Too late to re-suggest massive edits here though.

Comment thread docs/ilab-model-engine.md
3. `ilab data generate`
4. `ilab model train --convert`
5. `ilab model serve -i` (or followed by `ilab model chat`)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

So if I apply the enhancements like -i and ensure a server for generate (and chaining) it would be:
ilab init download generate train --convert serve -i. (maybe -i should be --chat)

So, removal of steps is separate from the redesign. I guess the argument here is that adding more words to the commands adds clarity. Not sure that's really good thing but...

I do, however, agree with the sub-module cli design so we're good.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think the -i bits have all been stripped from the enhancement

Comment thread docs/ilab-model-engine.md

## Changes to Existing flow

The current `ilab` commands will still work. Users will be able to type commands like `ilab model train` or `ilab train` for the foreseeable future to ensure feature parity. Eventually, this alias should be removed, and only the sub-commands should probably exist.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

we'll have to revisit having 2 ways of doing everything for sure. I guess it is comforting to suggest we a dual path for transition.

Comment thread docs/ilab-model-engine.md

### click

click doesn't like the setup we currently have in `ilab`. So, adding sub-parent commands won't be as easy as creating a new `click.group`. We will need to make different libraries, each of which is a click group most likely.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

If click is bad at this, is argparse better?

Also the "different libraries" comment is not clear to me and makes me concerned about how restructuring for click might be different than restructuring for future API or for general good structure.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I think switching from click to argparse is a different convo, but one I want to have!!!1

In my draft PR I have gotten click to work with this structure, though the docs weren't super helpful lol

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@cdoern I second that using groups might not be straightforward and the current lab.py might require a bit of remodeling but I think the statement "adding sub-parent commands won't be as easy as creating a new click.group" is a bit misleading. Implementing something like ilab foo bar --baz is possible :). I'm not sure why we need to make different libraries. Thanks!

@russellb russellb left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

My biggest remaining concern is about dropping the discussion of the data and config store.

I would include the -i feature in a similar category of a new feature that seems separate from this. I would prefer removing that, too.

The other comments are just trivial things I saw while reading through again.

Comment thread .spellcheck-en-custom.txt Outdated
docstring
podman
CLI
CLI's

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This isn't something to block on, but if you have to update the PR anyway, it'd be good to run make spellcheck-sort.

Comment thread docs/ilab-model-engine.md Outdated
Comment thread docs/ilab-model-engine.md Outdated
Comment thread docs/ilab-model-engine.md Outdated
| |____download
```

Note: -i will serve and start a chat process as opposed to the current flow which implicitly starts servers in certain commands

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Agree that this is a separate feature

Comment thread docs/ilab-model-engine.md Outdated
@cdoern
cdoern force-pushed the ilab-model-engine branch 2 times, most recently from a500ca9 to 2f6b888 Compare May 23, 2024 13:49
@cdoern

cdoern commented May 23, 2024

Copy link
Copy Markdown
Contributor Author

Ok, I removed the new flags I want to add and the bits about the global model store/config.

cc @russellb @n1hility @markstur PTAL 🙏

@cdoern
cdoern requested a review from russellb May 23, 2024 13:54
@cdoern
cdoern force-pushed the ilab-model-engine branch from 2f6b888 to 2475dad Compare May 23, 2024 15:13
This enhancement introduced a new design for `ilab`. Primarily adding sub-parent commands, new modes of interactions with `ilab`, and clarity on what the source + sink of data are in this system we are building

Signed-off-by: Charlie Doern <cdoern@redhat.com>
@cdoern
cdoern force-pushed the ilab-model-engine branch from 2475dad to 9d720b7 Compare May 23, 2024 15:17

@russellb russellb left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

lgtm, thank you @cdoern !

Comment thread docs/ilab-model-engine.md
vs. after:

```console
ilab

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Maybe, but the API definition isn't going to happen quickly. This moves us much closer to what a resource-aligned command structure would look like that's more aligned with an API. I think it's a good move in the near term without APIs defined.

Comment thread docs/ilab-model-engine.md
3. `ilab data generate`
4. `ilab model train --convert`
5. `ilab model serve -i` (or followed by `ilab model chat`)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think the -i bits have all been stripped from the enhancement

@russellb
russellb merged commit 4e230b4 into instructlab:main May 23, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

9 participants