Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

diagnose: the error argument is sent as epsilon; the output directory is never removed

Đang mở Phù hợp với người mới
#871 1 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Đánh giá

Độ khó
2/5
Thời gian dự kiến
1-3 giờ
Mức phù hợp với người mới
62/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
python
Lĩnh vực
tooling

Hướng nghiên cứu

Lỗi nằm trong cmdstanpy/model.py, tại CmdStanModel.diagnose: nhánh error nối thêm epsilon= thay vì error=, và thư mục đầu ra được tạo bằng tempfile.mkdtemp dưới _TMPDIR không bao giờ bị xóa. Hãy bắt đầu bằng việc đọc các kiểm thử của log_prob, vốn kiểm tra lệnh đã ghi log và là mẫu cho một kiểm thử mới. Công việc được coi là hoàn thành khi lệnh chứa error= và số mục trong _TMPDIR không đổi sau các lần gọi trên cả đường thành công lẫn đường thất bại. Hãy kiểm tra #869 trước, vì issue nói rằng cách dọn dẹp đã được thống nhất ở đó.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

Summary

CmdStanModel.diagnose (cmdstanpy develop at the time of writing, also 1.3.0) has two bugs:

  1. The error argument is sent as epsilon. CmdStan never receives error=, and when both arguments are given, epsilon appears twice on the command line.
  2. Each call leaves a temporary output directory under _TMPDIR, removed only at interpreter exit. This is the same pattern as #867, which is being fixed for log_prob in #869.
Where

cmdstanpy/model.py, CmdStanModel.diagnose, on develop:

if epsilon is not None:
    cmd.append(f"epsilon={epsilon}")
if error is not None:
    cmd.append(f"epsilon={error}")      # should be f"error={error}"
...
output_dir = tempfile.mkdtemp(prefix=self.name, dir=_TMPDIR)   # never removed

CmdStan 2.40.0's argument tree accepts both sub-arguments under diagnose test=gradient (output of <model> diagnose help-all):

gradient
  Valid subarguments: epsilon, error
  epsilon=<double>   Finite difference step size     Defaults to 1e-6
  error=<double>     Error threshold                 Defaults to 1e-6
Effect
  • diagnose(error=x) silently sets the finite-difference step to x, and the error threshold stays at its default 1e-6. The gradient check then judges against a threshold the caller did not ask for, using a step size the caller did not ask for.
  • diagnose(epsilon=a, error=b) passes epsilon=a epsilon=b.
  • The output directory accumulates in long-running processes, as described in #867.
Suggested fix
  • Send f"error={error}".
  • Scope the output directory with tempfile.TemporaryDirectory(prefix=self.name, dir=_TMPDIR), the approach agreed on #869.
  • Add a test asserting that the command carries error= (the logged command, as the log_prob tests do) and that _TMPDIR's entry count is unchanged after calls on both the success path and the failure path.

We can fold this into #869, or open a separate PR, whichever you prefer.

Versions

cmdstanpy develop (also 1.3.0), CmdStan 2.40.0, Python 3.12, Linux x86_64.

Ngôn ngữ chính
Python
Star
198
Fork
81
Merge trung bình
6 ngày 15 giờ
Pull request đã merge (30 ngày)
2

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của stan-dev/cmdstanpy

Tất cả issue của stan-dev/cmdstanpy

Issue tương tự

Thêm issue về Python

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.