Skip to content

Conversation

aztice
Copy link
Contributor

@aztice aztice commented Sep 30, 2025

PR Category

Operator Mechanism

PR Types

New features

Description

由于PR Types只给选择一个类型,其实我建议可以改成两个,具体直接在下面标注了
增强特性

将所有 paddle.disable_static() 以及 paddle.enable_static()with paddle.base.dygraph.guard() 代替,同时建议在后续可能存在的新feature采用自动的 disable + enable,避免意外。

新增特性

新增了 GPU + CPU 的一致性检查。

@unittest.skipIf(
    not (core.is_compiled_with_cuda() or is_custom_device()),
    "only support compiled with CUDA.",
)
class TestGatherGPUCPUConsistency(unittest.TestCase):
    def test_gpu_cpu_consistency(self):
        with paddle.base.dygraph.guard():
            np.random.seed(42)
            x = np.random.rand(1000, 128).astype("float32")
            index = np.random.randint(0, 1000, size=(100,))
            cpu_out = paddle.gather(
                paddle.to_tensor(x, place=paddle.CPUPlace()),
                paddle.to_tensor(index),
            )
            gpu_out = paddle.gather(
                paddle.to_tensor(x, place=paddle.CUDAPlace(0)),
                paddle.to_tensor(index),
            )
            np.testing.assert_allclose(
                cpu_out.numpy(), gpu_out.numpy(), rtol=1e-6
            )

Result

/opt/conda/envs/python35-paddle120-env/lib/python3.10/site-packages/paddle/base/framework.py:722: VisibleDeprecationWarning: 
Warning:
API "paddle.base.dygraph.tensor_patch_methods.gradient" is deprecated since 2.1.0, and will be removed in future versions.
    Reason: Please use tensor.grad, which returns the tensor value of the gradient. 
  return func(*args, **kwargs)
...........
----------------------------------------------------------------------
Ran 129 tests in 84.951s

OK

As a result, OK nya~

@luotao1 @YqGe585

Copy link

paddle-bot bot commented Sep 30, 2025

你的PR提交成功,感谢你对开源项目的贡献!
请关注后续CI自动化测试结果,详情请参考Paddle-CI手册
Your PR has been submitted. Thanks for your contribution!
Please wait for the result of CI firstly. See Paddle CI Manual for details.

@paddle-bot paddle-bot bot added the contributor External developers label Sep 30, 2025
Copy link
Contributor

@YqGe585 YqGe585 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

luotao1
luotao1 previously approved these changes Sep 30, 2025
@aztice
Copy link
Contributor Author

aztice commented Sep 30, 2025

/re-run all-failed

1 similar comment
@aztice
Copy link
Contributor Author

aztice commented Sep 30, 2025

/re-run all-failed

@aztice
Copy link
Contributor Author

aztice commented Sep 30, 2025

Notice

本单测的guard疑似出现问题,已还原。

@aztice
Copy link
Contributor Author

aztice commented Oct 1, 2025

Windows CI似乎有问题,这边看到一个没有Response,一个一秒就失败了,check approval可以忽略通常。

@aztice
Copy link
Contributor Author

aztice commented Oct 1, 2025

/re-run all-failed

@aztice aztice requested a review from luotao1 October 1, 2025 15:25
Copy link
Contributor

@YqGe585 YqGe585 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@aztice
Copy link
Contributor Author

aztice commented Oct 9, 2025

/re-run all-failed

@aztice
Copy link
Contributor Author

aztice commented Oct 9, 2025

/re-run all-failed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
contributor External developers HappyOpenSource 快乐开源活动issue与PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants