| # SIFQ β Plan & Experiment Tracker |
|
|
| DΓΉng file nΓ y Δα»: ghi kαΊΏ hoαΊ‘ch trΖ°α»c khi thay Δα»i code, track tiαΊΏn Δα», vΓ revert khi cαΊ§n. |
|
|
| --- |
|
|
| ## Active Experiments |
|
|
| ### v32 β Done β |
| **Goal:** Fix two concept grounding failures in v31 via T42 concept map |
| **Key changes from v31:** T42 concept map (2 changes): |
| - `dry_skin: [4, 2, 0] β [4, 0]` β remove continuity |
| - `noise: [3] β [1, 3]` β add clarity as co-target |
| **Script:** `scripts/run_train_v32.sh` |
| **Result:** KS=0.1375, Pearson=0.7892 β Track 2 regression vs v31 (KS +0.022, Pearson -0.097) |
| **Track 4 regressions vs v31:** |
| - blurβclarity: +0.046 β (was -0.305 β) |
| - noiseβclarity: +0.114 β (was -0.236 β) |
| - noiseβnoise_level: +0.121 β (was -0.081 β) |
| - occlusionβminutiae: +0.121 β (was -0.123 β) |
| - wet_pressβminutiae: +0.676 β (was -0.695 β) |
| **Root cause:** Adding clarity[1] to noise map caused clarity concept to absorb noise-degradation gradient, destroying its response to blur. Removing continuity[2] from dry_skin destabilised concept interactions across other degradation types. |
| **Reverted:** concept map β T39 (restored `noise:[3]`, `dry_skin:[4,2,0]`) |
| **Status:** Failed β reverted to T39 concept map |
|
|
| --- |
|
|
| ### v31 β Done β
|
| **Goal:** Benchmark DINOv2-ViTS/14 as public teacher replacing unpublished MDGT |
| **Key change from v28:** `--teacher dinov2` (frozen DINOv2-ViTS/14 CLS token [B,384]) |
| **Script:** `scripts/run_train_v31.sh` |
| **Result:** KS=0.1152, Pearson=0.8858, q_stdβ₯15 β
β **best Track 2 so far** |
| **Concept issues:** dry_skinβnoise_level Spearman -0.758 (spurious, noise_level NOT in target); |
| blurβcontinuity +0.214 (wrong direction); noiseβnoise_level -0.081 (weak signal) |
| **Status:** Complete |
| |
| --- |
| |
| ### v29 β Done β |
| **Goal:** Fix concept grounding failures in v28 β T41 concept map + anti-saturation losses |
| **Key changes from v28:** |
| - T41 concept map: jpegβ[1], dry_skinβ[4,0], noiseβ[1,3] (fix gradient conflicts + noise inversion) |
| - `--ortho-weight 3.0` (vs 1.0 default) β push saturated concepts apart |
| - `--concept-spread-weight 1.0` β penalise concepts with batch std < 0.20 |
| **Script:** `scripts/run_train_v29.sh` |
| **Result:** KS=0.2985, Pearson=0.1448 β catastrophic sensor invariance regression |
| **Root cause of failure:** `--concept-spread-weight 1.0` forces per-batch concept diversity |
| which amplifies sensor-specific texture features, destroying cross-sensor score alignment. |
| G_roll_png and H_roll_png particularly affected (KS 0.86 and 0.77 vs other sensors). |
| **Status:** Failed β reverted to v28 code base (train_sifq.py, degradation_ranking.py T39) |
|
|
| --- |
|
|
| ### v28 β Done β
|
| **Goal:** Validate matcher-free quality learning β L_mat disabled entirely (`--no-mat`) |
| **Key change from v26:** No MDGT teacher. Loss = L_sens + L_deg + L_ortho + L_spread only. |
| **Script:** `scripts/run_train_v28.sh` |
| **Result:** KS=0.1346, Pearson=0.7645, q_std~23.2 (60 epochs) |
| **Concept issues found:** continuity collapsed (mean=0.068), noise_level inverted (+0.56), orient_coh saturated (0.94), contrast_uni saturated (0.85), clarity flat (std=0.043). Only minutiae_rel discriminating. |
| **Paper claim:** β
"SIFQ quality is self-supervised β no external matcher needed" validated by KS close to v24 |
| **Status:** Complete β concept grounding needs fix (next experiment TBD) |
|
|
| --- |
|
|
| ### v26 β Δang train π |
| **Goal:** Verify v25 regression root cause = gamma=1.5 (not T40 concept map) |
| **Key change from v25:** `--concept-deg-gamma 2.0` (restored), DEGRADATION_CONCEPT_MAP reverted to T39 |
| **Script:** `scripts/run_train_v26.sh` |
| **Log:** `logs/train_v26.log` |
| **Expected:** KS β 0.126, Pearson β 0.80 (match v24) |
| **Eval:** `scripts/run_eval_v26.sh` (auto-runs after training) |
| **Status:** Training in progress |
|
|
| ### v27 β Pending β³ |
| **Goal:** Validate SpatialConceptHead (14Γ14 spatial tokens) improves concept grounding |
| **Key change from v26:** `--spatial-concept-head` flag β `SpatialConceptHead` replaces `ConceptHead` |
| **Script:** `scripts/run_train_v27.sh` |
| **Expected:** KS β v26, Track 4 diagonal stronger (especially orientation_coherence, continuity, minutiae_reliability) |
| **Blocker:** Wait for v26 to confirm KS/Pearson target first |
| **Status:** Code ready, not launched |
|
|
| --- |
|
|
| ## Code Change Log |
|
|
| ### 2026-06-04 β T42 concept map: 2 changes for v32 |
|
|
| **Files changed:** |
| - `src/losses/degradation_ranking.py` β T42 DEGRADATION_CONCEPT_MAP: |
| - `dry_skin: [4,2,0] β [4,0]` (removed continuity [2]) |
| - `noise: [3] β [1,3]` (added clarity [1] as co-target) |
|
|
| **Root cause (dry_skin):** v31 shows noise_level (c=3) Spearman -0.758 with dry_skin (NOT in target). |
| Continuity [2] shares backbone patch-scale features (~16Γ16) with noise texture β cross-activation. |
| Fix: use contrast[4] + orientation[0] (regional features at multi-patch scale) only. |
| |
| **Root cause (noise):** v31 shows noiseβnoise_level Spearman only -0.081 (nearly no signal). |
| TinyViT 16Γ16 patch embed averages out pixel Gaussian noise (Ο=5β30) β concept[3] gradient β 0. |
| Adding clarity[1] anchors noise degradation to ridge-valley blur (detectable at patch scale). |
| |
| **Backward compatibility:** β οΈ Modifies shared DEGRADATION_CONCEPT_MAP. |
|
|
| **Revert T42 β T39:** |
| ```python |
| "noise": [3], |
| "dry_skin": [4, 2, 0], |
| ``` |
|
|
| --- |
|
|
| ### 2026-06-03 β DINOv2Teacher: replace MDGT with public DINOv2-ViTS/14 |
|
|
| **Files changed:** |
| - `src/training/mdgt_teacher.py` β Added `DINOv2Teacher` class: frozen DINOv2-ViTS/14 (via `torch.hub`), handles grayscaleβRGB channel repeat + ImageNet normalization internally, returns L2-normalized [B, 384] CLS embeddings. `MDGTCheckpointTeacher` unchanged. |
| - `src/train.py` β Added `--teacher {dinov2,mdgt}` arg (default=`dinov2`). Import `DINOv2Teacher`. Instantiation in `main()` dispatches on `args.teacher`. `--mdgt-checkpoint` arg remains but only used when `--teacher=mdgt`. |
|
|
| **Root cause / motivation:** MDGT is unpublished work β not reproducible by reviewers β academic integrity risk. DINOv2-ViTS/14 is public (Meta, ICLR 2024), cite-able, and `torch.hub` reproducible. |
|
|
| **Expected Pearson impact:** DINOv2 raw β expect Pearson ~0.55β0.70 vs 0.80 with MDGT. Run v31 to benchmark. |
|
|
| **Backward compatibility:** β
All existing scripts using `--teacher mdgt --mdgt-checkpoint <path>` unaffected. |
|
|
| **Revert:** |
| ```bash |
| # train.py: change --teacher default back to "mdgt" |
| # or pass --teacher mdgt --mdgt-checkpoint <ckpt_path> explicitly |
| ``` |
|
|
| --- |
|
|
| ### 2026-06-02 β T41 concept map + anti-saturation losses (v29) |
|
|
| **Files changed:** |
| - `src/losses/degradation_ranking.py` β T41 DEGRADATION_CONCEPT_MAP: |
| - `jpeg: [2,1] β [1]` (remove continuity β JPEG artifacts wrong gradient direction in v28) |
| - `dry_skin: [4,2,0] β [4,0]` (remove continuity β gradient conflict, Spearman+0.10 wrong) |
| - `noise: [3] β [1,3]` (add clarity co-target β noise blurs ridges, anchors concept 3) |
| - `scripts/train_sifq.py` β Added `--ortho-weight` (default 1.0) and `--concept-spread-weight` (default 0.0) args; l_orth now weighted; per-concept spread loss (std < 0.20 β penalty) added to total loss; logged as `l_cspread` in running dict and epoch print |
|
|
| **Root cause:** v28 concept collapse/inversion diagnosed via inference stats: |
| - continuity std=0.076, mean=0.068 β dead concept (3 conflicting grad sources: blurβ, jpegβ, dry_skinβ) |
| - noise_level Spearman +0.56 β inverted (Gaussian noise increases texture energy in TinyViT) |
| - orient_coh mean=0.942, contrast_uni mean=0.851 β L_ortho=1.0 too weak to break saturation |
| |
| **Backward compatibility:** β
`--ortho-weight` default=1.0, `--concept-spread-weight` default=0.0 β all v16-v28 unaffected. |
| |
| **Revert T41 β T39:** |
| ```python |
| # degradation_ranking.py DEGRADATION_CONCEPT_MAP: |
| "noise": [3], |
| "jpeg": [2, 1], |
| "dry_skin": [4, 2, 0], |
| ``` |
| |
| --- |
| |
| ### 2026-06-02 β --no-mat flag (v28 teacher-free experiment) |
| |
| **Files changed:** |
| - `scripts/train_sifq.py` β Added `--no-mat` flag; MDGT teacher/emb_cache/prototypes wrapped in `if not args.no_mat`; training loop forces `l_mat = 0.0` when flag is set |
|
|
| **Backward compatibility:** β
Default `--no-mat=False` β all existing versions unaffected. |
|
|
| **Revert:** Remove `--no-mat` block in `parse_args()` and restore unconditional MDGT instantiation in `main()`. |
|
|
| --- |
|
|
| ### 2026-06-01 β SpatialConceptHead |
|
|
| **Files changed:** |
| - `src/models/concept_head.py` β Added `SpatialConceptHead` class |
| - `src/models/sifq.py` β `SIFQ.forward()` dispatches via `concept_head.uses_spatial` |
| - `src/models/__init__.py` β Export `SpatialConceptHead` |
| - `scripts/train_sifq.py` β `--spatial-concept-head` flag (default=False) |
| - `src/train.py` β same flag |
| - `scripts/run_eval.py` β auto-detect from `ckpt["config"]["spatial_concept_head"]` |
| - `scripts/run_infer.py` β same auto-detect |
| - `rules/SIFQ_explained.md` β Section 2.2 updated, diagram updated, File Map updated |
|
|
|
|
| **Backward compatibility:** β
All v16βv26 checkpoints load cleanly without flag. |
|
|
| --- |
|
|
| ### 2026-06-01 β T39 concept map revert + gamma restore (v26) |
|
|
| **Problem:** v25 used gamma=1.5 AND T40 concept map. Regression KS 0.126β0.213. |
| **Root cause identified:** gamma=1.5 too weak during S1βS2 ramp. |
| - v24 (gamma=2.0): spread stable ~0.003, q_std grows 18β22 monotonically |
| - v25 (gamma=1.5): spread spikes to 0.028, q_std collapses 22β10 (epochs 13β16) |
|
|
| **Files changed:** |
| - `src/losses/degradation_ranking.py` β T40 reverted to T39 DEGRADATION_CONCEPT_MAP |
| - `scripts/run_train_v26.sh` β `--concept-deg-gamma 2.0` |
|
|
| **DEGRADATION_CONCEPT_MAP T39 (current, correct):** |
| ```python |
| "blur": [1, 2] |
| "noise": [3] |
| "jpeg": [2, 1] |
| "occlusion": [5] |
| "dry_skin": [4, 2, 0] |
| "wet_press": [1, 5, 0] |
| ``` |
|
|
| **Revert target:** T40 map (v25): |
| ```python |
| "blur": [1, 2, 0] # + orient_coh |
| "noise": [3, 4] # + contrast_u |
| "jpeg": [2, 1, 4] # + contrast_u |
| "occlusion": [5] |
| "dry_skin": [4, 2, 0] |
| "wet_press": [1, 5, 0] |
| ``` |
| **Do NOT revert to T40** unless v26 confirms gamma=2.0 alone is insufficient and T39 concept grounding is weaker than expected. |
|
|
| --- |
|
|
| ## Revert Cookbook |
|
|
| ### Revert concept map to previous version |
| ```bash |
| # Check what the map looked like in a specific git commit: |
| git log --oneline src/losses/degradation_ranking.py |
| git show <commit>:sifq/src/losses/degradation_ranking.py | grep -A 30 "DEGRADATION_CONCEPT_MAP" |
| |
| # Edit directly: |
| # src/losses/degradation_ranking.py β DEGRADATION_CONCEPT_MAP dict |
| ``` |
|
|
| ### Revert to v24 hyperparameters (known good baseline) |
| ```bash |
| # Key v24 flags (from scripts/run_train_v24.sh): |
| --concept-deg-gamma 2.0 |
| --spread-weight 3.0 |
| --spread-mode uniform |
| --deg-every-n-steps 2 |
| --no-mat-stats |
| --proto-max-batches 0 |
| --k-cross 0 |
| --batch-size 96 |
| ``` |
|
|
| ### Load and inspect a checkpoint |
| ```python |
| import torch |
| ckpt = torch.load("checkpoints/v24/last.pt", map_location="cpu", weights_only=False) |
| print(ckpt["metrics"]) # KS, Pearson, q_std, etc. |
| print(ckpt["config"]) # all argparse flags used |
| print(ckpt["epoch"]) # which epoch |
| ``` |
|
|
| ### Compare two checkpoints' configs |
| ```python |
| import torch, json |
| c24 = torch.load("checkpoints/v24/last.pt", map_location="cpu", weights_only=False)["config"] |
| c25 = torch.load("checkpoints/v25/last.pt", map_location="cpu", weights_only=False)["config"] |
| for k in c24: |
| if c24.get(k) != c25.get(k): |
| print(f"{k}: v24={c24.get(k)} v25={c25.get(k)}") |
| ``` |
|
|
| ### Run eval manually on any checkpoint |
| ```bash |
| cd /home/aiserver/works/fingerprint |
| |
| # Step 1: Inference |
| python sifq/scripts/run_infer.py \ |
| --checkpoint sifq/checkpoints/vXX/last.pt \ |
| --root-302a dataset/302a/images/challengers \ |
| --root-302b dataset/302b/images/baseline \ |
| --root-302d dataset/nist_302d/images/auxiliary \ |
| --exclude-sensor "R_1000_slap,R_500_slap,S_500_slap" \ |
| --output sifq/eval_results/sifq_scores_vXX.jsonl |
| |
| # Step 2: Track 2 + Track 4 |
| python sifq/scripts/run_eval.py \ |
| --sifq-scores sifq/eval_results/sifq_scores_vXX.jsonl \ |
| --checkpoint sifq/checkpoints/vXX/last.pt \ |
| --out-dir sifq/eval_results/vXX \ |
| --exclude-sensor "R_1000_slap,R_500_slap,S_500_slap" \ |
| --skip-track1 |
| ``` |
|
|
| ### Smoke test (~2 min) |
| ```bash |
| cd /home/aiserver/works/fingerprint |
| bash sifq/scripts/run_smoke.sh |
| ``` |
|
|
| --- |
|
|
| ## Decision Log |
|
|
| ### Why not T40 concept map? |
| T40 added `orient_coh` to blur/noise/jpeg. Reverted in v26 because root cause of v25 regression was **gamma=1.5**, not concept map. T40 change had no confirmed benefit. Defer until v26 evaluation is done. |
|
|
| ### Why FVC-only L_deg (not SD302)? |
| SD302 images are all high quality by protocol β clean images satisfy L_rank at a single ~53 attractor β blocks quality discrimination signal from L_mat. FVC has genuine quality variation (8 impressions/subject) β MDGT cosine varies β L_mat gradient meaningful β transfers to SD302 at inference. (v20 root cause analysis) |
|
|
| ### Why --no-mat-stats? |
| Per-identity cosine stats (T31) created asymmetry: FVC has stable tanh targets, SD302 gets raw cosine ~0.85 constant. Backbone learned "FVC=quality-variable, SD302=fixed" β no L_mat gradient for SD302 β GRL destroyed SD302 features. (v17 root cause) |
| |
| ### Why --k-cross 0? |
| k_cross>0 forces k guaranteed cross-sensor pairs per batch β over-constrains L_sens β backbone over-optimises sensor invariance β loses quality discrimination β Pearson collapses to ~0.09. (v21 root cause) |
| |
| ### Why --proto-max-batches 0? |
| Partial prototypes (150 batches = 45% data) β SD302 identities have 2β3 sensor prototypes instead of full 19-sensor β cosine correlates with WHICH sensors in prototype window (sensor-biased) β no quality gradient for SD302. (v19/v20 root cause) |
| |
| ### Why gamma must be β₯ 2.0? |
| During S1βS2 ramp, mat loss is introduced alongside existing deg loss. If deg loss too weak (gamma=1.5), mat loss dominates momentarily β spread spikes β model partially collapses and never fully recovers. gamma=2.0 keeps deg strong enough to maintain ordinal grounding through the ramp. (v25 root cause) |
| |
| --- |
| |
| ## Pending Research Questions |
| |
| - [ ] **v26 eval:** Does restoring gamma=2.0 fully recover v24 KS/Pearson? (expected: yes) |
| - [ ] **v27 eval:** Does SpatialConceptHead improve Track 4 diagonal Ο vs v26? |
| - [ ] **noiseβnoise_level:** v24 Track 4 shows +0.365 (wrong direction). Defer to v28. |
| - [ ] **T40 revisit:** Once v26/v27 stable, evaluate if blur/noise/jpeg β orient_coh improves orientation_coherence grounding. |
| |