Conversation
The factory-owned DMLDataTransfer is shared across all sessions, but it
cached a single execution provider and routed every CopyTensors call
through that one provider's ExecutionContext/queue/fence. Each session
(e.g. a pipeline of separate text-encoder/UNet/VAE models) has its own
context and fence, so a copy for one session could run on another
session's context. Its readback then waited on the wrong queue's fence —
one already signaled — so WaitForSignal returned without blocking and the
copy read back GPU memory before the owning session's compute had
produced it, yielding stale or uninitialized (NaN) results on later runs.
Route each copy to the execution provider that owns the tensor instead of
a cached one. DMLDataTransfer now keeps a registry of live providers and
resolves the owner per copy by decoding the tensor's allocation handle to
its bucketized allocator and matching that allocator to a registered EP.
Copies with no GPU tensor (or an unmatched owner) fall back to the
attached provider. This ensures each readback waits on the fence that
actually produced the data.
- dml_data_transfer.{h,cc}: provider registry (Register/UnregisterProvider),
ResolveOwningProvider, and per-copy routing in CopyTensorsImpl
- dml_execution_provider.h: GetBucketizedAllocator accessor for owner matching
- dml_factory.cc: register/unregister each EP in Create/ReleaseEpImpl
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.
The factory-owned DMLDataTransfer is shared across all sessions, but it cached a single execution provider and routed every CopyTensors call through that one provider's ExecutionContext/queue/fence. Each session (e.g. a pipeline of separate text-encoder/UNet/VAE models) has its own context and fence, so a copy for one session could run on another session's context. Its readback then waited on the wrong queue's fence — one already signaled — so WaitForSignal returned without blocking and the copy read back GPU memory before the owning session's compute had produced it, yielding stale or uninitialized (NaN) results on later runs.
Route each copy to the execution provider that owns the tensor instead of a cached one. DMLDataTransfer now keeps a registry of live providers and resolves the owner per copy by decoding the tensor's allocation handle to its bucketized allocator and matching that allocator to a registered EP. Copies with no GPU tensor (or an unmatched owner) fall back to the attached provider. This ensures each readback waits on the fence that actually produced the data.