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.
While debugging the OPT model, I found out that a few things were not working as expected when batching inputs.
For a start,
is_contiguous
was never called (and dispatched) because it must be overloaded directly in subclasses (would need to check how many methods are actually needed inTensor
subclasses).Then, I realized that the chain of
aten
operations when torch Function is disabled in theTensor
subclass was not necessarily equivalent to their "functional" counterparts.A good example is
torch.matmul
: if I disable torch Function forQTensor
and invoketorch.matmul
, I end up with a sequence of operations that does not check if inputs are contiguous, which leads to failures when the modeling code is not bullet-proof.Finally, the calibration code was not strictly correct, as during calibration we were always using the "optimal" scale for inputs and outputs where it should be the "current" scale evaluated using a momentum.