Skip to content

Scalar field#21

Merged
EiffL merged 10 commits intomainfrom
scalar_field
May 24, 2025
Merged

Scalar field#21
EiffL merged 10 commits intomainfrom
scalar_field

Conversation

@EiffL
Copy link
Contributor

@EiffL EiffL commented May 24, 2025

This pull request introduces a new ScalarFieldCodec for handling scalar field modalities, including its implementation, integration into the existing framework, and associated tests. The changes focus on adding support for scalar fields as a new modality and ensuring compatibility with the current codec and modality structure.

Codec and Modality Enhancements:

  • Added a new ScalarFieldCodec class in aion/codecs/scalar_field.py, which includes an autoencoder-based architecture for encoding and decoding scalar fields. It supports features such as quantization, loss optimization, and exponential moving average (EMA) of model weights.
  • Introduced a new ScalarField modality in aion/modalities.py to represent 2D scalar fields like density or temperature maps. Updated the ModalityType union to include ScalarField. [1] [2]

Codebase Integration:

  • Registered the ScalarFieldCodec in aion/codecs/__init__.py to make it accessible within the codec package. [1] [2]
  • Added the ModelEmaV2 class in aion/codecs/modules/ema.py to support exponential moving average for model weights, which is used in the new codec.

Testing and Validation:

  • Added test data files for scalar field codec input, encoded, and decoded batches in tests/test_data for validating codec functionality. [1] [2] [3]
  • Implemented a new test case in tests/tokenizers/test_scalar_field_tokenizer.py to verify the encoding and decoding processes of the ScalarFieldCodec against reference data.

@EiffL EiffL requested a review from Copilot May 24, 2025 21:37
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR introduces a new ScalarField modality and its corresponding autoencoder-based codec, ScalarFieldCodec, to extend the framework’s support for 2D scalar field data. Key changes include:

  • Implementation of ScalarFieldCodec (with quantization and EMA support) in aion/codecs/scalar_field.py.
  • Integration of the new ScalarField modality in aion/modalities.py and registration of the codec in aion/codecs/init.py.
  • Addition of test cases and data for verifying codec functionality.

Reviewed Changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
tests/tokenizers/test_scalar_field_tokenizer.py Adds tests for encoding/decoding scalar field data.
tests/test_data/*.pt Provides test data for input, encoded, and decoded scalar field batches.
aion/modalities.py Introduces new ScalarField modality and updates ModalityType union.
aion/codecs/scalar_field.py Implements the ScalarFieldCodec with autoencoder, quantization, and EMA support.
aion/codecs/modules/ema.py Adds ModelEmaV2 implementation for model weight averaging.
aion/codecs/init.py Registers ScalarFieldCodec in the codecs package.
Comments suppressed due to low confidence (1)

aion/codecs/scalar_field.py:96

  • [nitpick] There's an inconsistent spelling between 'quantisation_loss_weight' in the parameter and 'quantization_loss_weight' in the assignment. Please choose one consistent spelling for clarity.
self.quantization_loss_weight = quantisation_loss_weight

EiffL and others added 2 commits May 24, 2025 23:41
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@EiffL EiffL merged commit 2b87a19 into main May 24, 2025
2 checks passed
@EiffL EiffL deleted the scalar_field branch May 24, 2025 21:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants