Skip to content

[Spyre-Next] [Cleanup] Rework of CustomOp wrapping#842

Merged
bohnstingl merged 12 commits intotorch-spyre:mainfrom
bohnstingl:wrapper_rework
Mar 19, 2026
Merged

[Spyre-Next] [Cleanup] Rework of CustomOp wrapping#842
bohnstingl merged 12 commits intotorch-spyre:mainfrom
bohnstingl:wrapper_rework

Conversation

@bohnstingl
Copy link
Copy Markdown
Collaborator

Description

This PR intends to simplify the way CustomOps are currently wrapped for execution on spyre. In addition to a simplification, this rework enables more features from upstream vLLM, for example the compilation interface. This will eventually be needed when larger parts of the model is executed on spyre.

Related Issues

#733

Test Plan

This change should be transparent to users and thus the already existing/running tests should not change.

Checklist

  • I have read the contributing guidelines
  • My code follows the project's code style (run bash format.sh)
  • I have added tests for my changes (if applicable)
  • I have updated the documentation (if applicable)
  • My commits include a Signed-off-by: line (DCO compliance)

Signed-off-by: Thomas Ortner <boh@zurich.ibm.com>
Signed-off-by: Thomas Ortner <boh@zurich.ibm.com>
Signed-off-by: Thomas Ortner <boh@zurich.ibm.com>
Signed-off-by: Thomas Ortner <boh@zurich.ibm.com>
Signed-off-by: Thomas Ortner <boh@zurich.ibm.com>
@github-actions
Copy link
Copy Markdown

👋 Hi! Thank you for contributing to vLLM support on Spyre.
Just a reminder: Make sure that your code passes all the linting checks, otherwise your PR won't be able to be merged. To do so, run ./format.sh.
Now you are good to go 🚀.

We also recommend installing prek and configuring it to check your code before every local commit.

@github-actions github-actions Bot changed the title [Cleanup] Rework of CustomOp wrapping [Spyre-Next] [Cleanup] Rework of CustomOp wrapping Mar 17, 2026
@joerunde
Copy link
Copy Markdown
Collaborator

bot:next-test

return prefix


def create_rmsnorm_op_pair():
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

what's the rationale for moving op-specific methods to a generic utilities package? I would expect this to continue living in rms_norm.py as e.g. rms_norm.create_op_pair()

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Yeah, I was debating about this myself. The issue here is that although the two functions are really close, upstream vLLM runs the infer_schema function, which requires explicit knowledge about the inputs and those inputs are specific for the CustomOp at hand. I left the _fake_impl function in utils.py, but the op specific function I moved back to the individual files.

@joerunde
Copy link
Copy Markdown
Collaborator

^^ looks like tests are failing, mind taking a look into it?

Signed-off-by: Thomas Ortner <boh@zurich.ibm.com>
Signed-off-by: Thomas Ortner <boh@zurich.ibm.com>
Signed-off-by: Thomas Ortner <boh@zurich.ibm.com>
@bohnstingl
Copy link
Copy Markdown
Collaborator Author

As a general comment, the CustomOp infrastructure will be overhauled once vLLM has its vLLM IR landed. I looked at it and I think we should be in a good position for a quick turn-over once the vLLM IR lands. In fact, the refactor of this PR should simplify this change even further

@bohnstingl bohnstingl requested a review from joerunde March 19, 2026 11:12
return pytree.tree_map(
lambda el: el[:orig_batch_size, :],
convert_from_spyre(outs, dtype=x_dtype, device=x_device),
lambda el: convert(el, dtype=x_dtype, device=x_device)[:orig_batch_size, :],
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I think there was a small bug here where convert wasn't in the transform so in the case where there is a residual, a tuple was being passed to convert which started failing with the new unit tests

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Looks good to me! Thank you @joerunde

@joerunde
Copy link
Copy Markdown
Collaborator

bot:next-test

Copy link
Copy Markdown
Collaborator

@joerunde joerunde left a comment

Choose a reason for hiding this comment

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

Nice cleanup!

I've merged in main and 🤞 the tests should be passing and we'll be good to merge

@joerunde
Copy link
Copy Markdown
Collaborator

Tests are passing!

@bohnstingl feel free to merge if you're fine with the tiny bugfix I added on the output conversion in rms_norm.py

@bohnstingl bohnstingl merged commit 16a88b7 into torch-spyre:main Mar 19, 2026
14 checks passed
coderfornow added a commit to coderfornow/vllm-spyre that referenced this pull request Mar 24, 2026
…ing Signed-off-by: coderfornow <ritikdhiranan@icloud.com>
coderfornow added a commit to coderfornow/vllm-spyre that referenced this pull request Mar 24, 2026
coderfornow added a commit to coderfornow/vllm-spyre that referenced this pull request Mar 24, 2026
  Signed-off-by: coderfornow <ritikdhiranan@icloud.com>
coderfornow added a commit to coderfornow/vllm-spyre that referenced this pull request Mar 24, 2026
  Signed-off-by: coderfornow <ritikdhiranan@icloud.com>

Signed-off-by: coderfornow <ritikdhiranan@icloud.com>
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