feat: add AION and SpecCLIP spectral foundation model adapters#46
Open
feat: add AION and SpecCLIP spectral foundation model adapters#46
Conversation
Adds AIONAdapter for the Polymathic AI AION multimodal foundation model. Uses ConvNeXt1d codec to tokenize DESI spectra, then a transformer encoder to produce continuous embeddings. Supports base (300M), large (900M), and xlarge (3B) sizes for scaling analysis. AION is in-domain for DESI spectra.
Bundles SpecFormerControl20_wstd from the SpecCLIP repo as a standalone nn.Module (no Lightning dependency). Key differences from AstroCLIP SpecFormer: pad=(1,0,1,0), stats token stores log10(std) only. Reuses transformer building blocks from specformer_arch.py.
Adds SpecCLIPAdapter with PreprocessSpecCLIP that resamples DESI spectra to the LAMOST wavelength grid (1462 pixels, 3700-9100 A). SpecCLIP was trained on LAMOST LRS spectra, so running it on DESI data is an intentional out-of-domain control experiment. Architecture bundled from the SpecCLIP repo with matching state_dict key names.
Register aion and specclip adapters in models/__init__.py. Update experiments.py to recognize both as spectral models and add model_map entries for AION (3 sizes) and SpecCLIP.
Adds half=True parameter to AIONAdapter.load() for loading xlarge (3B) model on GPUs with limited VRAM.
This was referenced Apr 12, 2026
Collaborator
|
@ksd3 there are some conflicts |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
What was there before
What changed
New files
src/pu/models/aion.pypolymathic-aioncodec to tokenize DESI spectra, then transformer encoder for embeddings. Supports base/large/xlarge sizes and fp16 loading.src/pu/models/specclip.pynp.interp. Intentional out-of-domain control.src/pu/models/specclip_arch.pySpecFormerControl20_wstdas plain nn.Module, no Lightning dependency).Modified files
src/pu/models/__init__.pyaionandspecclipadapterssrc/pu/experiments.pyis_spectral_modelcheck; add AION (base/large) and SpecCLIP tomodel_mappyproject.tomlmatplotlib>=3.8.0Design decisions
Why AION? AION was trained on DESI spectra — it's in-domain for the existing data pipeline. Three sizes (300M/900M/3.1B) enable scaling analysis matching the pattern used for vision models (ViT base/large/huge, DINOv2 small/base/large/giant). All three sizes were updated on HuggingFace two days before this work.
Why SpecCLIP as a control? SpecCLIP was trained on LAMOST spectra. There is no LAMOST data on HuggingFace to stream, and no LAMOST-HSC crossmatch exists. The paper (Section 5.2) found that wavelength resampling across instruments fails due to systematic differences (calibration, detector, observing conditions). Running SpecCLIP on DESI spectra serves as an intentional negative control — confirming that domain mismatch makes embeddings degenerate.
Minimum reproducible example
Expected output
Full pipeline
Test plan
uv run pytest)