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

Make llm benchmarks query faster #6258

Merged
merged 3 commits into from
Feb 5, 2025
Merged

Conversation

clee2000
Copy link
Contributor

@clee2000 clee2000 commented Feb 4, 2025

Make faster by adding a projection to the table

PROJECTION benchmark_name_projection
    (
        SELECT *
        ORDER BY 
            repo,
            tupleElement(benchmark, 'name'),
            tupleElement(model, 'name'),
            tupleElement(metric, 'name'),
            timestamp,
            head_branch,
            head_sha,
            workflow_id,
            job_id,
            servicelab_experiment_id,
            servicelab_trial_id
    ),

For some reason, ClickHouse won't use the projection unless t uses has instead of in and all the other tuple elements are in quotation marks

We should consider changing the order by key to be this instead since I can't imagine anyone not filtering by benchmark name

Perf results:

+------+----------+-----------+-------------+---------------+----------+-----------+------------+--------------+
| Test | Avg Time | Base Time | Time Change | % Time Change | Avg Mem  |  Base Mem | Mem Change | % Mem Change |
+------+----------+-----------+-------------+---------------+----------+-----------+------------+--------------+
|  0   |   131    |   33300   |    -33169   |      -100     | 57215999 | 335780375 | -278564376 |     -83      |
+------+----------+-----------+-------------+---------------+----------+-----------+------------+--------------+

Also added a test

Checked results were the same after sorting

Also a change to the script to compare queries that makes it easier to compare results that are different by piping them to files that can be diffed later

Copy link

vercel bot commented Feb 4, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated (UTC)
torchci ✅ Ready (Inspect) Visit Preview Feb 5, 2025 0:30am

@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Feb 4, 2025
floor(arrayAvg(o.metric.benchmark_values), 2) AS actual,
floor(toFloat64(o.metric.target_value), 2) AS target,
o.benchmark.dtype AS dtype,
o.model.'name' AS model,
Copy link
Contributor

Choose a reason for hiding this comment

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

One of of confusing aspect of ClickHouse is that sometimes model.name works, sometimes it needs to be model.'name', and the other times it is tupleElement(model, 'name'). The last one is probably the clearest because the field is a tuple, but it's also the lengthiest

Copy link
Contributor

@huydhn huydhn left a comment

Choose a reason for hiding this comment

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

LGTM! Thank you for the fix!

@huydhn
Copy link
Contributor

huydhn commented Feb 5, 2025

I'm not sure why the preview doesn't show up because Vercel cancels it

@huydhn
Copy link
Contributor

huydhn commented Feb 5, 2025

I think we should also add some more key to the projection if possible. They are the keys that I should have added when creating the table.

PROJECTION benchmark_name_projection
    (
        SELECT *
        ORDER BY 
            repo,
            tupleElement(benchmark, 'name'),
            tupleElement(model, 'name'),
            tupleElement(metric, 'name'),
            timestamp,
            head_branch,
            head_sha,
            workflow_id,
            job_id,
            servicelab_experiment_id,
            servicelab_trial_id
    ),

@huydhn
Copy link
Contributor

huydhn commented Feb 5, 2025

Also, could you try update the two queries?

I'm currently using a materialize view for them, which I think is slower than this projection approach (when I try to load the page)

It's better done in a separate PR then, as I think #6167 needs to be reverted to try it out

@clee2000 clee2000 marked this pull request as ready for review February 5, 2025 20:56
@clee2000 clee2000 merged commit 8f2607d into main Feb 5, 2025
8 checks passed
@clee2000 clee2000 deleted the csl/benchmark_llm_query_fast branch February 5, 2025 20:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants