Skip to content

Add Registration for Custom Cost Models #25

@saulshanabrook

Description

@saulshanabrook

I am working on adding support to the Python bindings for custom cost models, so that you could define them in pure Python.

I was wondering if it might be appropriate to provide a way to register custom cost models with an EGraph and then be able to use them with the builtin extract command.

Currently, the set_cost cost model in the experimental repo has to define a new extract command that effectively duplicates the existing one but changes the cost model provided. It doesn't currently support the extract report as well.

So if I wanted to allow others in Python to define custom cost models, I would have to support exposing the Extractor object directly, creating a larger API surface area than might be neccessary.

Instead, what if we:

  1. (egglog core): Allowed user to register custom cost models on an egraph from Rust, attaching a name to them.
  2. (egglog core): Allow you to change the "default" cost model used in the EGraph.
  3. (egglog core): Change the extract command to use the default cost model, unless the name of another cost model is specified.
  4. (egglog experimental): Remove the additional extract command and replace it with registering the SetCost cost model and setting it as default

This would work similarly to how custom schedulers are supported, registering them from rust then referencing them in the egglog program.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions