Skip to main content

Mask-Aware HEALPix Transformers

Project description

🌌 HealFormers: Mask-Aware HEALPix Transformers

architecture

HealFormer is a cutting-edge transformer model specifically designed for data structured on the HEALPix grid, widely used in cosmology, astrophysics, and large-scale structure analysis. HealFormer natively manages incomplete sky observations with state-of-the-art precision, eliminating the need for projections or specialized spherical convolutions, and scales effortlessly to large astronomical surveys.

[!NOTE]

  • Source code will be publicly available after paper acceptance.
  • Pretrained models and datasets will be hosted on 🤗 HuggingFace.

🌠 Why Choose HealFormer?

Traditional spherical analysis methods often struggle with partial-sky coverage and computational efficiency. HealFormer is uniquely designed to solve these challenges:

🚩 Pain Points 🎯 HealFormer Solutions
Inefficient mask handling ✅ Direct mask-aware learning
Distortion from projections ✅ Native HEALPix operations (no projections needed)
Poor scalability for high resolutions ✅ Efficient from Nside=256 up to Nside=1024+
Expensive model training ✅ LoRA-based tuning reduces cost by 90%+
Limited generalization ✅ Strong transfer learning and generalization

🌟 Key Features

  • Mask Awareness: Directly processes masked regions; adapts to arbitrary mask sizes and shapes.
  • Native HEALPix Integration: No need for projection or spherical approximation; maintains full data integrity.
  • State-of-the-Art Performance: Exceeds Wiener filter and Kaiser-Squires both in pixel space and harmonic space.
  • Unified Masking: A single model supports various mask patterns and sky coverage (e.g. KiDS, DES, DECaLS, Planck), without retraining.
  • Efficient Transfer Learning: LoRA-based fine-tuning reduces trainable parameters to ~10%, enabling efficient transfer learning.
  • Scalable & Generalizable: Efficiently scales from low (Nside=256) to high (Nside=1024+) resolutions; generalizes robustly across different cosmological parameters.

📦 Installation

Install HealFormer easily via pip:

pip install healformers

Requirements: Python 3.11+, healpy, torch, transformers, etc. (See pyproject.toml for details)


🚀 Quickstart Example: Weak-Lensing Mass Mapping

Minimal working example to reconstruct a kappa map:

import healpy as hp
import torch
from healformers import HealFormerModel, Mock

# Generate mock data (gamma1, gamma2)
batch = Mock.generate_full_batch(
    nside=256, mask_type="decals", batch_size=1, return_type="torch"
)
kappa_true = batch["targets"][0, -1]

# Load pretrained model
model_path = "path_to_model_directory"
model = HealFormerModel.from_pretrained(model_path)

# Predict kappa map
with torch.no_grad():
    kappa_pred = model(**batch)["logits"][0, 0]

# Visualization
hp.mollview(kappa_true.numpy(), nest=True, title="True Kappa", sub=(121))
hp.mollview(kappa_pred.numpy(), nest=True, title="Reconstructed Kappa", sub=(122))

🛰️ Scientific Applications

  • Weak lensing mass mapping under realistic, incomplete sky coverage – ✅ Ready
  • Power spectrum estimation on irregular spherical masks – 🔜 Coming soon
  • Field-level cosmological inference from partial-sky data – 🔜 Coming soon

🎨 Visualization Showcase

1. Clean Map Reconstruction (w/ mask)

Kaiser-Squires (KS) vs Wiener filter (WF) vs HealFormer (HF)

mask_effect

2. Noisy Map Reconstruction

noise_effect

3. Residuals Across Diverse Masks

residual_allMask


🧩 Model Zoo & Resources

  • 📦 Pretrained models: Coming soon
  • 📚 Fine-tuning guides: Coming soon

📄 Citation

If you utilize HealFormer, please cite:

[Your citation here after publication]

🤝 Contribution & Community

We warmly welcome contributions, feedback, and bug reports!

  • Open an issue on GitHub Issues
  • Submit pull requests for direct contributions.

⚙️ Built With

Special thanks to frameworks and models enabling this work:


📜 License

Licensed under Apache-2.0. See LICENSE for details.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

healformers-0.1.1.tar.gz (7.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

healformers-0.1.1-py3-none-any.whl (5.2 kB view details)

Uploaded Python 3

File details

Details for the file healformers-0.1.1.tar.gz.

File metadata

  • Download URL: healformers-0.1.1.tar.gz
  • Upload date:
  • Size: 7.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for healformers-0.1.1.tar.gz
Algorithm Hash digest
SHA256 86c69b85be079f8532449e865faa868b16191cb818a1becdf0f3f9535a4af334
MD5 ed770bacb43f5dc1e0249d4710f9ca47
BLAKE2b-256 0e3d30386fe6e2bd70c201adddac9101313b6a88852012688187626c87f1b16d

See more details on using hashes here.

Provenance

The following attestation bundles were made for healformers-0.1.1.tar.gz:

Publisher: python-publish.yml on lalalabox/healformers

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file healformers-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: healformers-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 5.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for healformers-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 67732cefaf10881c9e9c7c5ba881dd3f1bf5d89808147afeee63e6d16ea09695
MD5 bdf70a8083a78d88b1512c61ee2c208a
BLAKE2b-256 20ed3ff0beb8dcf1006e7a46607f0c275e7da9e5167dbebcef21cf3551508bd8

See more details on using hashes here.

Provenance

The following attestation bundles were made for healformers-0.1.1-py3-none-any.whl:

Publisher: python-publish.yml on lalalabox/healformers

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page