diffract-core 0.2.2__tar.gz → 0.3.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {diffract_core-0.2.2 → diffract_core-0.3.1}/.gitignore +4 -0
- {diffract_core-0.2.2 → diffract_core-0.3.1}/PKG-INFO +70 -33
- {diffract_core-0.2.2 → diffract_core-0.3.1}/README.md +64 -32
- {diffract_core-0.2.2 → diffract_core-0.3.1}/pyproject.toml +9 -12
- {diffract_core-0.2.2 → diffract_core-0.3.1}/ruff.toml +8 -0
- {diffract_core-0.2.2 → diffract_core-0.3.1}/src/diffract/__init__.py +3 -1
- {diffract_core-0.2.2 → diffract_core-0.3.1}/src/diffract/configs/hybrid.ini +2 -1
- {diffract_core-0.2.2 → diffract_core-0.3.1}/src/diffract/configs/sqlite.ini +2 -1
- {diffract_core-0.2.2 → diffract_core-0.3.1}/src/diffract/containers.py +11 -2
- {diffract_core-0.2.2 → diffract_core-0.3.1}/src/diffract/core/__init__.py +0 -6
- {diffract_core-0.2.2 → diffract_core-0.3.1}/src/diffract/core/cache/interface.py +3 -1
- {diffract_core-0.2.2 → diffract_core-0.3.1}/src/diffract/core/cache/redis_manager.py +36 -18
- {diffract_core-0.2.2 → diffract_core-0.3.1}/src/diffract/core/cache/simple_manager.py +30 -42
- {diffract_core-0.2.2 → diffract_core-0.3.1}/src/diffract/core/compute/execution/aggregation.py +1 -15
- {diffract_core-0.2.2 → diffract_core-0.3.1}/src/diffract/core/compute/execution/aggregation_runner.py +33 -18
- {diffract_core-0.2.2 → diffract_core-0.3.1}/src/diffract/core/compute/execution/executor.py +20 -11
- {diffract_core-0.2.2 → diffract_core-0.3.1}/src/diffract/core/compute/execution/parameter_runner.py +18 -6
- diffract_core-0.3.1/src/diffract/core/compute/execution/restrictions.py +81 -0
- {diffract_core-0.2.2 → diffract_core-0.3.1}/src/diffract/core/compute/execution/utils.py +18 -8
- {diffract_core-0.2.2 → diffract_core-0.3.1}/src/diffract/core/compute/extensions/power_law.py +13 -2
- {diffract_core-0.2.2 → diffract_core-0.3.1}/src/diffract/core/compute/kernels/__init__.py +4 -4
- {diffract_core-0.2.2 → diffract_core-0.3.1}/src/diffract/core/compute/kernels/alignment.py +28 -18
- {diffract_core-0.2.2 → diffract_core-0.3.1}/src/diffract/core/compute/kernels/heavy_tailed.py +82 -18
- {diffract_core-0.2.2 → diffract_core-0.3.1}/src/diffract/core/compute/kernels/marchenko_pastur.py +51 -18
- {diffract_core-0.2.2 → diffract_core-0.3.1}/src/diffract/core/compute/kernels/mat_decomposition.py +52 -12
- {diffract_core-0.2.2 → diffract_core-0.3.1}/src/diffract/core/compute/kernels/mat_properties.py +14 -13
- diffract_core-0.3.1/src/diffract/core/compute/kernels/model_quality.py +36 -0
- diffract_core-0.3.1/src/diffract/core/compute/kernels/norms.py +143 -0
- {diffract_core-0.2.2 → diffract_core-0.3.1}/src/diffract/core/compute/kernels/ranks.py +12 -5
- {diffract_core-0.2.2 → diffract_core-0.3.1}/src/diffract/core/compute/kernels/tracy_widom.py +11 -5
- {diffract_core-0.2.2 → diffract_core-0.3.1}/src/diffract/core/compute/metadata.py +5 -0
- diffract_core-0.3.1/src/diffract/core/constants.py +57 -0
- diffract_core-0.3.1/src/diffract/core/data/identity.py +116 -0
- {diffract_core-0.2.2 → diffract_core-0.3.1}/src/diffract/core/data/metadata/__init__.py +12 -0
- diffract_core-0.3.1/src/diffract/core/data/metadata/migrations.py +504 -0
- {diffract_core-0.2.2 → diffract_core-0.3.1}/src/diffract/core/data/metadata/sqlite_index.py +98 -31
- {diffract_core-0.2.2 → diffract_core-0.3.1}/src/diffract/core/data/nn/aggregates/metadata.py +10 -6
- {diffract_core-0.2.2 → diffract_core-0.3.1}/src/diffract/core/data/nn/aggregates/repository.py +5 -0
- {diffract_core-0.2.2 → diffract_core-0.3.1}/src/diffract/core/data/nn/extractors/base.py +2 -0
- {diffract_core-0.2.2 → diffract_core-0.3.1}/src/diffract/core/data/nn/extractors/factory.py +20 -1
- {diffract_core-0.2.2 → diffract_core-0.3.1}/src/diffract/core/data/nn/params/metadata.py +2 -2
- diffract_core-0.3.1/src/diffract/core/export/containers.py +19 -0
- {diffract_core-0.2.2 → diffract_core-0.3.1}/src/diffract/core/storage/base_manager.py +4 -8
- {diffract_core-0.2.2 → diffract_core-0.3.1}/src/diffract/core/storage/hdf5_manager.py +17 -28
- diffract_core-0.3.1/src/diffract/core/storage/serialization.py +92 -0
- {diffract_core-0.2.2 → diffract_core-0.3.1}/src/diffract/core/storage/sqlite_manager.py +20 -35
- {diffract_core-0.2.2 → diffract_core-0.3.1}/src/diffract/core/storage/zarr_manager.py +9 -32
- diffract_core-0.3.1/src/diffract/core/utils/fpenv.py +80 -0
- {diffract_core-0.2.2 → diffract_core-0.3.1}/src/diffract/session/__init__.py +9 -0
- diffract_core-0.3.1/src/diffract/session/_identifiers.py +31 -0
- diffract_core-0.3.1/src/diffract/session/errors.py +44 -0
- {diffract_core-0.2.2 → diffract_core-0.3.1}/src/diffract/session/field_cache.py +10 -6
- {diffract_core-0.2.2 → diffract_core-0.3.1}/src/diffract/session/namespaces/compute/__init__.py +121 -14
- {diffract_core-0.2.2 → diffract_core-0.3.1}/src/diffract/session/namespaces/models/__init__.py +27 -3
- {diffract_core-0.2.2 → diffract_core-0.3.1}/src/diffract/session/namespaces/models/parameters/__init__.py +18 -5
- {diffract_core-0.2.2 → diffract_core-0.3.1}/src/diffract/session/namespaces/results/__init__.py +256 -69
- diffract_core-0.3.1/src/diffract/session/namespaces/results/validation.py +193 -0
- {diffract_core-0.2.2 → diffract_core-0.3.1}/src/diffract/session/namespaces/utils/__init__.py +30 -1
- diffract_core-0.3.1/src/diffract/session/namespaces/viz/_utils.py +33 -0
- {diffract_core-0.2.2 → diffract_core-0.3.1}/src/diffract/session/namespaces/viz/box.py +5 -10
- {diffract_core-0.2.2 → diffract_core-0.3.1}/src/diffract/session/namespaces/viz/scatter.py +4 -3
- {diffract_core-0.2.2 → diffract_core-0.3.1}/src/diffract/session/namespaces/viz/sparkline.py +6 -14
- {diffract_core-0.2.2 → diffract_core-0.3.1}/src/diffract/session/namespaces/viz/violin.py +5 -6
- diffract_core-0.3.1/src/diffract/session/resolver.py +124 -0
- {diffract_core-0.2.2 → diffract_core-0.3.1}/src/diffract/session/session.py +20 -2
- diffract_core-0.3.1/src/diffract/session/summaries.py +49 -0
- {diffract_core-0.2.2 → diffract_core-0.3.1}/src/diffract/session/utils.py +18 -0
- {diffract_core-0.2.2 → diffract_core-0.3.1}/src/diffract/viz/data/extraction.py +23 -10
- {diffract_core-0.2.2 → diffract_core-0.3.1}/src/diffract/viz/data/ordering.py +2 -2
- {diffract_core-0.2.2 → diffract_core-0.3.1}/src/diffract/viz/renderer.py +3 -15
- {diffract_core-0.2.2 → diffract_core-0.3.1}/src/diffract/viz/styling/__init__.py +2 -0
- {diffract_core-0.2.2 → diffract_core-0.3.1}/src/diffract/viz/styling/sources.py +22 -0
- {diffract_core-0.2.2 → diffract_core-0.3.1}/tests/conftest.py +55 -34
- {diffract_core-0.2.2 → diffract_core-0.3.1}/tests/integration/__init__.py +0 -1
- {diffract_core-0.2.2 → diffract_core-0.3.1}/tests/integration/helpers.py +6 -7
- {diffract_core-0.2.2 → diffract_core-0.3.1}/tests/integration/test_containers.py +13 -11
- {diffract_core-0.2.2 → diffract_core-0.3.1}/tests/integration/test_full_stack_redis_hdf5.py +8 -8
- {diffract_core-0.2.2 → diffract_core-0.3.1}/tests/integration/test_full_stack_redis_hybrid.py +3 -5
- {diffract_core-0.2.2 → diffract_core-0.3.1}/tests/integration/test_full_stack_redis_sqlite.py +10 -16
- {diffract_core-0.2.2 → diffract_core-0.3.1}/tests/integration/test_full_stack_simple_cache_storage.py +10 -10
- {diffract_core-0.2.2 → diffract_core-0.3.1}/tests/integration/test_hybrid_zarr_s3.py +12 -19
- {diffract_core-0.2.2 → diffract_core-0.3.1}/tests/integration/test_redis_cache.py +34 -8
- {diffract_core-0.2.2 → diffract_core-0.3.1}/tests/integration/test_stress_concurrent_operations.py +36 -17
- {diffract_core-0.2.2 → diffract_core-0.3.1}/tests/integration/test_stress_large_datasets.py +17 -10
- {diffract_core-0.2.2 → diffract_core-0.3.1}/tests/integration/test_stress_session_operations.py +5 -3
- {diffract_core-0.2.2 → diffract_core-0.3.1}/tests/unit/core/cache/test_simple_cache.py +3 -3
- diffract_core-0.3.1/tests/unit/core/compute/extensions/test_fpenv.py +79 -0
- diffract_core-0.3.1/tests/unit/core/compute/kernels/conftest.py +29 -0
- diffract_core-0.3.1/tests/unit/core/compute/kernels/test_alignment.py +195 -0
- {diffract_core-0.2.2 → diffract_core-0.3.1}/tests/unit/core/compute/kernels/test_heavy_tailed.py +158 -27
- {diffract_core-0.2.2 → diffract_core-0.3.1}/tests/unit/core/compute/kernels/test_kernel_smoke.py +4 -4
- diffract_core-0.3.1/tests/unit/core/compute/kernels/test_marchenko_pastur.py +328 -0
- diffract_core-0.3.1/tests/unit/core/compute/kernels/test_mat_decomposition.py +192 -0
- diffract_core-0.3.1/tests/unit/core/compute/kernels/test_mat_properties.py +151 -0
- diffract_core-0.3.1/tests/unit/core/compute/kernels/test_model_quality.py +60 -0
- diffract_core-0.3.1/tests/unit/core/compute/kernels/test_norms.py +240 -0
- diffract_core-0.3.1/tests/unit/core/compute/kernels/test_ranks.py +123 -0
- diffract_core-0.3.1/tests/unit/core/compute/kernels/test_tracy_widom.py +127 -0
- {diffract_core-0.2.2 → diffract_core-0.3.1}/tests/unit/core/compute/test_default_kernels.py +5 -3
- {diffract_core-0.2.2 → diffract_core-0.3.1}/tests/unit/core/compute/test_executor.py +157 -44
- {diffract_core-0.2.2 → diffract_core-0.3.1}/tests/unit/core/compute/test_registry.py +214 -181
- diffract_core-0.3.1/tests/unit/core/data/metadata/test_migrations.py +667 -0
- diffract_core-0.3.1/tests/unit/core/data/metadata/test_sqlite_index.py +42 -0
- {diffract_core-0.2.2 → diffract_core-0.3.1}/tests/unit/core/data/nn/extractors/test_flax_extractors.py +8 -7
- {diffract_core-0.2.2 → diffract_core-0.3.1}/tests/unit/core/data/nn/extractors/test_numpy_extractors.py +5 -5
- {diffract_core-0.2.2 → diffract_core-0.3.1}/tests/unit/core/data/nn/extractors/test_onnx_extractors.py +0 -1
- {diffract_core-0.2.2 → diffract_core-0.3.1}/tests/unit/core/data/nn/extractors/test_tensorflow_extractors.py +0 -1
- {diffract_core-0.2.2 → diffract_core-0.3.1}/tests/unit/core/data/nn/extractors/test_torch_extractors.py +16 -8
- diffract_core-0.3.1/tests/unit/core/data/nn/test_aggregate_uid.py +70 -0
- {diffract_core-0.2.2 → diffract_core-0.3.1}/tests/unit/core/data/nn/test_collection_concurrent.py +56 -29
- {diffract_core-0.2.2 → diffract_core-0.3.1}/tests/unit/core/data/nn/test_parameter_module.py +41 -33
- diffract_core-0.3.1/tests/unit/core/data/test_identity.py +98 -0
- {diffract_core-0.2.2 → diffract_core-0.3.1}/tests/unit/core/export/test_exporters.py +32 -13
- {diffract_core-0.2.2 → diffract_core-0.3.1}/tests/unit/core/export/test_pandas_formatter.py +5 -3
- {diffract_core-0.2.2 → diffract_core-0.3.1}/tests/unit/core/export/test_polars_formatter.py +14 -4
- {diffract_core-0.2.2 → diffract_core-0.3.1}/tests/unit/core/parallel/__init__.py +0 -1
- {diffract_core-0.2.2 → diffract_core-0.3.1}/tests/unit/core/parallel/test_containers.py +0 -2
- {diffract_core-0.2.2 → diffract_core-0.3.1}/tests/unit/core/parallel/test_runtime.py +0 -2
- {diffract_core-0.2.2 → diffract_core-0.3.1}/tests/unit/core/storage/test_hdf5_storage.py +13 -10
- {diffract_core-0.2.2 → diffract_core-0.3.1}/tests/unit/core/storage/test_hybrid_storage.py +18 -20
- diffract_core-0.3.1/tests/unit/core/storage/test_serialization.py +115 -0
- {diffract_core-0.2.2 → diffract_core-0.3.1}/tests/unit/core/storage/test_sqlite_storage.py +75 -32
- {diffract_core-0.2.2 → diffract_core-0.3.1}/tests/unit/core/storage/test_zarr_storage.py +21 -10
- {diffract_core-0.2.2 → diffract_core-0.3.1}/tests/unit/core/utils/test_imports_utils.py +3 -2
- {diffract_core-0.2.2 → diffract_core-0.3.1}/tests/unit/core/utils/test_session_helpers.py +2 -5
- diffract_core-0.3.1/tests/unit/session/test_compute_hints.py +181 -0
- diffract_core-0.3.1/tests/unit/session/test_export_field_validation.py +268 -0
- {diffract_core-0.2.2 → diffract_core-0.3.1}/tests/unit/session/test_field_cache.py +19 -0
- diffract_core-0.3.1/tests/unit/session/test_identifier_validation.py +183 -0
- diffract_core-0.3.1/tests/unit/session/test_resolver.py +291 -0
- diffract_core-0.3.1/tests/unit/session/test_results_export_format.py +80 -0
- {diffract_core-0.2.2 → diffract_core-0.3.1}/tests/unit/session/test_session.py +296 -24
- diffract_core-0.3.1/tests/unit/session/test_store_version.py +148 -0
- diffract_core-0.3.1/tests/unit/test_bench_pipeline.py +166 -0
- {diffract_core-0.2.2 → diffract_core-0.3.1}/tests/unit/test_containers_config_loading.py +27 -1
- {diffract_core-0.2.2 → diffract_core-0.3.1}/tests/unit/test_containers_logging.py +33 -0
- {diffract_core-0.2.2 → diffract_core-0.3.1}/tests/unit/viz/conftest.py +5 -2
- {diffract_core-0.2.2 → diffract_core-0.3.1}/tests/unit/viz/test_common.py +60 -31
- {diffract_core-0.2.2 → diffract_core-0.3.1}/tests/unit/viz/test_plots.py +145 -0
- diffract_core-0.2.2/src/diffract/core/compute/execution/restrictions.py +0 -61
- diffract_core-0.2.2/src/diffract/core/compute/kernels/model_quality.py +0 -27
- diffract_core-0.2.2/src/diffract/core/compute/kernels/norms.py +0 -88
- diffract_core-0.2.2/src/diffract/core/constants.py +0 -147
- diffract_core-0.2.2/src/diffract/core/export/containers.py +0 -47
- diffract_core-0.2.2/src/diffract/session/errors.py +0 -17
- diffract_core-0.2.2/src/diffract/session/namespaces/viz/_utils.py +0 -14
- diffract_core-0.2.2/tests/unit/core/compute/kernels/test_mat_decomposition.py +0 -62
- diffract_core-0.2.2/tests/unit/session/test_compute_hints.py +0 -47
- {diffract_core-0.2.2 → diffract_core-0.3.1}/LICENSE +0 -0
- {diffract_core-0.2.2 → diffract_core-0.3.1}/NOTICE +0 -0
- {diffract_core-0.2.2 → diffract_core-0.3.1}/src/diffract/configs/fast_speed_without_disk.ini +0 -0
- {diffract_core-0.2.2 → diffract_core-0.3.1}/src/diffract/core/cache/__init__.py +0 -0
- {diffract_core-0.2.2 → diffract_core-0.3.1}/src/diffract/core/cache/containers.py +0 -0
- {diffract_core-0.2.2 → diffract_core-0.3.1}/src/diffract/core/compute/__init__.py +0 -0
- {diffract_core-0.2.2 → diffract_core-0.3.1}/src/diffract/core/compute/config.py +0 -0
- {diffract_core-0.2.2 → diffract_core-0.3.1}/src/diffract/core/compute/containers.py +0 -0
- {diffract_core-0.2.2 → diffract_core-0.3.1}/src/diffract/core/compute/decorator.py +0 -0
- {diffract_core-0.2.2 → diffract_core-0.3.1}/src/diffract/core/compute/exceptions.py +0 -0
- {diffract_core-0.2.2 → diffract_core-0.3.1}/src/diffract/core/compute/execution/__init__.py +0 -0
- {diffract_core-0.2.2 → diffract_core-0.3.1}/src/diffract/core/compute/execution/_types.py +0 -0
- {diffract_core-0.2.2 → diffract_core-0.3.1}/src/diffract/core/compute/execution/enums.py +0 -0
- {diffract_core-0.2.2 → diffract_core-0.3.1}/src/diffract/core/compute/execution/strategy.py +0 -0
- {diffract_core-0.2.2 → diffract_core-0.3.1}/src/diffract/core/compute/extensions/__init__.py +0 -0
- {diffract_core-0.2.2 → diffract_core-0.3.1}/src/diffract/core/compute/extensions/rmt.py +0 -0
- {diffract_core-0.2.2 → diffract_core-0.3.1}/src/diffract/core/compute/extensions/utils.py +0 -0
- {diffract_core-0.2.2 → diffract_core-0.3.1}/src/diffract/core/compute/field_signature.py +0 -0
- {diffract_core-0.2.2 → diffract_core-0.3.1}/src/diffract/core/compute/registry.py +0 -0
- {diffract_core-0.2.2 → diffract_core-0.3.1}/src/diffract/core/data/__init__.py +0 -0
- {diffract_core-0.2.2 → diffract_core-0.3.1}/src/diffract/core/data/interface.py +0 -0
- {diffract_core-0.2.2 → diffract_core-0.3.1}/src/diffract/core/data/metadata/containers.py +0 -0
- {diffract_core-0.2.2 → diffract_core-0.3.1}/src/diffract/core/data/metadata/interface.py +0 -0
- {diffract_core-0.2.2 → diffract_core-0.3.1}/src/diffract/core/data/nn/__init__.py +0 -0
- {diffract_core-0.2.2 → diffract_core-0.3.1}/src/diffract/core/data/nn/aggregates/__init__.py +0 -0
- {diffract_core-0.2.2 → diffract_core-0.3.1}/src/diffract/core/data/nn/aggregates/proxy.py +0 -0
- {diffract_core-0.2.2 → diffract_core-0.3.1}/src/diffract/core/data/nn/aggregates/view.py +0 -0
- {diffract_core-0.2.2 → diffract_core-0.3.1}/src/diffract/core/data/nn/containers.py +0 -0
- {diffract_core-0.2.2 → diffract_core-0.3.1}/src/diffract/core/data/nn/extractors/__init__.py +0 -0
- {diffract_core-0.2.2 → diffract_core-0.3.1}/src/diffract/core/data/nn/extractors/flax.py +0 -0
- {diffract_core-0.2.2 → diffract_core-0.3.1}/src/diffract/core/data/nn/extractors/handlers/__init__.py +0 -0
- {diffract_core-0.2.2 → diffract_core-0.3.1}/src/diffract/core/data/nn/extractors/handlers/base.py +0 -0
- {diffract_core-0.2.2 → diffract_core-0.3.1}/src/diffract/core/data/nn/extractors/handlers/flax_handlers.py +0 -0
- {diffract_core-0.2.2 → diffract_core-0.3.1}/src/diffract/core/data/nn/extractors/handlers/numpy_handlers.py +0 -0
- {diffract_core-0.2.2 → diffract_core-0.3.1}/src/diffract/core/data/nn/extractors/handlers/onnx_handlers.py +0 -0
- {diffract_core-0.2.2 → diffract_core-0.3.1}/src/diffract/core/data/nn/extractors/handlers/tensorflow_handlers.py +0 -0
- {diffract_core-0.2.2 → diffract_core-0.3.1}/src/diffract/core/data/nn/extractors/handlers/torch_handlers.py +0 -0
- {diffract_core-0.2.2 → diffract_core-0.3.1}/src/diffract/core/data/nn/extractors/interface.py +0 -0
- {diffract_core-0.2.2 → diffract_core-0.3.1}/src/diffract/core/data/nn/extractors/numpy.py +0 -0
- {diffract_core-0.2.2 → diffract_core-0.3.1}/src/diffract/core/data/nn/extractors/onnx.py +0 -0
- {diffract_core-0.2.2 → diffract_core-0.3.1}/src/diffract/core/data/nn/extractors/tensorflow.py +0 -0
- {diffract_core-0.2.2 → diffract_core-0.3.1}/src/diffract/core/data/nn/extractors/torch.py +0 -0
- {diffract_core-0.2.2 → diffract_core-0.3.1}/src/diffract/core/data/nn/params/__init__.py +0 -0
- {diffract_core-0.2.2 → diffract_core-0.3.1}/src/diffract/core/data/nn/params/interface.py +0 -0
- {diffract_core-0.2.2 → diffract_core-0.3.1}/src/diffract/core/data/nn/params/proxy.py +0 -0
- {diffract_core-0.2.2 → diffract_core-0.3.1}/src/diffract/core/data/nn/params/repository.py +0 -0
- {diffract_core-0.2.2 → diffract_core-0.3.1}/src/diffract/core/data/nn/params/schema.py +0 -0
- {diffract_core-0.2.2 → diffract_core-0.3.1}/src/diffract/core/data/nn/params/view.py +0 -0
- {diffract_core-0.2.2 → diffract_core-0.3.1}/src/diffract/core/data/proxy.py +0 -0
- {diffract_core-0.2.2 → diffract_core-0.3.1}/src/diffract/core/data/repository.py +0 -0
- {diffract_core-0.2.2 → diffract_core-0.3.1}/src/diffract/core/data/utils.py +0 -0
- {diffract_core-0.2.2 → diffract_core-0.3.1}/src/diffract/core/data/view.py +0 -0
- {diffract_core-0.2.2 → diffract_core-0.3.1}/src/diffract/core/export/__init__.py +0 -0
- {diffract_core-0.2.2 → diffract_core-0.3.1}/src/diffract/core/export/exporters.py +0 -0
- {diffract_core-0.2.2 → diffract_core-0.3.1}/src/diffract/core/export/formatters/__init__.py +0 -0
- {diffract_core-0.2.2 → diffract_core-0.3.1}/src/diffract/core/export/formatters/base.py +0 -0
- {diffract_core-0.2.2 → diffract_core-0.3.1}/src/diffract/core/export/formatters/dict_formatter.py +0 -0
- {diffract_core-0.2.2 → diffract_core-0.3.1}/src/diffract/core/export/formatters/json_formatter.py +0 -0
- {diffract_core-0.2.2 → diffract_core-0.3.1}/src/diffract/core/export/formatters/list_formatter.py +0 -0
- {diffract_core-0.2.2 → diffract_core-0.3.1}/src/diffract/core/export/formatters/pandas_formatter.py +0 -0
- {diffract_core-0.2.2 → diffract_core-0.3.1}/src/diffract/core/export/formatters/polars_formatter.py +0 -0
- {diffract_core-0.2.2 → diffract_core-0.3.1}/src/diffract/core/export/formatters/registry.py +0 -0
- {diffract_core-0.2.2 → diffract_core-0.3.1}/src/diffract/core/export/interface.py +0 -0
- {diffract_core-0.2.2 → diffract_core-0.3.1}/src/diffract/core/parallel/__init__.py +0 -0
- {diffract_core-0.2.2 → diffract_core-0.3.1}/src/diffract/core/parallel/containers.py +0 -0
- {diffract_core-0.2.2 → diffract_core-0.3.1}/src/diffract/core/parallel/execution.py +0 -0
- {diffract_core-0.2.2 → diffract_core-0.3.1}/src/diffract/core/parallel/runtime.py +0 -0
- {diffract_core-0.2.2 → diffract_core-0.3.1}/src/diffract/core/storage/__init__.py +0 -0
- {diffract_core-0.2.2 → diffract_core-0.3.1}/src/diffract/core/storage/containers.py +0 -0
- {diffract_core-0.2.2 → diffract_core-0.3.1}/src/diffract/core/storage/hybrid_manager.py +0 -0
- {diffract_core-0.2.2 → diffract_core-0.3.1}/src/diffract/core/storage/interface.py +0 -0
- {diffract_core-0.2.2 → diffract_core-0.3.1}/src/diffract/core/storage/metadata.py +0 -0
- {diffract_core-0.2.2 → diffract_core-0.3.1}/src/diffract/core/storage/ram_manager.py +0 -0
- {diffract_core-0.2.2 → diffract_core-0.3.1}/src/diffract/core/utils/__init__.py +0 -0
- {diffract_core-0.2.2 → diffract_core-0.3.1}/src/diffract/core/utils/build.py +0 -0
- {diffract_core-0.2.2 → diffract_core-0.3.1}/src/diffract/core/utils/exceptions.py +0 -0
- {diffract_core-0.2.2 → diffract_core-0.3.1}/src/diffract/core/utils/hashing.py +0 -0
- {diffract_core-0.2.2 → diffract_core-0.3.1}/src/diffract/core/utils/imports.py +0 -0
- {diffract_core-0.2.2 → diffract_core-0.3.1}/src/diffract/core/utils/math.py +0 -0
- {diffract_core-0.2.2 → diffract_core-0.3.1}/src/diffract/py.typed +0 -0
- {diffract_core-0.2.2 → diffract_core-0.3.1}/src/diffract/session/namespaces/__init__.py +0 -0
- {diffract_core-0.2.2 → diffract_core-0.3.1}/src/diffract/session/namespaces/models/parameters/meta_patcher.py +0 -0
- {diffract_core-0.2.2 → diffract_core-0.3.1}/src/diffract/session/namespaces/results/eraser.py +0 -0
- {diffract_core-0.2.2 → diffract_core-0.3.1}/src/diffract/session/namespaces/results/injester.py +0 -0
- {diffract_core-0.2.2 → diffract_core-0.3.1}/src/diffract/session/namespaces/utils/merger.py +0 -0
- {diffract_core-0.2.2 → diffract_core-0.3.1}/src/diffract/session/namespaces/viz/__init__.py +0 -0
- {diffract_core-0.2.2 → diffract_core-0.3.1}/src/diffract/session/namespaces/viz/grid.py +0 -0
- {diffract_core-0.2.2 → diffract_core-0.3.1}/src/diffract/session/namespaces/viz/heatmap.py +0 -0
- {diffract_core-0.2.2 → diffract_core-0.3.1}/src/diffract/viz/__init__.py +0 -0
- {diffract_core-0.2.2 → diffract_core-0.3.1}/src/diffract/viz/data/__init__.py +0 -0
- {diffract_core-0.2.2 → diffract_core-0.3.1}/src/diffract/viz/data/detection.py +0 -0
- {diffract_core-0.2.2 → diffract_core-0.3.1}/src/diffract/viz/data/filtering.py +0 -0
- {diffract_core-0.2.2 → diffract_core-0.3.1}/src/diffract/viz/data/provider.py +0 -0
- {diffract_core-0.2.2 → diffract_core-0.3.1}/src/diffract/viz/data/types.py +0 -0
- {diffract_core-0.2.2 → diffract_core-0.3.1}/src/diffract/viz/plots/__init__.py +0 -0
- {diffract_core-0.2.2 → diffract_core-0.3.1}/src/diffract/viz/plots/base/__init__.py +0 -0
- {diffract_core-0.2.2 → diffract_core-0.3.1}/src/diffract/viz/plots/base/axis.py +0 -0
- {diffract_core-0.2.2 → diffract_core-0.3.1}/src/diffract/viz/plots/base/coloraxis.py +0 -0
- {diffract_core-0.2.2 → diffract_core-0.3.1}/src/diffract/viz/plots/base/configurator.py +0 -0
- {diffract_core-0.2.2 → diffract_core-0.3.1}/src/diffract/viz/plots/base/jitter.py +0 -0
- {diffract_core-0.2.2 → diffract_core-0.3.1}/src/diffract/viz/plots/base/line.py +0 -0
- {diffract_core-0.2.2 → diffract_core-0.3.1}/src/diffract/viz/plots/base/marker.py +0 -0
- {diffract_core-0.2.2 → diffract_core-0.3.1}/src/diffract/viz/plots/base/overlay.py +0 -0
- {diffract_core-0.2.2 → diffract_core-0.3.1}/src/diffract/viz/plots/base/plot.py +0 -0
- {diffract_core-0.2.2 → diffract_core-0.3.1}/src/diffract/viz/plots/base/update.py +0 -0
- {diffract_core-0.2.2 → diffract_core-0.3.1}/src/diffract/viz/plots/boxplot.py +0 -0
- {diffract_core-0.2.2 → diffract_core-0.3.1}/src/diffract/viz/plots/cluster.py +0 -0
- {diffract_core-0.2.2 → diffract_core-0.3.1}/src/diffract/viz/plots/heatmap.py +0 -0
- {diffract_core-0.2.2 → diffract_core-0.3.1}/src/diffract/viz/plots/scatter.py +0 -0
- {diffract_core-0.2.2 → diffract_core-0.3.1}/src/diffract/viz/plots/sparkline.py +0 -0
- {diffract_core-0.2.2 → diffract_core-0.3.1}/src/diffract/viz/plots/subplots/__init__.py +0 -0
- {diffract_core-0.2.2 → diffract_core-0.3.1}/src/diffract/viz/plots/subplots/coloraxis.py +0 -0
- {diffract_core-0.2.2 → diffract_core-0.3.1}/src/diffract/viz/plots/subplots/factory.py +0 -0
- {diffract_core-0.2.2 → diffract_core-0.3.1}/src/diffract/viz/plots/subplots/grid.py +0 -0
- {diffract_core-0.2.2 → diffract_core-0.3.1}/src/diffract/viz/plots/subplots/layout.py +0 -0
- {diffract_core-0.2.2 → diffract_core-0.3.1}/src/diffract/viz/plots/subplots/spec.py +0 -0
- {diffract_core-0.2.2 → diffract_core-0.3.1}/src/diffract/viz/plots/violin.py +0 -0
- {diffract_core-0.2.2 → diffract_core-0.3.1}/src/diffract/viz/styling/palettes/__init__.py +0 -0
- {diffract_core-0.2.2 → diffract_core-0.3.1}/src/diffract/viz/styling/palettes/bundle.py +0 -0
- {diffract_core-0.2.2 → diffract_core-0.3.1}/src/diffract/viz/styling/palettes/color.py +0 -0
- {diffract_core-0.2.2 → diffract_core-0.3.1}/src/diffract/viz/styling/palettes/dashes.py +0 -0
- {diffract_core-0.2.2 → diffract_core-0.3.1}/src/diffract/viz/styling/palettes/symbols.py +0 -0
- {diffract_core-0.2.2 → diffract_core-0.3.1}/src/diffract/viz/styling/resolvers/__init__.py +0 -0
- {diffract_core-0.2.2 → diffract_core-0.3.1}/src/diffract/viz/styling/resolvers/categorical.py +0 -0
- {diffract_core-0.2.2 → diffract_core-0.3.1}/src/diffract/viz/styling/resolvers/color.py +0 -0
- {diffract_core-0.2.2 → diffract_core-0.3.1}/src/diffract/viz/styling/resolvers/numeric.py +0 -0
- {diffract_core-0.2.2 → diffract_core-0.3.1}/src/diffract/viz/styling/theme/__init__.py +0 -0
- {diffract_core-0.2.2 → diffract_core-0.3.1}/src/diffract/viz/styling/theme/applier.py +0 -0
- {diffract_core-0.2.2 → diffract_core-0.3.1}/src/diffract/viz/styling/theme/components.py +0 -0
- {diffract_core-0.2.2 → diffract_core-0.3.1}/src/diffract/viz/styling/theme/presets.py +0 -0
- {diffract_core-0.2.2 → diffract_core-0.3.1}/src/diffract/viz/styling/theme/theme.py +0 -0
- {diffract_core-0.2.2 → diffract_core-0.3.1}/tests/unit/conftest.py +0 -0
- {diffract_core-0.2.2 → diffract_core-0.3.1}/tests/unit/core/compute/extensions/__init__.py +0 -0
- {diffract_core-0.2.2 → diffract_core-0.3.1}/tests/unit/core/compute/extensions/_golden/rmt_values.json +0 -0
- {diffract_core-0.2.2 → diffract_core-0.3.1}/tests/unit/core/compute/extensions/test_rmt.py +0 -0
- {diffract_core-0.2.2 → diffract_core-0.3.1}/tests/unit/core/compute/kernels/__init__.py +0 -0
- {diffract_core-0.2.2 → diffract_core-0.3.1}/tests/unit/core/compute/test_field_signature.py +4 -4
- {diffract_core-0.2.2 → diffract_core-0.3.1}/tests/unit/core/export/test_formatter_hints.py +0 -0
- {diffract_core-0.2.2 → diffract_core-0.3.1}/tests/unit/core/storage/test_ram_storage.py +1 -1
- {diffract_core-0.2.2 → diffract_core-0.3.1}/tests/unit/session/__init__.py +0 -0
- {diffract_core-0.2.2 → diffract_core-0.3.1}/tests/unit/viz/__init__.py +0 -0
- {diffract_core-0.2.2 → diffract_core-0.3.1}/tests/unit/viz/test_data_source.py +0 -0
- {diffract_core-0.2.2 → diffract_core-0.3.1}/tests/unit/viz/test_field_ref_coercion.py +0 -0
- {diffract_core-0.2.2 → diffract_core-0.3.1}/tests/unit/viz/test_renderer.py +0 -0
- {diffract_core-0.2.2 → diffract_core-0.3.1}/tests/unit/viz/test_themes.py +0 -0
|
@@ -2,6 +2,9 @@
|
|
|
2
2
|
model_checkpoints
|
|
3
3
|
.diffract
|
|
4
4
|
|
|
5
|
+
# Benchmark reports (machine-specific; regenerated by scripts/bench_pipeline.py)
|
|
6
|
+
bench_pipeline_results*.json
|
|
7
|
+
|
|
5
8
|
# Byte-compiled / optimized
|
|
6
9
|
__pycache__/
|
|
7
10
|
*.py[cod]
|
|
@@ -75,6 +78,7 @@ instance/
|
|
|
75
78
|
# Sphinx documentation
|
|
76
79
|
docs/_build/
|
|
77
80
|
docs/reference/_generated/
|
|
81
|
+
docs/reference/metrics/_generated_table.md
|
|
78
82
|
|
|
79
83
|
# PyBuilder
|
|
80
84
|
target/
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: diffract-core
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.3.1
|
|
4
4
|
Summary: Spectral analysis of neural network weights and their evolution over training
|
|
5
5
|
Project-URL: Homepage, https://github.com/Risk-AI-Research/diffract
|
|
6
6
|
Project-URL: Documentation, https://risk-ai-research.github.io/diffract/
|
|
@@ -41,6 +41,8 @@ Requires-Dist: polars>=0.20.0; extra == 'all'
|
|
|
41
41
|
Requires-Dist: pyyaml>=6.0.1; extra == 'all'
|
|
42
42
|
Requires-Dist: taichi>=1.7.3; extra == 'all'
|
|
43
43
|
Requires-Dist: torch>=2.7.0; extra == 'all'
|
|
44
|
+
Provides-Extra: bench
|
|
45
|
+
Requires-Dist: psutil>=5.9.0; extra == 'bench'
|
|
44
46
|
Provides-Extra: common
|
|
45
47
|
Requires-Dist: hydra-core>=1.3.0; extra == 'common'
|
|
46
48
|
Requires-Dist: kaleido>=0.2.1; extra == 'common'
|
|
@@ -53,6 +55,7 @@ Provides-Extra: dev
|
|
|
53
55
|
Requires-Dist: bandit[toml]>=1.7.5; extra == 'dev'
|
|
54
56
|
Requires-Dist: fsspec>=2024.2.0; extra == 'dev'
|
|
55
57
|
Requires-Dist: hydra-core>=1.3.0; extra == 'dev'
|
|
58
|
+
Requires-Dist: hypothesis>=6.0.0; extra == 'dev'
|
|
56
59
|
Requires-Dist: interrogate>=1.7.0; extra == 'dev'
|
|
57
60
|
Requires-Dist: kaleido>=0.2.1; extra == 'dev'
|
|
58
61
|
Requires-Dist: mypy>=1.10.1; extra == 'dev'
|
|
@@ -61,6 +64,7 @@ Requires-Dist: pandas>=2.1.0; extra == 'dev'
|
|
|
61
64
|
Requires-Dist: plotly>=6.0.0; extra == 'dev'
|
|
62
65
|
Requires-Dist: polars>=0.20.0; extra == 'dev'
|
|
63
66
|
Requires-Dist: pre-commit>=3.6.0; extra == 'dev'
|
|
67
|
+
Requires-Dist: psutil>=5.9.0; extra == 'dev'
|
|
64
68
|
Requires-Dist: pytest-cov>=4.0.0; extra == 'dev'
|
|
65
69
|
Requires-Dist: pytest-mock>=3.12.0; extra == 'dev'
|
|
66
70
|
Requires-Dist: pytest-timeout>=2.4.0; extra == 'dev'
|
|
@@ -81,6 +85,7 @@ Requires-Dist: sphinx-autodoc-typehints>=1.25.0; extra == 'docs'
|
|
|
81
85
|
Requires-Dist: sphinx-copybutton>=0.5.0; extra == 'docs'
|
|
82
86
|
Requires-Dist: sphinx-design>=0.6.0; extra == 'docs'
|
|
83
87
|
Requires-Dist: sphinx>=7.0.0; extra == 'docs'
|
|
88
|
+
Requires-Dist: sphinxcontrib-bibtex>=2.6.0; extra == 'docs'
|
|
84
89
|
Requires-Dist: sphinxext-opengraph>=0.9.0; extra == 'docs'
|
|
85
90
|
Provides-Extra: flax
|
|
86
91
|
Requires-Dist: flax>=0.10.0; extra == 'flax'
|
|
@@ -128,7 +133,8 @@ Description-Content-Type: text/markdown
|
|
|
128
133
|
[](https://risk-ai-research.github.io/diffract/)
|
|
129
134
|
[](https://opensource.org/licenses/Apache-2.0)
|
|
130
135
|
|
|
131
|
-
Official library of
|
|
136
|
+
Official library of
|
|
137
|
+
["Diffract: Spectral View of LLM Domain Adaptation"](https://openreview.net/forum?id=XBUHoiAGDE)
|
|
132
138
|
(**ICML 2026 Oral**).
|
|
133
139
|
|
|
134
140
|
Diffract is a Python package for analyzing deep neural network weights and tracking
|
|
@@ -145,7 +151,7 @@ dictionaries of NumPy weight matrices.
|
|
|
145
151
|
|
|
146
152
|
## 🚀 Quick Start
|
|
147
153
|
|
|
148
|
-
Diffract requires Python 3.12. The core package installs without any deep
|
|
154
|
+
Diffract requires Python 3.12 or newer. The core package installs without any deep
|
|
149
155
|
learning framework; heavy dependencies are opt-in extras:
|
|
150
156
|
|
|
151
157
|
```bash
|
|
@@ -156,10 +162,9 @@ pip install "diffract-core[taichi]" # + accelerated heavy-tailed fits and p
|
|
|
156
162
|
pip install "diffract-core[all]" # torch + viz + taichi + pandas/polars exports
|
|
157
163
|
```
|
|
158
164
|
|
|
159
|
-
Further extras: `frameworks` (TensorFlow, Flax, ONNX), `pandas` / `polars`
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
`"diffract-core[...]"` matter in zsh.
|
|
165
|
+
Further extras: `frameworks` (TensorFlow, Flax, ONNX), `pandas` / `polars` (DataFrame
|
|
166
|
+
exports), `zarr` (cloud storage), `redis` (shared cache), `notebooks` (tooling for the
|
|
167
|
+
example notebooks). The quotes around `"diffract-core[...]"` matter in zsh.
|
|
163
168
|
|
|
164
169
|
### Development Install
|
|
165
170
|
|
|
@@ -167,7 +172,7 @@ Further extras: `frameworks` (TensorFlow, Flax, ONNX), `pandas` / `polars`
|
|
|
167
172
|
# Install uv if you haven't already
|
|
168
173
|
curl -LsSf https://astral.sh/uv/install.sh | sh
|
|
169
174
|
|
|
170
|
-
# Clone and install (uv provisions Python
|
|
175
|
+
# Clone and install (uv provisions the right Python automatically)
|
|
171
176
|
git clone https://github.com/Risk-AI-Research/diffract.git
|
|
172
177
|
cd diffract
|
|
173
178
|
uv sync --extra dev --extra torch
|
|
@@ -220,7 +225,7 @@ internal structure:
|
|
|
220
225
|
|
|
221
226
|
<br>
|
|
222
227
|
|
|
223
|
-
##
|
|
228
|
+
## Key Features
|
|
224
229
|
|
|
225
230
|
- **Session-based API**: Simple `models.add`, `compute.apply`, and
|
|
226
231
|
`results.export_metrics` workflow.
|
|
@@ -233,9 +238,12 @@ internal structure:
|
|
|
233
238
|
HDF5, SQLite, Zarr, and hybrid backends.
|
|
234
239
|
|
|
235
240
|
- **Kernel Apply Levels**: Kernels can work at multiple levels:
|
|
241
|
+
|
|
236
242
|
- **PARAMETER** - Operate on individual weight matrices.
|
|
237
243
|
- **IN_MODEL** - Aggregate within a single model.
|
|
238
|
-
- **CROSS_MODEL** - Compare or aggregate across models.
|
|
244
|
+
- **CROSS_MODEL** - Compare or aggregate across models. Pairwise comparisons
|
|
245
|
+
(the alignment/overlap family) compare exactly two models—scope to a pair with
|
|
246
|
+
`filter(model_ids=[a, b])`.
|
|
239
247
|
|
|
240
248
|
- **Built-in Visualization**: Publication-ready Plotly plots with theming support.
|
|
241
249
|
|
|
@@ -258,7 +266,9 @@ session = Session()
|
|
|
258
266
|
|
|
259
267
|
with session:
|
|
260
268
|
session.models.add(torch_model) # torch.nn.Module
|
|
261
|
-
session.models.add(
|
|
269
|
+
session.models.add(
|
|
270
|
+
torch_state_dict, model_id="checkpoint"
|
|
271
|
+
) # Dict[str, torch.Tensor]
|
|
262
272
|
session.models.add(numpy_weights, model_id="raw-weights") # Dict[str, np.ndarray]
|
|
263
273
|
session.models.add(onnx_model, model_id="onnx-model") # onnx.ModelProto
|
|
264
274
|
session.models.add(flax_model, model_id="flax-model") # flax.linen.Module
|
|
@@ -274,6 +284,10 @@ session.compute.apply("frob_norm", "stable_rank")
|
|
|
274
284
|
session.compute.apply("pl_ks") # has many dependencies—all resolved automatically
|
|
275
285
|
```
|
|
276
286
|
|
|
287
|
+
Every built-in metric—its formula, apply level, required inputs, and configuration—is
|
|
288
|
+
catalogued in the
|
|
289
|
+
[metrics reference](https://risk-ai-research.github.io/diffract/reference/metrics/).
|
|
290
|
+
|
|
277
291
|
### Filtering Parameters
|
|
278
292
|
|
|
279
293
|
Filter computations by model, parameter type, or name:
|
|
@@ -309,16 +323,21 @@ with attn:
|
|
|
309
323
|
Export results in various formats (`pandas`, `polars`, `dict`, `json`, or `list`):
|
|
310
324
|
|
|
311
325
|
```python
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
#
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
326
|
+
with session:
|
|
327
|
+
session.compute.apply("stable_rank", "log_norm")
|
|
328
|
+
|
|
329
|
+
# PARAMETER-level fields come from export_metrics
|
|
330
|
+
scalars_df = session.results.export_metrics("stable_rank", export_format="pandas")
|
|
331
|
+
# IN_MODEL / CROSS_MODEL fields come from export_aggregates
|
|
332
|
+
aggregates_df = session.results.export_aggregates(
|
|
333
|
+
"log_norm", export_format="pandas"
|
|
334
|
+
)
|
|
335
|
+
|
|
336
|
+
# Other formats work the same way
|
|
337
|
+
results = session.results.export_metrics("stable_rank", export_format="polars")
|
|
338
|
+
results = session.results.export_metrics("stable_rank", export_format="dict")
|
|
339
|
+
results = session.results.export_metrics("stable_rank", export_format="json")
|
|
340
|
+
results = session.results.export_metrics("stable_rank", export_format="list")
|
|
322
341
|
```
|
|
323
342
|
|
|
324
343
|
### Visualization
|
|
@@ -352,9 +371,22 @@ List and configure kernels at runtime:
|
|
|
352
371
|
```python
|
|
353
372
|
session.compute.list_available_kernels(verbose=True)
|
|
354
373
|
session.compute.list_available_metrics(verbose=True)
|
|
355
|
-
session.compute.configure_kernel("hard_rank",
|
|
374
|
+
session.compute.configure_kernel("hard_rank", rtol=1e-6)
|
|
356
375
|
```
|
|
357
376
|
|
|
377
|
+
Configuration takes effect when a kernel executes. Fields already stored are reused
|
|
378
|
+
as-is — `apply` skips them by field presence, without comparing stored values to the
|
|
379
|
+
current configuration. To recompute under a new configuration, erase the stored fields
|
|
380
|
+
first:
|
|
381
|
+
|
|
382
|
+
```python
|
|
383
|
+
session.results.erase("hard_rank")
|
|
384
|
+
session.compute.apply("hard_rank") # computes with rtol=1e-6
|
|
385
|
+
```
|
|
386
|
+
|
|
387
|
+
See [kernel configuration](https://risk-ai-research.github.io/diffract/guide/recipes/kernels_and_compute.html)
|
|
388
|
+
for the erase-then-apply pattern with multi-output kernels and dependent fields.
|
|
389
|
+
|
|
358
390
|
### Session Management
|
|
359
391
|
|
|
360
392
|
Parameters and results stay available whenever the session is reopened. `Session()`
|
|
@@ -403,8 +435,11 @@ You can also override the registered name and output fields:
|
|
|
403
435
|
|
|
404
436
|
```python
|
|
405
437
|
with session:
|
|
438
|
+
|
|
406
439
|
@session.compute.kernel(name="scaled_metric", produce_fields=["scaled_result"])
|
|
407
|
-
def custom_analysis(
|
|
440
|
+
def custom_analysis(
|
|
441
|
+
frob_norm: float, stable_rank: float, *, weight: float = 0.5
|
|
442
|
+
) -> float:
|
|
408
443
|
"""Custom analysis combining multiple metrics."""
|
|
409
444
|
return weight * frob_norm + (1 - weight) * stable_rank
|
|
410
445
|
```
|
|
@@ -449,9 +484,9 @@ Diffract offers built-in **profiles** for common setups:
|
|
|
449
484
|
from diffract import Session
|
|
450
485
|
|
|
451
486
|
# Use a profile (recommended for most users)
|
|
452
|
-
session = Session(profile="ram")
|
|
453
|
-
session = Session(profile="local")
|
|
454
|
-
session = Session(profile="hybrid")
|
|
487
|
+
session = Session(profile="ram") # fast, temporary
|
|
488
|
+
session = Session(profile="local") # persistent, simple
|
|
489
|
+
session = Session(profile="hybrid") # persistent, optimized for large arrays
|
|
455
490
|
|
|
456
491
|
# Or use a custom config file for full control
|
|
457
492
|
session = Session(config_path="my_config.ini")
|
|
@@ -497,12 +532,14 @@ max_workers = 4
|
|
|
497
532
|
|
|
498
533
|
## 📚 Documentation
|
|
499
534
|
|
|
500
|
-
The documentation
|
|
501
|
-
|
|
535
|
+
The documentation is hosted at
|
|
536
|
+
[risk-ai-research.github.io/diffract](https://risk-ai-research.github.io/diffract/). It
|
|
537
|
+
is sourced from `docs/` and built with Sphinx + MyST; `uv sync --extra docs` and
|
|
538
|
+
`make docs` render the HTML locally.
|
|
502
539
|
|
|
503
540
|
<br>
|
|
504
541
|
|
|
505
|
-
##
|
|
542
|
+
## Citation
|
|
506
543
|
|
|
507
544
|
If you use Diffract or build on the paper, please cite:
|
|
508
545
|
|
|
@@ -518,14 +555,14 @@ If you use Diffract or build on the paper, please cite:
|
|
|
518
555
|
|
|
519
556
|
<br>
|
|
520
557
|
|
|
521
|
-
##
|
|
558
|
+
## Contributions
|
|
522
559
|
|
|
523
|
-
Contributions are welcome
|
|
524
|
-
|
|
560
|
+
Contributions are welcome — see [CONTRIBUTING.md](CONTRIBUTING.md) for the development
|
|
561
|
+
setup, the checks CI runs, and the design principles.
|
|
525
562
|
|
|
526
563
|
<br>
|
|
527
564
|
|
|
528
|
-
##
|
|
565
|
+
## License
|
|
529
566
|
|
|
530
567
|
Licensed under the Apache License 2.0 — see [LICENSE](LICENSE). Copyright 2026 Risk AI
|
|
531
568
|
Research.
|
|
@@ -6,7 +6,8 @@
|
|
|
6
6
|
[](https://risk-ai-research.github.io/diffract/)
|
|
7
7
|
[](https://opensource.org/licenses/Apache-2.0)
|
|
8
8
|
|
|
9
|
-
Official library of
|
|
9
|
+
Official library of
|
|
10
|
+
["Diffract: Spectral View of LLM Domain Adaptation"](https://openreview.net/forum?id=XBUHoiAGDE)
|
|
10
11
|
(**ICML 2026 Oral**).
|
|
11
12
|
|
|
12
13
|
Diffract is a Python package for analyzing deep neural network weights and tracking
|
|
@@ -23,7 +24,7 @@ dictionaries of NumPy weight matrices.
|
|
|
23
24
|
|
|
24
25
|
## 🚀 Quick Start
|
|
25
26
|
|
|
26
|
-
Diffract requires Python 3.12. The core package installs without any deep
|
|
27
|
+
Diffract requires Python 3.12 or newer. The core package installs without any deep
|
|
27
28
|
learning framework; heavy dependencies are opt-in extras:
|
|
28
29
|
|
|
29
30
|
```bash
|
|
@@ -34,10 +35,9 @@ pip install "diffract-core[taichi]" # + accelerated heavy-tailed fits and p
|
|
|
34
35
|
pip install "diffract-core[all]" # torch + viz + taichi + pandas/polars exports
|
|
35
36
|
```
|
|
36
37
|
|
|
37
|
-
Further extras: `frameworks` (TensorFlow, Flax, ONNX), `pandas` / `polars`
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
`"diffract-core[...]"` matter in zsh.
|
|
38
|
+
Further extras: `frameworks` (TensorFlow, Flax, ONNX), `pandas` / `polars` (DataFrame
|
|
39
|
+
exports), `zarr` (cloud storage), `redis` (shared cache), `notebooks` (tooling for the
|
|
40
|
+
example notebooks). The quotes around `"diffract-core[...]"` matter in zsh.
|
|
41
41
|
|
|
42
42
|
### Development Install
|
|
43
43
|
|
|
@@ -45,7 +45,7 @@ Further extras: `frameworks` (TensorFlow, Flax, ONNX), `pandas` / `polars`
|
|
|
45
45
|
# Install uv if you haven't already
|
|
46
46
|
curl -LsSf https://astral.sh/uv/install.sh | sh
|
|
47
47
|
|
|
48
|
-
# Clone and install (uv provisions Python
|
|
48
|
+
# Clone and install (uv provisions the right Python automatically)
|
|
49
49
|
git clone https://github.com/Risk-AI-Research/diffract.git
|
|
50
50
|
cd diffract
|
|
51
51
|
uv sync --extra dev --extra torch
|
|
@@ -98,7 +98,7 @@ internal structure:
|
|
|
98
98
|
|
|
99
99
|
<br>
|
|
100
100
|
|
|
101
|
-
##
|
|
101
|
+
## Key Features
|
|
102
102
|
|
|
103
103
|
- **Session-based API**: Simple `models.add`, `compute.apply`, and
|
|
104
104
|
`results.export_metrics` workflow.
|
|
@@ -111,9 +111,12 @@ internal structure:
|
|
|
111
111
|
HDF5, SQLite, Zarr, and hybrid backends.
|
|
112
112
|
|
|
113
113
|
- **Kernel Apply Levels**: Kernels can work at multiple levels:
|
|
114
|
+
|
|
114
115
|
- **PARAMETER** - Operate on individual weight matrices.
|
|
115
116
|
- **IN_MODEL** - Aggregate within a single model.
|
|
116
|
-
- **CROSS_MODEL** - Compare or aggregate across models.
|
|
117
|
+
- **CROSS_MODEL** - Compare or aggregate across models. Pairwise comparisons
|
|
118
|
+
(the alignment/overlap family) compare exactly two models—scope to a pair with
|
|
119
|
+
`filter(model_ids=[a, b])`.
|
|
117
120
|
|
|
118
121
|
- **Built-in Visualization**: Publication-ready Plotly plots with theming support.
|
|
119
122
|
|
|
@@ -136,7 +139,9 @@ session = Session()
|
|
|
136
139
|
|
|
137
140
|
with session:
|
|
138
141
|
session.models.add(torch_model) # torch.nn.Module
|
|
139
|
-
session.models.add(
|
|
142
|
+
session.models.add(
|
|
143
|
+
torch_state_dict, model_id="checkpoint"
|
|
144
|
+
) # Dict[str, torch.Tensor]
|
|
140
145
|
session.models.add(numpy_weights, model_id="raw-weights") # Dict[str, np.ndarray]
|
|
141
146
|
session.models.add(onnx_model, model_id="onnx-model") # onnx.ModelProto
|
|
142
147
|
session.models.add(flax_model, model_id="flax-model") # flax.linen.Module
|
|
@@ -152,6 +157,10 @@ session.compute.apply("frob_norm", "stable_rank")
|
|
|
152
157
|
session.compute.apply("pl_ks") # has many dependencies—all resolved automatically
|
|
153
158
|
```
|
|
154
159
|
|
|
160
|
+
Every built-in metric—its formula, apply level, required inputs, and configuration—is
|
|
161
|
+
catalogued in the
|
|
162
|
+
[metrics reference](https://risk-ai-research.github.io/diffract/reference/metrics/).
|
|
163
|
+
|
|
155
164
|
### Filtering Parameters
|
|
156
165
|
|
|
157
166
|
Filter computations by model, parameter type, or name:
|
|
@@ -187,16 +196,21 @@ with attn:
|
|
|
187
196
|
Export results in various formats (`pandas`, `polars`, `dict`, `json`, or `list`):
|
|
188
197
|
|
|
189
198
|
```python
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
#
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
199
|
+
with session:
|
|
200
|
+
session.compute.apply("stable_rank", "log_norm")
|
|
201
|
+
|
|
202
|
+
# PARAMETER-level fields come from export_metrics
|
|
203
|
+
scalars_df = session.results.export_metrics("stable_rank", export_format="pandas")
|
|
204
|
+
# IN_MODEL / CROSS_MODEL fields come from export_aggregates
|
|
205
|
+
aggregates_df = session.results.export_aggregates(
|
|
206
|
+
"log_norm", export_format="pandas"
|
|
207
|
+
)
|
|
208
|
+
|
|
209
|
+
# Other formats work the same way
|
|
210
|
+
results = session.results.export_metrics("stable_rank", export_format="polars")
|
|
211
|
+
results = session.results.export_metrics("stable_rank", export_format="dict")
|
|
212
|
+
results = session.results.export_metrics("stable_rank", export_format="json")
|
|
213
|
+
results = session.results.export_metrics("stable_rank", export_format="list")
|
|
200
214
|
```
|
|
201
215
|
|
|
202
216
|
### Visualization
|
|
@@ -230,9 +244,22 @@ List and configure kernels at runtime:
|
|
|
230
244
|
```python
|
|
231
245
|
session.compute.list_available_kernels(verbose=True)
|
|
232
246
|
session.compute.list_available_metrics(verbose=True)
|
|
233
|
-
session.compute.configure_kernel("hard_rank",
|
|
247
|
+
session.compute.configure_kernel("hard_rank", rtol=1e-6)
|
|
234
248
|
```
|
|
235
249
|
|
|
250
|
+
Configuration takes effect when a kernel executes. Fields already stored are reused
|
|
251
|
+
as-is — `apply` skips them by field presence, without comparing stored values to the
|
|
252
|
+
current configuration. To recompute under a new configuration, erase the stored fields
|
|
253
|
+
first:
|
|
254
|
+
|
|
255
|
+
```python
|
|
256
|
+
session.results.erase("hard_rank")
|
|
257
|
+
session.compute.apply("hard_rank") # computes with rtol=1e-6
|
|
258
|
+
```
|
|
259
|
+
|
|
260
|
+
See [kernel configuration](https://risk-ai-research.github.io/diffract/guide/recipes/kernels_and_compute.html)
|
|
261
|
+
for the erase-then-apply pattern with multi-output kernels and dependent fields.
|
|
262
|
+
|
|
236
263
|
### Session Management
|
|
237
264
|
|
|
238
265
|
Parameters and results stay available whenever the session is reopened. `Session()`
|
|
@@ -281,8 +308,11 @@ You can also override the registered name and output fields:
|
|
|
281
308
|
|
|
282
309
|
```python
|
|
283
310
|
with session:
|
|
311
|
+
|
|
284
312
|
@session.compute.kernel(name="scaled_metric", produce_fields=["scaled_result"])
|
|
285
|
-
def custom_analysis(
|
|
313
|
+
def custom_analysis(
|
|
314
|
+
frob_norm: float, stable_rank: float, *, weight: float = 0.5
|
|
315
|
+
) -> float:
|
|
286
316
|
"""Custom analysis combining multiple metrics."""
|
|
287
317
|
return weight * frob_norm + (1 - weight) * stable_rank
|
|
288
318
|
```
|
|
@@ -327,9 +357,9 @@ Diffract offers built-in **profiles** for common setups:
|
|
|
327
357
|
from diffract import Session
|
|
328
358
|
|
|
329
359
|
# Use a profile (recommended for most users)
|
|
330
|
-
session = Session(profile="ram")
|
|
331
|
-
session = Session(profile="local")
|
|
332
|
-
session = Session(profile="hybrid")
|
|
360
|
+
session = Session(profile="ram") # fast, temporary
|
|
361
|
+
session = Session(profile="local") # persistent, simple
|
|
362
|
+
session = Session(profile="hybrid") # persistent, optimized for large arrays
|
|
333
363
|
|
|
334
364
|
# Or use a custom config file for full control
|
|
335
365
|
session = Session(config_path="my_config.ini")
|
|
@@ -375,12 +405,14 @@ max_workers = 4
|
|
|
375
405
|
|
|
376
406
|
## 📚 Documentation
|
|
377
407
|
|
|
378
|
-
The documentation
|
|
379
|
-
|
|
408
|
+
The documentation is hosted at
|
|
409
|
+
[risk-ai-research.github.io/diffract](https://risk-ai-research.github.io/diffract/). It
|
|
410
|
+
is sourced from `docs/` and built with Sphinx + MyST; `uv sync --extra docs` and
|
|
411
|
+
`make docs` render the HTML locally.
|
|
380
412
|
|
|
381
413
|
<br>
|
|
382
414
|
|
|
383
|
-
##
|
|
415
|
+
## Citation
|
|
384
416
|
|
|
385
417
|
If you use Diffract or build on the paper, please cite:
|
|
386
418
|
|
|
@@ -396,14 +428,14 @@ If you use Diffract or build on the paper, please cite:
|
|
|
396
428
|
|
|
397
429
|
<br>
|
|
398
430
|
|
|
399
|
-
##
|
|
431
|
+
## Contributions
|
|
400
432
|
|
|
401
|
-
Contributions are welcome
|
|
402
|
-
|
|
433
|
+
Contributions are welcome — see [CONTRIBUTING.md](CONTRIBUTING.md) for the development
|
|
434
|
+
setup, the checks CI runs, and the design principles.
|
|
403
435
|
|
|
404
436
|
<br>
|
|
405
437
|
|
|
406
|
-
##
|
|
438
|
+
## License
|
|
407
439
|
|
|
408
440
|
Licensed under the Apache License 2.0 — see [LICENSE](LICENSE). Copyright 2026 Risk AI
|
|
409
441
|
Research.
|
|
@@ -85,6 +85,7 @@ notebooks = [
|
|
|
85
85
|
"einops >=0.7.0",
|
|
86
86
|
]
|
|
87
87
|
taichi = ["taichi >=1.7.3"]
|
|
88
|
+
bench = ["psutil >=5.9.0"]
|
|
88
89
|
all = [
|
|
89
90
|
"torch >=2.7.0",
|
|
90
91
|
"plotly >=6.0.0",
|
|
@@ -105,14 +106,17 @@ docs = [
|
|
|
105
106
|
"sphinx-design >=0.6.0",
|
|
106
107
|
"furo >=2024.8.0",
|
|
107
108
|
"sphinxext-opengraph >=0.9.0",
|
|
109
|
+
"sphinxcontrib-bibtex >=2.6.0",
|
|
108
110
|
]
|
|
109
111
|
dev = [
|
|
110
112
|
"bandit[toml] >=1.7.5",
|
|
113
|
+
"hypothesis >=6.0.0",
|
|
111
114
|
"interrogate >=1.7.0",
|
|
112
115
|
"mypy >=1.10.1",
|
|
113
116
|
"pandas >=2.1.0",
|
|
114
117
|
"polars >=0.20.0",
|
|
115
118
|
"pre-commit >=3.6.0",
|
|
119
|
+
"psutil >=5.9.0",
|
|
116
120
|
"pytest >=7.4.0",
|
|
117
121
|
"pytest-cov >=4.0.0",
|
|
118
122
|
"pytest-mock >=3.12.0",
|
|
@@ -170,8 +174,10 @@ filterwarnings = [
|
|
|
170
174
|
"ignore::DeprecationWarning",
|
|
171
175
|
"ignore::UserWarning",
|
|
172
176
|
"ignore::PendingDeprecationWarning",
|
|
173
|
-
# taichi 1.7.x ships a docstring with an invalid escape sequence
|
|
174
|
-
|
|
177
|
+
# taichi 1.7.x ships a docstring with an invalid escape sequence; the
|
|
178
|
+
# compile-time warning is attributed to the importing frame rather than
|
|
179
|
+
# the module that carries it, so it is matched by message.
|
|
180
|
+
"ignore:invalid escape sequence:SyntaxWarning",
|
|
175
181
|
]
|
|
176
182
|
log_cli = true
|
|
177
183
|
log_cli_level = "INFO"
|
|
@@ -201,7 +207,6 @@ omit = [
|
|
|
201
207
|
"*/.venv/*",
|
|
202
208
|
"*/venv/*",
|
|
203
209
|
"*/.tox/*",
|
|
204
|
-
"src/diffract/core/compute/kernels/*",
|
|
205
210
|
]
|
|
206
211
|
branch = true
|
|
207
212
|
parallel = true
|
|
@@ -225,7 +230,7 @@ exclude_lines = [
|
|
|
225
230
|
]
|
|
226
231
|
show_missing = true
|
|
227
232
|
precision = 2
|
|
228
|
-
fail_under =
|
|
233
|
+
fail_under = 67
|
|
229
234
|
skip_covered = false
|
|
230
235
|
skip_empty = false
|
|
231
236
|
|
|
@@ -294,11 +299,3 @@ check-hidden = true
|
|
|
294
299
|
name = "pypi"
|
|
295
300
|
url = "https://pypi.org/simple"
|
|
296
301
|
explicit = false
|
|
297
|
-
|
|
298
|
-
[tool.commitizen]
|
|
299
|
-
name = "cz_conventional_commits"
|
|
300
|
-
tag_format = "v$version"
|
|
301
|
-
version_scheme = "pep440"
|
|
302
|
-
version_provider = "uv"
|
|
303
|
-
update_changelog_on_bump = true
|
|
304
|
-
major_version_zero = true
|
|
@@ -187,8 +187,16 @@ dummy-variable-rgx = "^(_+|(_+[a-zA-Z0-9_]*[a-zA-Z0-9]+?))$"
|
|
|
187
187
|
"PLR0913", # Too many arguments
|
|
188
188
|
"PLR0915", # Too many statements
|
|
189
189
|
"ARG001", # Unused function argument
|
|
190
|
+
"ARG002", # Unused method argument (fixtures, mock signatures)
|
|
191
|
+
"ARG005", # Unused lambda argument (stub implementations)
|
|
190
192
|
"FBT001", # Boolean positional argument
|
|
191
193
|
"PT011", # pytest.raises() is too broad
|
|
194
|
+
"PLR2004", # Literal expectations are the substance of an assertion
|
|
195
|
+
"SLF001", # Tests exercise private members deliberately
|
|
196
|
+
"INP001", # Test directories are namespace packages by design
|
|
197
|
+
"PLC0415", # Imports inside tests control DI wiring order
|
|
198
|
+
"S108", # /tmp only appears as literal data in config-parsing asserts
|
|
199
|
+
"S110", # try/except/pass in teardown paths
|
|
192
200
|
]
|
|
193
201
|
"notebooks/*" = [
|
|
194
202
|
"D", # Docstring requirements
|
|
@@ -22,9 +22,10 @@ from __future__ import annotations
|
|
|
22
22
|
import importlib
|
|
23
23
|
from typing import TYPE_CHECKING, Any
|
|
24
24
|
|
|
25
|
-
__version__ = "0.
|
|
25
|
+
__version__ = "0.3.1"
|
|
26
26
|
|
|
27
27
|
from .containers import list_profiles
|
|
28
|
+
from .core.data.metadata import upgrade_metadata_index
|
|
28
29
|
from .core.data.nn.params.schema import ParameterType
|
|
29
30
|
from .session import ParameterOverrides, Session
|
|
30
31
|
|
|
@@ -37,6 +38,7 @@ __all__ = [
|
|
|
37
38
|
"Session",
|
|
38
39
|
"__version__",
|
|
39
40
|
"list_profiles",
|
|
41
|
+
"upgrade_metadata_index",
|
|
40
42
|
"viz",
|
|
41
43
|
]
|
|
42
44
|
|
|
@@ -25,6 +25,7 @@ from .core.compute.containers import (
|
|
|
25
25
|
ComputeSingletonContainerWiringConfig,
|
|
26
26
|
)
|
|
27
27
|
from .core.data.metadata.containers import MetadataContainer
|
|
28
|
+
from .core.data.metadata.sqlite_index import IN_MEMORY_DATABASE
|
|
28
29
|
from .core.data.nn.containers import ModelParametersContainer
|
|
29
30
|
from .core.export.containers import ExportContainer
|
|
30
31
|
from .core.parallel import ParallelSingletonContainer
|
|
@@ -42,6 +43,10 @@ PROFILES: dict[str, str] = {
|
|
|
42
43
|
"hybrid": "configs/hybrid.ini",
|
|
43
44
|
}
|
|
44
45
|
|
|
46
|
+
# Backend sentinels that occupy a "path" key without naming a file. They are
|
|
47
|
+
# carried verbatim so a backend can recognize them by equality.
|
|
48
|
+
_NON_FILESYSTEM_PATH_VALUES: frozenset[str] = frozenset({IN_MEMORY_DATABASE})
|
|
49
|
+
|
|
45
50
|
|
|
46
51
|
def list_profiles() -> list[str]:
|
|
47
52
|
"""Return available profile names."""
|
|
@@ -176,8 +181,10 @@ class MainContainer(containers.DeclarativeContainer):
|
|
|
176
181
|
# Configuration
|
|
177
182
|
config = providers.Configuration()
|
|
178
183
|
|
|
179
|
-
#
|
|
180
|
-
|
|
184
|
+
# Callable, not Resource: logging is configured once at build and must stay
|
|
185
|
+
# out of the init_resources()/shutdown_resources() lifecycle, which would
|
|
186
|
+
# otherwise re-run dictConfig on every context entry and reset user handlers.
|
|
187
|
+
logging_config = providers.Callable(
|
|
181
188
|
"logging.config.dictConfig",
|
|
182
189
|
config=config.logging,
|
|
183
190
|
)
|
|
@@ -371,6 +378,8 @@ def create_main_container(
|
|
|
371
378
|
if k != key or not isinstance(v, str):
|
|
372
379
|
continue
|
|
373
380
|
value = v.strip().strip('"')
|
|
381
|
+
if value in _NON_FILESYSTEM_PATH_VALUES:
|
|
382
|
+
continue
|
|
374
383
|
if value.startswith(("ext://", "/", "~")):
|
|
375
384
|
continue
|
|
376
385
|
cur[k] = str(base_path / value)
|
|
@@ -1,23 +1,17 @@
|
|
|
1
1
|
"""Core module for diffract."""
|
|
2
2
|
|
|
3
3
|
from diffract.core.constants import (
|
|
4
|
-
CONTEXT_SEPARATOR,
|
|
5
4
|
HDF5_INDEX_DATASET,
|
|
6
5
|
HDF5_INDEX_GROUP,
|
|
7
6
|
HDF5_INDEX_TOMBSTONE,
|
|
8
|
-
MODELS_CONTEXT_PREFIX,
|
|
9
|
-
PARAMS_CONTEXT_PREFIX,
|
|
10
7
|
REGEX_PREFIX,
|
|
11
8
|
WEIGHTS_FIELD,
|
|
12
9
|
)
|
|
13
10
|
|
|
14
11
|
__all__ = [
|
|
15
|
-
"CONTEXT_SEPARATOR",
|
|
16
12
|
"HDF5_INDEX_DATASET",
|
|
17
13
|
"HDF5_INDEX_GROUP",
|
|
18
14
|
"HDF5_INDEX_TOMBSTONE",
|
|
19
|
-
"MODELS_CONTEXT_PREFIX",
|
|
20
|
-
"PARAMS_CONTEXT_PREFIX",
|
|
21
15
|
"REGEX_PREFIX",
|
|
22
16
|
"WEIGHTS_FIELD",
|
|
23
17
|
]
|
|
@@ -70,9 +70,11 @@ class ICacheManager(Protocol):
|
|
|
70
70
|
Args:
|
|
71
71
|
obj_uid: Unique identifier for the cached object.
|
|
72
72
|
field_name: Name of the field to store.
|
|
73
|
-
value: Value to cache
|
|
73
|
+
value: Value to cache. Must be a numpy array, a JSON-serializable
|
|
74
|
+
value, or bytes.
|
|
74
75
|
|
|
75
76
|
Raises:
|
|
77
|
+
ValueError: If the value is not a supported kind.
|
|
76
78
|
Exception: If storage operation fails.
|
|
77
79
|
"""
|
|
78
80
|
...
|