Skip to content

fix: the swept dt values must be distinct on disk - #8

Merged
sotashimozono merged 1 commit into
mainfrom
fix/the-swept-dt-values-must-be-distinct-on-disk
Sep 9, 2026
Merged

sotashimozono merged 1 commit into
mainfrom
fix/the-swept-dt-values-must-be-distinct-on-disk

Conversation

@sotashimozono

Copy link
Copy Markdown
Member

Description

production.toml swept the natural halving sequence, and the natural halving sequence is the
wrong answer. A swept float reaches its directory name through %.2f.

Type of Change

  • 🐛 Bug Fix (bug)

Proposed Changes

dt = [1e-2, 5e-3, 2.5e-3, 1.25e-3] renders as 0.01, 0.01, 0.00, 0.00. Twenty distinct points
claim ten directories; half the sweep silently overwrites the other half while the ledger reports
every point as done. ParamIO.diagnose:

config
smoke.toml ok=true 1 point
debug.toml ok=false 4 points → 2 directories
production.toml ok=false 20 points → 10 directories

Only smoke.toml was clean — and smoke.toml is the one CI runs. That is why a template could
ship a sweep that cannot be run at size.

The replacement values are not free either. MyModule.decay_error takes
n = round(Int, t_end/dt), so a dt that does not divide t_end integrates to a different final
time and contributes an error unrelated to the step size. [0.08, 0.04, 0.02, 0.01] is distinct
on disk and still wrong:

dt=0.08   n=12   n*dt=0.960   err=5.79e-04   err/dt=0.0072
dt=0.04   n=25   n*dt=1.000   err=2.03e-02   err/dt=0.5085
dt=0.02   n=50   n*dt=1.000   err=1.01e-02   err/dt=0.5042
dt=0.01   n=100  n*dt=1.000   err=5.02e-03   err/dt=0.5021

At dt=0.08 the truncation error cancels against the end-time error, so the coarsest point
lands below the finest and the convergence plot reads backwards.

[0.1, 0.05, 0.02, 0.01] satisfies both constraints — distinct under %.2f, exact divisors of
1.0 — and the rendered name equals the value rather than a rounding of it. debug.toml becomes
[0.05, 0.01] for the same reasons.

Usage or Results

# From a fresh copy of the template
cd projects/ExampleSweep
julia --project=. scripts/compute.jl configs/debug.toml
julia --project=. scripts/collect.jl configs/debug.toml
  a        dt         rel_error
  0.5      0.01       1.253e-03
  0.5      0.05       6.336e-03
  1        0.01       5.021e-03
  1        0.05       2.553e-02

  4 points

on-disk key directories:
  sysa0.50_numdt0.01   sysa0.50_numdt0.05   sysa1.00_numdt0.01   sysa1.00_numdt0.05

Four points, four directories, four distinct rows, and err/dt flat across them. All three
configs now report ok=true. test/runtests.jl and report/report.jl both still pass.

The upstream half

DataVault #39 and #41 fix the other side: Vault now honours [datavault] float_format = "auto"
— which was previously read by ParamIO.diagnose and ignored by the writer, so setting it turned
the diagnostic green while the data kept colliding — and warns at construction when a grid
collides at all. With that, a sweep can use whatever values the physics wants.

This template pins the registered DataVault 0.7, so it cannot adopt auto until there is a
release. Changing the values is the fix that works today, and it is the right example regardless:
a template's configs should not need a knob to be correct.

check list

  • ./setup.sh を通したか — configs only, no renamed identifiers touched
  • projects/ExampleSweep が instantiate できるか — compute / collect / report all re-run
  • 新しいファイルを足したなら、setup.sh の書き換え対象に入っているか — no new files
  • 施設固有の記述・資格情報を含めていないか

🤖 Generated with Claude Code

`production.toml` swept `dt = [1e-2, 5e-3, 2.5e-3, 1.25e-3]`, which is the natural
halving sequence and the wrong answer. A swept float reaches its directory name
through `%.2f`, so those four render `0.01, 0.01, 0.00, 0.00`: twenty distinct points
claim ten directories and half the sweep silently overwrites the other half while the
ledger reports every point as done. `debug.toml` had the same shape at four points
into two. `ParamIO.diagnose` said so all along; nothing ran it.

    smoke.toml       ok=true   1 point
    debug.toml       ok=false  4 points ->  2 directories
    production.toml  ok=false 20 points -> 10 directories

Only smoke.toml was clean, and smoke.toml is the one CI runs — which is why this
template shipped a sweep that cannot be run at size.

The replacement values are not free either. `MyModule.decay_error` takes
`n = round(Int, t_end/dt)`, so a dt that does not divide `t_end` integrates to a
different final time and contributes an error that has nothing to do with the step
size. `[0.08, 0.04, 0.02, 0.01]` is distinct on disk and fails this: at dt=0.08 the
integration stops at t=0.96 and the truncation error cancels against the end-time
error, giving 5.79e-04 — SMALLER than the error at dt=0.01, so the coarsest point
would sit below the finest on the convergence plot.

`[0.1, 0.05, 0.02, 0.01]` satisfies both: distinct under `%.2f`, exact divisors of 1.0,
and the rendered name equals the value rather than a rounding of it.

Verified: all three configs `ok=true`; the debug sweep runs to four distinct
directories with four distinct rows, and err/dt stays flat across them; test/runtests.jl
and report.jl both still pass.

The upstream half of this is DataVault #39/#41 — `Vault` now honours
`[datavault] float_format = "auto"`, which lets a sweep use any values it likes, and
warns at construction when a grid collides. This template pins the registered
DataVault 0.7, so it cannot adopt that until a release; the values are the fix that
works today.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@github-actions github-actions Bot added the bug Something isn't working label Sep 9, 2026
@github-actions

github-actions Bot commented Sep 9, 2026

Copy link
Copy Markdown

📚 Docs preview: https://qatlashub.github.io/templateHPC.jl/previews/PR8/

(updates on each push to this PR)

@sotashimozono
sotashimozono merged commit 347f0ee into main Sep 9, 2026
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant