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

[ML] Make Streaming Results Writeable #122527

Merged
merged 6 commits into from
Feb 20, 2025

Conversation

prwhelan
Copy link
Member

Make streaming elements extend Writeable and create StreamInput constructors so we can publish elements across nodes using the transport layer.

Additional notes:

  • Moved optional methods into the InferenceServiceResults interface and default them
  • StreamingUnifiedChatCompletionResults elements are now all records

Make streaming elements extend Writeable and create StreamInput
constructors so we can publish elements across nodes using the transport
layer.

Additional notes:
- Moved optional methods into the InferenceServiceResults interface and
  default them
- StreamingUnifiedChatCompletionResults elements are now all records
@prwhelan prwhelan added >refactoring :ml Machine learning Team:ML Meta label for the ML team v9.1.0 labels Feb 13, 2025
@prwhelan prwhelan marked this pull request as ready for review February 14, 2025 13:43
@elasticsearchmachine
Copy link
Collaborator

Pinging @elastic/ml-core (Team:ML)

Copy link
Contributor

@jonathan-buttner jonathan-buttner left a comment

Choose a reason for hiding this comment

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

Should we backport this to 8.19?

@@ -27,18 +31,39 @@ public interface InferenceServiceResults extends NamedWriteable, ChunkedToXConte
*
* <p>For other results like SparseEmbeddingResults, this method can be a pass through to the transformToLegacyFormat.</p>
*/
List<? extends InferenceResults> transformToCoordinationFormat();
default List<? extends InferenceResults> transformToCoordinationFormat() {
Copy link
Contributor

Choose a reason for hiding this comment

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

❤️

public boolean equals(Object o) {
if (o == null || getClass() != o.getClass()) return false;
Results other = (Results) o;
return dequeEquals(this.results, other.results());
Copy link
Contributor

Choose a reason for hiding this comment

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

Ah was this why you were saying deque was a bad idea haha?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah, it took me a few minutes to realize most of the Deque implementations do not have an equals method =(

}

public String getModel() {
return model;
private static boolean dequeEquals(Deque<?> thisDeque, Deque<?> otherDeque) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Looks like we use this in a couple places, do you think it'd be worth moving it to a utility function?

}

public Usage getUsage() {
return usage;
private static int dequeHashCode(Deque<?> deque) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Same here maybe move to a utility function.

@prwhelan prwhelan enabled auto-merge (squash) February 20, 2025 13:55
@prwhelan prwhelan merged commit e74ef2d into elastic:main Feb 20, 2025
16 of 17 checks passed
prwhelan added a commit to prwhelan/elasticsearch that referenced this pull request Feb 21, 2025
Make streaming elements extend Writeable and create StreamInput
constructors so we can publish elements across nodes using the transport
layer.

Additional notes:
- Moved optional methods into the InferenceServiceResults interface and
  default them
- StreamingUnifiedChatCompletionResults elements are now all records
elasticsearchmachine added a commit that referenced this pull request Feb 21, 2025
* [ML] Make Streaming Results Writeable (#122527)

Make streaming elements extend Writeable and create StreamInput
constructors so we can publish elements across nodes using the transport
layer.

Additional notes:
- Moved optional methods into the InferenceServiceResults interface and
  default them
- StreamingUnifiedChatCompletionResults elements are now all records

* [CI] Auto commit changes from spotless

---------

Co-authored-by: elasticsearchmachine <infra-root+elasticsearchmachine@elastic.co>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
:ml Machine learning >refactoring Team:ML Meta label for the ML team v8.19.0 v9.1.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants