# v6/v7 Zero-Base Re-Audit (2026-03-23)

## 1) User Goal (frozen)

- Core objective: use DANTE to solve a CFD control problem under expensive evaluations.
- Key transformation: convert control policy search into low-sample parameter optimization.
- Practical constraints:
  - one run is very expensive (about one day), so no destructive trial-and-error on running jobs;
  - surrogate must be trainable from small initial database;
  - acquisition should discover high-reward basin instead of drifting to easy-to-fit boundary regions.

## 2) Paper-to-Task Mapping (DANTE original intent)

From `DANTE/paper/s43588-025-00858-x.md`:

- DANTE is designed for non-cumulative objective optimization with limited data.
- Key mechanisms are:
  - DUCB exploration term based on visit counts and surrogate value;
  - conditional selection (avoid value deterioration);
  - local backpropagation of visits;
  - adaptive exploration scaling;
  - top-visit + high-score mixed sampling.
- Paper also emphasizes DNN surrogate expressivity as a key success factor.
- For control tasks (paper lunar landing case), conversion is done by fixing initial condition and optimizing pre-designed action parameterization.

Interpretation for this project:

- the controller parameterization quality is first-order (decides landscape smoothness and identifiability);
- surrogate quality under small data is second-order but still critical;
- if parameterization induces heavy truncation/failure regions, DANTE will tend to exploit boundary patterns and stall locally.

## 3) Original DANTE Code Baseline (reference behavior)

From `DANTE/dante/tree_exploration.py`:

- Tree expansion mutates one or multiple dimensions with discrete step `turn`.
- Choose step uses UCB-like criterion with `value + exploration_weight * sqrt(logN/(n+1))`.
- Conditional selection exists: continue with root unless child UCB exceeds root.
- Local backpropagation is implemented as local visit count update (`self.N[path] += 1`).
- Candidate set mixes:
  - most visited nodes,
  - top predicted nodes,
  - random nodes.

From `DANTE/dante/neural_surrogate.py`:

- Surrogate design is deep Conv1D-heavy, matching paper claim.

Important baseline implication:

- DANTE search quality assumes surrogate can provide stable relative ranking.
- If surrogate fitting is unstable/biased, UCB dynamics may push toward artificial easy zones (often boundaries).

## 4) v6/v7 Parameterization Audit

### v6 (closed-loop basis controller)

From `scripts/d1a3o12_250421_dante_v6.py`:

- parameterization: per-action bias + basis coefficients (compact basis profile), total dims = 18 in current run;
- controller includes derivative and one-step action history terms (`dobs*`, `act*_l1`), introducing piecewise/non-smooth response wrt parameters;
- candidate evaluation uses hard reset and truncation-aware fallback;
- invalid sample (`failure_code != 0`) is not added to training set.

Potential risk:

- derivative/history terms can create sensitive local discontinuities under rollout + truncation, making small-data surrogate fitting harder.

### v7 (open-loop periodic)

From `scripts/d1a3o12_250421_dante_v7_openloop.py`:

- parameterization: direct periodic control points, dims = 24 (3 channels * 8 control points), optional period parameter;
- non-integer period supported via continuous phase accumulation;
- period initialized from PPO data FFT median (`period_steps ~= 15.789` currently).

Expected advantage:

- objective wrt parameters is smoother than closed-loop derivative/history mapping;
- better surrogate learnability under limited data.

## 5) Live Evidence From Current Runs

Data extracted from:

- `output/d1a3o12_250421_forces02_dante_v6_3_database_live.npz`
- `output/d1a3o12_250421_forces02_dante_v6_3_dante_log.csv`
- `output/d1a3o12_250421_forces02_dante_v7_1_database_live.npz`
- `output/d1a3o12_250421_forces02_dante_v7_1_dante_log.csv`
- runtime logs: `scripts/nohup_dante_v6.out`, `scripts/nohup_dante_v7.out`

### 5.1 Boundary drift (major)

v6_3:

- init boundary ratio `|x|>=0.95`: 0.0744
- acquired boundary ratio `|x|>=0.95`: 0.5342
- init exact boundary `|x|==1`: 0.0225
- acquired exact boundary `|x|==1`: 0.5010

v7_1:

- init boundary ratio `|x|>=0.95`: 0.0727
- acquired boundary ratio `|x|>=0.95`: 0.4485
- init exact boundary `|x|==1`: 0.0247
- acquired exact boundary `|x|==1`: 0.4293

Conclusion:

- both v6 and v7 still show strong boundary-seeking collapse;
- v7 is better than v6 but problem remains.

### 5.2 Initial database learnability vs later acq

v6_3:

- init scaled reward mean/max: 13.2496 / 29.3712
- acquired scaled reward mean/max: 14.4590 / 25.3012

Interpretation:

- acquisition improves mean a little, but fails to exceed init max;
- indicates poor exploration of true high-reward basin (or surrogate ranking mismatch).

v7_1:

- init scaled reward mean/max: 17.4189 / 33.5647
- acquired scaled reward mean/max: 19.2403 / 36.9052

Interpretation:

- v7 acquisition can surpass init max, consistent with smoother parameterization.

### 5.3 Invalid/truncation pressure

v6_3:

- invalid ratio in dante_log: 0.3626 (194 / 535)

v7_1:

- invalid ratio in dante_log: 0.0 (0 / 401)

Interpretation:

- v6 landscape is heavily constrained by invalid regions, harming surrogate data quality;
- v7 reduces this burden substantially.

### 5.4 Surrogate quality and cuDNN symptom

v6 log (`nohup_dante_v6.out`):

- repeated `surrogate cnn failed: cuDNN ...`;
- val_r2 stats: mean -0.3763, max 0.0820, min -1.9995.

v7 log (`nohup_dante_v7.out`):

- repeated cnn fail still present;
- selected architecture mostly `mlp`;
- val_r2 stats: mean 0.0790, max 0.3766, min -0.2300.

Interpretation:

- v6 fitting is notably weak;
- v7 fitting is better but still fragile;
- cnn failure currently forces implicit fallback behavior and noisy model-selection dynamics.

## 6) Root-Cause Stack (ordered)

### RC-1: Parameterization-induced landscape hardness (primary)

- v6 closed-loop basis with derivative/history terms + truncation recovery introduces high local nonlinearity and effective discontinuities.
- This directly raises surrogate fitting difficulty from small initial data.

### RC-2: Search distribution collapse to boundaries (primary)

- acquisition increasingly samples boundary points where surrogate/DUCB can maintain confidence but true objective improvement is limited.
- consistent with "easy-to-fit but locally suboptimal" phenomenon described by user.

### RC-3: Surrogate architecture instability on this runtime (secondary but severe)

- CNN path repeatedly fails in runtime logs (`CUDNN_STATUS_MAPPING_ERROR`), creating inconsistent ensemble behavior.

### RC-4: DANTE defaults not retuned for this control manifold (secondary)

- current `TreeExploration` defaults (`ratio`, `num_list`, rollout schedule) are inherited from generic synthetic settings;
- not yet adapted to constrained CFD control manifold where invalid-region pressure is high.

## 7) Gap vs Paper Design (why drift happens)

- Paper success assumes expressive and stable DNN surrogate; current runtime repeatedly disables CNN branch in practice.
- Paper uses adaptive exploration with data-driven scaling; current runs mostly use fixed defaults, lacking targeted anti-collapse constraints.
- Paper top-visit sampling helps diversity; but when candidate generation is already boundary-dominated, top-visit can reinforce collapse.

This is not a contradiction of DANTE; it is a mismatch between:

- control parameterization geometry,
- runtime surrogate stability,
- and search hyperparameters calibrated for this geometry.

## 8) Immediate Non-Destructive Plan (no killing running jobs)

1. Continue current jobs untouched; only monitor and collect diagnostics.
2. Build an offline replay audit from existing `database_live + dante_log`:
   - per-acq boundary ratio trend,
   - per-acq surrogate r2 trend,
   - per-acq invalid ratio trend,
   - best-so-far progression.
3. Design v6.1/v7.1 candidates as code patches only (not executed yet):
   - explicit anti-boundary regularization in candidate filter or score,
   - tree expansion step schedule tied to valid-region occupancy,
   - manifold-aware initialization (seed around top PPO + noise, not pure uniform only).
4. Run tiny dry-run diagnostics on copied DB (no CFD call) to test whether modified acquisition reduces boundary concentration.
5. Only after user确认, start a new expensive run.

## 9) Frozen Facts (for anti-forget)

- User explicitly disallows interrupting expensive ongoing runs.
- Main blocker hierarchy:
  1) initial DB hard to fit,
  2) best region not reached,
  3) DANTE drifts to boundaries and gets local-trapped.
- Core mission is control-to-parameter conversion quality, not just fixing runtime errors.

---

This file is the session source-of-truth for re-audit decisions and will be continuously appended.

## 10) Additional Mismatch Checks (new)

### 10.1 Batch-size mismatch vs paper regime

Paper states small-batch active loop (`batch size <= 20`) for efficient convergence in scarce-data settings.

Current runs:

- v6: `samples_per_acq = 18` (within paper range)
- v7: `samples_per_acq = 24` (outside paper range)

Risk:

- larger batch can over-commit to one surrogate snapshot and reduce corrective feedback frequency;
- this can reinforce boundary drift when surrogate ranking is biased.

### 10.2 Exploration hyperparameters are generic defaults

`TreeExploration` is instantiated with default settings, not task-adapted settings:

- fixed `ratio`, fixed `num_list`, fixed rollout schedule;
- no explicit anti-boundary penalty;
- no validity-aware expansion constraints.

Risk:

- defaults derived from synthetic objective settings may not transfer to CFD control landscape with truncation boundaries.

### 10.3 Objective uses valid-only dataset update

Current logic drops invalid samples from surrogate training.

Benefit:

- avoids contaminating reward regression with hard-zero artifacts.

Cost:

- surrogate receives no direct supervision of boundary-danger zones;
- acquisition can repeatedly propose invalid-adjacent points before feedback correction.

### 10.4 PPO-derived period estimate is stable (not a major uncertainty)

From three seeds and three channels, dominant period is consistently `15.789`.

Implication:

- v7 underperformance is not caused by noisy period inference;
- main issue remains search distribution + surrogate dynamics.

## 11) Parameter-Optimization Reformulation Guidance (for next version design)

The main design question is not "which optimizer" but "which parameter manifold makes reward smooth and identifiable".

### 11.1 v6 closed-loop manifold issue

- derivative/history terms increase temporal expressivity but amplify local ruggedness under truncation.
- this tends to create disconnected feasible islands, hard for small-data surrogate.

### 11.2 v7 open-loop manifold benefit and limitation

- control-point periodic manifold is smoother and easier to fit;
- but unconstrained amplitude still allows edge-seeking behavior.

### 11.3 Recommended manifold constraints (code changes pending user approval)

1. Soft amplitude regularization in acquisition score:
  - add penalty term proportional to boundary occupancy ratio.
2. Smoothness prior for open-loop waveform:
  - penalize adjacent control-point jumps (`L2` on first differences).
3. Feasible-region seeding:
  - replace pure-uniform init with mixture:
    - 60% local perturbation around top PPO trajectories,
    - 40% broad random coverage.
4. Adaptive batch sizing:
  - reduce to 12-18 when surrogate `val_r2` is low; restore when stable.
5. Validity-aware replay buffer for surrogate:
  - keep a small labeled set of invalids with separate classifier head (or weighted regression mask) to teach boundary avoidance.

## 12) Next-Step Deliverables (without stopping current runs)

1. Generate per-acquisition diagnostics from current live logs:
  - boundary ratio trend;
  - invalid ratio trend;
  - surrogate val_r2 trend;
  - best-so-far improvement slope.
2. Draft patch set for v6.1/v7.1 only as code diff (not executed).
3. Provide a strict pre-run checklist to prevent another full-day failed run.

## 13) Per-Acquisition Trend Audit (new offline diagnostics)

Generated artifacts:

- `output/report_dante_v2_v5_v6/v6_v7_acq_diagnostics_summary_20260323.json`
- `output/report_dante_v2_v5_v6/d1a3o12_250421_forces02_dante_v6_3_acq_diagnostics.csv`
- `output/report_dante_v2_v5_v6/d1a3o12_250421_forces02_dante_v6_3_acq_diagnostics.png`
- `output/report_dante_v2_v5_v6/d1a3o12_250421_forces02_dante_v7_1_acq_diagnostics.csv`
- `output/report_dante_v2_v5_v6/d1a3o12_250421_forces02_dante_v7_1_acq_diagnostics.png`

### 13.1 v6_3 trend summary

- logged acquisitions: 17
- mean invalid ratio: 0.4444
- mean accepted-boundary ratio (`|x|>=0.95`): 0.4902
- accepted-boundary slope over acquisitions: +0.00278 (still worsening)
- best reward at acq end: 0.29371179 -> 0.29371179 (no improvement)
- mean best-gain-per-acq: 0.0
- surrogate mean val_r2: -0.3763

Interpretation:

- v6 is effectively stalled in exploitation of a non-improving region.
- surrogate quality remains too weak to provide useful ranking lift.
- boundary pressure and invalid pressure co-exist and reinforce local trapping.

### 13.2 v7_1 trend summary

- logged acquisitions: 8
- mean invalid ratio: 0.0
- mean accepted-boundary ratio (`|x|>=0.95`): 0.4353
- accepted-boundary slope over acquisitions: -0.0772 (boundary pressure decreasing in current window)
- best reward at acq end: 0.33564682 -> 0.36905161 (improving)
- mean best-gain-per-acq: +0.00220
- surrogate mean val_r2: +0.0790

Interpretation:

- v7 currently shows positive progress and reduced collapse tendency, but absolute boundary occupancy is still high.
- this confirms parameterization smoothing helps, yet anti-boundary control is still missing.

### 13.3 Differential diagnosis update

Compared with previous section conclusions, new trend evidence strengthens:

1. The main blocker is not only cuDNN/runtime instability; even with fallback, v6 search dynamics are fundamentally unhealthy.
2. The controller parameterization change (v6 -> v7) directly changes optimization geometry and data efficiency.
3. Without explicit boundary-aware acquisition shaping, both variants remain vulnerable to local attractors near constraints.

## 14) Patch Blueprint (audit-level, not executed)

### 14.1 v6.1 (closed-loop) minimal-risk changes

1. Replace default basis profile from `compact_deriv_nl` to a smoother profile for first-stage search.
2. Add acquisition-time boundary penalty (score-level, not objective rewrite):
  - penalize candidate if high fraction of dimensions satisfy `|x| >= 0.95`.
3. Add surrogate reliability gate:
  - if `val_r2 < 0`, reduce effective exploration radius and acquisition batch for next round.

Expected outcome:

- reduce invalid-rate and boundary-collapse speed;
- restore monotonic best progression possibility.

### 14.2 v7.1 (open-loop) minimal-risk changes

1. Set `samples_per_acq` from 24 to <=20 (paper-consistent low-batch regime).
2. Add waveform smoothness regularization in candidate scoring:
  - penalty on first differences of control points for each channel.
3. Add amplitude soft cap in acquisition ranking to avoid full-range saturation.

Expected outcome:

- preserve current positive trend while reducing residual boundary occupancy.

## 15) Zero-Risk Validation Checklist (before any new 1-day run)

1. Offline replay check on existing DB/log:
  - boundary ratio in top-ranked candidates should drop vs baseline.
2. Surrogate holdout check:
  - `val_r2` distribution should improve or at least not degrade.
3. Short synthetic call-chain smoke (no CFD heavy run):
  - no runtime errors in surrogate fit + rollout.
4. Dry launch first 1-2 acquisitions only, then inspect:
  - invalid ratio,
  - boundary ratio,
  - best gain in acquisition.
5. Only if above pass, start full-day run.

## 16) Latest Runtime Validation (2026-03-23, non-destructive)

Validation goal:

- verify whether current code path still throws `CUDNN_STATUS_MAPPING_ERROR` during CNN surrogate fit.

Validation method (no long-run, no environment-day run):

1. Confirm no active v6/v7 process.
2. Use current `scripts/dante_v6_surrogate_torch.py` directly.
3. Load live DB from:
  - `output/d1a3o12_250421_forces02_dante_v6_3_database_live.npz`
  - `output/d1a3o12_250421_forces02_dante_v7_1_database_live.npz`
4. Run CNN fit + predict on target GPUs:
  - case A: v6 DB on GPU:1
  - case B: v7 DB on GPU:0

Observed result:

- case A: PASS, no cuDNN mapping error, `val_r2=0.3204`, `device=GPU:1`.
- case B: PASS, no cuDNN mapping error, `val_r2=0.5205`, `device=GPU:0`.
- overall status: `RESULT PASS`.

Important interpretation:

- Historical `nohup` logs still show repeated `surrogate cnn failed ... CUDNN_STATUS_MAPPING_ERROR` because they come from earlier runs.
- Current surrogate module path can execute CNN fit/predict successfully on GPU in isolated validation.
- Full conclusion for "problem fully solved" still requires at least one fresh acquisition-stage real run log without this error.
