cont_engine: evaluate a zero-volume general product through a tile-less evaluator - #590
Merged
Merged
Conversation
…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.
Member
|
@kshitij-05 still a draft? |
kshitij-05
marked this pull request as ready for review
September 18, 2026 20:37
evaleev
approved these changes
Sep 18, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
ContEngine::init_distribution_generalskips the process grid when the general (fused x contracted) product's result has zero volume -- some result mode has no tiles, andProcGridneeds at least one row and one column -- butmake_dist_eval_generalstill built the batched SUMMA evaluator and its slab-replicated pmap from the default-constructedproc_grid_, trippingTA_ASSERT(world_)inProcGrid::make_pmap(orTA_ASSERT(nh_ > 0)incontraction_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, aDistEvalImplover a zero-volume tiled range: it owns no tiles,internal_eval()spawns nothing, andget_tilethrows. Installed alongside the otherdist_evalheaders.expressions/cont_engine.h: whentrange_.tiles_range().volume() == 0,make_dist_eval_generalreturns that evaluator in the target layout, with the pmapinit_distribution_generalchose, 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_denseand..._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, onDensePolicyandSparsePolicy. Without the fix four of the six combinations abort inProcGrid::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.