diffract-core 0.2.1__tar.gz → 0.3.0__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.1 → diffract_core-0.3.0}/.gitignore +1 -0
- {diffract_core-0.2.1 → diffract_core-0.3.0}/PKG-INFO +39 -26
- {diffract_core-0.2.1 → diffract_core-0.3.0}/README.md +34 -24
- {diffract_core-0.2.1 → diffract_core-0.3.0}/pyproject.toml +9 -5
- {diffract_core-0.2.1 → diffract_core-0.3.0}/ruff.toml +8 -0
- {diffract_core-0.2.1 → diffract_core-0.3.0}/src/diffract/__init__.py +1 -1
- {diffract_core-0.2.1 → diffract_core-0.3.0}/src/diffract/configs/hybrid.ini +2 -1
- {diffract_core-0.2.1 → diffract_core-0.3.0}/src/diffract/configs/sqlite.ini +2 -1
- {diffract_core-0.2.1 → diffract_core-0.3.0}/src/diffract/containers.py +7 -0
- {diffract_core-0.2.1 → diffract_core-0.3.0}/src/diffract/core/cache/interface.py +3 -1
- {diffract_core-0.2.1 → diffract_core-0.3.0}/src/diffract/core/cache/redis_manager.py +36 -18
- {diffract_core-0.2.1 → diffract_core-0.3.0}/src/diffract/core/cache/simple_manager.py +30 -42
- {diffract_core-0.2.1 → diffract_core-0.3.0}/src/diffract/core/compute/execution/utils.py +18 -8
- {diffract_core-0.2.1 → diffract_core-0.3.0}/src/diffract/core/compute/extensions/power_law.py +13 -2
- {diffract_core-0.2.1 → diffract_core-0.3.0}/src/diffract/core/compute/kernels/__init__.py +4 -4
- {diffract_core-0.2.1 → diffract_core-0.3.0}/src/diffract/core/compute/kernels/alignment.py +28 -18
- {diffract_core-0.2.1 → diffract_core-0.3.0}/src/diffract/core/compute/kernels/heavy_tailed.py +82 -18
- {diffract_core-0.2.1 → diffract_core-0.3.0}/src/diffract/core/compute/kernels/marchenko_pastur.py +51 -18
- {diffract_core-0.2.1 → diffract_core-0.3.0}/src/diffract/core/compute/kernels/mat_decomposition.py +52 -12
- {diffract_core-0.2.1 → diffract_core-0.3.0}/src/diffract/core/compute/kernels/mat_properties.py +14 -13
- diffract_core-0.3.0/src/diffract/core/compute/kernels/model_quality.py +36 -0
- diffract_core-0.3.0/src/diffract/core/compute/kernels/norms.py +143 -0
- {diffract_core-0.2.1 → diffract_core-0.3.0}/src/diffract/core/compute/kernels/ranks.py +12 -5
- {diffract_core-0.2.1 → diffract_core-0.3.0}/src/diffract/core/compute/kernels/tracy_widom.py +11 -5
- {diffract_core-0.2.1 → diffract_core-0.3.0}/src/diffract/core/compute/metadata.py +5 -0
- {diffract_core-0.2.1 → diffract_core-0.3.0}/src/diffract/core/data/metadata/sqlite_index.py +61 -21
- diffract_core-0.3.0/src/diffract/core/export/containers.py +19 -0
- {diffract_core-0.2.1 → diffract_core-0.3.0}/src/diffract/core/storage/base_manager.py +4 -8
- {diffract_core-0.2.1 → diffract_core-0.3.0}/src/diffract/core/storage/hdf5_manager.py +17 -28
- diffract_core-0.3.0/src/diffract/core/storage/serialization.py +92 -0
- {diffract_core-0.2.1 → diffract_core-0.3.0}/src/diffract/core/storage/sqlite_manager.py +20 -35
- {diffract_core-0.2.1 → diffract_core-0.3.0}/src/diffract/core/storage/zarr_manager.py +9 -32
- diffract_core-0.3.0/src/diffract/core/utils/fpenv.py +80 -0
- {diffract_core-0.2.1 → diffract_core-0.3.0}/src/diffract/session/namespaces/results/__init__.py +35 -3
- {diffract_core-0.2.1 → diffract_core-0.3.0}/tests/conftest.py +55 -34
- {diffract_core-0.2.1 → diffract_core-0.3.0}/tests/integration/__init__.py +0 -1
- {diffract_core-0.2.1 → diffract_core-0.3.0}/tests/integration/helpers.py +6 -7
- {diffract_core-0.2.1 → diffract_core-0.3.0}/tests/integration/test_containers.py +13 -11
- {diffract_core-0.2.1 → diffract_core-0.3.0}/tests/integration/test_full_stack_redis_hdf5.py +8 -8
- {diffract_core-0.2.1 → diffract_core-0.3.0}/tests/integration/test_full_stack_redis_hybrid.py +3 -5
- {diffract_core-0.2.1 → diffract_core-0.3.0}/tests/integration/test_full_stack_redis_sqlite.py +10 -16
- {diffract_core-0.2.1 → diffract_core-0.3.0}/tests/integration/test_full_stack_simple_cache_storage.py +10 -10
- {diffract_core-0.2.1 → diffract_core-0.3.0}/tests/integration/test_hybrid_zarr_s3.py +17 -26
- {diffract_core-0.2.1 → diffract_core-0.3.0}/tests/integration/test_redis_cache.py +34 -8
- {diffract_core-0.2.1 → diffract_core-0.3.0}/tests/integration/test_stress_concurrent_operations.py +36 -17
- {diffract_core-0.2.1 → diffract_core-0.3.0}/tests/integration/test_stress_large_datasets.py +17 -10
- {diffract_core-0.2.1 → diffract_core-0.3.0}/tests/integration/test_stress_session_operations.py +5 -3
- {diffract_core-0.2.1 → diffract_core-0.3.0}/tests/unit/core/cache/test_simple_cache.py +3 -3
- diffract_core-0.3.0/tests/unit/core/compute/extensions/test_fpenv.py +79 -0
- diffract_core-0.3.0/tests/unit/core/compute/kernels/conftest.py +29 -0
- diffract_core-0.3.0/tests/unit/core/compute/kernels/test_alignment.py +195 -0
- {diffract_core-0.2.1 → diffract_core-0.3.0}/tests/unit/core/compute/kernels/test_heavy_tailed.py +158 -27
- {diffract_core-0.2.1 → diffract_core-0.3.0}/tests/unit/core/compute/kernels/test_kernel_smoke.py +4 -4
- diffract_core-0.3.0/tests/unit/core/compute/kernels/test_marchenko_pastur.py +328 -0
- diffract_core-0.3.0/tests/unit/core/compute/kernels/test_mat_decomposition.py +192 -0
- diffract_core-0.3.0/tests/unit/core/compute/kernels/test_mat_properties.py +151 -0
- diffract_core-0.3.0/tests/unit/core/compute/kernels/test_model_quality.py +60 -0
- diffract_core-0.3.0/tests/unit/core/compute/kernels/test_norms.py +240 -0
- diffract_core-0.3.0/tests/unit/core/compute/kernels/test_ranks.py +123 -0
- diffract_core-0.3.0/tests/unit/core/compute/kernels/test_tracy_widom.py +127 -0
- {diffract_core-0.2.1 → diffract_core-0.3.0}/tests/unit/core/compute/test_default_kernels.py +5 -3
- {diffract_core-0.2.1 → diffract_core-0.3.0}/tests/unit/core/compute/test_executor.py +83 -36
- {diffract_core-0.2.1 → diffract_core-0.3.0}/tests/unit/core/compute/test_registry.py +214 -181
- diffract_core-0.3.0/tests/unit/core/data/metadata/test_sqlite_index.py +42 -0
- {diffract_core-0.2.1 → diffract_core-0.3.0}/tests/unit/core/data/nn/extractors/test_flax_extractors.py +8 -7
- {diffract_core-0.2.1 → diffract_core-0.3.0}/tests/unit/core/data/nn/extractors/test_onnx_extractors.py +0 -1
- {diffract_core-0.2.1 → diffract_core-0.3.0}/tests/unit/core/data/nn/extractors/test_tensorflow_extractors.py +0 -1
- {diffract_core-0.2.1 → diffract_core-0.3.0}/tests/unit/core/data/nn/extractors/test_torch_extractors.py +16 -8
- {diffract_core-0.2.1 → diffract_core-0.3.0}/tests/unit/core/data/nn/test_collection_concurrent.py +56 -29
- {diffract_core-0.2.1 → diffract_core-0.3.0}/tests/unit/core/data/nn/test_parameter_module.py +41 -33
- {diffract_core-0.2.1 → diffract_core-0.3.0}/tests/unit/core/export/test_exporters.py +32 -13
- {diffract_core-0.2.1 → diffract_core-0.3.0}/tests/unit/core/export/test_pandas_formatter.py +5 -3
- {diffract_core-0.2.1 → diffract_core-0.3.0}/tests/unit/core/export/test_polars_formatter.py +14 -4
- {diffract_core-0.2.1 → diffract_core-0.3.0}/tests/unit/core/parallel/__init__.py +0 -1
- {diffract_core-0.2.1 → diffract_core-0.3.0}/tests/unit/core/parallel/test_containers.py +0 -2
- {diffract_core-0.2.1 → diffract_core-0.3.0}/tests/unit/core/parallel/test_runtime.py +0 -2
- {diffract_core-0.2.1 → diffract_core-0.3.0}/tests/unit/core/storage/test_hdf5_storage.py +13 -10
- {diffract_core-0.2.1 → diffract_core-0.3.0}/tests/unit/core/storage/test_hybrid_storage.py +18 -20
- diffract_core-0.3.0/tests/unit/core/storage/test_serialization.py +115 -0
- {diffract_core-0.2.1 → diffract_core-0.3.0}/tests/unit/core/storage/test_sqlite_storage.py +75 -32
- {diffract_core-0.2.1 → diffract_core-0.3.0}/tests/unit/core/storage/test_zarr_storage.py +21 -10
- {diffract_core-0.2.1 → diffract_core-0.3.0}/tests/unit/core/utils/test_imports_utils.py +3 -2
- {diffract_core-0.2.1 → diffract_core-0.3.0}/tests/unit/core/utils/test_session_helpers.py +2 -5
- {diffract_core-0.2.1 → diffract_core-0.3.0}/tests/unit/session/test_compute_hints.py +2 -2
- {diffract_core-0.2.1 → diffract_core-0.3.0}/tests/unit/session/test_field_cache.py +2 -0
- diffract_core-0.3.0/tests/unit/session/test_results_export_format.py +80 -0
- {diffract_core-0.2.1 → diffract_core-0.3.0}/tests/unit/session/test_session.py +22 -23
- {diffract_core-0.2.1 → diffract_core-0.3.0}/tests/unit/test_containers_config_loading.py +27 -1
- {diffract_core-0.2.1 → diffract_core-0.3.0}/tests/unit/viz/conftest.py +5 -2
- diffract_core-0.2.1/src/diffract/core/compute/kernels/model_quality.py +0 -27
- diffract_core-0.2.1/src/diffract/core/compute/kernels/norms.py +0 -88
- diffract_core-0.2.1/src/diffract/core/export/containers.py +0 -47
- diffract_core-0.2.1/tests/unit/core/compute/kernels/test_mat_decomposition.py +0 -62
- {diffract_core-0.2.1 → diffract_core-0.3.0}/LICENSE +0 -0
- {diffract_core-0.2.1 → diffract_core-0.3.0}/NOTICE +0 -0
- {diffract_core-0.2.1 → diffract_core-0.3.0}/src/diffract/configs/fast_speed_without_disk.ini +0 -0
- {diffract_core-0.2.1 → diffract_core-0.3.0}/src/diffract/core/__init__.py +0 -0
- {diffract_core-0.2.1 → diffract_core-0.3.0}/src/diffract/core/cache/__init__.py +0 -0
- {diffract_core-0.2.1 → diffract_core-0.3.0}/src/diffract/core/cache/containers.py +0 -0
- {diffract_core-0.2.1 → diffract_core-0.3.0}/src/diffract/core/compute/__init__.py +0 -0
- {diffract_core-0.2.1 → diffract_core-0.3.0}/src/diffract/core/compute/config.py +0 -0
- {diffract_core-0.2.1 → diffract_core-0.3.0}/src/diffract/core/compute/containers.py +0 -0
- {diffract_core-0.2.1 → diffract_core-0.3.0}/src/diffract/core/compute/decorator.py +0 -0
- {diffract_core-0.2.1 → diffract_core-0.3.0}/src/diffract/core/compute/exceptions.py +0 -0
- {diffract_core-0.2.1 → diffract_core-0.3.0}/src/diffract/core/compute/execution/__init__.py +0 -0
- {diffract_core-0.2.1 → diffract_core-0.3.0}/src/diffract/core/compute/execution/_types.py +0 -0
- {diffract_core-0.2.1 → diffract_core-0.3.0}/src/diffract/core/compute/execution/aggregation.py +0 -0
- {diffract_core-0.2.1 → diffract_core-0.3.0}/src/diffract/core/compute/execution/aggregation_runner.py +0 -0
- {diffract_core-0.2.1 → diffract_core-0.3.0}/src/diffract/core/compute/execution/enums.py +0 -0
- {diffract_core-0.2.1 → diffract_core-0.3.0}/src/diffract/core/compute/execution/executor.py +0 -0
- {diffract_core-0.2.1 → diffract_core-0.3.0}/src/diffract/core/compute/execution/parameter_runner.py +0 -0
- {diffract_core-0.2.1 → diffract_core-0.3.0}/src/diffract/core/compute/execution/restrictions.py +0 -0
- {diffract_core-0.2.1 → diffract_core-0.3.0}/src/diffract/core/compute/execution/strategy.py +0 -0
- {diffract_core-0.2.1 → diffract_core-0.3.0}/src/diffract/core/compute/extensions/__init__.py +0 -0
- {diffract_core-0.2.1 → diffract_core-0.3.0}/src/diffract/core/compute/extensions/rmt.py +0 -0
- {diffract_core-0.2.1 → diffract_core-0.3.0}/src/diffract/core/compute/extensions/utils.py +0 -0
- {diffract_core-0.2.1 → diffract_core-0.3.0}/src/diffract/core/compute/field_signature.py +0 -0
- {diffract_core-0.2.1 → diffract_core-0.3.0}/src/diffract/core/compute/registry.py +0 -0
- {diffract_core-0.2.1 → diffract_core-0.3.0}/src/diffract/core/constants.py +0 -0
- {diffract_core-0.2.1 → diffract_core-0.3.0}/src/diffract/core/data/__init__.py +0 -0
- {diffract_core-0.2.1 → diffract_core-0.3.0}/src/diffract/core/data/interface.py +0 -0
- {diffract_core-0.2.1 → diffract_core-0.3.0}/src/diffract/core/data/metadata/__init__.py +0 -0
- {diffract_core-0.2.1 → diffract_core-0.3.0}/src/diffract/core/data/metadata/containers.py +0 -0
- {diffract_core-0.2.1 → diffract_core-0.3.0}/src/diffract/core/data/metadata/interface.py +0 -0
- {diffract_core-0.2.1 → diffract_core-0.3.0}/src/diffract/core/data/nn/__init__.py +0 -0
- {diffract_core-0.2.1 → diffract_core-0.3.0}/src/diffract/core/data/nn/aggregates/__init__.py +0 -0
- {diffract_core-0.2.1 → diffract_core-0.3.0}/src/diffract/core/data/nn/aggregates/metadata.py +0 -0
- {diffract_core-0.2.1 → diffract_core-0.3.0}/src/diffract/core/data/nn/aggregates/proxy.py +0 -0
- {diffract_core-0.2.1 → diffract_core-0.3.0}/src/diffract/core/data/nn/aggregates/repository.py +0 -0
- {diffract_core-0.2.1 → diffract_core-0.3.0}/src/diffract/core/data/nn/aggregates/view.py +0 -0
- {diffract_core-0.2.1 → diffract_core-0.3.0}/src/diffract/core/data/nn/containers.py +0 -0
- {diffract_core-0.2.1 → diffract_core-0.3.0}/src/diffract/core/data/nn/extractors/__init__.py +0 -0
- {diffract_core-0.2.1 → diffract_core-0.3.0}/src/diffract/core/data/nn/extractors/base.py +0 -0
- {diffract_core-0.2.1 → diffract_core-0.3.0}/src/diffract/core/data/nn/extractors/factory.py +0 -0
- {diffract_core-0.2.1 → diffract_core-0.3.0}/src/diffract/core/data/nn/extractors/flax.py +0 -0
- {diffract_core-0.2.1 → diffract_core-0.3.0}/src/diffract/core/data/nn/extractors/handlers/__init__.py +0 -0
- {diffract_core-0.2.1 → diffract_core-0.3.0}/src/diffract/core/data/nn/extractors/handlers/base.py +0 -0
- {diffract_core-0.2.1 → diffract_core-0.3.0}/src/diffract/core/data/nn/extractors/handlers/flax_handlers.py +0 -0
- {diffract_core-0.2.1 → diffract_core-0.3.0}/src/diffract/core/data/nn/extractors/handlers/numpy_handlers.py +0 -0
- {diffract_core-0.2.1 → diffract_core-0.3.0}/src/diffract/core/data/nn/extractors/handlers/onnx_handlers.py +0 -0
- {diffract_core-0.2.1 → diffract_core-0.3.0}/src/diffract/core/data/nn/extractors/handlers/tensorflow_handlers.py +0 -0
- {diffract_core-0.2.1 → diffract_core-0.3.0}/src/diffract/core/data/nn/extractors/handlers/torch_handlers.py +0 -0
- {diffract_core-0.2.1 → diffract_core-0.3.0}/src/diffract/core/data/nn/extractors/interface.py +0 -0
- {diffract_core-0.2.1 → diffract_core-0.3.0}/src/diffract/core/data/nn/extractors/numpy.py +0 -0
- {diffract_core-0.2.1 → diffract_core-0.3.0}/src/diffract/core/data/nn/extractors/onnx.py +0 -0
- {diffract_core-0.2.1 → diffract_core-0.3.0}/src/diffract/core/data/nn/extractors/tensorflow.py +0 -0
- {diffract_core-0.2.1 → diffract_core-0.3.0}/src/diffract/core/data/nn/extractors/torch.py +0 -0
- {diffract_core-0.2.1 → diffract_core-0.3.0}/src/diffract/core/data/nn/params/__init__.py +0 -0
- {diffract_core-0.2.1 → diffract_core-0.3.0}/src/diffract/core/data/nn/params/interface.py +0 -0
- {diffract_core-0.2.1 → diffract_core-0.3.0}/src/diffract/core/data/nn/params/metadata.py +0 -0
- {diffract_core-0.2.1 → diffract_core-0.3.0}/src/diffract/core/data/nn/params/proxy.py +0 -0
- {diffract_core-0.2.1 → diffract_core-0.3.0}/src/diffract/core/data/nn/params/repository.py +0 -0
- {diffract_core-0.2.1 → diffract_core-0.3.0}/src/diffract/core/data/nn/params/schema.py +0 -0
- {diffract_core-0.2.1 → diffract_core-0.3.0}/src/diffract/core/data/nn/params/view.py +0 -0
- {diffract_core-0.2.1 → diffract_core-0.3.0}/src/diffract/core/data/proxy.py +0 -0
- {diffract_core-0.2.1 → diffract_core-0.3.0}/src/diffract/core/data/repository.py +0 -0
- {diffract_core-0.2.1 → diffract_core-0.3.0}/src/diffract/core/data/utils.py +0 -0
- {diffract_core-0.2.1 → diffract_core-0.3.0}/src/diffract/core/data/view.py +0 -0
- {diffract_core-0.2.1 → diffract_core-0.3.0}/src/diffract/core/export/__init__.py +0 -0
- {diffract_core-0.2.1 → diffract_core-0.3.0}/src/diffract/core/export/exporters.py +0 -0
- {diffract_core-0.2.1 → diffract_core-0.3.0}/src/diffract/core/export/formatters/__init__.py +0 -0
- {diffract_core-0.2.1 → diffract_core-0.3.0}/src/diffract/core/export/formatters/base.py +0 -0
- {diffract_core-0.2.1 → diffract_core-0.3.0}/src/diffract/core/export/formatters/dict_formatter.py +0 -0
- {diffract_core-0.2.1 → diffract_core-0.3.0}/src/diffract/core/export/formatters/json_formatter.py +0 -0
- {diffract_core-0.2.1 → diffract_core-0.3.0}/src/diffract/core/export/formatters/list_formatter.py +0 -0
- {diffract_core-0.2.1 → diffract_core-0.3.0}/src/diffract/core/export/formatters/pandas_formatter.py +0 -0
- {diffract_core-0.2.1 → diffract_core-0.3.0}/src/diffract/core/export/formatters/polars_formatter.py +0 -0
- {diffract_core-0.2.1 → diffract_core-0.3.0}/src/diffract/core/export/formatters/registry.py +0 -0
- {diffract_core-0.2.1 → diffract_core-0.3.0}/src/diffract/core/export/interface.py +0 -0
- {diffract_core-0.2.1 → diffract_core-0.3.0}/src/diffract/core/parallel/__init__.py +0 -0
- {diffract_core-0.2.1 → diffract_core-0.3.0}/src/diffract/core/parallel/containers.py +0 -0
- {diffract_core-0.2.1 → diffract_core-0.3.0}/src/diffract/core/parallel/execution.py +0 -0
- {diffract_core-0.2.1 → diffract_core-0.3.0}/src/diffract/core/parallel/runtime.py +0 -0
- {diffract_core-0.2.1 → diffract_core-0.3.0}/src/diffract/core/storage/__init__.py +0 -0
- {diffract_core-0.2.1 → diffract_core-0.3.0}/src/diffract/core/storage/containers.py +0 -0
- {diffract_core-0.2.1 → diffract_core-0.3.0}/src/diffract/core/storage/hybrid_manager.py +0 -0
- {diffract_core-0.2.1 → diffract_core-0.3.0}/src/diffract/core/storage/interface.py +0 -0
- {diffract_core-0.2.1 → diffract_core-0.3.0}/src/diffract/core/storage/metadata.py +0 -0
- {diffract_core-0.2.1 → diffract_core-0.3.0}/src/diffract/core/storage/ram_manager.py +0 -0
- {diffract_core-0.2.1 → diffract_core-0.3.0}/src/diffract/core/utils/__init__.py +0 -0
- {diffract_core-0.2.1 → diffract_core-0.3.0}/src/diffract/core/utils/build.py +0 -0
- {diffract_core-0.2.1 → diffract_core-0.3.0}/src/diffract/core/utils/exceptions.py +0 -0
- {diffract_core-0.2.1 → diffract_core-0.3.0}/src/diffract/core/utils/hashing.py +0 -0
- {diffract_core-0.2.1 → diffract_core-0.3.0}/src/diffract/core/utils/imports.py +0 -0
- {diffract_core-0.2.1 → diffract_core-0.3.0}/src/diffract/core/utils/math.py +0 -0
- {diffract_core-0.2.1 → diffract_core-0.3.0}/src/diffract/py.typed +0 -0
- {diffract_core-0.2.1 → diffract_core-0.3.0}/src/diffract/session/__init__.py +0 -0
- {diffract_core-0.2.1 → diffract_core-0.3.0}/src/diffract/session/errors.py +0 -0
- {diffract_core-0.2.1 → diffract_core-0.3.0}/src/diffract/session/field_cache.py +0 -0
- {diffract_core-0.2.1 → diffract_core-0.3.0}/src/diffract/session/namespaces/__init__.py +0 -0
- {diffract_core-0.2.1 → diffract_core-0.3.0}/src/diffract/session/namespaces/compute/__init__.py +0 -0
- {diffract_core-0.2.1 → diffract_core-0.3.0}/src/diffract/session/namespaces/models/__init__.py +0 -0
- {diffract_core-0.2.1 → diffract_core-0.3.0}/src/diffract/session/namespaces/models/parameters/__init__.py +0 -0
- {diffract_core-0.2.1 → diffract_core-0.3.0}/src/diffract/session/namespaces/models/parameters/meta_patcher.py +0 -0
- {diffract_core-0.2.1 → diffract_core-0.3.0}/src/diffract/session/namespaces/results/eraser.py +0 -0
- {diffract_core-0.2.1 → diffract_core-0.3.0}/src/diffract/session/namespaces/results/injester.py +0 -0
- {diffract_core-0.2.1 → diffract_core-0.3.0}/src/diffract/session/namespaces/utils/__init__.py +0 -0
- {diffract_core-0.2.1 → diffract_core-0.3.0}/src/diffract/session/namespaces/utils/merger.py +0 -0
- {diffract_core-0.2.1 → diffract_core-0.3.0}/src/diffract/session/namespaces/viz/__init__.py +0 -0
- {diffract_core-0.2.1 → diffract_core-0.3.0}/src/diffract/session/namespaces/viz/_utils.py +0 -0
- {diffract_core-0.2.1 → diffract_core-0.3.0}/src/diffract/session/namespaces/viz/box.py +0 -0
- {diffract_core-0.2.1 → diffract_core-0.3.0}/src/diffract/session/namespaces/viz/grid.py +0 -0
- {diffract_core-0.2.1 → diffract_core-0.3.0}/src/diffract/session/namespaces/viz/heatmap.py +0 -0
- {diffract_core-0.2.1 → diffract_core-0.3.0}/src/diffract/session/namespaces/viz/scatter.py +0 -0
- {diffract_core-0.2.1 → diffract_core-0.3.0}/src/diffract/session/namespaces/viz/sparkline.py +0 -0
- {diffract_core-0.2.1 → diffract_core-0.3.0}/src/diffract/session/namespaces/viz/violin.py +0 -0
- {diffract_core-0.2.1 → diffract_core-0.3.0}/src/diffract/session/session.py +0 -0
- {diffract_core-0.2.1 → diffract_core-0.3.0}/src/diffract/session/utils.py +0 -0
- {diffract_core-0.2.1 → diffract_core-0.3.0}/src/diffract/viz/__init__.py +0 -0
- {diffract_core-0.2.1 → diffract_core-0.3.0}/src/diffract/viz/data/__init__.py +0 -0
- {diffract_core-0.2.1 → diffract_core-0.3.0}/src/diffract/viz/data/detection.py +0 -0
- {diffract_core-0.2.1 → diffract_core-0.3.0}/src/diffract/viz/data/extraction.py +0 -0
- {diffract_core-0.2.1 → diffract_core-0.3.0}/src/diffract/viz/data/filtering.py +0 -0
- {diffract_core-0.2.1 → diffract_core-0.3.0}/src/diffract/viz/data/ordering.py +0 -0
- {diffract_core-0.2.1 → diffract_core-0.3.0}/src/diffract/viz/data/provider.py +0 -0
- {diffract_core-0.2.1 → diffract_core-0.3.0}/src/diffract/viz/data/types.py +0 -0
- {diffract_core-0.2.1 → diffract_core-0.3.0}/src/diffract/viz/plots/__init__.py +0 -0
- {diffract_core-0.2.1 → diffract_core-0.3.0}/src/diffract/viz/plots/base/__init__.py +0 -0
- {diffract_core-0.2.1 → diffract_core-0.3.0}/src/diffract/viz/plots/base/axis.py +0 -0
- {diffract_core-0.2.1 → diffract_core-0.3.0}/src/diffract/viz/plots/base/coloraxis.py +0 -0
- {diffract_core-0.2.1 → diffract_core-0.3.0}/src/diffract/viz/plots/base/configurator.py +0 -0
- {diffract_core-0.2.1 → diffract_core-0.3.0}/src/diffract/viz/plots/base/jitter.py +0 -0
- {diffract_core-0.2.1 → diffract_core-0.3.0}/src/diffract/viz/plots/base/line.py +0 -0
- {diffract_core-0.2.1 → diffract_core-0.3.0}/src/diffract/viz/plots/base/marker.py +0 -0
- {diffract_core-0.2.1 → diffract_core-0.3.0}/src/diffract/viz/plots/base/overlay.py +0 -0
- {diffract_core-0.2.1 → diffract_core-0.3.0}/src/diffract/viz/plots/base/plot.py +0 -0
- {diffract_core-0.2.1 → diffract_core-0.3.0}/src/diffract/viz/plots/base/update.py +0 -0
- {diffract_core-0.2.1 → diffract_core-0.3.0}/src/diffract/viz/plots/boxplot.py +0 -0
- {diffract_core-0.2.1 → diffract_core-0.3.0}/src/diffract/viz/plots/cluster.py +0 -0
- {diffract_core-0.2.1 → diffract_core-0.3.0}/src/diffract/viz/plots/heatmap.py +0 -0
- {diffract_core-0.2.1 → diffract_core-0.3.0}/src/diffract/viz/plots/scatter.py +0 -0
- {diffract_core-0.2.1 → diffract_core-0.3.0}/src/diffract/viz/plots/sparkline.py +0 -0
- {diffract_core-0.2.1 → diffract_core-0.3.0}/src/diffract/viz/plots/subplots/__init__.py +0 -0
- {diffract_core-0.2.1 → diffract_core-0.3.0}/src/diffract/viz/plots/subplots/coloraxis.py +0 -0
- {diffract_core-0.2.1 → diffract_core-0.3.0}/src/diffract/viz/plots/subplots/factory.py +0 -0
- {diffract_core-0.2.1 → diffract_core-0.3.0}/src/diffract/viz/plots/subplots/grid.py +0 -0
- {diffract_core-0.2.1 → diffract_core-0.3.0}/src/diffract/viz/plots/subplots/layout.py +0 -0
- {diffract_core-0.2.1 → diffract_core-0.3.0}/src/diffract/viz/plots/subplots/spec.py +0 -0
- {diffract_core-0.2.1 → diffract_core-0.3.0}/src/diffract/viz/plots/violin.py +0 -0
- {diffract_core-0.2.1 → diffract_core-0.3.0}/src/diffract/viz/renderer.py +0 -0
- {diffract_core-0.2.1 → diffract_core-0.3.0}/src/diffract/viz/styling/__init__.py +0 -0
- {diffract_core-0.2.1 → diffract_core-0.3.0}/src/diffract/viz/styling/palettes/__init__.py +0 -0
- {diffract_core-0.2.1 → diffract_core-0.3.0}/src/diffract/viz/styling/palettes/bundle.py +0 -0
- {diffract_core-0.2.1 → diffract_core-0.3.0}/src/diffract/viz/styling/palettes/color.py +0 -0
- {diffract_core-0.2.1 → diffract_core-0.3.0}/src/diffract/viz/styling/palettes/dashes.py +0 -0
- {diffract_core-0.2.1 → diffract_core-0.3.0}/src/diffract/viz/styling/palettes/symbols.py +0 -0
- {diffract_core-0.2.1 → diffract_core-0.3.0}/src/diffract/viz/styling/resolvers/__init__.py +0 -0
- {diffract_core-0.2.1 → diffract_core-0.3.0}/src/diffract/viz/styling/resolvers/categorical.py +0 -0
- {diffract_core-0.2.1 → diffract_core-0.3.0}/src/diffract/viz/styling/resolvers/color.py +0 -0
- {diffract_core-0.2.1 → diffract_core-0.3.0}/src/diffract/viz/styling/resolvers/numeric.py +0 -0
- {diffract_core-0.2.1 → diffract_core-0.3.0}/src/diffract/viz/styling/sources.py +0 -0
- {diffract_core-0.2.1 → diffract_core-0.3.0}/src/diffract/viz/styling/theme/__init__.py +0 -0
- {diffract_core-0.2.1 → diffract_core-0.3.0}/src/diffract/viz/styling/theme/applier.py +0 -0
- {diffract_core-0.2.1 → diffract_core-0.3.0}/src/diffract/viz/styling/theme/components.py +0 -0
- {diffract_core-0.2.1 → diffract_core-0.3.0}/src/diffract/viz/styling/theme/presets.py +0 -0
- {diffract_core-0.2.1 → diffract_core-0.3.0}/src/diffract/viz/styling/theme/theme.py +0 -0
- {diffract_core-0.2.1 → diffract_core-0.3.0}/tests/unit/conftest.py +0 -0
- {diffract_core-0.2.1 → diffract_core-0.3.0}/tests/unit/core/compute/extensions/__init__.py +0 -0
- {diffract_core-0.2.1 → diffract_core-0.3.0}/tests/unit/core/compute/extensions/_golden/rmt_values.json +0 -0
- {diffract_core-0.2.1 → diffract_core-0.3.0}/tests/unit/core/compute/extensions/test_rmt.py +0 -0
- {diffract_core-0.2.1 → diffract_core-0.3.0}/tests/unit/core/compute/kernels/__init__.py +0 -0
- {diffract_core-0.2.1 → diffract_core-0.3.0}/tests/unit/core/compute/test_field_signature.py +4 -4
- {diffract_core-0.2.1 → diffract_core-0.3.0}/tests/unit/core/data/nn/extractors/test_numpy_extractors.py +0 -0
- {diffract_core-0.2.1 → diffract_core-0.3.0}/tests/unit/core/export/test_formatter_hints.py +0 -0
- {diffract_core-0.2.1 → diffract_core-0.3.0}/tests/unit/core/storage/test_ram_storage.py +1 -1
- {diffract_core-0.2.1 → diffract_core-0.3.0}/tests/unit/session/__init__.py +0 -0
- {diffract_core-0.2.1 → diffract_core-0.3.0}/tests/unit/test_containers_logging.py +0 -0
- {diffract_core-0.2.1 → diffract_core-0.3.0}/tests/unit/viz/__init__.py +0 -0
- {diffract_core-0.2.1 → diffract_core-0.3.0}/tests/unit/viz/test_common.py +0 -0
- {diffract_core-0.2.1 → diffract_core-0.3.0}/tests/unit/viz/test_data_source.py +0 -0
- {diffract_core-0.2.1 → diffract_core-0.3.0}/tests/unit/viz/test_field_ref_coercion.py +0 -0
- {diffract_core-0.2.1 → diffract_core-0.3.0}/tests/unit/viz/test_plots.py +0 -0
- {diffract_core-0.2.1 → diffract_core-0.3.0}/tests/unit/viz/test_renderer.py +0 -0
- {diffract_core-0.2.1 → diffract_core-0.3.0}/tests/unit/viz/test_themes.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: diffract-core
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.3.0
|
|
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/
|
|
@@ -17,10 +17,11 @@ Keywords: deep-learning,llm,neural-networks,random-matrix-theory,spectral-analys
|
|
|
17
17
|
Classifier: Development Status :: 3 - Alpha
|
|
18
18
|
Classifier: Intended Audience :: Science/Research
|
|
19
19
|
Classifier: Programming Language :: Python :: 3.12
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
20
21
|
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
21
22
|
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
22
23
|
Classifier: Typing :: Typed
|
|
23
|
-
Requires-Python:
|
|
24
|
+
Requires-Python: >=3.12
|
|
24
25
|
Requires-Dist: dependency-injector>=4.44.0
|
|
25
26
|
Requires-Dist: h5py>=3.9.0
|
|
26
27
|
Requires-Dist: numpy<3,>=1.26
|
|
@@ -52,6 +53,7 @@ Provides-Extra: dev
|
|
|
52
53
|
Requires-Dist: bandit[toml]>=1.7.5; extra == 'dev'
|
|
53
54
|
Requires-Dist: fsspec>=2024.2.0; extra == 'dev'
|
|
54
55
|
Requires-Dist: hydra-core>=1.3.0; extra == 'dev'
|
|
56
|
+
Requires-Dist: hypothesis>=6.0.0; extra == 'dev'
|
|
55
57
|
Requires-Dist: interrogate>=1.7.0; extra == 'dev'
|
|
56
58
|
Requires-Dist: kaleido>=0.2.1; extra == 'dev'
|
|
57
59
|
Requires-Dist: mypy>=1.10.1; extra == 'dev'
|
|
@@ -80,6 +82,7 @@ Requires-Dist: sphinx-autodoc-typehints>=1.25.0; extra == 'docs'
|
|
|
80
82
|
Requires-Dist: sphinx-copybutton>=0.5.0; extra == 'docs'
|
|
81
83
|
Requires-Dist: sphinx-design>=0.6.0; extra == 'docs'
|
|
82
84
|
Requires-Dist: sphinx>=7.0.0; extra == 'docs'
|
|
85
|
+
Requires-Dist: sphinxcontrib-bibtex>=2.6.0; extra == 'docs'
|
|
83
86
|
Requires-Dist: sphinxext-opengraph>=0.9.0; extra == 'docs'
|
|
84
87
|
Provides-Extra: flax
|
|
85
88
|
Requires-Dist: flax>=0.10.0; extra == 'flax'
|
|
@@ -127,7 +130,8 @@ Description-Content-Type: text/markdown
|
|
|
127
130
|
[](https://risk-ai-research.github.io/diffract/)
|
|
128
131
|
[](https://opensource.org/licenses/Apache-2.0)
|
|
129
132
|
|
|
130
|
-
Official library of
|
|
133
|
+
Official library of
|
|
134
|
+
["Diffract: Spectral View of LLM Domain Adaptation"](https://openreview.net/forum?id=XBUHoiAGDE)
|
|
131
135
|
(**ICML 2026 Oral**).
|
|
132
136
|
|
|
133
137
|
Diffract is a Python package for analyzing deep neural network weights and tracking
|
|
@@ -144,7 +148,7 @@ dictionaries of NumPy weight matrices.
|
|
|
144
148
|
|
|
145
149
|
## 🚀 Quick Start
|
|
146
150
|
|
|
147
|
-
Diffract requires Python 3.12. The core package installs without any deep
|
|
151
|
+
Diffract requires Python 3.12 or newer. The core package installs without any deep
|
|
148
152
|
learning framework; heavy dependencies are opt-in extras:
|
|
149
153
|
|
|
150
154
|
```bash
|
|
@@ -155,10 +159,9 @@ pip install "diffract-core[taichi]" # + accelerated heavy-tailed fits and p
|
|
|
155
159
|
pip install "diffract-core[all]" # torch + viz + taichi + pandas/polars exports
|
|
156
160
|
```
|
|
157
161
|
|
|
158
|
-
Further extras: `frameworks` (TensorFlow, Flax, ONNX), `pandas` / `polars`
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
`"diffract-core[...]"` matter in zsh.
|
|
162
|
+
Further extras: `frameworks` (TensorFlow, Flax, ONNX), `pandas` / `polars` (DataFrame
|
|
163
|
+
exports), `zarr` (cloud storage), `redis` (shared cache), `notebooks` (tooling for the
|
|
164
|
+
example notebooks). The quotes around `"diffract-core[...]"` matter in zsh.
|
|
162
165
|
|
|
163
166
|
### Development Install
|
|
164
167
|
|
|
@@ -166,7 +169,7 @@ Further extras: `frameworks` (TensorFlow, Flax, ONNX), `pandas` / `polars`
|
|
|
166
169
|
# Install uv if you haven't already
|
|
167
170
|
curl -LsSf https://astral.sh/uv/install.sh | sh
|
|
168
171
|
|
|
169
|
-
# Clone and install (uv provisions Python
|
|
172
|
+
# Clone and install (uv provisions the right Python automatically)
|
|
170
173
|
git clone https://github.com/Risk-AI-Research/diffract.git
|
|
171
174
|
cd diffract
|
|
172
175
|
uv sync --extra dev --extra torch
|
|
@@ -219,7 +222,7 @@ internal structure:
|
|
|
219
222
|
|
|
220
223
|
<br>
|
|
221
224
|
|
|
222
|
-
##
|
|
225
|
+
## Key Features
|
|
223
226
|
|
|
224
227
|
- **Session-based API**: Simple `models.add`, `compute.apply`, and
|
|
225
228
|
`results.export_metrics` workflow.
|
|
@@ -232,6 +235,7 @@ internal structure:
|
|
|
232
235
|
HDF5, SQLite, Zarr, and hybrid backends.
|
|
233
236
|
|
|
234
237
|
- **Kernel Apply Levels**: Kernels can work at multiple levels:
|
|
238
|
+
|
|
235
239
|
- **PARAMETER** - Operate on individual weight matrices.
|
|
236
240
|
- **IN_MODEL** - Aggregate within a single model.
|
|
237
241
|
- **CROSS_MODEL** - Compare or aggregate across models.
|
|
@@ -257,7 +261,9 @@ session = Session()
|
|
|
257
261
|
|
|
258
262
|
with session:
|
|
259
263
|
session.models.add(torch_model) # torch.nn.Module
|
|
260
|
-
session.models.add(
|
|
264
|
+
session.models.add(
|
|
265
|
+
torch_state_dict, model_id="checkpoint"
|
|
266
|
+
) # Dict[str, torch.Tensor]
|
|
261
267
|
session.models.add(numpy_weights, model_id="raw-weights") # Dict[str, np.ndarray]
|
|
262
268
|
session.models.add(onnx_model, model_id="onnx-model") # onnx.ModelProto
|
|
263
269
|
session.models.add(flax_model, model_id="flax-model") # flax.linen.Module
|
|
@@ -273,6 +279,10 @@ session.compute.apply("frob_norm", "stable_rank")
|
|
|
273
279
|
session.compute.apply("pl_ks") # has many dependencies—all resolved automatically
|
|
274
280
|
```
|
|
275
281
|
|
|
282
|
+
Every built-in metric—its formula, apply level, required inputs, and configuration—is
|
|
283
|
+
catalogued in the
|
|
284
|
+
[metrics reference](https://risk-ai-research.github.io/diffract/reference/metrics/).
|
|
285
|
+
|
|
276
286
|
### Filtering Parameters
|
|
277
287
|
|
|
278
288
|
Filter computations by model, parameter type, or name:
|
|
@@ -309,9 +319,7 @@ Export results in various formats (`pandas`, `polars`, `dict`, `json`, or `list`
|
|
|
309
319
|
|
|
310
320
|
```python
|
|
311
321
|
scalars_df = session.results.export_metrics("stable_rank", export_format="pandas")
|
|
312
|
-
aggregates_df = session.results.export_aggregates(
|
|
313
|
-
"stable_rank", export_format="pandas"
|
|
314
|
-
)
|
|
322
|
+
aggregates_df = session.results.export_aggregates("stable_rank", export_format="pandas")
|
|
315
323
|
|
|
316
324
|
# Other formats work the same way
|
|
317
325
|
results = session.results.export_metrics("stable_rank", export_format="polars")
|
|
@@ -351,7 +359,7 @@ List and configure kernels at runtime:
|
|
|
351
359
|
```python
|
|
352
360
|
session.compute.list_available_kernels(verbose=True)
|
|
353
361
|
session.compute.list_available_metrics(verbose=True)
|
|
354
|
-
session.compute.configure_kernel("hard_rank",
|
|
362
|
+
session.compute.configure_kernel("hard_rank", rtol=1e-6)
|
|
355
363
|
```
|
|
356
364
|
|
|
357
365
|
### Session Management
|
|
@@ -402,8 +410,11 @@ You can also override the registered name and output fields:
|
|
|
402
410
|
|
|
403
411
|
```python
|
|
404
412
|
with session:
|
|
413
|
+
|
|
405
414
|
@session.compute.kernel(name="scaled_metric", produce_fields=["scaled_result"])
|
|
406
|
-
def custom_analysis(
|
|
415
|
+
def custom_analysis(
|
|
416
|
+
frob_norm: float, stable_rank: float, *, weight: float = 0.5
|
|
417
|
+
) -> float:
|
|
407
418
|
"""Custom analysis combining multiple metrics."""
|
|
408
419
|
return weight * frob_norm + (1 - weight) * stable_rank
|
|
409
420
|
```
|
|
@@ -448,9 +459,9 @@ Diffract offers built-in **profiles** for common setups:
|
|
|
448
459
|
from diffract import Session
|
|
449
460
|
|
|
450
461
|
# Use a profile (recommended for most users)
|
|
451
|
-
session = Session(profile="ram")
|
|
452
|
-
session = Session(profile="local")
|
|
453
|
-
session = Session(profile="hybrid")
|
|
462
|
+
session = Session(profile="ram") # fast, temporary
|
|
463
|
+
session = Session(profile="local") # persistent, simple
|
|
464
|
+
session = Session(profile="hybrid") # persistent, optimized for large arrays
|
|
454
465
|
|
|
455
466
|
# Or use a custom config file for full control
|
|
456
467
|
session = Session(config_path="my_config.ini")
|
|
@@ -496,12 +507,14 @@ max_workers = 4
|
|
|
496
507
|
|
|
497
508
|
## 📚 Documentation
|
|
498
509
|
|
|
499
|
-
The documentation
|
|
500
|
-
|
|
510
|
+
The documentation is hosted at
|
|
511
|
+
[risk-ai-research.github.io/diffract](https://risk-ai-research.github.io/diffract/). It
|
|
512
|
+
is sourced from `docs/` and built with Sphinx + MyST; `uv sync --extra docs` and
|
|
513
|
+
`make docs` render the HTML locally.
|
|
501
514
|
|
|
502
515
|
<br>
|
|
503
516
|
|
|
504
|
-
##
|
|
517
|
+
## Citation
|
|
505
518
|
|
|
506
519
|
If you use Diffract or build on the paper, please cite:
|
|
507
520
|
|
|
@@ -517,14 +530,14 @@ If you use Diffract or build on the paper, please cite:
|
|
|
517
530
|
|
|
518
531
|
<br>
|
|
519
532
|
|
|
520
|
-
##
|
|
533
|
+
## Contributions
|
|
521
534
|
|
|
522
|
-
Contributions are welcome
|
|
523
|
-
|
|
535
|
+
Contributions are welcome — see [CONTRIBUTING.md](CONTRIBUTING.md) for the development
|
|
536
|
+
setup, the checks CI runs, and the design principles.
|
|
524
537
|
|
|
525
538
|
<br>
|
|
526
539
|
|
|
527
|
-
##
|
|
540
|
+
## License
|
|
528
541
|
|
|
529
542
|
Licensed under the Apache License 2.0 — see [LICENSE](LICENSE). Copyright 2026 Risk AI
|
|
530
543
|
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,6 +111,7 @@ 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
117
|
- **CROSS_MODEL** - Compare or aggregate across models.
|
|
@@ -136,7 +137,9 @@ session = Session()
|
|
|
136
137
|
|
|
137
138
|
with session:
|
|
138
139
|
session.models.add(torch_model) # torch.nn.Module
|
|
139
|
-
session.models.add(
|
|
140
|
+
session.models.add(
|
|
141
|
+
torch_state_dict, model_id="checkpoint"
|
|
142
|
+
) # Dict[str, torch.Tensor]
|
|
140
143
|
session.models.add(numpy_weights, model_id="raw-weights") # Dict[str, np.ndarray]
|
|
141
144
|
session.models.add(onnx_model, model_id="onnx-model") # onnx.ModelProto
|
|
142
145
|
session.models.add(flax_model, model_id="flax-model") # flax.linen.Module
|
|
@@ -152,6 +155,10 @@ session.compute.apply("frob_norm", "stable_rank")
|
|
|
152
155
|
session.compute.apply("pl_ks") # has many dependencies—all resolved automatically
|
|
153
156
|
```
|
|
154
157
|
|
|
158
|
+
Every built-in metric—its formula, apply level, required inputs, and configuration—is
|
|
159
|
+
catalogued in the
|
|
160
|
+
[metrics reference](https://risk-ai-research.github.io/diffract/reference/metrics/).
|
|
161
|
+
|
|
155
162
|
### Filtering Parameters
|
|
156
163
|
|
|
157
164
|
Filter computations by model, parameter type, or name:
|
|
@@ -188,9 +195,7 @@ Export results in various formats (`pandas`, `polars`, `dict`, `json`, or `list`
|
|
|
188
195
|
|
|
189
196
|
```python
|
|
190
197
|
scalars_df = session.results.export_metrics("stable_rank", export_format="pandas")
|
|
191
|
-
aggregates_df = session.results.export_aggregates(
|
|
192
|
-
"stable_rank", export_format="pandas"
|
|
193
|
-
)
|
|
198
|
+
aggregates_df = session.results.export_aggregates("stable_rank", export_format="pandas")
|
|
194
199
|
|
|
195
200
|
# Other formats work the same way
|
|
196
201
|
results = session.results.export_metrics("stable_rank", export_format="polars")
|
|
@@ -230,7 +235,7 @@ List and configure kernels at runtime:
|
|
|
230
235
|
```python
|
|
231
236
|
session.compute.list_available_kernels(verbose=True)
|
|
232
237
|
session.compute.list_available_metrics(verbose=True)
|
|
233
|
-
session.compute.configure_kernel("hard_rank",
|
|
238
|
+
session.compute.configure_kernel("hard_rank", rtol=1e-6)
|
|
234
239
|
```
|
|
235
240
|
|
|
236
241
|
### Session Management
|
|
@@ -281,8 +286,11 @@ You can also override the registered name and output fields:
|
|
|
281
286
|
|
|
282
287
|
```python
|
|
283
288
|
with session:
|
|
289
|
+
|
|
284
290
|
@session.compute.kernel(name="scaled_metric", produce_fields=["scaled_result"])
|
|
285
|
-
def custom_analysis(
|
|
291
|
+
def custom_analysis(
|
|
292
|
+
frob_norm: float, stable_rank: float, *, weight: float = 0.5
|
|
293
|
+
) -> float:
|
|
286
294
|
"""Custom analysis combining multiple metrics."""
|
|
287
295
|
return weight * frob_norm + (1 - weight) * stable_rank
|
|
288
296
|
```
|
|
@@ -327,9 +335,9 @@ Diffract offers built-in **profiles** for common setups:
|
|
|
327
335
|
from diffract import Session
|
|
328
336
|
|
|
329
337
|
# Use a profile (recommended for most users)
|
|
330
|
-
session = Session(profile="ram")
|
|
331
|
-
session = Session(profile="local")
|
|
332
|
-
session = Session(profile="hybrid")
|
|
338
|
+
session = Session(profile="ram") # fast, temporary
|
|
339
|
+
session = Session(profile="local") # persistent, simple
|
|
340
|
+
session = Session(profile="hybrid") # persistent, optimized for large arrays
|
|
333
341
|
|
|
334
342
|
# Or use a custom config file for full control
|
|
335
343
|
session = Session(config_path="my_config.ini")
|
|
@@ -375,12 +383,14 @@ max_workers = 4
|
|
|
375
383
|
|
|
376
384
|
## 📚 Documentation
|
|
377
385
|
|
|
378
|
-
The documentation
|
|
379
|
-
|
|
386
|
+
The documentation is hosted at
|
|
387
|
+
[risk-ai-research.github.io/diffract](https://risk-ai-research.github.io/diffract/). It
|
|
388
|
+
is sourced from `docs/` and built with Sphinx + MyST; `uv sync --extra docs` and
|
|
389
|
+
`make docs` render the HTML locally.
|
|
380
390
|
|
|
381
391
|
<br>
|
|
382
392
|
|
|
383
|
-
##
|
|
393
|
+
## Citation
|
|
384
394
|
|
|
385
395
|
If you use Diffract or build on the paper, please cite:
|
|
386
396
|
|
|
@@ -396,14 +406,14 @@ If you use Diffract or build on the paper, please cite:
|
|
|
396
406
|
|
|
397
407
|
<br>
|
|
398
408
|
|
|
399
|
-
##
|
|
409
|
+
## Contributions
|
|
400
410
|
|
|
401
|
-
Contributions are welcome
|
|
402
|
-
|
|
411
|
+
Contributions are welcome — see [CONTRIBUTING.md](CONTRIBUTING.md) for the development
|
|
412
|
+
setup, the checks CI runs, and the design principles.
|
|
403
413
|
|
|
404
414
|
<br>
|
|
405
415
|
|
|
406
|
-
##
|
|
416
|
+
## License
|
|
407
417
|
|
|
408
418
|
Licensed under the Apache License 2.0 — see [LICENSE](LICENSE). Copyright 2026 Risk AI
|
|
409
419
|
Research.
|
|
@@ -11,12 +11,13 @@ maintainers = [
|
|
|
11
11
|
]
|
|
12
12
|
license = "Apache-2.0"
|
|
13
13
|
license-files = ["LICENSE", "NOTICE"]
|
|
14
|
-
requires-python = ">=3.12
|
|
14
|
+
requires-python = ">=3.12"
|
|
15
15
|
keywords = ["spectral-analysis", "random-matrix-theory", "deep-learning", "llm", "neural-networks"]
|
|
16
16
|
classifiers = [
|
|
17
17
|
"Development Status :: 3 - Alpha",
|
|
18
18
|
"Intended Audience :: Science/Research",
|
|
19
19
|
"Programming Language :: Python :: 3.12",
|
|
20
|
+
"Programming Language :: Python :: 3.13",
|
|
20
21
|
"Topic :: Scientific/Engineering :: Artificial Intelligence",
|
|
21
22
|
"Topic :: Software Development :: Libraries :: Python Modules",
|
|
22
23
|
"Typing :: Typed",
|
|
@@ -104,9 +105,11 @@ docs = [
|
|
|
104
105
|
"sphinx-design >=0.6.0",
|
|
105
106
|
"furo >=2024.8.0",
|
|
106
107
|
"sphinxext-opengraph >=0.9.0",
|
|
108
|
+
"sphinxcontrib-bibtex >=2.6.0",
|
|
107
109
|
]
|
|
108
110
|
dev = [
|
|
109
111
|
"bandit[toml] >=1.7.5",
|
|
112
|
+
"hypothesis >=6.0.0",
|
|
110
113
|
"interrogate >=1.7.0",
|
|
111
114
|
"mypy >=1.10.1",
|
|
112
115
|
"pandas >=2.1.0",
|
|
@@ -169,8 +172,10 @@ filterwarnings = [
|
|
|
169
172
|
"ignore::DeprecationWarning",
|
|
170
173
|
"ignore::UserWarning",
|
|
171
174
|
"ignore::PendingDeprecationWarning",
|
|
172
|
-
# taichi 1.7.x ships a docstring with an invalid escape sequence
|
|
173
|
-
|
|
175
|
+
# taichi 1.7.x ships a docstring with an invalid escape sequence; the
|
|
176
|
+
# compile-time warning is attributed to the importing frame rather than
|
|
177
|
+
# the module that carries it, so it is matched by message.
|
|
178
|
+
"ignore:invalid escape sequence:SyntaxWarning",
|
|
174
179
|
]
|
|
175
180
|
log_cli = true
|
|
176
181
|
log_cli_level = "INFO"
|
|
@@ -200,7 +205,6 @@ omit = [
|
|
|
200
205
|
"*/.venv/*",
|
|
201
206
|
"*/venv/*",
|
|
202
207
|
"*/.tox/*",
|
|
203
|
-
"src/diffract/core/compute/kernels/*",
|
|
204
208
|
]
|
|
205
209
|
branch = true
|
|
206
210
|
parallel = true
|
|
@@ -224,7 +228,7 @@ exclude_lines = [
|
|
|
224
228
|
]
|
|
225
229
|
show_missing = true
|
|
226
230
|
precision = 2
|
|
227
|
-
fail_under =
|
|
231
|
+
fail_under = 67
|
|
228
232
|
skip_covered = false
|
|
229
233
|
skip_empty = false
|
|
230
234
|
|
|
@@ -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
|
|
@@ -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."""
|
|
@@ -371,6 +376,8 @@ def create_main_container(
|
|
|
371
376
|
if k != key or not isinstance(v, str):
|
|
372
377
|
continue
|
|
373
378
|
value = v.strip().strip('"')
|
|
379
|
+
if value in _NON_FILESYSTEM_PATH_VALUES:
|
|
380
|
+
continue
|
|
374
381
|
if value.startswith(("ext://", "/", "~")):
|
|
375
382
|
continue
|
|
376
383
|
cur[k] = str(base_path / value)
|
|
@@ -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
|
...
|
|
@@ -7,7 +7,7 @@ LRU eviction and configurable memory limits.
|
|
|
7
7
|
Features:
|
|
8
8
|
- RAM-only storage with LRU eviction
|
|
9
9
|
- Configurable memory limits and TTL
|
|
10
|
-
-
|
|
10
|
+
- Safe typed serialization via the shared storage codec
|
|
11
11
|
- Connection pooling and error handling
|
|
12
12
|
- Health monitoring and memory usage tracking
|
|
13
13
|
|
|
@@ -21,17 +21,41 @@ from __future__ import annotations
|
|
|
21
21
|
|
|
22
22
|
import contextlib
|
|
23
23
|
import logging
|
|
24
|
-
import pickle
|
|
25
24
|
from types import TracebackType
|
|
26
25
|
from typing import Any, Self
|
|
27
26
|
|
|
28
27
|
import diffract.core.utils.imports as import_utils
|
|
28
|
+
from diffract.core.storage.serialization import decode_value, encode_value
|
|
29
29
|
from diffract.core.utils.exceptions import format_exception_message
|
|
30
30
|
|
|
31
31
|
from .interface import UID, ICacheManager
|
|
32
32
|
|
|
33
33
|
logger = logging.getLogger(__name__)
|
|
34
34
|
|
|
35
|
+
_TAG_HEADER_BYTES = 1
|
|
36
|
+
_DECODE_MISS_ERRORS = (
|
|
37
|
+
ValueError,
|
|
38
|
+
EOFError,
|
|
39
|
+
OSError,
|
|
40
|
+
IndexError,
|
|
41
|
+
UnicodeDecodeError,
|
|
42
|
+
)
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
def _frame(payload: bytes, tag: str) -> bytes:
|
|
46
|
+
"""Prefix a codec payload with its tag so the tag survives the round trip."""
|
|
47
|
+
tag_bytes = tag.encode("utf-8")
|
|
48
|
+
return bytes((len(tag_bytes),)) + tag_bytes + payload
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
def _unframe(data: bytes) -> tuple[bytes, str]:
|
|
52
|
+
"""Split a framed blob back into its codec payload and tag."""
|
|
53
|
+
tag_len = data[0]
|
|
54
|
+
tag = data[_TAG_HEADER_BYTES : _TAG_HEADER_BYTES + tag_len].decode("utf-8")
|
|
55
|
+
payload = data[_TAG_HEADER_BYTES + tag_len :]
|
|
56
|
+
return payload, tag
|
|
57
|
+
|
|
58
|
+
|
|
35
59
|
if not import_utils.is_available("redis"):
|
|
36
60
|
logger.debug("Redis not available, disabling Redis cache manager")
|
|
37
61
|
|
|
@@ -61,7 +85,7 @@ else:
|
|
|
61
85
|
|
|
62
86
|
The manager configures Redis for RAM-only operation by disabling
|
|
63
87
|
RDB snapshots and AOF logging, focusing on speed over durability.
|
|
64
|
-
|
|
88
|
+
Cached values are serialized through the shared storage codec.
|
|
65
89
|
|
|
66
90
|
Attributes:
|
|
67
91
|
_key_prefix: Prefix for all Redis keys to avoid collisions.
|
|
@@ -213,17 +237,9 @@ else:
|
|
|
213
237
|
if data is None:
|
|
214
238
|
return None
|
|
215
239
|
try:
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
ImportError,
|
|
220
|
-
AttributeError,
|
|
221
|
-
ValueError,
|
|
222
|
-
pickle.UnpicklingError,
|
|
223
|
-
EOFError,
|
|
224
|
-
):
|
|
225
|
-
# Cache may contain pickles produced by a different Python/numpy
|
|
226
|
-
# version. Treat as a cache miss and delete the corrupted entry.
|
|
240
|
+
payload, tag = _unframe(data)
|
|
241
|
+
return decode_value(payload, tag)
|
|
242
|
+
except _DECODE_MISS_ERRORS:
|
|
227
243
|
with contextlib.suppress(RedisError):
|
|
228
244
|
self._redis.delete(key)
|
|
229
245
|
return None
|
|
@@ -287,19 +303,21 @@ else:
|
|
|
287
303
|
Args:
|
|
288
304
|
obj_uid: Unique identifier for the cached object.
|
|
289
305
|
field_name: Name of the field to store.
|
|
290
|
-
value: Value to cache
|
|
306
|
+
value: Value to cache. Supported kinds are NumPy arrays,
|
|
307
|
+
``bytes``, and JSON-serializable values.
|
|
291
308
|
|
|
292
309
|
Raises:
|
|
310
|
+
ValueError: If the value is not a supported kind.
|
|
293
311
|
RedisError: If storage operation fails.
|
|
294
312
|
"""
|
|
313
|
+
blob = _frame(*encode_value(value))
|
|
295
314
|
try:
|
|
296
315
|
key = self._make_key(obj_uid, field_name)
|
|
297
|
-
payload = pickle.dumps(value, protocol=pickle.HIGHEST_PROTOCOL)
|
|
298
316
|
|
|
299
317
|
if self._ttl_seconds is not None:
|
|
300
|
-
self._redis.setex(key, self._ttl_seconds,
|
|
318
|
+
self._redis.setex(key, self._ttl_seconds, blob)
|
|
301
319
|
else:
|
|
302
|
-
self._redis.set(key,
|
|
320
|
+
self._redis.set(key, blob)
|
|
303
321
|
|
|
304
322
|
except RedisError:
|
|
305
323
|
logger.exception("Redis set_field error")
|