Repository navigation
Commit 1526114
Make QuantAbsorption's input-side absorption opt-in (#24780)
Summary:
This should have been part of
#24720, which added
`QuantAbsorptionPass` with the other fused_quant graph passes. It was left out
of that PR by mistake.
By default, `QuantAbsorptionPass` now only runs the rewrite that is never less
accurate. The docstring explains why the other two modes are opt-in.
- Output side (unchanged, always on): the producer writes its output directly
in the downstream quantize's qparams. The value still ends up on that grid,
rounded once instead of twice, so each element is at least as close to the
float result. It isn't bit-exact with the q/dq graph, though.
- Input side (now opt-in, `absorb_into_inputs`): the consumer reads values on
the dequantize's grid instead of the quantize's. Dropping the second rounding
is more accurate on average, but not for every value.
- Forked dequantize (already opt-in, `absorb_with_fork`): its float users see
values on the quantize's grid instead of the producer's, which can be
coarser. Only the docstring changes.
With input-side absorption off, a pair that only the input side would remove
is left to `ReplaceDequantQuantWithRequantize`, which turns it into a
`fused_quant.requantize`.
Differential Revision: D1304666731 parent e0015e1 commit 1526114
2 files changed
Lines changed: 39 additions & 17 deletions
File tree
- backends/transforms/fused_quant
- optimization_passes
- test
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
567 | 567 | | |
568 | 568 | | |
569 | 569 | | |
| 570 | + | |
| 571 | + | |
| 572 | + | |
| 573 | + | |
570 | 574 | | |
571 | 575 | | |
572 | 576 | | |
573 | 577 | | |
574 | | - | |
| 578 | + | |
| 579 | + | |
575 | 580 | | |
576 | 581 | | |
577 | 582 | | |
| |||
581 | 586 | | |
582 | 587 | | |
583 | 588 | | |
584 | | - | |
585 | | - | |
586 | | - | |
587 | | - | |
| 589 | + | |
| 590 | + | |
| 591 | + | |
| 592 | + | |
| 593 | + | |
| 594 | + | |
| 595 | + | |
| 596 | + | |
588 | 597 | | |
589 | 598 | | |
590 | 599 | | |
| |||
594 | 603 | | |
595 | 604 | | |
596 | 605 | | |
| 606 | + | |
597 | 607 | | |
598 | 608 | | |
599 | 609 | | |
600 | 610 | | |
| 611 | + | |
601 | 612 | | |
602 | 613 | | |
603 | 614 | | |
| |||
615 | 626 | | |
616 | 627 | | |
617 | 628 | | |
| 629 | + | |
| 630 | + | |
618 | 631 | | |
619 | 632 | | |
620 | 633 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1416 | 1416 | | |
1417 | 1417 | | |
1418 | 1418 | | |
| 1419 | + | |
| 1420 | + | |
| 1421 | + | |
| 1422 | + | |
| 1423 | + | |
| 1424 | + | |
| 1425 | + | |
1419 | 1426 | | |
1420 | 1427 | | |
1421 | 1428 | | |
1422 | | - | |
| 1429 | + | |
1423 | 1430 | | |
1424 | 1431 | | |
1425 | 1432 | | |
| |||
1458 | 1465 | | |
1459 | 1466 | | |
1460 | 1467 | | |
1461 | | - | |
| 1468 | + | |
1462 | 1469 | | |
1463 | 1470 | | |
1464 | 1471 | | |
| |||
1501 | 1508 | | |
1502 | 1509 | | |
1503 | 1510 | | |
1504 | | - | |
| 1511 | + | |
1505 | 1512 | | |
1506 | 1513 | | |
1507 | 1514 | | |
| |||
1546 | 1553 | | |
1547 | 1554 | | |
1548 | 1555 | | |
1549 | | - | |
| 1556 | + | |
1550 | 1557 | | |
1551 | 1558 | | |
1552 | 1559 | | |
| |||
1562 | 1569 | | |
1563 | 1570 | | |
1564 | 1571 | | |
1565 | | - | |
| 1572 | + | |
1566 | 1573 | | |
1567 | 1574 | | |
1568 | 1575 | | |
| |||
1628 | 1635 | | |
1629 | 1636 | | |
1630 | 1637 | | |
1631 | | - | |
| 1638 | + | |
1632 | 1639 | | |
1633 | 1640 | | |
1634 | 1641 | | |
| |||
1668 | 1675 | | |
1669 | 1676 | | |
1670 | 1677 | | |
1671 | | - | |
| 1678 | + | |
1672 | 1679 | | |
1673 | 1680 | | |
1674 | 1681 | | |
| |||
1683 | 1690 | | |
1684 | 1691 | | |
1685 | 1692 | | |
| 1693 | + | |
1686 | 1694 | | |
1687 | 1695 | | |
1688 | | - | |
| 1696 | + | |
1689 | 1697 | | |
1690 | 1698 | | |
1691 | 1699 | | |
| |||
1696 | 1704 | | |
1697 | 1705 | | |
1698 | 1706 | | |
| 1707 | + | |
1699 | 1708 | | |
1700 | 1709 | | |
1701 | | - | |
| 1710 | + | |
1702 | 1711 | | |
1703 | 1712 | | |
1704 | 1713 | | |
| |||
1746 | 1755 | | |
1747 | 1756 | | |
1748 | 1757 | | |
1749 | | - | |
| 1758 | + | |
1750 | 1759 | | |
1751 | 1760 | | |
1752 | 1761 | | |
| |||
1762 | 1771 | | |
1763 | 1772 | | |
1764 | 1773 | | |
1765 | | - | |
| 1774 | + | |
1766 | 1775 | | |
1767 | 1776 | | |
1768 | 1777 | | |
| |||
1779 | 1788 | | |
1780 | 1789 | | |
1781 | 1790 | | |
1782 | | - | |
| 1791 | + | |
1783 | 1792 | | |
1784 | 1793 | | |
1785 | 1794 | | |
| |||
0 commit comments