4

From Candidate Lists to Tensorized Computation Graphs

AI999第4课:现代计算底座与张量化并行演化
00:00

In evolutionary computation,diversityis a prerequisite for the algorithm to work: only by maintaining enough candidate solutions will selection pressure avoid prematurely squeezing the population into a local optimum. But diversity also means a huge computational load—a single run often requires evaluating tens of thousands, even millions, of candidate solutions. When candidates are written as ordinary arrays of objects and fed one by one into evaluation through item-by-item loops, most of the computation time is spent on item-by-item scheduling and host-language control flow rather than on actual numerical operations. This is preciselythe root cause of why traditional serial CPU loops are inefficient when handling tens of thousands of candidate evaluations.

From Candidate Lists to Tensorized Computation GraphsA Leap in RepresentationCandidate list (item-by-item processing)Each candidate is a separate object1Candidate x₁2Candidate x₂3Candidate x₃4Candidate x₄One candidate at a time · serial CPU loopInefficient at tens of thousands of evaluationsOverhead in item-by-item scheduling and control flowCandidate tensorWhole generation written in at once[population size, solution dimension]One row = one candidate solutionComputation graph: tensorized operationsSelection and state updates enter the graph, gaining compiler optimizationsMutationApplied to the whole populationEvaluationWhole generation per callSelectionTensor indexingState updateReduction nodeThe whole graph undergoes compiler optimization: operator fusion · parallel schedulingEvaluation output shape: [population size] or [population size, number of objectives]Overall computation: mutation, evaluation, selection, and state update all enter the computation graph together

A Leap in Representation: From Candidate Lists to Tensorized Computation Graphs

What EvoX brings is not a local speedup of some operator, buta change in how the evolutionary process is represented: a shift from list-style processing of candidates one by one to batch computation with tensors as first-class citizens. The set of candidates is no longer scattered across arrays of objects; instead, together with evaluation results and algorithm state, it is uniformly organized into tensors so that everything can participate in computation as a whole.

  • Candidate tensor: The entire generation of candidates is written as a tensor of shape [population size, solution dimension]. A "candidate" is now just a row in the tensor rather than a separate host-language object.
  • Batch operators: Operations such as mutation act directly on the entire population; a single call updates all candidates instead of looping N times.
  • Batch evaluation: Using evaluate(candidate tensor) to obtain the evaluation results for the whole generation in one go, the unit of evaluation changes from "one" to "a batch".
  • Computation graph: Selection and state updates are no longer merely serial control logic but nodes in the graph, thus gaining compiler optimization opportunities such as operator fusion and parallel scheduling.

Comparing the Two Styles

The list-style approach is roughly: take out candidates one by one, evaluate one by one, compare one by one, and update state—every step relies on host-language loops and is hard to optimize as a whole. The tensorized approach is: candidate tensor → mutation → evaluation → selection → state update, with the entire chain composed of tensor operations and expressed as a single computation graph that the compiler can fuse and schedule across devices. Note that the algorithm's logic (mutation distribution, selection pressure) is not rewritten; what is rewritten isthe representation.

Key term
Tensorized computation—using tensors as the smallest unit of processing, so that mutation, evaluation, selection, and state update all act on the entire population in batch form, and allowing these batch operations to enter a computation graph for compiler optimization. The key transition on this page can be captured in one sentence: from "candidate lists" to "tensorized computation graphs."