In this article
Astropy exposes a Quantity's unit and value separately and provides to or to_value for requested conversions. Reading value alone preserves the current representation's magnitude. A numerical array with stripped units no longer carries the conversion obligation automatically. A changed input source can therefore introduce a scale discrepancy without changing the tensor shape or dtype. Unit compatibility is also different from arbitrary equality of unit strings, and supported equivalencies mu.
Extracting Quantity.value returns a number in the quantity’s current unit; it does not convert that number to the unit a model expects. Two physically equal observations can therefore become different numerical inputs if an importer strips units first. Scientific AI preparation needs an explicit target-unit conversion before unitless tensor construction.
The scientific interface
Astropy exposes a Quantity’s unit and value separately and provides to or to_value for requested conversions. Reading value alone preserves the current representation’s magnitude. A numerical array with stripped units no longer carries the conversion obligation automatically. A changed input source can therefore introduce a scale discrepancy without changing the tensor shape or dtype. Unit compatibility is also different from arbitrary equality of unit strings, and supported equivalencies must be intentional rather than assumed for unrelated physical quantities.
Implementation details
Define target units in the feature schema and convert while Quantity information is still available. Record the original unit, selected conversion and effective tensor unit as provenance. Validate incompatible inputs before stripping metadata. Keep numerical normalization, such as centering or scaling for a model, separate from physical conversion so inverse interpretation can be checked. If a scientific equivalency is required, preserve its explicit configuration. Do not infer that a dimensionless model output has the desired physical unit unless the output contract and inverse transformations establish it.
A constructed validation case
Prepare physically equal quantities expressed in different compatible units and convert them through the intended model-input path. Compare effective numerical values in the declared target unit. Add a deliberately value-only extraction and an incompatible-unit input as separate negative cases. Verify inverse output interpretation under the same schema. Acceptance requires unit-consistent values and visible rejection or reviewed equivalency where needed, not equality of raw magnitudes or a test that only checks tensor shape. Preserve the fixture units and conversion configuration for later source changes.
Numerical and data limits
Unit consistency does not establish sensor calibration or physical-model accuracy. It establishes the meaning of numerical values crossing the tensor boundary. Keep that meaning explicit before comparing scientific AI predictions so a representation scale error is not mistaken for learned-model bias or a need for more compute.
Primary references
Astropy Quantity values and conversions; Astropy units and quantities.
This is a proposed scientific-interface validation, not an executed Retrivium benchmark. Preserve the implementation version and unresolved outcomes; interface documentation does not establish the accuracy or performance of a scientific model.
Related reading
Tensor axes in a language model: batch, sequence and hidden width; A GPU inference benchmark you can trust.
Earn rental income from GPUs
Have idle GPUs or looking to fund AI infrastructure? Retrivium finds a rental platform, sets up the server and helps you assess income and costs with a pilot.