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

Moved tree_inference #465

Merged
merged 1 commit into from
Sep 5, 2023
Merged

Moved tree_inference #465

merged 1 commit into from
Sep 5, 2023

Conversation

patrick-kidger
Copy link
Owner

@patrick-kidger patrick-kidger commented Aug 31, 2023

Renamed eqx.tree_inference -> eqx.nn.inference_mode, as it's really an eqx.nn thing, not an eqx thing.


A copy of `pytree` with all `inference` flags set to `value`.
"""
return tree_at(_inferences, pytree, replace_fn=lambda _: value)
Copy link
Contributor

Choose a reason for hiding this comment

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

while you're in here, could I avail upon you to make this work with partitioned trees?

Suggested change
return tree_at(_inferences, pytree, replace_fn=lambda _: value)
return tree_at(_inferences, pytree, replace_fn=lambda _: value, is_leaf: lambda x: x is None)

The issue is something like:

lora_model, base_model = eqx.partition(model, is_lora_param)  # model has dropouts
lora_model = eqx.tree_inference(lora_model, False)

this currently blows up (assuming dropouts aren't lora_params). Imho tree_inference/inference_mode should be pretty "safe" at all times?

Copy link
Owner Author

Choose a reason for hiding this comment

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

Hmm. That seems dangerous, I think. If you then do eqx.combine(base_model, lora_model) -- note the order of arguments -- then the old inference value of base_model will take priority over the new inference value recorded in lora_model. You won't actually end up with an inference model.

Copy link
Contributor

Choose a reason for hiding this comment

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

fair enough!

@patrick-kidger patrick-kidger changed the title moved inference Moved tree_inference Sep 1, 2023
@patrick-kidger patrick-kidger changed the base branch from main to dev September 5, 2023 14:24
@patrick-kidger patrick-kidger merged commit 3bcc628 into dev Sep 5, 2023
@patrick-kidger patrick-kidger deleted the moved-inference branch September 5, 2023 14:32
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