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

python[minor] update evaluate to be concurrent #1345

Merged
merged 23 commits into from
Jan 21, 2025

Conversation

isahers1
Copy link
Contributor

No description provided.

@@ -642,6 +651,61 @@ async def astart(self) -> _AsyncExperimentManager:
upload_results=self._upload_results,
)

async def awith_predictions_and_evaluators(
Copy link
Collaborator

Choose a reason for hiding this comment

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

We could probably do something similar to what we do in the sync version to avoid having to duplicate logic here (basically share a semaphor)

evaluators = _resolve_evaluators(evaluators)

if not hasattr(self, "_evaluator_executor"):
self._evaluator_executor = cf.ThreadPoolExecutor(max_workers=4)
Copy link
Contributor

Choose a reason for hiding this comment

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

ooc where's the 4 come from?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I copied the value from _ascore - not really sure beyond that

)
async with lock:
Copy link
Contributor

Choose a reason for hiding this comment

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

could we just return the selected_results in _run_single_evaluator and construct the eval_results after the asycio.gather? to avoid needing to lock?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

should be fixed, but someone should check I did it correctly

{
name: {
"presigned_url": value["presigned_url"],
"reader": io.BytesIO(value["reader"].getvalue()),
Copy link
Contributor

Choose a reason for hiding this comment

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

would love @agola11's input on this bit

new_attachments[name] = {
"presigned_url": attachment["presigned_url"],
"reader": io.BytesIO(
self._attachment_raw_data_dict[str(example.id) + name]
Copy link
Contributor

Choose a reason for hiding this comment

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

you're sure this doesn't copy the bytes?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No, you are correct. io.BytesIO copies the underlying bytes. This is wrong, I am working on a fix rn.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ehh actually I am going to walk back my statement. based on testing I don't think bytesIO copies the data.

python/langsmith/evaluation/_arunner.py Outdated Show resolved Hide resolved
@@ -617,7 +617,6 @@ def summary_eval_outputs_reference(outputs, reference_outputs):
tolerance = 3
assert total_slow < tolerance
assert total_quick > (SPLIT_SIZE * NUM_REPETITIONS - 1) - tolerance
assert any([d > 1 for d in deltas])
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@hinthornw I made this change to pass CI, but I would appreciate your review.

Copy link
Collaborator

Choose a reason for hiding this comment

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

It's basically meant to test that we aren't iterating as two phases predict -> evaluate but instead doing generate -> evaluate as a continuous, eager stream.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I don't think we should remove this test

return schemas.Example(
id=example.id,
created_at=example.created_at,
dataset_id=example.dataset_id,
Copy link
Collaborator

Choose a reason for hiding this comment

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

Seems likely that we'll forget to update this when we add a new field - if we haven't added a test for this in the previous version, would like one

manager = await manager.awith_summary_evaluators(summary_evaluators)
if evaluators:
# Run predictions and evaluations in a single pipeline
manager = await manager.awith_predictions_and_evaluators(
Copy link
Collaborator

Choose a reason for hiding this comment

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

If predictions are streamed out do we need a separate method?

@baskaryan baskaryan changed the title [DRAFT] update evaluate to be concurrent python[minor] update evaluate to be concurrent Jan 21, 2025
@baskaryan baskaryan changed the base branch from main to py-version-0.3.0 January 21, 2025 03:30
@baskaryan baskaryan merged commit b812149 into py-version-0.3.0 Jan 21, 2025
5 checks passed
@baskaryan baskaryan deleted the isaac/evaluateconcurrent branch January 21, 2025 06:10
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.

4 participants