cancel
Showing results forย 
Search instead forย 
Did you mean:ย 
Generative AI
Explore discussions on generative artificial intelligence techniques and applications within the Databricks Community. Share ideas, challenges, and breakthroughs in this cutting-edge field.
cancel
Showing results forย 
Search instead forย 
Did you mean:ย 

ai-query Execution

IM_01
Valued Contributor

Hi,

I see that ai-query supports parallelization. Is it executed in parallel across each partition of the dataframe.
could any one explain how it supports optimized batch inference

2 REPLIES 2

sundar-sg
New Contributor II
Hi @IM_01,

ai_query is built for batch inference, but the docs do not say that it runs one call per DataFrame partition, and they do not describe the internal batching. They say the platform manages it. The AI Functions page says: "AI Functions automatically manage parallelization, retries, and scaling. It is advised to submit your full dataset in a single query rather than manually splitting it into small batches."

The same page says "your query runs on the compute you submit it from, such as a SQL warehouse, notebook, cluster, or pipeline", and that "the model inference may run on separate Databricks-managed infrastructure". So the docs do not link the number of partitions to the number of parallel model calls, and I would not tune partitions for this.

For optimised batch inference, the best practices on the "Use ai_query" page are:
1) Use Databricks-hosted system.ai model services, not provisioned throughput endpoints.
2) Pick a model from the batch-optimised list on that page. A non-optimised model "can result in reduced throughput and longer job completion times."
3) Submit your full dataset in a single query. "Manually splitting data into small batches can reduce throughput."
4) Set failOnError to false for large workloads, so failed rows return an error message and you keep the successful results.

[https://docs.databricks.com/aws/en/large-language-models/ai-query]
To see what happened in a run, open the query profile in the SQL editor and click AI Query. It shows the completed and failed inferences and the total time.

Yougasundar
Contributor
Hi @IM_01,

ai_query is built for batch inference, but the docs do not say that it runs one call per DataFrame partition, and they do not describe the internal batching. They say the platform manages it. The AI Functions page says: "AI Functions automatically manage parallelization, retries, and scaling. It is advised to submit your full dataset in a single query rather than manually splitting it into small batches."

The same page says "your query runs on the compute you submit it from, such as a SQL warehouse, notebook, cluster, or pipeline", and that "the model inference may run on separate Databricks-managed infrastructure". So the docs do not link the number of partitions to the number of parallel model calls, and I would not tune partitions for this.

For optimised batch inference, the best practices on the "Use ai_query" page are:
1) Use Databricks-hosted system.ai model services, not provisioned throughput endpoints.
2) Pick a model from the batch-optimised list on that page. A non-optimised model "can result in reduced throughput and longer job completion times."
3) Submit your full dataset in a single query. "Manually splitting data into small batches can reduce throughput."
4) Set failOnError to false for large workloads, so failed rows return an error message and you keep the successful results.

[https://docs.databricks.com/aws/en/large-language-models/ai-query]
To see what happened in a run, open the query profile in the SQL editor and click AI Query. It shows the completed and failed inferences and the total time.