ManmohanSharma commited on
Commit
2c3f055
Β·
verified Β·
1 Parent(s): 6681a46

Upload README.md

Browse files
Files changed (1) hide show
  1. README.md +114 -0
README.md ADDED
@@ -0,0 +1,114 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # NativeSpecZ-296M β€” Wavelength-Aware Scale-Up Experiment
2
+
3
+ A 296M-parameter unimodal foundation model for DESI spectra, trained from scratch with no AION pretrained weights. **This is the project's scale-up ablation** β€” it hits the spec's ~300M-parameter target and is competitive with AION-base on DESI in-distribution, but it does NOT beat AION on out-of-distribution data. The smaller **NativeSpecZ-FM-76M** is the recommended headline submission; this 296M model is documented here as the larger wavelength-aware scaling experiment.
4
+
5
+ ## What it is
6
+
7
+ - 296,269,116 parameters
8
+ - Conv-stem transformer: 20 layers, d_model=1024, conv_width=512, 16 heads, stem_stride=8
9
+ - 8-channel raw-flux input including log-wavelength channels
10
+ - `[CLS]` + `[Z_MASK]` tokens β€” **Approach B**: z token always masked
11
+ - Bin-residual z head + pixel-level reconstruction head β€” **Approach A**: joint training
12
+ - Trained on 97,332 DESI spectra with **wavelength-grid jitter** and OOD-style augmentation (the "wavelength-aware" recipe designed to improve cross-instrument transfer)
13
+ - Mixed-span masking at 30%
14
+ - Resumed from an earlier 300M joint checkpoint, gentle fine-tune (3 epochs, lr 2e-6, 1500 steps)
15
+
16
+ ## Results (held-out, TTA)
17
+
18
+ | Dataset | n | MAE(z) | NMAD | Cat>0.01 |
19
+ |---|---:|---:|---:|---:|
20
+ | DESI held-out | 2500 | **0.0674** | 0.0048 | 0.213 |
21
+ | SDSS (real non-DESI) | 2000 | 0.314 | 0.278 | 0.692 |
22
+ | VIPERS (real non-DESI) | 2000 | 0.316 | 0.154 | 0.906 |
23
+
24
+ Clean-subset (ZWARN==0) MAE: DESI 0.457, SDSS 0.306 β€” same high-z clean-label weakness as the 76M.
25
+
26
+ Masked reconstruction (DESI, mask=0.25): rec MSE 0.066, line-region ~2Γ— harder than continuum.
27
+
28
+ ## Three-way comparison
29
+
30
+ | Dataset | NativeSpecZ-296M | NativeSpecZ-76M (headline) | AION-base |
31
+ |---|---:|---:|---:|
32
+ | **DESI** | **0.067** | 0.069 | 0.074 |
33
+ | SDSS | 0.314 | 0.382 | **0.127** |
34
+ | VIPERS | 0.316 | **0.172** | 0.274 |
35
+
36
+ **Honest read of the scale-up:**
37
+ - On DESI in-distribution, the 296M is the best of the three (ties the 76M, beats AION). Scaling helped in-distribution.
38
+ - The wavelength-jitter training **homogenized** cross-instrument behavior β€” SDSS improved over the 76M (0.314 vs 0.382), but VIPERS regressed badly (0.316 vs the 76M's 0.172).
39
+ - Critically, the 296M **beats AION-base on no OOD dataset** (loses on both SDSS and VIPERS). The 76M, by contrast, beats AION on VIPERS by 37% β€” the strongest foundation-model claim in the project.
40
+ - Conclusion: bigger + wavelength-aware did not improve the foundation-model criterion. This model is a legitimate scale ablation, not the headline.
41
+
42
+ ## Why it's still worth submitting as an ablation
43
+
44
+ 1. It hits the spec's ~300M-parameter target (the 76M is below it).
45
+ 2. It is genuinely competitive with AION-base on DESI in-distribution (0.067 vs 0.074), from scratch, no AION weights.
46
+ 3. It demonstrates the scaling + wavelength-jitter direction was tried and honestly evaluated β€” the negative OOD result is a real finding, not a gap.
47
+
48
+ ## Folder structure
49
+
50
+ ```
51
+ NativeSpecZ-296M_Submission/
52
+ β”œβ”€β”€ README.md
53
+ β”œβ”€β”€ NativeSpecZ-296M.ipynb
54
+ β”œβ”€β”€ weights/
55
+ β”‚ β”œβ”€β”€ best.pt (1.18 GB checkpoint)
56
+ β”‚ β”œβ”€β”€ training_args.json
57
+ β”‚ β”œβ”€β”€ best_metrics.json
58
+ β”‚ └── final_metrics.json
59
+ β”œβ”€β”€ code/
60
+ β”‚ β”œβ”€β”€ hybrid_redshift.py (model architecture; load with strict=False β€” see note)
61
+ β”‚ β”œβ”€β”€ data.py, metrics.py, model.py, plots.py
62
+ β”‚ └── run_eval_296m.py (evaluation script, strict=False load)
63
+ β”œβ”€β”€ eval/
64
+ β”‚ β”œβ”€β”€ desi_heldout/ sdss/ vipers/ (summary.json + NPZ predictions + multi_mask.json)
65
+ └── plots/
66
+ β”œβ”€β”€ scatter_redshift.png
67
+ β”œβ”€β”€ scatter_3datasets.png
68
+ β”œβ”€β”€ comparison_296m_76m_aion.png
69
+ β”œβ”€β”€ multi_mask_reconstruction.png
70
+ └── stress_curve.png
71
+ ```
72
+
73
+ ## Note on loading
74
+
75
+ The current `hybrid_redshift.py` includes `z_rerank_head` and `z_calib_head` modules that were added AFTER this checkpoint was trained. Load with `strict=False`:
76
+
77
+ ```python
78
+ import torch, sys
79
+ sys.path.append("code")
80
+ from hybrid_redshift import HybridSpecZ
81
+
82
+ ckpt = torch.load("weights/best.pt", map_location="cuda", weights_only=False)
83
+ a = ckpt["args"]
84
+ model = HybridSpecZ(
85
+ d_model=a["d_model"], conv_width=a["conv_width"], layers=a["layers"],
86
+ heads=a["heads"], dropout=a["dropout"], z_bins=a["z_bins"],
87
+ stem_stride=a["stem_stride"], rec_hidden_mult=a["rec_hidden_mult"],
88
+ rec_refine_width=a["rec_refine_width"], rec_refine_kernel=a["rec_refine_kernel"],
89
+ layerscale_init=a["layerscale_init"], prediction_mode=a["prediction_mode"],
90
+ bin_temperature=a["bin_temperature"], residual_scale=a["residual_scale"],
91
+ candidate_topk=a["candidate_topk"],
92
+ ).cuda()
93
+ model.load_state_dict(ckpt["model"], strict=False) # rerank/calib heads unused in bin_residual mode
94
+ model.eval()
95
+ ```
96
+
97
+ The `z_rerank_head` and `z_calib_head` are not used in the `bin_residual` prediction path β€” they were exploratory and left in the code. The bin-residual z prediction and the reconstruction head are fully loaded.
98
+
99
+ ## Hugging Face
100
+
101
+ `ManmohanSharma/NativeSpecZ-296M` on Hugging Face.
102
+
103
+ ## Submission checklist
104
+
105
+ - [x] Approach A β€” joint z-head training
106
+ - [x] Approach B β€” always-masked z token
107
+ - [x] ~300M parameter target β€” **296M, meets the spec target**
108
+ - [x] (a) Redshift prediction β€” MAE 0.067 on held-out DESI (beats AION 0.074)
109
+ - [x] (b) Masked reconstruction β€” rec MSE 0.066 at mask=0.25
110
+ - [x] Unimodal DESI + z only, no imaging
111
+ - [x] No AION pretrained weights
112
+ - [x] Cross-instrument tested on SDSS + VIPERS
113
+ - [⚠] Does NOT beat AION-base on any OOD dataset (the 76M does, on VIPERS) β€” this is why the 76M is the headline
114
+ - [⚠] Clean-subset MAE 0.46 (DESI) β€” high-z clean-label weakness shared with the 76M