[query] force aggregate_cols to be local#13405
Conversation
|
Looks like you need the globals too. Two concerns:
|
|
|
I can't find the conversation we all had about this, but I strongly disagree with (2). It has to be the case that this always evaluates to true. This would be profoundly confusing if not. I hate it but I'm willing to accept that Returns them out of order, even though I don't like that. EDIT: hit enter too fast |
|
Heh. We can't annotate_globals. |
|
OK, alright. I think you're right. I'm just reliving how frustrated I am by this situation. Can you modify aggregate_cols to include the same warning from |
|
I can't find good tests either, can you add some tests in the spirit of my shared ipython session? |
|
Had to chase down a latent bug in |
danking
left a comment
There was a problem hiding this comment.
Can you update your PR message with a CHANGELOG line indicating that we fixed the performance regression?
| mt = mt.checkpoint(path) | ||
| assert(mt.aggregate_cols(hl.agg.collect(mt.col_idx)) == [0, 1, 2]) | ||
| mt = mt.key_cols_by() | ||
| assert(mt.aggregate_cols(hl.agg.collect(mt.col_idx)) == [2, 1, 0]) |
There was a problem hiding this comment.
oops, sorry, assert in Python doesn't use parentheses. My bad
CHANGELOG: MatrixTable.aggregate_cols no longer forces a distributed computation. This should be what you want in the majority of cases. In case you know the aggregation is very slow and should be parallelized, use mt.cols().aggregate instead.
Most of the time,
aggregate_colswill be much faster performing the aggregation locally. Currently, we generate aTableAggregateover aTableParallelizeof the columns. We shouldn't try to optimize that to a local computation during compilation;TableParallelizeshould express the intent that the computation is expensive and really should be parallelized. This should be considered part of the semantics the compiler must preserve.This PR changes
aggregate_colsto explicitly generate a local computation usingStreamAgg(which was only exposed in Python relatively recently, which is why we haven't made this change sooner). Longer term, aggregating columns should probably get its own IR node, especially once we start partitioning along columns.