Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ops w/ default implementation for QTensorOps #2125

Merged
merged 16 commits into from
Sep 9, 2024
Merged

Conversation

laggui
Copy link
Member

@laggui laggui commented Aug 7, 2024

Checklist

  • Confirmed that run-checks all script has been executed.

Related Issues/PRs

Follow-up to #2025

Changes

  • Added float ops as q_* ops in QTensorOps with some default implementations
    • All float ops now match based on the tensor primitive enum (Float vs QFloat) to call the corresponding ops
    • Implemented ops for ndarray and tch backends
  • Added quantize_dynamic which computes the quantization parameters at runtime
  • Added testgen_quantization test macro to use with backends that support quantization
  • Added missing sort_with_indices op to tch backend
  • Refactored existing chunk to call the corresponding backend methods (previously always ran the default implementation regardless of backend implementation)

Testing

Added unit tests for all ops.

Note: the tests try to use tensors with floating point values which can be de/quantized without introducing too much quantization error, but the result always depends on the operation (e.g., tensor product of values can grow larger and significantly increase the output tensor range, leading to more de/quantization error on the results).

@laggui laggui changed the title Add ops default implementation for QTensorOps Add ops w/ default implementation for QTensorOps Aug 7, 2024
Copy link

codecov bot commented Aug 7, 2024

Codecov Report

Attention: Patch coverage is 88.05777% with 645 lines in your changes missing coverage. Please review.

Project coverage is 85.83%. Comparing base (ccb5b22) to head (d5e6976).
Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
crates/burn-tch/src/ops/qtensor.rs 0.00% 196 Missing ⚠️
crates/burn-tensor/src/tensor/ops/qtensor.rs 71.52% 162 Missing ⚠️
crates/burn-autodiff/src/ops/qtensor.rs 0.00% 60 Missing ⚠️
crates/burn-fusion/src/ops/qtensor.rs 0.00% 48 Missing ⚠️
crates/burn-candle/src/ops/qtensor.rs 0.00% 43 Missing ⚠️
crates/burn-jit/src/ops/qtensor.rs 0.00% 43 Missing ⚠️
...es/burn-tensor/src/tests/quantization/ops/chunk.rs 77.87% 25 Missing ⚠️
crates/burn-tensor/src/tensor/api/numeric.rs 89.23% 21 Missing ⚠️
crates/burn-ndarray/src/ops/qtensor.rs 82.41% 16 Missing ⚠️
crates/burn-tensor/src/tensor/api/base.rs 81.70% 15 Missing ⚠️
... and 3 more
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2125      +/-   ##
==========================================
+ Coverage   85.57%   85.83%   +0.25%     
==========================================
  Files         707      750      +43     
  Lines       89097    94420    +5323     
==========================================
+ Hits        76249    81048    +4799     
- Misses      12848    13372     +524     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@laggui laggui marked this pull request as ready for review August 7, 2024 15:26
@laggui laggui requested a review from nathanielsimard August 7, 2024 15:26
Copy link
Contributor

github-actions bot commented Sep 7, 2024

This PR has been marked as stale because it has not been updated for over a month

@github-actions github-actions bot added the stale The issue or pr has been open for too long label Sep 7, 2024
@laggui laggui force-pushed the feat/quant/default-ops branch from 3796c4b to bbb5ece Compare September 9, 2024 15:53
@laggui laggui merged commit eb899db into main Sep 9, 2024
11 checks passed
@laggui laggui deleted the feat/quant/default-ops branch September 9, 2024 16:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stale The issue or pr has been open for too long
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant