Monte Carlo results are not bit-reproducible with a fixed SEED (scheduler keeps sweeping past SWEEPS; MPI merges runs in arrival order)

Aperta
#293 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 3 giorni

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
42/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Attiva
Stack tecnologico
cpp

Direzione di ricerca

Start with Worker::run() and SingleScheduler::run() in src/alps/scheduler/src/scheduler/single_scheduler.C, then inspect SlaveTask::run() and MCSimulation::get_measurements, get_summary and work_done in montecarlo.C. Compare the legacy scheduler with mcbase::run in src/alps/mc/src/mcbase.cpp; the issue describes the desired stopping and MPI receive ordering. Done means fixed-seed runs produce identical results and the proposed serial and two-rank run-twice comparisons pass.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

Problem

Two runs of the same task with identical parameters, SEED, binary and one thread give different averages. The random stream is identical; the number of measurements is not.

SingleScheduler::run() (src/alps/scheduler/src/scheduler/single_scheduler.C) performs one dostep() per loop iteration and asks finished() only every Tmin..Tmax seconds (defaults 60 and 900 s). Nothing stops dostep() once work_done() reaches 1, so sweeps accumulate until the next wall-clock check. The serial and MPI schedulers, and MPI slaves via SlaveTask::run(), share the pattern. The newer mcbase::run (src/alps/mc/src/mcbase.cpp) already stops at fraction_completed() >= 1; the legacy scheduler should do the same.

In MPI runs there is a second source: MCSimulation::get_measurements (montecarlo.C) receives remote results with IMPDump receive(MCMP_measurements), that is from MPI_ANY_SOURCE, so runs are merged in arrival order.

Consequences: SWEEPS is a lower bound, no bit-exact regression test exists for any MC application, and a short task runs for at least Tmin after it is done.

Reproduce

spinmc, square lattice L=4, MODEL="Ising", J=1, T=2.269186, THERMALIZATION=20000, SWEEPS=400000, UPDATE="cluster", fixed SEED, --Tmin 5, run twice: |Magnetization| differs at the 1 sigma level. fulldiag, sparsediag and dmrg are bit-identical under the same conditions.

Proposed fix

  1. Step only while work remains, in Worker::run():

    void Worker::run()
    {
      if (started && work_done() < 1.)
        dostep();
    }
    

    The time-based finished() poll then decides only when to halt and write. AbstractSpinSim::work_done() with ERROR_LIMIT computes an error estimate, so cache its result or evaluate it every n sweeps.

  2. Evaluate finished() as soon as all local runs report work_done() >= 1, removing the dead time for short tasks.

  3. Merge remote runs in a fixed order: receive from each process in where_master explicitly (IMPDump receive(where_master[i], MCMP_measurements)), in get_measurements, get_summary and work_done.

  4. Document that a fixed SEED with one thread per run is then bit-reproducible on a given build, and add a run-twice-and-compare test per MC application, serial and with two ranks.

Lingua principale
C++
Stelle
32
Fork
10
Merge medio
4g 14h
PR unite (30g)
46

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di ALPSim/ALPS

Tutte le issue di ALPSim/ALPS

Issue simili

Altre issue su C++

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.