English edition updated

When batch inference is faster and when it slows down

  • #Batch Inference
  • #AI

The speed of batch inference: It cannot be generalized.

I've recently been working on a project that uses a large model API. The requirements aren't complicated: extract keywords from webpage text, identify brand names and their aliases, and then determine the article's sentiment towards that brand—positive or negative. This kind of semantic understanding and sentiment analysis is exactly what large models excel at, and doesn't require deep reasoning.

The task is simple, but the volume is significant. In the most basic scenario, there are around a hundred articles. Calling the API line by line, or using regular concurrent calls, either triggers frequency limits or results in excessively slow overall throughput.

After some research, I discovered that platforms like Volcano Engine offer two methods besides single-call APIs: "online inference" and "batch inference." Batch inference has two modes: batch inference tasks, which process statically stored data; and an access point similar to online inference, which processes dynamic data. My scenario involves batches of web articles, which falls under the former. I hadn't used it before, but after some research, I found it to be a perfect fit—the prompts remain almost unchanged, only the input data changes.

1. Why is it fast?

Batch inference is different from what I originally imagined. I thought batching was just sending requests in a bunch, but that's not the case—its real advantage lies in the fact that when all requests share the same set of prompts and only the data content changes, the server-side cache hit rate is extremely high.

The official explanation is more direct: the cost per input and output is 50% of that of online inference, and the cost per input can be reduced by another 60% after a cache hit—the caching benefit is not just about speed, but also about cost. The default quota is 10 billion tokens/day, with support for quota increases via work orders, and thanks to flexible scheduling strategies, it can maintain a considerable processing rate even during peak periods.

I submitted 300 articles at once, prepared to wait, but they returned in a minute or two—exceeding my expectations.

There are several key points to consider when using this interface:

  • Extremely high concurrency. It can handle 50,000 concurrent calls using asynchronous I/O. This requires removing local concurrency limits to prevent the client itself from becoming a bottleneck.
  • Extremely long timeout settings. Thousands of requests being processed in parallel on the server side takes time, so long timeouts are advisable—24-hour timeouts are not uncommon and are the norm for batch tasks.
  • Exponential backoff retries for 429. Server overload will return 429. Instead of hard retries, use an exponential backoff strategy to wait for the server to recover before retrying.

It's worth mentioning the low barrier to entry for the Batch Chat interface: the parameters of the Batch Chat interface are the same as those of the regular Chat interface. You only need to focus on the timeout and concurrency strategies to switch between them, without having to change the business logic—which is why I was able to get started quickly.

The system retrieves all results at once upon returning. The entire process takes only a few minutes.

II. Changing the deep reasoning model yields drastically different results.

Just when I thought I had found the ideal solution, I tried it again today—this time using DeepThink's doubao-seed-2-1-pro, and it was Sunday. Almost the same scenario, but the performance was completely different.

Previously, with lightweight models like doubao-seed-2.0-mini, it could be completed in a few minutes; but this time, with the deep inference-based doubao-seed-2-1-pro, it was almost impossible to proceed.

The "waiting and queuing" described in the official documentation is not an exaggeration. On a uncrowded model, queuing is almost non-existent; however, on a more crowded model, or a model with deeper reasoning, the fast method of batch inference becomes ineffective—thousands of requests enter the queue, and deep inference itself is slow, getting slower the deeper it goes, so the backlog only exacerbates the problem.

But whether this slowdown is due to the deeper and slower reasoning of doubao-seed-2-1-pro itself, or to the platform's limited capacity and increased queues on Sunday, is difficult to determine based on a single comparison.

Conclusion: Generalizations cannot be made.

The speed of batch inference cannot be judged solely by the interface. It's fast and stable on doubao-seed-2.0-mini, but almost unusable on doubao-seed-2-1-pro—but this doesn't mean "deep inference models shouldn't use batch processing." The applicable scenarios and real-world performance of deep inference need to be cross-validated: sometimes the bottleneck lies in the model's own inference depth and speed, and sometimes in the platform's concurrency capacity and queuing situation. These two factors are intertwined and cannot be generalized.

The interface provides high concurrency, long timeouts, and exponential backoff, and the platform also offers low unit price, high quota, and flexible scheduling. However, the speed of the final run is determined by the model, platform capacity, and time period. Only actual testing can clarify the combination of these three factors.

Reference link: Volcano Engine - Batch Inference

The speed of batch reasoning: It cannot be generalized (Illustration)