-
Notifications
You must be signed in to change notification settings - Fork 350
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
support a compiled chain.model for improved performance #113
Conversation
31e4f20
to
dc902ce
Compare
Note, this is basically similar to #102, but does it via a separate class. |
An advantage of doing this via a separate class is that one can do: model = CompiledText(model) and so the original model can be garbage-collected to prevent redundant non-memoized structures from occupying a large amount of mem |
Thank you, @erikerlandson! This sounds both interesting and likely worth merging. I'll aim to take a closer look soon. In the meantime, would you be willing to add a short description to the notes section here, right after the bullet point that begins "If you have accidentally read [...]"? |
@jsvine it is done 👍 |
@jsvine have you had a chance to look at this? |
HI @erikerlandson, and thank you for the reminder! Now that I've had the chance to look at the code, I have a question about the implementation: Why not make |
@jsvine, sorry I didn't see your comment 😦 My original reasoning about not making it a subclass is that not all If we can design it so that a sufficient number of methods are directly inherited, and the overloadings that need to be maintained are relatively stable, then I think it would be a good idea. |
@jsvine another possible strategy would be to define something like a |
Thanks for the response, @erikerlandson! My thoughts below.
Fantastic! I think you're right that some of the traditional
Interesting! In the abstract, I can see how that might be useful. If you want to propose a rough (non-code) outline for how |
@jsvine, it occurs to me that what is really being "compiled" is just the something like Doing it this way should also handle |
In fact, it's just the |
That sounds like a smart, promising approach! |
I'll try to get to it soon, it's been a hectic couple of weeks :D |
0155f23
to
32960f5
Compare
@jsvine what do you think of this? |
Thanks, @erikerlandson! I'm impressed by how concise you were able to make the changes. I'll need a bit more time to think through this and review it more carefully, but on first glance it looks promising. One question that initially comes to mind: Is it a better experience for users to have |
@jsvine, I have no problem making it return a copy. I could support an |
@jsvine here's a tweak that makes non-destructive compile the default |
Many thanks @erikerlandson! These changes look great. Merged, and now available in |
This PR proposes to add a new compiled format for
chain.model
that pre-caches all the state transitions, as opposed to caching only the "begin".I've been seeing generation 50 to 100x faster. Generation throughput increase depends on model size.