Children forked after a run generate identical sampler data
Maintainer thường phản hồi trong vòng 1 ngày
Đánh giá
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức phù hợp với người mới
- 25/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức độ hoạt động
- Đình trệ
- Công nghệ
- numpy, python
- Lĩnh vực
- data-engineering
Hướng nghiên cứu
Start at engine/sampling_gen/utils.py:36, where check_random_state(None) selects NumPy's global generator, and trace Faker and distribution sampling paths used by preview() and create(). Use the issue's multiprocessing reproduction to compare fork and spawn, preserving in-process seeding tested by scripts/benchmarks/benchmark_engine_v2.py. Done means forked workers produce independent sampler data while explicit process-local seeding remains repeatable; note that linked PR #1077 already targets this issue.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Priority Level
Medium (Annoying but has workaround)
Describe the bug
Every child forked after the parent has run preview() or create() generates the same sampler data. Nothing fails or warns; a fork pool of N workers returns N copies of one dataset's sampler columns.
Samplers draw from numpy's global RandomState (check_random_state(None) returns np.random.mtrand._rand, engine/sampling_gen/utils.py:36) and from Faker's shared Random (faker.generator.random, used by every Faker(locale) instance). A fork copies their state, and nothing reseeds it: CPython reseeds the stdlib random module in a forked child, but not numpy's global generator or Faker's. Each child therefore draws the same sequence.
Before #1069 the forked child hung on its first run (#1068), so this was not reachable. With that fix merged, any fork pool created after a first run hits it. fork is the Linux default on Python 3.10–3.13.
Affected: every sampler that draws from scipy/numpy (category, uniform, gaussian, and the other distribution samplers), person_from_faker, and distribution-valued inference parameters (temperature, top_p), which also use numpy's global generator. Not affected: UUIDs, managed-dataset person sampling (DuckDB), and code using the stdlib random module.
Steps/Code to reproduce bug
No model provider needed:
import multiprocessing as mp
import data_designer.config as dd
from data_designer.interface import DataDesigner
def preview(_: int = 0) -> list:
builder = dd.DataDesignerConfigBuilder()
builder.add_column(dd.SamplerColumnConfig(
name="category", sampler_type=dd.SamplerType.CATEGORY,
params=dd.CategorySamplerParams(values=list("abcdefgh"))))
builder.add_column(dd.SamplerColumnConfig(
name="uniform", sampler_type=dd.SamplerType.UNIFORM,
params=dd.UniformSamplerParams(low=0, high=1000)))
df = DataDesigner().preview(builder, num_records=4).dataset
return [f"{c}:{u:.1f}" for c, u in zip(df["category"], df["uniform"])]
if __name__ == "__main__":
preview() # a parent run, e.g. checking the config before fanning out
for method in ("fork", "spawn"):
with mp.get_context(method).Pool(3) as pool:
rows = pool.map(preview, range(3))
print(f"{method:<5} distinct worker outputs: {len(set(map(tuple, rows)))} of 3")
for r in rows:
print(" ", r)
Output on main (2c9b66ef, CPython 3.14.0, numpy 2.4.3, Faker 20.1.0, Linux):
fork distinct worker outputs: 1 of 3
['b:965.9', 'c:719.3', 'h:599.7', 'a:869.9']
['b:965.9', 'c:719.3', 'h:599.7', 'a:869.9']
['b:965.9', 'c:719.3', 'h:599.7', 'a:869.9']
spawn distinct worker outputs: 3 of 3
['h:910.8', 'g:252.2', 'g:270.8', 'b:558.7']
['g:1.1', 'a:485.1', 'e:968.6', 'a:27.8']
['a:624.4', 'f:66.1', 'g:708.3', 'e:586.6']
Expected behavior
Forked children generate independent sampler data, as spawn children do.
Agent Diagnostic / Prior Investigation
Found by an agent sweeping the codebase for process-global state after #1069. It confirmed:
numpy.randomis not reseeded after fork once the parent has drawn from it. numpy seeds the global generator lazily, so children forked before any draw happen to differ.faker.generator.randomis not reseeded after fork, andFaker(locale).random is faker.generator.random.- The stdlib
randommodule is reseeded after fork by CPython.
The repo's own benchmark (scripts/benchmarks/benchmark_engine_v2.py:585-586) seeds random and numpy.random for repeatable sampler output, so a fix should keep in-process seeding working.
Additional context
Workaround: use mp.get_context("spawn") or "forkserver", or call numpy.random.seed() and faker.Faker.seed() with no argument at the start of each forked worker.
Related: #1068, #1069.
- Ngôn ngữ chính
- Python
- Star
- 2.4k
- Fork
- 234
- Merge trung bình
- 23 giờ
- Pull request đã merge (30 ngày)
- 75
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- 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.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của NVIDIA-NeMo/DataDesigner
-
`ValidationColumnConfig` misaligns rows and discards the whole batch after an upstream row is droppedCó thể đã có người làm @suryapilla đã nhận 1 ngày trước. Đang mởtriaged
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
NVIDIA-NeMo/DataDesigner#1073 · 4 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
docs: required_columns description is incomplete for LLM and multimodal columnsCó thể đã có người làm @rksharma-owg đã nhận 7 ngày trước. Đang mởbug triaged
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
NVIDIA-NeMo/DataDesigner#1002 · 4 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
enforce \from future import annotations` via ruff FA102 rule`Có thể đã có người làm @chethanuk đã nhận 43 ngày trước. Đang mởtask
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
NVIDIA-NeMo/DataDesigner#760 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
enhancement
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 58/100
NVIDIA-NeMo/DataDesigner#1085 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
bug
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 78/100
NVIDIA-NeMo/DataDesigner#1082 ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của NVIDIA-NeMo/DataDesigner
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 84/100
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 77/100
AstrBotDevs/AstrBot#10720 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
fix(xiaomi): curated picker list still offers six ids that return 400 (plan-limited vs retired)Đang mởcause/upstream comp/cli P2 provider/other tool/file type/bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
NousResearch/hermes-agent#143900 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 1/5 1-3 giờ Mức phù hợp với người mới 85/100
WLAN-Pi/wlanpi-profiler#341 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 77/100
Maintainer thường phản hồi trong vòng 1 ngày