Skip to content

Conversation

@AndreyPavlenko
Copy link
Contributor

@AndreyPavlenko AndreyPavlenko commented Oct 16, 2025

The purpose of this refactoring is to simplify development for new architectures by subclassing the base class instead of adding conditional code blocks.

The main changes:

  • Allow metaclasses injection: use XPUBackendMeta from the .meta submodule as the metaclass, if it exists.
  • Try to find an arch-specific implementation in the .arch.<name> submodule.

@etiotto etiotto changed the title XPUBackend refactoring to facilitate arch-specific implementations [NFI]: XPUBackend refactoring to facilitate arch-specific implementations Oct 16, 2025
Copy link
Contributor

@etiotto etiotto left a comment

Choose a reason for hiding this comment

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

Wondering whether we should use easier to understand alternative. Have you considered:

  1. Inheritance: create a base class that can be derived (my preference)
  2. class Decorators to modify the behavior of the BE after creation

@AndreyPavlenko
Copy link
Contributor Author

  1. Inheritance: create a base class that can be derived (my preference)

XPUBackend is the base class. Arch-specific implementations derive from it and override the required methods. For example, they could override get_llir_passes() and add/remove passes.

  1. class Decorators to modify the behavior of the BE after creation

It could be done, by defining a metaclass, but the inheritance should be used in most use-cases.

@AndreyPavlenko AndreyPavlenko force-pushed the AndreyPavlenko/backend-refactor branch from 2c0c89d to 055acd2 Compare October 21, 2025 08:50
@AndreyPavlenko AndreyPavlenko force-pushed the AndreyPavlenko/backend-refactor branch from 055acd2 to abbf291 Compare October 28, 2025 13:00
@AndreyPavlenko AndreyPavlenko force-pushed the AndreyPavlenko/backend-refactor branch from abbf291 to 82ab83b Compare October 29, 2025 11:25
@whitneywhtsang
Copy link
Contributor

@AndreyPavlenko please resolve the merge conflicts, and merge it tomorrow as there are no more review comments.

@AndreyPavlenko AndreyPavlenko force-pushed the AndreyPavlenko/backend-refactor branch 3 times, most recently from d3ce2a9 to b0263fb Compare November 11, 2025 17:37
@AndreyPavlenko
Copy link
Contributor Author

Seems there is some issue with CI. I see the same errors on the main branch:
RuntimeError: 0 active drivers ([]). There should only be one.

@whitneywhtsang
Copy link
Contributor

Seems there is some issue with CI. I see the same errors on the main branch: RuntimeError: 0 active drivers ([]). There should only be one.

Should be fixed now.

@AndreyPavlenko AndreyPavlenko force-pushed the AndreyPavlenko/backend-refactor branch from b0263fb to 2dec49c Compare November 11, 2025 19:01
@AndreyPavlenko
Copy link
Contributor Author

The SPIRVRunner test is also failing.

@kwasd
Copy link
Contributor

kwasd commented Nov 11, 2025

Should be fixed after either merging #5459 or fixing #5458

@kwasd
Copy link
Contributor

kwasd commented Nov 11, 2025

As #5459 is approved, you could now git cherry-pick 95dcbd5f567be0f1f7d502dc75007ccea1d8b406 to save time before #5459's checks are completed

@AndreyPavlenko AndreyPavlenko force-pushed the AndreyPavlenko/backend-refactor branch from 2dec49c to a37ad7e Compare November 11, 2025 22:01
 - Allow metaclasses injection: use XPUBackendMeta from the .meta submodule as the metaclass, if it exists.
 - Try to find an arch-specific implementation in the .arch.<name> submodule.
 - Create the list of passes in separate methods to allow subclasses to modify it.
@AndreyPavlenko AndreyPavlenko force-pushed the AndreyPavlenko/backend-refactor branch from a37ad7e to cade688 Compare November 13, 2025 07:51
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.

5 participants