diff --git a/python/paddle/nn/functional/flash_attention.py b/python/paddle/nn/functional/flash_attention.py index 11b85df5d1377..c9d1c4bf4da3c 100644 --- a/python/paddle/nn/functional/flash_attention.py +++ b/python/paddle/nn/functional/flash_attention.py @@ -183,10 +183,22 @@ def flash_attention( >>> import paddle - >>> paddle.seed(1) + >>> paddle.seed(2023) >>> q = paddle.rand((1, 128, 2, 16)) >>> output = paddle.nn.functional.flash_attention.flash_attention(q, q, q, 0.9, False, False) + >>> print(output) + (Tensor(shape=[1, 128, 2, 16], dtype=float32, place=Place(cpu), stop_gradient=True, + [[[[0.34992966, 0.34456208, 0.45826620, ..., 0.39883569, + 0.42132431, 0.39157745], + [0.76687670, 0.65837246, 0.69117945, ..., 0.82817286, + 0.76690865, 0.71485823]], + ..., + [[0.71662450, 0.57275224, 0.57053083, ..., 0.48108247, + 0.53336465, 0.54540104], + [0.59137970, 0.51350880, 0.50449550, ..., 0.38860250, + 0.40526697, 0.60541755]]]]), None) + """ head_dim = query.shape[3] sdp_func_name = _select_sdp(head_dim) @@ -339,12 +351,16 @@ def flash_attn_unpadded( Examples: .. code-block:: python + >>> # doctest: +SKIP("`is_sm8x || is_sm75` check failed at /paddle/third_party/flashattn/csrc/flash_attn/flash_attn.cpp:293") >>> import paddle - >>> paddle.seed(1) - >>> q = paddle.rand((1, 128, 2, 16)) - >>> output = paddle.nn.functional.flash_attention.flash_attn_unpadded(q, q, q, 0.9, False, False) + >>> paddle.seed(2023) + >>> q = paddle.rand((2, 128, 8, 16), dtype='float16') + >>> cu = paddle.arange(0, 384, 128, dtype='int32') + >>> qq = paddle.reshape(q, [256, 8, 16]) + >>> output = paddle.nn.functional.flash_attention.flash_attn_unpadded(qq, qq, qq, cu, cu, 128, 128, 0.25, 0.0, False, False) >>> print(output) + >>> # doctest: -SKIP """ if in_dynamic_mode(): ( @@ -461,7 +477,7 @@ def scaled_dot_product_attention( Examples: .. code-block:: python - >>> # doctest: +SKIP() + >>> # doctest: +SKIP((InvalidArgument) flash_attn(): argument (position 5) must be double, but got NoneType (at ../paddle/fluid/pybind/op_function_common.cc:241)) >>> import paddle >>> q = paddle.rand((1, 128, 2, 16), dtype=paddle.bfloat16) >>> output = paddle.nn.functional.scaled_dot_product_attention(q, q, q, None, 0.9, False) diff --git a/python/paddle/quantization/config.py b/python/paddle/quantization/config.py index 28feb8c6b087f..81a09190c605c 100644 --- a/python/paddle/quantization/config.py +++ b/python/paddle/quantization/config.py @@ -127,12 +127,10 @@ def add_layer_config( >>> quanter = FakeQuanterWithAbsMaxObserver(moving_rate=0.9) >>> q_config = QuantConfig(activation=None, weight=None) >>> q_config.add_layer_config([model.fc], activation=quanter, weight=quanter) - >>> # doctest: +SKIP - >>> print(q_config) - Global config: - None - Layer prefix config: - {'linear_0': } + >>> print(q_config.default_qat_layer_mapping) + {: , + : , + : } """ if isinstance(layer, list): @@ -176,12 +174,10 @@ def add_name_config( >>> quanter = FakeQuanterWithAbsMaxObserver(moving_rate=0.9) >>> q_config = QuantConfig(activation=None, weight=None) >>> q_config.add_name_config([model.fc.full_name()], activation=quanter, weight=quanter) - >>> # doctest: +SKIP - >>> print(q_config) - Global config: - None - Layer prefix config: - {'linear_0': } + >>> print(q_config.default_qat_layer_mapping) + {: , + : , + : } """ if isinstance(layer_name, str): @@ -226,12 +222,10 @@ def add_type_config( >>> quanter = FakeQuanterWithAbsMaxObserver(moving_rate=0.9) >>> q_config = QuantConfig(activation=None, weight=None) >>> q_config.add_type_config([Linear], activation=quanter, weight=quanter) - >>> # doctest: +SKIP - >>> print(q_config) - Global config: - None - Layer type config: - {: } + >>> print(q_config.default_qat_layer_mapping) + {: , + : , + : } """ if isinstance(layer_type, type) and issubclass( diff --git a/python/paddle/quantization/factory.py b/python/paddle/quantization/factory.py index b0ef906220186..14d00f1034e6f 100644 --- a/python/paddle/quantization/factory.py +++ b/python/paddle/quantization/factory.py @@ -83,8 +83,7 @@ def quanter(class_name): Examples: .. code-block:: python - >>> # doctest: +SKIP - >>> # Given codes in ./customized_quanter.py + >>> from paddle.quantization import QuantConfig >>> from paddle.quantization import quanter >>> from paddle.quantization import BaseQuanter >>> @quanter("CustomizedQuanter") @@ -92,13 +91,14 @@ def quanter(class_name): ... def __init__(self, arg1, kwarg1=None): ... pass - >>> # Used in ./test.py - >>> # from .customized_quanter import CustomizedQuanter - >>> from paddle.quantization import QuantConfig >>> arg1_value = "test" >>> kwarg1_value = 20 >>> quanter = CustomizedQuanter(arg1_value, kwarg1=kwarg1_value) >>> q_config = QuantConfig(activation=quanter, weight=quanter) + >>> print(q_config) + Global config: + activation: CustomizedQuanter(test,kwarg1=20) + weight: CustomizedQuanter(test,kwarg1=20) """ diff --git a/python/paddle/tensor/linalg.py b/python/paddle/tensor/linalg.py index 97172e39b5492..8983e4e5fd05b 100644 --- a/python/paddle/tensor/linalg.py +++ b/python/paddle/tensor/linalg.py @@ -1958,14 +1958,12 @@ def slogdet(x, name=None): >>> import paddle >>> paddle.seed(2023) - >>> x = paddle.randn([3,3,3]) + >>> x = paddle.randn([3, 3, 3]) >>> A = paddle.linalg.slogdet(x) >>> print(A) - >>> # doctest: +SKIP Tensor(shape=[2, 3], dtype=float32, place=Place(cpu), stop_gradient=True, [[-1. , 1. , 1. ], [ 0.25681755, -0.25061053, -0.10809582]]) - >>> # doctest: -SKIP """ if in_dynamic_mode():