Skip to content

cont_engine: evaluate a zero-volume general product through a tile-less evaluator - #590

Merged
evaleev merged 3 commits into
masterfrom
kshitij/fix/zero-volume-general-product
Sep 19, 2026
Merged

evaleev merged 3 commits into
masterfrom
kshitij/fix/zero-volume-general-product

Conversation

@kshitij-05

@kshitij-05 kshitij-05 commented Sep 17, 2026 •

Copy link
Copy Markdown
Member

Problem

ContEngine::init_distribution_general skips the process grid when the general (fused x contracted) product's result has zero volume -- some result mode has no tiles, and ProcGrid needs at least one row and one column -- but make_dist_eval_general still built the batched SUMMA evaluator and its slab-replicated pmap from the default-constructed proc_grid_, tripping TA_ASSERT(world_) in ProcGrid::make_pmap (or TA_ASSERT(nh_ > 0) in contraction_eval.h). Hit by a shape-imposed tensor-of-tensor product whose sliced aux mode had no tiles.

Fix

  • dist_eval/zero_volume_eval.h: ZeroVolumeEvalImpl, a DistEvalImpl over a zero-volume tiled range: it owns no tiles, internal_eval() spawns nothing, and get_tile throws. Installed alongside the other dist_eval headers.
  • expressions/cont_engine.h: when trange_.tiles_range().volume() == 0, make_dist_eval_general returns that evaluator in the target layout, with the pmap init_distribution_general chose, instead of building the SUMMA evaluator (whose operands are then not evaluated either).

Testing

general_product_suite (tests/general_product.cpp):

  • expression_general_product_zero_volume_dense and ..._sparse: all three ways the result volume vanishes -- an empty left-external (M == 0), fused (n_slabs_ == 0) and right-external (N == 0) mode -- each with a canonical and a repermuted target, on DensePolicy and SparsePolicy. Without the fix four of the six combinations abort in ProcGrid::make_pmap / contraction_eval.h.
  • expression_general_product_zero_volume_contracted_mode: control -- an empty contracted mode keeps the ordinary process-grid path and yields a zero array with tiles.

Local run (macOS arm64, TA_ASSERT_THROW): ta_test --run_test=general_product_suite -> no errors; the same test file built against master fails the two zero-volume cases. GitHub Actions and GitLab CI green.

kshitij-05 and others added 3 commits September 17, 2026 13:02
…ss evaluator

init_distribution_general skips the process grid for a zero-volume result
(ProcGrid needs at least one row and one column), but make_dist_eval_general
still built the SUMMA evaluator and its canonical slabbed pmap from
proc_grid_, tripping TA_ASSERT(world_) in ProcGrid::make_pmap. The result has
no tiles, so evaluate it through ZeroVolumeEvalImpl, a DistEvalImpl that owns
no tiles and produces nothing. Hit by a shape-imposed ToT product whose
sliced aux mode had no tiles.
It is a DistEvalImpl that owns no tiles, not a contraction detail, so it
belongs next to the other distributed evaluators rather than in
expressions/cont_engine.h -- which also relied on picking up DistEvalImpl
transitively through dist_eval/contraction_eval.h. Installed alongside the
other dist_eval headers.
A result mode with no tiles makes the general product's result zero-volume,
which is the corner case where init_distribution_general skips the process
grid. Covers all three ways the result volume vanishes -- an empty left
external (M == 0), fused (n_slabs_ == 0), and right external (N == 0) mode --
with canonical and repermuted targets, dense and block-sparse. Four of those
six combinations abort without the ZeroVolumeEvalImpl path (TA_ASSERT(world_)
in ProcGrid::make_pmap, or nh_ > 0 in contraction_eval). Also pins the
adjacent case that must keep taking the ordinary path: an empty *contracted*
mode, whose result still has tiles and is zero.
@evaleev

evaleev commented Sep 18, 2026

Copy link
Copy Markdown
Member

@kshitij-05 still a draft?

@kshitij-05
kshitij-05 marked this pull request as ready for review September 18, 2026 20:37
@evaleev
evaleev merged commit 4d4db03 into master Sep 19, 2026
9 checks passed
@evaleev
evaleev deleted the kshitij/fix/zero-volume-general-product branch September 19, 2026 20:44
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.

2 participants