Skip to content

[Refactor][Meta-schedule] Remove meta-schedule as_string mechanism in favor of default representation#19709

Merged
tlopex merged 1 commit into
apache:mainfrom
tlopex:fix-s-tir-meta-schedule-derived-object-str
Jun 10, 2026
Merged

[Refactor][Meta-schedule] Remove meta-schedule as_string mechanism in favor of default representation#19709
tlopex merged 1 commit into
apache:mainfrom
tlopex:fix-s-tir-meta-schedule-derived-object-str

Conversation

@tlopex

@tlopex tlopex commented Jun 9, 2026

Copy link
Copy Markdown
Member

Python-side meta-schedule classes (PyCostModel, PyFeatureExtractor, PyMeasureCallback, PyScheduleRule, PyMutator, PyPostproc) carried an f_as_string callback whose only purpose was to produce a repr-style string (s_tir.meta_schedule.<SubclassName>(0x...)) for str(...).

This mechanism stopped working after #19461 migrated ReprPrinter to the tvm-ffi __ffi_repr__ mechanism and intentionally removed the per-type set_dispatch<Py*Node> hooks that called back into f_as_string, which broke three *_as_string tests:

  • test_meta_schedule_cost_model.py::test_meta_schedule_cost_model_as_string
  • test_meta_schedule_feature_extractor.py::test_meta_schedule_feature_extractor_as_string
  • test_meta_schedule_measure_callback.py::test_meta_schedule_measure_callback_as_string

Rather than restoring the old behavior, this PR removes the mechanism entirely: the string it produced is just a repr, and tvm-ffi reflection already provides an auto-generated default repr for every object. Keeping a dedicated Python → FFI → C++ callback chain alive only to reproduce that is not worth the complexity.

@tlopex tlopex force-pushed the fix-s-tir-meta-schedule-derived-object-str branch from fe04ec3 to bcf403c Compare June 9, 2026 23:50

@gemini-code-assist gemini-code-assist Bot 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.

Code Review

This pull request removes the AsString and __str__ methods across several Meta Schedule components (such as CostModel, FeatureExtractor, MeasureCallback, Mutator, Postproc, and ScheduleRule) in both C++ and Python, along with their associated tests and utility functions. The review feedback points out a copy-paste typo in the docstring of CostModel::PyCostModel that incorrectly refers to a "feature extractor" instead of a "cost model".

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

* \param f_predict The packed function of `Predict`.
* \param f_as_string The packed function of `AsString`.
* \return The feature extractor created.
* \return The cost model created.

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.

medium

There is a copy-paste typo in the docstring for CostModel::PyCostModel. It refers to a "feature extractor" instead of a "cost model". Please update it to refer to "cost model". Note that the first line of this docstring (which is outside the diff hunk) also contains "Create a feature extractor..." and should be updated to "Create a cost model..." as well.

   * \return The cost model created.

@tlopex tlopex changed the title [Refactor] Remove meta-schedule as_string mechanism in favor of default repr [Refactor][Meta-schedule] Remove meta-schedule as_string mechanism in favor of default representation Jun 10, 2026
@tlopex tlopex merged commit 219f1d8 into apache:main Jun 10, 2026
11 checks passed
MasterJH5574 pushed a commit to MasterJH5574/tvm that referenced this pull request Jun 15, 2026
… favor of default representation (apache#19709)

Python-side meta-schedule classes (`PyCostModel`, `PyFeatureExtractor`,
`PyMeasureCallback`, `PyScheduleRule`, `PyMutator`, `PyPostproc`)
carried an `f_as_string` callback whose only purpose was to produce a
repr-style string (`s_tir.meta_schedule.<SubclassName>(0x...)`) for
`str(...)`.

This mechanism stopped working after apache#19461 migrated `ReprPrinter` to
the tvm-ffi `__ffi_repr__` mechanism and intentionally removed the
per-type `set_dispatch<Py*Node>` hooks that called back into
`f_as_string`, which broke three `*_as_string` tests:
-
`test_meta_schedule_cost_model.py::test_meta_schedule_cost_model_as_string`
-
`test_meta_schedule_feature_extractor.py::test_meta_schedule_feature_extractor_as_string`
-
`test_meta_schedule_measure_callback.py::test_meta_schedule_measure_callback_as_string`

Rather than restoring the old behavior, this PR removes the mechanism
entirely: the string it produced is just a repr, and tvm-ffi reflection
already provides an auto-generated default repr for every object.
Keeping a dedicated Python → FFI → C++ callback chain alive only to
reproduce that is not worth the complexity.

(cherry picked from commit 219f1d8)
MasterJH5574 pushed a commit to MasterJH5574/tvm that referenced this pull request Jun 15, 2026
… favor of default representation (apache#19709)

Python-side meta-schedule classes (`PyCostModel`, `PyFeatureExtractor`,
`PyMeasureCallback`, `PyScheduleRule`, `PyMutator`, `PyPostproc`)
carried an `f_as_string` callback whose only purpose was to produce a
repr-style string (`s_tir.meta_schedule.<SubclassName>(0x...)`) for
`str(...)`.

This mechanism stopped working after apache#19461 migrated `ReprPrinter` to
the tvm-ffi `__ffi_repr__` mechanism and intentionally removed the
per-type `set_dispatch<Py*Node>` hooks that called back into
`f_as_string`, which broke three `*_as_string` tests:
-
`test_meta_schedule_cost_model.py::test_meta_schedule_cost_model_as_string`
-
`test_meta_schedule_feature_extractor.py::test_meta_schedule_feature_extractor_as_string`
-
`test_meta_schedule_measure_callback.py::test_meta_schedule_measure_callback_as_string`

Rather than restoring the old behavior, this PR removes the mechanism
entirely: the string it produced is just a repr, and tvm-ffi reflection
already provides an auto-generated default repr for every object.
Keeping a dedicated Python → FFI → C++ callback chain alive only to
reproduce that is not worth the complexity.

(cherry picked from commit 219f1d8)
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