lamlvh 0cfe202a8b Complete P4 Volve; pivot the manuscript to theory + benchmark
P4 (Volve field case). Add the deviated-well and Volve well builders
(ml_porosity/data/deviated.py, volve_wells.py), the ml_porosity/volve/
pipeline, scripts 23-25, the run_p4 drivers and tests. The protocol
configs/protocol_volve.yaml was locked at 2026-10-29T01:17:42Z before the
run (.sha256, .lock.json) and is committed here after the run. Gate G-D
failed: M2-Sa beats the selected B3 at 2/6 wells (lowo) and 3/6 (slot),
coverage90 is about 0.47, and no method has blind-well skill (R2 < 0).
A post hoc constant at the training-well mean beats every network, so
G-D had no power. The dropped P4x exploratory run is kept as a record
only (exploratory/, docs/research/p4-exploratory.md).

Applicability and Teapot Dome (exploratory, pre-declared). Scripts 26-29
and docs/research/applicability-*.md: F3 and Volve fail C1 and pass C2;
T3 power needs 5-18 blind wells with an exact reference; Teapot T0 and
pilot P-a failed, so Teapot is stopped. Raw Teapot data stay gitignored.

Manuscript (Pivot 1, level A). Reframe paper/ as a theory and synthetic
benchmark paper: Propositions 3-6, Corollaries 3-4, T4 coverage
(script 30) and the post hoc H2b bound check (script 31), with F3/Volve
moved to Appendix B. Correct two earlier claims: the Berkson and
classical bounds differ by 1.5-4.6x at the f^4-weighted band, and the
bank gain exceeds the registered classical bound (7/8 wide cells at
N = 16) but only 3/8 under the post hoc Berkson bound.

Docs. Sync plan, AGENTS.md, README, report.html, theory and technical
overview. The length pass for the venue is dropped by the user
(plan section 12 item 25); the length risk stays recorded as R9.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-29 12:18:22 +00:00

ML-Porosity

Dự đoán porosity từ seismic F3 khi well tie không chắc chắn. Kế hoạch: docs/plan.md; tiến độ: report.html.

Cài đặt

python -m venv .venv
.venv/bin/pip install -r requirements-lock.txt
.venv/bin/pip install --no-deps -e .

Dữ liệu F3 Demo 2023 đặt ở data/F3_Demo_2023/F3_Demo_2023/, dữ liệu Volve ở data/Volve/, LAS và TD của NLOG ở data/NLOG/ (hoặc trỏ ML_POROSITY_F3_ROOT tới thư mục chứa .survey). Kết quả ghi vào outputs/ (đổi bằng ML_POROSITY_OUTPUTS).

Code luận văn được lưu ở code_thesis/, các output gốc ở outputs_thesis/. SHA-256 của 7 artifact nằm trong data_manifest/thesis_outputs.json; kết quả kiểm tra ngày 27/10/2026 ở thesis-output-audit.md. Pipeline nghiên cứu ghi kết quả mới vào outputs/.

P3 trên Windows / RTX 3060

Môi trường trên máy này: Python 3.12.16, PyTorch 2.11.0+cu128, driver NVIDIA 577.00, RTX 3060 12 GB và RAM 24 GB. Các phiên bản được lưu riêng trong requirements-windows-rtx3060.txt; không thay bản khóa môi trường Linux. Cài vào venv bằng uv pip install --python .venv/Scripts/python.exe -r requirements-windows-rtx3060.txt, rồi cài project bằng uv pip install --python .venv/Scripts/python.exe --no-deps -e ..

P3 dùng configs/protocol_f3.yaml. Bản khóa kèm theo lưu SHA-256 của protocol, code, dữ liệu đầu vào và phiên bản thư viện. Checkpoint được chọn bằng ba vòng validation bên trong, giếng ngoài chỉ dùng để chấm điểm. Đọc chi tiết rà soát và giới hạn khoa học ở p3-code-review.md.

# Chỉ dùng khi chưa khóa/chưa chạy P3; không khóa lại sau khi có kết quả.
powershell -NoProfile -ExecutionPolicy Bypass -File scripts/run_p3.ps1 -Stage lock
# Chạy toàn bộ: registration, 1.320 trajectory, diagnostics, LOWO, 20 mô hình volume.
powershell -NoProfile -ExecutionPolicy Bypass -File scripts/run_p3.ps1 -Stage all -Device cuda:0 -Workers 4 -Detach

Lệnh all có thể chạy lại để resume đúng fingerprint; job hoàn tất được kiểm tra checksum trước khi tái sử dụng. Không chạy đồng thời hai scheduler trên cùng thư mục output. Tiến độ cập nhật mỗi 10 giây khi mở report.html, kể cả qua file://; dữ liệu gốc ở outputs/p3/progress.json, log ở logs/runs/. Process giữ máy thức trong thời gian chạy, không đổi chính sách nguồn toàn hệ thống. Driver giới hạn mỗi worker ở hai luồng CPU và chạy cửa sổ nền ẩn.

Benchmark thực tế so sánh 1/2/3/4/6 worker: 4 nhanh nhất (khoảng 319 bước/s). Riêng huấn luyện dự kiến 1,6–3,3 giờ; tổng thời gian có thêm registration, diagnostics và volume được lưu ở outputs/p3/progress.json sau pilot. Đây là khoảng dự toán thời gian, không phải khoảng tin cậy thống kê.

Theo yêu cầu phiên làm việc: không chạy script 04 hoặc 09. P3 chỉ fit wavelet/prior cục bộ theo đúng giếng train, ghi trong outputs/p3/; hai artifact cũ outputs/wavelets.npz và outputs/p2/warp_prior_f3.json được bảo vệ bằng hash. G-C giữ nguyên: cải thiện ít nhất 3/4 giếng và coverage 80/90% trong ±5 điểm %. Kết quả G-C nằm ở outputs/p3/summary/gate_gc.json; fail vẫn được báo cáo.

Chạy

scripts/run_p0.sh          # toàn bộ pipeline P0 và test
scripts/run_p1.sh          # P1: tie QC, LOWO baseline (khoảng 16 phút với GPU)
scripts/run_p2.sh          # P2: prior warp F3, QC D2, test, lưới D2, H1, tổng hợp (GPU cuda:1; đổi bằng DEVICE=...)
scripts/run_p2r_dev.sh      # chuẩn bị P2r (chạy lại P2) trên dev 900/901: screen, train, stability, sigma_a, f3, h3 (+ stability_m5, b3d_old, train_sa)
scripts/run_p2r_main.sh     # lưới chính P2r trên realization 8–15
scripts/run_p4.sh           # P4 Volve: register, train, summarize nhánh σ_a chính (DEVICE mặc định cuda:1)
ARMS=sensitivity scripts/run_p4.sh register train   # nhánh σ_a = 3,5 / 14 ms; sau đó ARMS=all scripts/run_p4.sh summarize

Log và runtime: mỗi lần chạy run_p*.sh tạo logs/runs/<YYYYmmdd-HHMMSS>_p*/, mỗi bước là một thư mục con có log.txt (stdout + stderr, cả của worker, đầu dòng có thời gian đã trôi) và meta.json (lệnh, git commit + hash mã nguồn, biến luồng, thiết bị, wall/CPU time, RSS và VRAM đỉnh, mã thoát). Mỗi bước thêm một dòng vào logs/index.csv. Chạy lẻ một script thì bọc bằng scripts/runlog.sh:

scripts/runlog.sh scripts/15_diag_train.py --rids 900 901 --device cuda:1   # file .py chạy bằng .venv/bin/python
scripts/runlog.sh -n ten_rieng --note "ghi chú" -- <lệnh bất kỳ>
scripts/runlog.sh ls                                                        # các lần chạy gần nhất, cả lần đang chạy

logs/runs/ không đẩy lên git; logs/index.csv thì có thể commit. Các dòng có source=backfill là lần chạy trước ngày 27/10/2026, dựng lại từ log còn lại và transcript (trường nào không đo được thì để trống). Chạy lại sau khi bị ngắt: 11_run_d2.py, 14_diag_posterior.py, 15_diag_train.py bỏ qua các ô đã có CSV kết quả; 05_lowo.py và 12_h1_blur.py chạy lại từ đầu.

P2 theo configs/protocol_p2.yaml (khoá bằng configs/protocol_p2.sha256) và bộ sinh configs/d2_synth.yaml. P2r, tức chạy lại P2 trên realization mới sau khi cổng G-B trượt (không phải pha P3 F3 của plan), theo configs/protocol_p2r.yaml (khoá bằng configs/protocol_p2r.sha256 và tag git protocol-p2r) và configs/d2_synth_p2r.yaml (cùng bộ sinh, thêm các chế độ SNR × mật độ anchor); mọi lựa chọn của P3 dựa trên dev 900/901, tổng hợp ở outputs/p2/diag/p2rdev/summary.md; lưới chính dùng realization 8–15.

Biến môi trường máy đặt sẵn OMP_NUM_THREADS=40 (cả MKL, OpenBLAS): các script nhiều worker tự giới hạn luồng, còn khi chạy tay thì đặt rõ OMP_NUM_THREADS, MKL_NUM_THREADS, OPENBLAS_NUM_THREADS (và CUDA_VISIBLE_DEVICES= cho việc chỉ dùng CPU). Lý thuyết (Mệnh đề 1–2, chọn λ, các baseline là trường hợp riêng của RML): docs/theory.md.

Script Việc
scripts/00_data_manifest.py [--check] [--dataset f3|volve|nlog|thesis] Ghi/kiểm SHA-256 theo data_manifest/*.json (F3: 279 file; thesis: 7 artifact trong outputs_thesis/)
scripts/01_build_wells.py Vị trí giếng từ .survey, 4 TDR (legacy, calibrated, anchors, wlt), log sang thời gian có chống alias, trích patch seismic → outputs/f3_wells.npz
scripts/02_td_qc.py Lệch của các nguồn TD so với marker → outputs/figures/td_drift.png, outputs/td_qc.csv
scripts/03_train.py --config configs/b2_smoke.yaml CNN–GRU v2 + loss gốc (B2), split tách rời train/val/test (chạy thử P0)
scripts/04_wavelet_tie.py Wavelet, synthetic 4 giếng, misregistration còn lại và ngưỡng nhiễu → outputs/tie_qc.csv, outputs/figures/ties.png
scripts/05_lowo.py LOWO 5 seed cho B0a, B0b, B1, B2, B3a, B3b theo configs/protocol.yaml (kiểm hash trong configs/protocol.sha256)
scripts/06_summarize_p1.py Bảng macro/theo giếng, calibration, G-A → outputs/p1/summary.md, outputs/figures/p1_lowo.png
scripts/07_volve_interp_qc.py QC horizon, well picks, checkshot và cube ST10010 của Volve theo configs/d3_volve.yaml → outputs/volve/
scripts/08_d1_label_check.py Kiểm tra D-1: porosity theo RHOB đo của NLOG so với nhãn sonic PHIE_DT → outputs/d1/
scripts/09_fit_warp_prior_f3.py Fit prior warp GP Matérn-3/2 (type-II ML) trên marker TD của F3, kiểm tra leave-one-anchor-out → outputs/p2/warp_prior_f3.json, outputs/figures/p2_f3_drift.png. File json đã ghi hash trong protocol P2: không chạy lại khi đã có
scripts/10_build_d2.py QC bộ sinh D2 so với F3 (nhãn, anchor, drift) → outputs/d2/qc.json, outputs/figures/p2_d2_qc.png
scripts/11_run_d2.py --dev|--main [--workers 6] [--device cuda:1] Mỗi ô (realization, c, N): đăng ký warp giếng train, huấn luyện Oracle, B3a–B3d, B4a–B4d, M1, M2 với 5 seed, chấm điểm trên 8 giếng test → outputs/p2/{dev,main}/. --dev chọn ngân sách bước; --main cần protocol khớp hash
scripts/12_h1_blur.py [--workers 6] [--device cuda:1] H1: huấn luyện MSE với nhãn lệch δ ~ N(0, σ²), so hàm truyền đo được với exp(−2π²σ²f²) → outputs/p2/h1/
scripts/13_summarize_p2.py [--mode main|dev] Cổng G-B, bản đồ pha v1, H1, H3 (M2-ens so với B5), H4, chẩn đoán warp → outputs/p2/summary/<mode>/, outputs/figures/p2_*.png
scripts/14_diag_posterior.py [--snr] [--anchor-density] [--sigma-a-reg] [--particles] [--smc-seeds] [--device cuda:1] Chẩn đoán posterior warp trên dev: SMC tôi luyện có điều kiện seismic (γ = 1/κ, pha phase_R ước lượng qua log Z), sai số warp, độ phủ, σ_post → outputs/p2/diag/…
scripts/15_diag_train.py [--post-dir] [--methods] [--budgets-from] [--save-preds] Huấn luyện trên dev với nhãn từ posterior SMC (B3d-Sa, M2-Sa…) và các baseline, cổng kiểu G-B, ensemble kiểu H3 → outputs/p2/diag/train*/
scripts/16_f3_posterior.py [--device cuda:1] Đặt F3 lên trục σ_post (chỉ mô tả): posterior SMC trên 4 giếng F3 → outputs/p2/diag/f3_posterior/
scripts/17_summarize_p2r_dev.py [--only …] Tổng hợp dev cho P2r: screen, train/dose-response H2b, B(σ), stability, σ_a, F3 → outputs/p2/diag/p2rdev/summary.md
scripts/18_summarize_p2r.py [--root DIR] Phán quyết của protocol_p2r trên lưới chính (realization 8–15): H2a, H2b, σ_a, H3, H4 → outputs/p2r/summary/ (verdict.json, summary.md)
scripts/19_run_f3.py <stage> [--device] [--workers] P3 F3: prepare → benchmark → lock → register → train → diagnostics → summarize theo configs/protocol_f3.yaml → outputs/p3/
scripts/20_summarize_f3.py Tổng hợp lượt P3 đã khóa, cổng G-C → outputs/p3/summary/
scripts/21_predict_f3.py Mô hình triển khai và volume F3 mô tả (649 inline) sau LOWO của P3 → outputs/p3/volume/
scripts/22_paper_figures.py [--only …] Hình cho bài báo (paper/figures/*.pdf), chỉ đọc các summary đã khóa
scripts/23_build_volve_wells.py [--config configs/d3_volve.yaml] Dữ liệu 6 giếng nghiêng Volve trên miền thời gian (survey, TDR calibrated và blind, patch 3×3 dọc đường giếng, nhãn PHIF) → outputs/volve/volve_wells.npz, volve_wells_summary.json
scripts/24_run_volve.py <stage> [--arms primary|sensitivity|all] [--device] [--workers] P4 Volve: benchmark → lock → register → train → summarize theo configs/protocol_volve.yaml, cổng G-D → outputs/p4/
scripts/25_p4_posthoc.py Post hoc P4, ngoài khóa, không đổi G-D: hằng số bằng trung bình giếng train và tách RMSE thành bias + SD → outputs/p4/posthoc/
scripts/26_applicability.py Điều kiện áp dụng C1, C2 (khai báo ở docs/research/applicability-teapot.md), hồi cứu trên F3 và Volve; chỉ đọc output đã khóa và nhãn giếng train của từng fold, không train → outputs/applicability/
scripts/27_t3_power.py T3 exploratory: chấm lại dự đoán P2r đã lưu với tham chiếu lệch σ_ref, power của luật k-of-n và sign test theo số giếng blind (beta-binomial) → outputs/t3/
python -P scripts/28_teapot_inventory.py --root data/Teapot/raw/rmotc --out outputs/teapot/inventory T0 kiểm kê Teapot Dome (chỉ header và độ phủ đường cong; không đọc quan hệ porosity–seismic). Dữ liệu là archive tải về, chạy bằng python -P từ gốc repo → outputs/teapot/inventory/
python -P scripts/29_teapot_pilot.py Pilot P-a Teapot (Deviation 2): hình học, độ phủ horizon, σ̂_knot trên giếng dev (inline ≤ 200), không đọc porosity → outputs/teapot/pilot_pa/
scripts/30_t4_coverage.py T4 post hoc, mô tả: tỉ số phân tán ξ (cột kappa), coverage90 và phần do số vòng lặp của các ensemble 5 seed, từ outputs/p2r/train/*/cells/*.npz và dev P2 → outputs/t4/
scripts/31_p2r_posthoc.py Post hoc H2b, đọc outputs/p2r/summary/ và dự đoán Oracle trong outputs/p2r/train/<regime>/cells/*.npz (khoảng 6 phút): tỉ số Oracle / B3d-Sa / M2-Sa, phần khoảng cách đã đóng; cận 1/B cho cấu trúc (a) classical (đã đăng ký) và (b) Berkson (thêm biến thể giữ hệ số ở 60 Hz và biến thể phổ chéo), tại σ_post và tại sai số warp; cờ vượt mép lưới B → outputs/p2r/posthoc/{bound.csv, blur_ab.csv, meta.json}

code_thesis/ là bản lưu trữ code luận văn. Giữ nguyên nội dung để đối chiếu: các script này còn đường dẫn máy cũ và ghi vào outputs/, nên cần một bản sao đã điều chỉnh đường dẫn nếu muốn chạy lại. Kiểm tra bộ artifact hiện có bằng python scripts/00_data_manifest.py --dataset thesis --check.

Description
No description provided
Readme 499 MiB
Languages
Lasso 69.1%
Python 18.8%
Mathematica 5.4%
TeX 4.6%
HTML 1.8%
Other 0.3%