ray-project / ray

Ray is a unified framework for scaling AI and Python applications. Ray consists of a core distributed runtime and a set of AI Libraries for accelerating ML workloads.
https://ray.io
Apache License 2.0
32.93k stars 5.57k forks source link

[Tune] Quantized with q=1 bug #45494

Open vakker opened 3 months ago

vakker commented 3 months ago

What happened + What you expected to happen

If I run tune.quniform(-10,10, 1).sample() then it doesn't follow the quantization. If I use anything else than 1 then it works. There's a special case for Quantized here, which changes for only q=1. This is a bit confusing, and misleading, which can result in weird bugs (as it did in my case).

Versions / Dependencies

Ray: d9e795c (current master)

Reproduction script

from ray import tune

[tune.quniform(-10,10, 2).sample() for _ in range(10)]
# [-4.0, 10.0, -10.0, 4.0, -6.0, 4.0, 8.0, 8.0, -0.0, 8.0]

[tune.quniform(-10,10, 1).sample() for _ in range(10)]
# [4.475882088058176, ... ]

Issue Severity

Medium: It is a significant difficulty but I can work around it.

hongpeng-guo commented 3 months ago

@justinvyu Can you remind me why do we have a special case here for q=1 https://github.com/ray-project/ray/blob/d9e795c17a6d4fe61fa57f691c9bcc60dcace72e/python/ray/tune/search/sample.py#L552-L553