Skip to content

Moving builtins lower in the pipeline and adding option to force. - #13994

Merged
benvanik merged 1 commit into
mainfrom
benvanik-emulate-splat-fill
Jun 8, 2023
Merged

benvanik merged 1 commit into
mainfrom
benvanik-emulate-splat-fill

Conversation

@benvanik

@benvanik benvanik commented Jun 7, 2023 •

Copy link
Copy Markdown
Collaborator

By moving it after partitioning we can use the resource config local to the partitioned execution region where the ops live to make decisions. We also are able to preserve the semantics of the ops through partitioning/placement such as whether splats should be rematerialized.

To work around the CUDA issue in #13984 a global flag was added to force all splats/fills into builtins that must be passed when graphs are used at runtime.

I was hoping this would make it easier to support complex<f64> as well but that doesn't quite fit due to the lack of an i128 in MLIR. One day. May need to move the canonicalizeFillPattern doing the integer conversion down into MaterializeBuiltins but that would mean removing the verifier on AsyncSplatOp/AsyncFillOp that the type is actually supported and spreads encoding across stages of the pipeline. Still may be worth it for readability but we can re-evaluate when we have a need for complex<f64>.

@benvanik
benvanik requested a review from antiagainst June 7, 2023 23:35
@benvanik
benvanik force-pushed the benvanik-emulate-splat-fill branch 2 times, most recently from 1384be0 to 02c6370 Compare June 7, 2023 23:41
By moving it after partitioning we can use the resource config local
to the partitioned execution region where the ops live to make decisions.

To work around the CUDA issue in #13984 a global flag was added to force
all splats/fills into builtins that must be passed when graphs are used
at runtime.
@benvanik
benvanik force-pushed the benvanik-emulate-splat-fill branch from 02c6370 to bd597a1 Compare June 8, 2023 00:20
@benvanik
benvanik marked this pull request as ready for review June 8, 2023 00:56
@benvanik
benvanik enabled auto-merge (squash) June 8, 2023 01:02

@antiagainst antiagainst left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Neat! Nice to have builtins at stream level so we are programing in linalg level; much easier and have the CodeGen flow across all backends!

@benvanik
benvanik merged commit 4e48c13 into main Jun 8, 2023
@benvanik
benvanik deleted the benvanik-emulate-splat-fill branch June 8, 2023 05:08
benvanik added a commit that referenced this pull request Jun 8, 2023
…3440)

These aren't actually async as the CUDA HAL is synchronous but will make
use of CUDA's memory pooling features to reduce the alloc/free cost in a
way more friendly to CUDA's memory management than just the normal
allocator.

With this our queue-ordered allocations in CUDA now average a few us
(for me) and the caching allocator (or any other) is only needed for
caching non-queue-ordered allocations. A few compiler tweaks to switch
all allocations to queue-ordered will mean only explicitly allocated
buffers (constants/variables, stuff the user does manually, etc) will
not route to the pools.

It'd also be possible to explore using the same pools the queue-ordered
allocations use for explicit synchronous allocations (at least the
device-local pool) but it'd be nicer to get those out of the critical
path and then keep the pools separate such that the transient pool isn't
filled with persistent allocations.

Due to #13984 this relies on the `--iree-stream-emulate-memset` flag
added in #13994 being set when graphs are enabled. Since this is not the
default path today and there's just two test suites using it we just
flip the flag for them.
NatashaKnk pushed a commit to NatashaKnk/iree that referenced this pull request Jul 6, 2023
…ee-org#13994)

By moving it after partitioning we can use the resource config local to
the partitioned execution region where the ops live to make decisions.
We also are able to preserve the semantics of the ops through
partitioning/placement such as whether splats should be rematerialized.

To work around the CUDA issue in iree-org#13984 a global flag was added to force
all splats/fills into builtins that must be passed when graphs are used
at runtime.

I was hoping this would make it easier to support `complex<f64>` as well
but that doesn't quite fit due to the lack of an `i128` in MLIR. One
day. May need to move the canonicalizeFillPattern doing the integer
conversion down into MaterializeBuiltins but that would mean removing
the verifier on AsyncSplatOp/AsyncFillOp that the type is actually
supported and spreads encoding across stages of the pipeline. Still may
be worth it for readability but we can re-evaluate when we have a need
for `complex<f64>`.
NatashaKnk pushed a commit to NatashaKnk/iree that referenced this pull request Jul 6, 2023
…ee-org#13440)

These aren't actually async as the CUDA HAL is synchronous but will make
use of CUDA's memory pooling features to reduce the alloc/free cost in a
way more friendly to CUDA's memory management than just the normal
allocator.

With this our queue-ordered allocations in CUDA now average a few us
(for me) and the caching allocator (or any other) is only needed for
caching non-queue-ordered allocations. A few compiler tweaks to switch
all allocations to queue-ordered will mean only explicitly allocated
buffers (constants/variables, stuff the user does manually, etc) will
not route to the pools.

It'd also be possible to explore using the same pools the queue-ordered
allocations use for explicit synchronous allocations (at least the
device-local pool) but it'd be nicer to get those out of the critical
path and then keep the pools separate such that the transient pool isn't
filled with persistent allocations.

Due to iree-org#13984 this relies on the `--iree-stream-emulate-memset` flag
added in iree-org#13994 being set when graphs are enabled. Since this is not the
default path today and there's just two test suites using it we just
flip the flag for them.
nhasabni pushed a commit to plaidml/iree that referenced this pull request Aug 24, 2023
…ee-org#13994)

By moving it after partitioning we can use the resource config local to
the partitioned execution region where the ops live to make decisions.
We also are able to preserve the semantics of the ops through
partitioning/placement such as whether splats should be rematerialized.

To work around the CUDA issue in iree-org#13984 a global flag was added to force
all splats/fills into builtins that must be passed when graphs are used
at runtime.

I was hoping this would make it easier to support `complex<f64>` as well
but that doesn't quite fit due to the lack of an `i128` in MLIR. One
day. May need to move the canonicalizeFillPattern doing the integer
conversion down into MaterializeBuiltins but that would mean removing
the verifier on AsyncSplatOp/AsyncFillOp that the type is actually
supported and spreads encoding across stages of the pipeline. Still may
be worth it for readability but we can re-evaluate when we have a need
for `complex<f64>`.
nhasabni pushed a commit to plaidml/iree that referenced this pull request Aug 24, 2023
…ee-org#13440)

These aren't actually async as the CUDA HAL is synchronous but will make
use of CUDA's memory pooling features to reduce the alloc/free cost in a
way more friendly to CUDA's memory management than just the normal
allocator.

With this our queue-ordered allocations in CUDA now average a few us
(for me) and the caching allocator (or any other) is only needed for
caching non-queue-ordered allocations. A few compiler tweaks to switch
all allocations to queue-ordered will mean only explicitly allocated
buffers (constants/variables, stuff the user does manually, etc) will
not route to the pools.

It'd also be possible to explore using the same pools the queue-ordered
allocations use for explicit synchronous allocations (at least the
device-local pool) but it'd be nicer to get those out of the critical
path and then keep the pools separate such that the transient pool isn't
filled with persistent allocations.

Due to iree-org#13984 this relies on the `--iree-stream-emulate-memset` flag
added in iree-org#13994 being set when graphs are enabled. Since this is not the
default path today and there's just two test suites using it we just
flip the flag for them.
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