diffract-core 0.2.2__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.2 → diffract_core-0.3.0}/.gitignore +1 -0
- {diffract_core-0.2.2 → diffract_core-0.3.0}/PKG-INFO +37 -25
- {diffract_core-0.2.2 → diffract_core-0.3.0}/README.md +34 -24
- {diffract_core-0.2.2 → diffract_core-0.3.0}/pyproject.toml +7 -4
- {diffract_core-0.2.2 → diffract_core-0.3.0}/ruff.toml +8 -0
- {diffract_core-0.2.2 → diffract_core-0.3.0}/src/diffract/__init__.py +1 -1
- {diffract_core-0.2.2 → diffract_core-0.3.0}/src/diffract/configs/hybrid.ini +2 -1
- {diffract_core-0.2.2 → diffract_core-0.3.0}/src/diffract/configs/sqlite.ini +2 -1
- {diffract_core-0.2.2 → diffract_core-0.3.0}/src/diffract/containers.py +7 -0
- {diffract_core-0.2.2 → diffract_core-0.3.0}/src/diffract/core/cache/interface.py +3 -1
- {diffract_core-0.2.2 → diffract_core-0.3.0}/src/diffract/core/cache/redis_manager.py +36 -18
- {diffract_core-0.2.2 → diffract_core-0.3.0}/src/diffract/core/cache/simple_manager.py +30 -42
- {diffract_core-0.2.2 → diffract_core-0.3.0}/src/diffract/core/compute/execution/utils.py +18 -8
- {diffract_core-0.2.2 → diffract_core-0.3.0}/src/diffract/core/compute/extensions/power_law.py +13 -2
- {diffract_core-0.2.2 → diffract_core-0.3.0}/src/diffract/core/compute/kernels/__init__.py +4 -4
- {diffract_core-0.2.2 → diffract_core-0.3.0}/src/diffract/core/compute/kernels/alignment.py +28 -18
- {diffract_core-0.2.2 → diffract_core-0.3.0}/src/diffract/core/compute/kernels/heavy_tailed.py +82 -18
- {diffract_core-0.2.2 → diffract_core-0.3.0}/src/diffract/core/compute/kernels/marchenko_pastur.py +51 -18
- {diffract_core-0.2.2 → diffract_core-0.3.0}/src/diffract/core/compute/kernels/mat_decomposition.py +52 -12
- {diffract_core-0.2.2 → 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.2 → diffract_core-0.3.0}/src/diffract/core/compute/kernels/ranks.py +12 -5
- {diffract_core-0.2.2 → diffract_core-0.3.0}/src/diffract/core/compute/kernels/tracy_widom.py +11 -5
- {diffract_core-0.2.2 → diffract_core-0.3.0}/src/diffract/core/compute/metadata.py +5 -0
- {diffract_core-0.2.2 → 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.2 → diffract_core-0.3.0}/src/diffract/core/storage/base_manager.py +4 -8
- {diffract_core-0.2.2 → 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.2 → diffract_core-0.3.0}/src/diffract/core/storage/sqlite_manager.py +20 -35
- {diffract_core-0.2.2 → 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.2 → diffract_core-0.3.0}/src/diffract/session/namespaces/results/__init__.py +35 -3
- {diffract_core-0.2.2 → diffract_core-0.3.0}/tests/conftest.py +55 -34
- {diffract_core-0.2.2 → diffract_core-0.3.0}/tests/integration/__init__.py +0 -1
- {diffract_core-0.2.2 → diffract_core-0.3.0}/tests/integration/helpers.py +6 -7
- {diffract_core-0.2.2 → diffract_core-0.3.0}/tests/integration/test_containers.py +13 -11
- {diffract_core-0.2.2 → diffract_core-0.3.0}/tests/integration/test_full_stack_redis_hdf5.py +8 -8
- {diffract_core-0.2.2 → diffract_core-0.3.0}/tests/integration/test_full_stack_redis_hybrid.py +3 -5
- {diffract_core-0.2.2 → diffract_core-0.3.0}/tests/integration/test_full_stack_redis_sqlite.py +10 -16
- {diffract_core-0.2.2 → diffract_core-0.3.0}/tests/integration/test_full_stack_simple_cache_storage.py +10 -10
- {diffract_core-0.2.2 → diffract_core-0.3.0}/tests/integration/test_hybrid_zarr_s3.py +12 -19
- {diffract_core-0.2.2 → diffract_core-0.3.0}/tests/integration/test_redis_cache.py +34 -8
- {diffract_core-0.2.2 → diffract_core-0.3.0}/tests/integration/test_stress_concurrent_operations.py +36 -17
- {diffract_core-0.2.2 → diffract_core-0.3.0}/tests/integration/test_stress_large_datasets.py +17 -10
- {diffract_core-0.2.2 → diffract_core-0.3.0}/tests/integration/test_stress_session_operations.py +5 -3
- {diffract_core-0.2.2 → 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.2 → diffract_core-0.3.0}/tests/unit/core/compute/kernels/test_heavy_tailed.py +158 -27
- {diffract_core-0.2.2 → 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.2 → diffract_core-0.3.0}/tests/unit/core/compute/test_default_kernels.py +5 -3
- {diffract_core-0.2.2 → diffract_core-0.3.0}/tests/unit/core/compute/test_executor.py +83 -36
- {diffract_core-0.2.2 → 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.2 → diffract_core-0.3.0}/tests/unit/core/data/nn/extractors/test_flax_extractors.py +8 -7
- {diffract_core-0.2.2 → diffract_core-0.3.0}/tests/unit/core/data/nn/extractors/test_onnx_extractors.py +0 -1
- {diffract_core-0.2.2 → diffract_core-0.3.0}/tests/unit/core/data/nn/extractors/test_tensorflow_extractors.py +0 -1
- {diffract_core-0.2.2 → diffract_core-0.3.0}/tests/unit/core/data/nn/extractors/test_torch_extractors.py +16 -8
- {diffract_core-0.2.2 → diffract_core-0.3.0}/tests/unit/core/data/nn/test_collection_concurrent.py +56 -29
- {diffract_core-0.2.2 → diffract_core-0.3.0}/tests/unit/core/data/nn/test_parameter_module.py +41 -33
- {diffract_core-0.2.2 → diffract_core-0.3.0}/tests/unit/core/export/test_exporters.py +32 -13
- {diffract_core-0.2.2 → diffract_core-0.3.0}/tests/unit/core/export/test_pandas_formatter.py +5 -3
- {diffract_core-0.2.2 → diffract_core-0.3.0}/tests/unit/core/export/test_polars_formatter.py +14 -4
- {diffract_core-0.2.2 → diffract_core-0.3.0}/tests/unit/core/parallel/__init__.py +0 -1
- {diffract_core-0.2.2 → diffract_core-0.3.0}/tests/unit/core/parallel/test_containers.py +0 -2
- {diffract_core-0.2.2 → diffract_core-0.3.0}/tests/unit/core/parallel/test_runtime.py +0 -2
- {diffract_core-0.2.2 → diffract_core-0.3.0}/tests/unit/core/storage/test_hdf5_storage.py +13 -10
- {diffract_core-0.2.2 → 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.2 → diffract_core-0.3.0}/tests/unit/core/storage/test_sqlite_storage.py +75 -32
- {diffract_core-0.2.2 → diffract_core-0.3.0}/tests/unit/core/storage/test_zarr_storage.py +21 -10
- {diffract_core-0.2.2 → diffract_core-0.3.0}/tests/unit/core/utils/test_imports_utils.py +3 -2
- {diffract_core-0.2.2 → diffract_core-0.3.0}/tests/unit/core/utils/test_session_helpers.py +2 -5
- {diffract_core-0.2.2 → diffract_core-0.3.0}/tests/unit/session/test_compute_hints.py +2 -2
- {diffract_core-0.2.2 → 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.2 → diffract_core-0.3.0}/tests/unit/session/test_session.py +22 -23
- {diffract_core-0.2.2 → diffract_core-0.3.0}/tests/unit/test_containers_config_loading.py +27 -1
- {diffract_core-0.2.2 → diffract_core-0.3.0}/tests/unit/viz/conftest.py +5 -2
- 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/export/containers.py +0 -47
- diffract_core-0.2.2/tests/unit/core/compute/kernels/test_mat_decomposition.py +0 -62
- {diffract_core-0.2.2 → diffract_core-0.3.0}/LICENSE +0 -0
- {diffract_core-0.2.2 → diffract_core-0.3.0}/NOTICE +0 -0
- {diffract_core-0.2.2 → diffract_core-0.3.0}/src/diffract/configs/fast_speed_without_disk.ini +0 -0
- {diffract_core-0.2.2 → diffract_core-0.3.0}/src/diffract/core/__init__.py +0 -0
- {diffract_core-0.2.2 → diffract_core-0.3.0}/src/diffract/core/cache/__init__.py +0 -0
- {diffract_core-0.2.2 → diffract_core-0.3.0}/src/diffract/core/cache/containers.py +0 -0
- {diffract_core-0.2.2 → diffract_core-0.3.0}/src/diffract/core/compute/__init__.py +0 -0
- {diffract_core-0.2.2 → diffract_core-0.3.0}/src/diffract/core/compute/config.py +0 -0
- {diffract_core-0.2.2 → diffract_core-0.3.0}/src/diffract/core/compute/containers.py +0 -0
- {diffract_core-0.2.2 → diffract_core-0.3.0}/src/diffract/core/compute/decorator.py +0 -0
- {diffract_core-0.2.2 → diffract_core-0.3.0}/src/diffract/core/compute/exceptions.py +0 -0
- {diffract_core-0.2.2 → diffract_core-0.3.0}/src/diffract/core/compute/execution/__init__.py +0 -0
- {diffract_core-0.2.2 → diffract_core-0.3.0}/src/diffract/core/compute/execution/_types.py +0 -0
- {diffract_core-0.2.2 → diffract_core-0.3.0}/src/diffract/core/compute/execution/aggregation.py +0 -0
- {diffract_core-0.2.2 → diffract_core-0.3.0}/src/diffract/core/compute/execution/aggregation_runner.py +0 -0
- {diffract_core-0.2.2 → diffract_core-0.3.0}/src/diffract/core/compute/execution/enums.py +0 -0
- {diffract_core-0.2.2 → diffract_core-0.3.0}/src/diffract/core/compute/execution/executor.py +0 -0
- {diffract_core-0.2.2 → diffract_core-0.3.0}/src/diffract/core/compute/execution/parameter_runner.py +0 -0
- {diffract_core-0.2.2 → diffract_core-0.3.0}/src/diffract/core/compute/execution/restrictions.py +0 -0
- {diffract_core-0.2.2 → diffract_core-0.3.0}/src/diffract/core/compute/execution/strategy.py +0 -0
- {diffract_core-0.2.2 → diffract_core-0.3.0}/src/diffract/core/compute/extensions/__init__.py +0 -0
- {diffract_core-0.2.2 → diffract_core-0.3.0}/src/diffract/core/compute/extensions/rmt.py +0 -0
- {diffract_core-0.2.2 → diffract_core-0.3.0}/src/diffract/core/compute/extensions/utils.py +0 -0
- {diffract_core-0.2.2 → diffract_core-0.3.0}/src/diffract/core/compute/field_signature.py +0 -0
- {diffract_core-0.2.2 → diffract_core-0.3.0}/src/diffract/core/compute/registry.py +0 -0
- {diffract_core-0.2.2 → diffract_core-0.3.0}/src/diffract/core/constants.py +0 -0
- {diffract_core-0.2.2 → diffract_core-0.3.0}/src/diffract/core/data/__init__.py +0 -0
- {diffract_core-0.2.2 → diffract_core-0.3.0}/src/diffract/core/data/interface.py +0 -0
- {diffract_core-0.2.2 → diffract_core-0.3.0}/src/diffract/core/data/metadata/__init__.py +0 -0
- {diffract_core-0.2.2 → diffract_core-0.3.0}/src/diffract/core/data/metadata/containers.py +0 -0
- {diffract_core-0.2.2 → diffract_core-0.3.0}/src/diffract/core/data/metadata/interface.py +0 -0
- {diffract_core-0.2.2 → diffract_core-0.3.0}/src/diffract/core/data/nn/__init__.py +0 -0
- {diffract_core-0.2.2 → diffract_core-0.3.0}/src/diffract/core/data/nn/aggregates/__init__.py +0 -0
- {diffract_core-0.2.2 → diffract_core-0.3.0}/src/diffract/core/data/nn/aggregates/metadata.py +0 -0
- {diffract_core-0.2.2 → diffract_core-0.3.0}/src/diffract/core/data/nn/aggregates/proxy.py +0 -0
- {diffract_core-0.2.2 → diffract_core-0.3.0}/src/diffract/core/data/nn/aggregates/repository.py +0 -0
- {diffract_core-0.2.2 → diffract_core-0.3.0}/src/diffract/core/data/nn/aggregates/view.py +0 -0
- {diffract_core-0.2.2 → diffract_core-0.3.0}/src/diffract/core/data/nn/containers.py +0 -0
- {diffract_core-0.2.2 → diffract_core-0.3.0}/src/diffract/core/data/nn/extractors/__init__.py +0 -0
- {diffract_core-0.2.2 → diffract_core-0.3.0}/src/diffract/core/data/nn/extractors/base.py +0 -0
- {diffract_core-0.2.2 → diffract_core-0.3.0}/src/diffract/core/data/nn/extractors/factory.py +0 -0
- {diffract_core-0.2.2 → diffract_core-0.3.0}/src/diffract/core/data/nn/extractors/flax.py +0 -0
- {diffract_core-0.2.2 → diffract_core-0.3.0}/src/diffract/core/data/nn/extractors/handlers/__init__.py +0 -0
- {diffract_core-0.2.2 → diffract_core-0.3.0}/src/diffract/core/data/nn/extractors/handlers/base.py +0 -0
- {diffract_core-0.2.2 → diffract_core-0.3.0}/src/diffract/core/data/nn/extractors/handlers/flax_handlers.py +0 -0
- {diffract_core-0.2.2 → diffract_core-0.3.0}/src/diffract/core/data/nn/extractors/handlers/numpy_handlers.py +0 -0
- {diffract_core-0.2.2 → diffract_core-0.3.0}/src/diffract/core/data/nn/extractors/handlers/onnx_handlers.py +0 -0
- {diffract_core-0.2.2 → diffract_core-0.3.0}/src/diffract/core/data/nn/extractors/handlers/tensorflow_handlers.py +0 -0
- {diffract_core-0.2.2 → diffract_core-0.3.0}/src/diffract/core/data/nn/extractors/handlers/torch_handlers.py +0 -0
- {diffract_core-0.2.2 → diffract_core-0.3.0}/src/diffract/core/data/nn/extractors/interface.py +0 -0
- {diffract_core-0.2.2 → diffract_core-0.3.0}/src/diffract/core/data/nn/extractors/numpy.py +0 -0
- {diffract_core-0.2.2 → diffract_core-0.3.0}/src/diffract/core/data/nn/extractors/onnx.py +0 -0
- {diffract_core-0.2.2 → diffract_core-0.3.0}/src/diffract/core/data/nn/extractors/tensorflow.py +0 -0
- {diffract_core-0.2.2 → diffract_core-0.3.0}/src/diffract/core/data/nn/extractors/torch.py +0 -0
- {diffract_core-0.2.2 → diffract_core-0.3.0}/src/diffract/core/data/nn/params/__init__.py +0 -0
- {diffract_core-0.2.2 → diffract_core-0.3.0}/src/diffract/core/data/nn/params/interface.py +0 -0
- {diffract_core-0.2.2 → diffract_core-0.3.0}/src/diffract/core/data/nn/params/metadata.py +0 -0
- {diffract_core-0.2.2 → diffract_core-0.3.0}/src/diffract/core/data/nn/params/proxy.py +0 -0
- {diffract_core-0.2.2 → diffract_core-0.3.0}/src/diffract/core/data/nn/params/repository.py +0 -0
- {diffract_core-0.2.2 → diffract_core-0.3.0}/src/diffract/core/data/nn/params/schema.py +0 -0
- {diffract_core-0.2.2 → diffract_core-0.3.0}/src/diffract/core/data/nn/params/view.py +0 -0
- {diffract_core-0.2.2 → diffract_core-0.3.0}/src/diffract/core/data/proxy.py +0 -0
- {diffract_core-0.2.2 → diffract_core-0.3.0}/src/diffract/core/data/repository.py +0 -0
- {diffract_core-0.2.2 → diffract_core-0.3.0}/src/diffract/core/data/utils.py +0 -0
- {diffract_core-0.2.2 → diffract_core-0.3.0}/src/diffract/core/data/view.py +0 -0
- {diffract_core-0.2.2 → diffract_core-0.3.0}/src/diffract/core/export/__init__.py +0 -0
- {diffract_core-0.2.2 → diffract_core-0.3.0}/src/diffract/core/export/exporters.py +0 -0
- {diffract_core-0.2.2 → diffract_core-0.3.0}/src/diffract/core/export/formatters/__init__.py +0 -0
- {diffract_core-0.2.2 → diffract_core-0.3.0}/src/diffract/core/export/formatters/base.py +0 -0
- {diffract_core-0.2.2 → diffract_core-0.3.0}/src/diffract/core/export/formatters/dict_formatter.py +0 -0
- {diffract_core-0.2.2 → diffract_core-0.3.0}/src/diffract/core/export/formatters/json_formatter.py +0 -0
- {diffract_core-0.2.2 → diffract_core-0.3.0}/src/diffract/core/export/formatters/list_formatter.py +0 -0
- {diffract_core-0.2.2 → diffract_core-0.3.0}/src/diffract/core/export/formatters/pandas_formatter.py +0 -0
- {diffract_core-0.2.2 → diffract_core-0.3.0}/src/diffract/core/export/formatters/polars_formatter.py +0 -0
- {diffract_core-0.2.2 → diffract_core-0.3.0}/src/diffract/core/export/formatters/registry.py +0 -0
- {diffract_core-0.2.2 → diffract_core-0.3.0}/src/diffract/core/export/interface.py +0 -0
- {diffract_core-0.2.2 → diffract_core-0.3.0}/src/diffract/core/parallel/__init__.py +0 -0
- {diffract_core-0.2.2 → diffract_core-0.3.0}/src/diffract/core/parallel/containers.py +0 -0
- {diffract_core-0.2.2 → diffract_core-0.3.0}/src/diffract/core/parallel/execution.py +0 -0
- {diffract_core-0.2.2 → diffract_core-0.3.0}/src/diffract/core/parallel/runtime.py +0 -0
- {diffract_core-0.2.2 → diffract_core-0.3.0}/src/diffract/core/storage/__init__.py +0 -0
- {diffract_core-0.2.2 → diffract_core-0.3.0}/src/diffract/core/storage/containers.py +0 -0
- {diffract_core-0.2.2 → diffract_core-0.3.0}/src/diffract/core/storage/hybrid_manager.py +0 -0
- {diffract_core-0.2.2 → diffract_core-0.3.0}/src/diffract/core/storage/interface.py +0 -0
- {diffract_core-0.2.2 → diffract_core-0.3.0}/src/diffract/core/storage/metadata.py +0 -0
- {diffract_core-0.2.2 → diffract_core-0.3.0}/src/diffract/core/storage/ram_manager.py +0 -0
- {diffract_core-0.2.2 → diffract_core-0.3.0}/src/diffract/core/utils/__init__.py +0 -0
- {diffract_core-0.2.2 → diffract_core-0.3.0}/src/diffract/core/utils/build.py +0 -0
- {diffract_core-0.2.2 → diffract_core-0.3.0}/src/diffract/core/utils/exceptions.py +0 -0
- {diffract_core-0.2.2 → diffract_core-0.3.0}/src/diffract/core/utils/hashing.py +0 -0
- {diffract_core-0.2.2 → diffract_core-0.3.0}/src/diffract/core/utils/imports.py +0 -0
- {diffract_core-0.2.2 → diffract_core-0.3.0}/src/diffract/core/utils/math.py +0 -0
- {diffract_core-0.2.2 → diffract_core-0.3.0}/src/diffract/py.typed +0 -0
- {diffract_core-0.2.2 → diffract_core-0.3.0}/src/diffract/session/__init__.py +0 -0
- {diffract_core-0.2.2 → diffract_core-0.3.0}/src/diffract/session/errors.py +0 -0
- {diffract_core-0.2.2 → diffract_core-0.3.0}/src/diffract/session/field_cache.py +0 -0
- {diffract_core-0.2.2 → diffract_core-0.3.0}/src/diffract/session/namespaces/__init__.py +0 -0
- {diffract_core-0.2.2 → diffract_core-0.3.0}/src/diffract/session/namespaces/compute/__init__.py +0 -0
- {diffract_core-0.2.2 → diffract_core-0.3.0}/src/diffract/session/namespaces/models/__init__.py +0 -0
- {diffract_core-0.2.2 → diffract_core-0.3.0}/src/diffract/session/namespaces/models/parameters/__init__.py +0 -0
- {diffract_core-0.2.2 → diffract_core-0.3.0}/src/diffract/session/namespaces/models/parameters/meta_patcher.py +0 -0
- {diffract_core-0.2.2 → diffract_core-0.3.0}/src/diffract/session/namespaces/results/eraser.py +0 -0
- {diffract_core-0.2.2 → diffract_core-0.3.0}/src/diffract/session/namespaces/results/injester.py +0 -0
- {diffract_core-0.2.2 → diffract_core-0.3.0}/src/diffract/session/namespaces/utils/__init__.py +0 -0
- {diffract_core-0.2.2 → diffract_core-0.3.0}/src/diffract/session/namespaces/utils/merger.py +0 -0
- {diffract_core-0.2.2 → diffract_core-0.3.0}/src/diffract/session/namespaces/viz/__init__.py +0 -0
- {diffract_core-0.2.2 → diffract_core-0.3.0}/src/diffract/session/namespaces/viz/_utils.py +0 -0
- {diffract_core-0.2.2 → diffract_core-0.3.0}/src/diffract/session/namespaces/viz/box.py +0 -0
- {diffract_core-0.2.2 → diffract_core-0.3.0}/src/diffract/session/namespaces/viz/grid.py +0 -0
- {diffract_core-0.2.2 → diffract_core-0.3.0}/src/diffract/session/namespaces/viz/heatmap.py +0 -0
- {diffract_core-0.2.2 → diffract_core-0.3.0}/src/diffract/session/namespaces/viz/scatter.py +0 -0
- {diffract_core-0.2.2 → diffract_core-0.3.0}/src/diffract/session/namespaces/viz/sparkline.py +0 -0
- {diffract_core-0.2.2 → diffract_core-0.3.0}/src/diffract/session/namespaces/viz/violin.py +0 -0
- {diffract_core-0.2.2 → diffract_core-0.3.0}/src/diffract/session/session.py +0 -0
- {diffract_core-0.2.2 → diffract_core-0.3.0}/src/diffract/session/utils.py +0 -0
- {diffract_core-0.2.2 → diffract_core-0.3.0}/src/diffract/viz/__init__.py +0 -0
- {diffract_core-0.2.2 → diffract_core-0.3.0}/src/diffract/viz/data/__init__.py +0 -0
- {diffract_core-0.2.2 → diffract_core-0.3.0}/src/diffract/viz/data/detection.py +0 -0
- {diffract_core-0.2.2 → diffract_core-0.3.0}/src/diffract/viz/data/extraction.py +0 -0
- {diffract_core-0.2.2 → diffract_core-0.3.0}/src/diffract/viz/data/filtering.py +0 -0
- {diffract_core-0.2.2 → diffract_core-0.3.0}/src/diffract/viz/data/ordering.py +0 -0
- {diffract_core-0.2.2 → diffract_core-0.3.0}/src/diffract/viz/data/provider.py +0 -0
- {diffract_core-0.2.2 → diffract_core-0.3.0}/src/diffract/viz/data/types.py +0 -0
- {diffract_core-0.2.2 → diffract_core-0.3.0}/src/diffract/viz/plots/__init__.py +0 -0
- {diffract_core-0.2.2 → diffract_core-0.3.0}/src/diffract/viz/plots/base/__init__.py +0 -0
- {diffract_core-0.2.2 → diffract_core-0.3.0}/src/diffract/viz/plots/base/axis.py +0 -0
- {diffract_core-0.2.2 → diffract_core-0.3.0}/src/diffract/viz/plots/base/coloraxis.py +0 -0
- {diffract_core-0.2.2 → diffract_core-0.3.0}/src/diffract/viz/plots/base/configurator.py +0 -0
- {diffract_core-0.2.2 → diffract_core-0.3.0}/src/diffract/viz/plots/base/jitter.py +0 -0
- {diffract_core-0.2.2 → diffract_core-0.3.0}/src/diffract/viz/plots/base/line.py +0 -0
- {diffract_core-0.2.2 → diffract_core-0.3.0}/src/diffract/viz/plots/base/marker.py +0 -0
- {diffract_core-0.2.2 → diffract_core-0.3.0}/src/diffract/viz/plots/base/overlay.py +0 -0
- {diffract_core-0.2.2 → diffract_core-0.3.0}/src/diffract/viz/plots/base/plot.py +0 -0
- {diffract_core-0.2.2 → diffract_core-0.3.0}/src/diffract/viz/plots/base/update.py +0 -0
- {diffract_core-0.2.2 → diffract_core-0.3.0}/src/diffract/viz/plots/boxplot.py +0 -0
- {diffract_core-0.2.2 → diffract_core-0.3.0}/src/diffract/viz/plots/cluster.py +0 -0
- {diffract_core-0.2.2 → diffract_core-0.3.0}/src/diffract/viz/plots/heatmap.py +0 -0
- {diffract_core-0.2.2 → diffract_core-0.3.0}/src/diffract/viz/plots/scatter.py +0 -0
- {diffract_core-0.2.2 → diffract_core-0.3.0}/src/diffract/viz/plots/sparkline.py +0 -0
- {diffract_core-0.2.2 → diffract_core-0.3.0}/src/diffract/viz/plots/subplots/__init__.py +0 -0
- {diffract_core-0.2.2 → diffract_core-0.3.0}/src/diffract/viz/plots/subplots/coloraxis.py +0 -0
- {diffract_core-0.2.2 → diffract_core-0.3.0}/src/diffract/viz/plots/subplots/factory.py +0 -0
- {diffract_core-0.2.2 → diffract_core-0.3.0}/src/diffract/viz/plots/subplots/grid.py +0 -0
- {diffract_core-0.2.2 → diffract_core-0.3.0}/src/diffract/viz/plots/subplots/layout.py +0 -0
- {diffract_core-0.2.2 → diffract_core-0.3.0}/src/diffract/viz/plots/subplots/spec.py +0 -0
- {diffract_core-0.2.2 → diffract_core-0.3.0}/src/diffract/viz/plots/violin.py +0 -0
- {diffract_core-0.2.2 → diffract_core-0.3.0}/src/diffract/viz/renderer.py +0 -0
- {diffract_core-0.2.2 → diffract_core-0.3.0}/src/diffract/viz/styling/__init__.py +0 -0
- {diffract_core-0.2.2 → diffract_core-0.3.0}/src/diffract/viz/styling/palettes/__init__.py +0 -0
- {diffract_core-0.2.2 → diffract_core-0.3.0}/src/diffract/viz/styling/palettes/bundle.py +0 -0
- {diffract_core-0.2.2 → diffract_core-0.3.0}/src/diffract/viz/styling/palettes/color.py +0 -0
- {diffract_core-0.2.2 → diffract_core-0.3.0}/src/diffract/viz/styling/palettes/dashes.py +0 -0
- {diffract_core-0.2.2 → diffract_core-0.3.0}/src/diffract/viz/styling/palettes/symbols.py +0 -0
- {diffract_core-0.2.2 → diffract_core-0.3.0}/src/diffract/viz/styling/resolvers/__init__.py +0 -0
- {diffract_core-0.2.2 → diffract_core-0.3.0}/src/diffract/viz/styling/resolvers/categorical.py +0 -0
- {diffract_core-0.2.2 → diffract_core-0.3.0}/src/diffract/viz/styling/resolvers/color.py +0 -0
- {diffract_core-0.2.2 → diffract_core-0.3.0}/src/diffract/viz/styling/resolvers/numeric.py +0 -0
- {diffract_core-0.2.2 → diffract_core-0.3.0}/src/diffract/viz/styling/sources.py +0 -0
- {diffract_core-0.2.2 → diffract_core-0.3.0}/src/diffract/viz/styling/theme/__init__.py +0 -0
- {diffract_core-0.2.2 → diffract_core-0.3.0}/src/diffract/viz/styling/theme/applier.py +0 -0
- {diffract_core-0.2.2 → diffract_core-0.3.0}/src/diffract/viz/styling/theme/components.py +0 -0
- {diffract_core-0.2.2 → diffract_core-0.3.0}/src/diffract/viz/styling/theme/presets.py +0 -0
- {diffract_core-0.2.2 → diffract_core-0.3.0}/src/diffract/viz/styling/theme/theme.py +0 -0
- {diffract_core-0.2.2 → diffract_core-0.3.0}/tests/unit/conftest.py +0 -0
- {diffract_core-0.2.2 → diffract_core-0.3.0}/tests/unit/core/compute/extensions/__init__.py +0 -0
- {diffract_core-0.2.2 → diffract_core-0.3.0}/tests/unit/core/compute/extensions/_golden/rmt_values.json +0 -0
- {diffract_core-0.2.2 → diffract_core-0.3.0}/tests/unit/core/compute/extensions/test_rmt.py +0 -0
- {diffract_core-0.2.2 → diffract_core-0.3.0}/tests/unit/core/compute/kernels/__init__.py +0 -0
- {diffract_core-0.2.2 → diffract_core-0.3.0}/tests/unit/core/compute/test_field_signature.py +4 -4
- {diffract_core-0.2.2 → diffract_core-0.3.0}/tests/unit/core/data/nn/extractors/test_numpy_extractors.py +0 -0
- {diffract_core-0.2.2 → diffract_core-0.3.0}/tests/unit/core/export/test_formatter_hints.py +0 -0
- {diffract_core-0.2.2 → diffract_core-0.3.0}/tests/unit/core/storage/test_ram_storage.py +1 -1
- {diffract_core-0.2.2 → diffract_core-0.3.0}/tests/unit/session/__init__.py +0 -0
- {diffract_core-0.2.2 → diffract_core-0.3.0}/tests/unit/test_containers_logging.py +0 -0
- {diffract_core-0.2.2 → diffract_core-0.3.0}/tests/unit/viz/__init__.py +0 -0
- {diffract_core-0.2.2 → diffract_core-0.3.0}/tests/unit/viz/test_common.py +0 -0
- {diffract_core-0.2.2 → diffract_core-0.3.0}/tests/unit/viz/test_data_source.py +0 -0
- {diffract_core-0.2.2 → diffract_core-0.3.0}/tests/unit/viz/test_field_ref_coercion.py +0 -0
- {diffract_core-0.2.2 → diffract_core-0.3.0}/tests/unit/viz/test_plots.py +0 -0
- {diffract_core-0.2.2 → diffract_core-0.3.0}/tests/unit/viz/test_renderer.py +0 -0
- {diffract_core-0.2.2 → 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/
|
|
@@ -53,6 +53,7 @@ Provides-Extra: dev
|
|
|
53
53
|
Requires-Dist: bandit[toml]>=1.7.5; extra == 'dev'
|
|
54
54
|
Requires-Dist: fsspec>=2024.2.0; extra == 'dev'
|
|
55
55
|
Requires-Dist: hydra-core>=1.3.0; extra == 'dev'
|
|
56
|
+
Requires-Dist: hypothesis>=6.0.0; extra == 'dev'
|
|
56
57
|
Requires-Dist: interrogate>=1.7.0; extra == 'dev'
|
|
57
58
|
Requires-Dist: kaleido>=0.2.1; extra == 'dev'
|
|
58
59
|
Requires-Dist: mypy>=1.10.1; extra == 'dev'
|
|
@@ -81,6 +82,7 @@ Requires-Dist: sphinx-autodoc-typehints>=1.25.0; extra == 'docs'
|
|
|
81
82
|
Requires-Dist: sphinx-copybutton>=0.5.0; extra == 'docs'
|
|
82
83
|
Requires-Dist: sphinx-design>=0.6.0; extra == 'docs'
|
|
83
84
|
Requires-Dist: sphinx>=7.0.0; extra == 'docs'
|
|
85
|
+
Requires-Dist: sphinxcontrib-bibtex>=2.6.0; extra == 'docs'
|
|
84
86
|
Requires-Dist: sphinxext-opengraph>=0.9.0; extra == 'docs'
|
|
85
87
|
Provides-Extra: flax
|
|
86
88
|
Requires-Dist: flax>=0.10.0; extra == 'flax'
|
|
@@ -128,7 +130,8 @@ Description-Content-Type: text/markdown
|
|
|
128
130
|
[](https://risk-ai-research.github.io/diffract/)
|
|
129
131
|
[](https://opensource.org/licenses/Apache-2.0)
|
|
130
132
|
|
|
131
|
-
Official library of
|
|
133
|
+
Official library of
|
|
134
|
+
["Diffract: Spectral View of LLM Domain Adaptation"](https://openreview.net/forum?id=XBUHoiAGDE)
|
|
132
135
|
(**ICML 2026 Oral**).
|
|
133
136
|
|
|
134
137
|
Diffract is a Python package for analyzing deep neural network weights and tracking
|
|
@@ -145,7 +148,7 @@ dictionaries of NumPy weight matrices.
|
|
|
145
148
|
|
|
146
149
|
## 🚀 Quick Start
|
|
147
150
|
|
|
148
|
-
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
|
|
149
152
|
learning framework; heavy dependencies are opt-in extras:
|
|
150
153
|
|
|
151
154
|
```bash
|
|
@@ -156,10 +159,9 @@ pip install "diffract-core[taichi]" # + accelerated heavy-tailed fits and p
|
|
|
156
159
|
pip install "diffract-core[all]" # torch + viz + taichi + pandas/polars exports
|
|
157
160
|
```
|
|
158
161
|
|
|
159
|
-
Further extras: `frameworks` (TensorFlow, Flax, ONNX), `pandas` / `polars`
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
`"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.
|
|
163
165
|
|
|
164
166
|
### Development Install
|
|
165
167
|
|
|
@@ -167,7 +169,7 @@ Further extras: `frameworks` (TensorFlow, Flax, ONNX), `pandas` / `polars`
|
|
|
167
169
|
# Install uv if you haven't already
|
|
168
170
|
curl -LsSf https://astral.sh/uv/install.sh | sh
|
|
169
171
|
|
|
170
|
-
# Clone and install (uv provisions Python
|
|
172
|
+
# Clone and install (uv provisions the right Python automatically)
|
|
171
173
|
git clone https://github.com/Risk-AI-Research/diffract.git
|
|
172
174
|
cd diffract
|
|
173
175
|
uv sync --extra dev --extra torch
|
|
@@ -220,7 +222,7 @@ internal structure:
|
|
|
220
222
|
|
|
221
223
|
<br>
|
|
222
224
|
|
|
223
|
-
##
|
|
225
|
+
## Key Features
|
|
224
226
|
|
|
225
227
|
- **Session-based API**: Simple `models.add`, `compute.apply`, and
|
|
226
228
|
`results.export_metrics` workflow.
|
|
@@ -233,6 +235,7 @@ internal structure:
|
|
|
233
235
|
HDF5, SQLite, Zarr, and hybrid backends.
|
|
234
236
|
|
|
235
237
|
- **Kernel Apply Levels**: Kernels can work at multiple levels:
|
|
238
|
+
|
|
236
239
|
- **PARAMETER** - Operate on individual weight matrices.
|
|
237
240
|
- **IN_MODEL** - Aggregate within a single model.
|
|
238
241
|
- **CROSS_MODEL** - Compare or aggregate across models.
|
|
@@ -258,7 +261,9 @@ session = Session()
|
|
|
258
261
|
|
|
259
262
|
with session:
|
|
260
263
|
session.models.add(torch_model) # torch.nn.Module
|
|
261
|
-
session.models.add(
|
|
264
|
+
session.models.add(
|
|
265
|
+
torch_state_dict, model_id="checkpoint"
|
|
266
|
+
) # Dict[str, torch.Tensor]
|
|
262
267
|
session.models.add(numpy_weights, model_id="raw-weights") # Dict[str, np.ndarray]
|
|
263
268
|
session.models.add(onnx_model, model_id="onnx-model") # onnx.ModelProto
|
|
264
269
|
session.models.add(flax_model, model_id="flax-model") # flax.linen.Module
|
|
@@ -274,6 +279,10 @@ session.compute.apply("frob_norm", "stable_rank")
|
|
|
274
279
|
session.compute.apply("pl_ks") # has many dependencies—all resolved automatically
|
|
275
280
|
```
|
|
276
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
|
+
|
|
277
286
|
### Filtering Parameters
|
|
278
287
|
|
|
279
288
|
Filter computations by model, parameter type, or name:
|
|
@@ -310,9 +319,7 @@ Export results in various formats (`pandas`, `polars`, `dict`, `json`, or `list`
|
|
|
310
319
|
|
|
311
320
|
```python
|
|
312
321
|
scalars_df = session.results.export_metrics("stable_rank", export_format="pandas")
|
|
313
|
-
aggregates_df = session.results.export_aggregates(
|
|
314
|
-
"stable_rank", export_format="pandas"
|
|
315
|
-
)
|
|
322
|
+
aggregates_df = session.results.export_aggregates("stable_rank", export_format="pandas")
|
|
316
323
|
|
|
317
324
|
# Other formats work the same way
|
|
318
325
|
results = session.results.export_metrics("stable_rank", export_format="polars")
|
|
@@ -352,7 +359,7 @@ List and configure kernels at runtime:
|
|
|
352
359
|
```python
|
|
353
360
|
session.compute.list_available_kernels(verbose=True)
|
|
354
361
|
session.compute.list_available_metrics(verbose=True)
|
|
355
|
-
session.compute.configure_kernel("hard_rank",
|
|
362
|
+
session.compute.configure_kernel("hard_rank", rtol=1e-6)
|
|
356
363
|
```
|
|
357
364
|
|
|
358
365
|
### Session Management
|
|
@@ -403,8 +410,11 @@ You can also override the registered name and output fields:
|
|
|
403
410
|
|
|
404
411
|
```python
|
|
405
412
|
with session:
|
|
413
|
+
|
|
406
414
|
@session.compute.kernel(name="scaled_metric", produce_fields=["scaled_result"])
|
|
407
|
-
def custom_analysis(
|
|
415
|
+
def custom_analysis(
|
|
416
|
+
frob_norm: float, stable_rank: float, *, weight: float = 0.5
|
|
417
|
+
) -> float:
|
|
408
418
|
"""Custom analysis combining multiple metrics."""
|
|
409
419
|
return weight * frob_norm + (1 - weight) * stable_rank
|
|
410
420
|
```
|
|
@@ -449,9 +459,9 @@ Diffract offers built-in **profiles** for common setups:
|
|
|
449
459
|
from diffract import Session
|
|
450
460
|
|
|
451
461
|
# Use a profile (recommended for most users)
|
|
452
|
-
session = Session(profile="ram")
|
|
453
|
-
session = Session(profile="local")
|
|
454
|
-
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
|
|
455
465
|
|
|
456
466
|
# Or use a custom config file for full control
|
|
457
467
|
session = Session(config_path="my_config.ini")
|
|
@@ -497,12 +507,14 @@ max_workers = 4
|
|
|
497
507
|
|
|
498
508
|
## 📚 Documentation
|
|
499
509
|
|
|
500
|
-
The documentation
|
|
501
|
-
|
|
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.
|
|
502
514
|
|
|
503
515
|
<br>
|
|
504
516
|
|
|
505
|
-
##
|
|
517
|
+
## Citation
|
|
506
518
|
|
|
507
519
|
If you use Diffract or build on the paper, please cite:
|
|
508
520
|
|
|
@@ -518,14 +530,14 @@ If you use Diffract or build on the paper, please cite:
|
|
|
518
530
|
|
|
519
531
|
<br>
|
|
520
532
|
|
|
521
|
-
##
|
|
533
|
+
## Contributions
|
|
522
534
|
|
|
523
|
-
Contributions are welcome
|
|
524
|
-
|
|
535
|
+
Contributions are welcome — see [CONTRIBUTING.md](CONTRIBUTING.md) for the development
|
|
536
|
+
setup, the checks CI runs, and the design principles.
|
|
525
537
|
|
|
526
538
|
<br>
|
|
527
539
|
|
|
528
|
-
##
|
|
540
|
+
## License
|
|
529
541
|
|
|
530
542
|
Licensed under the Apache License 2.0 — see [LICENSE](LICENSE). Copyright 2026 Risk AI
|
|
531
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.
|
|
@@ -105,9 +105,11 @@ docs = [
|
|
|
105
105
|
"sphinx-design >=0.6.0",
|
|
106
106
|
"furo >=2024.8.0",
|
|
107
107
|
"sphinxext-opengraph >=0.9.0",
|
|
108
|
+
"sphinxcontrib-bibtex >=2.6.0",
|
|
108
109
|
]
|
|
109
110
|
dev = [
|
|
110
111
|
"bandit[toml] >=1.7.5",
|
|
112
|
+
"hypothesis >=6.0.0",
|
|
111
113
|
"interrogate >=1.7.0",
|
|
112
114
|
"mypy >=1.10.1",
|
|
113
115
|
"pandas >=2.1.0",
|
|
@@ -170,8 +172,10 @@ filterwarnings = [
|
|
|
170
172
|
"ignore::DeprecationWarning",
|
|
171
173
|
"ignore::UserWarning",
|
|
172
174
|
"ignore::PendingDeprecationWarning",
|
|
173
|
-
# taichi 1.7.x ships a docstring with an invalid escape sequence
|
|
174
|
-
|
|
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",
|
|
175
179
|
]
|
|
176
180
|
log_cli = true
|
|
177
181
|
log_cli_level = "INFO"
|
|
@@ -201,7 +205,6 @@ omit = [
|
|
|
201
205
|
"*/.venv/*",
|
|
202
206
|
"*/venv/*",
|
|
203
207
|
"*/.tox/*",
|
|
204
|
-
"src/diffract/core/compute/kernels/*",
|
|
205
208
|
]
|
|
206
209
|
branch = true
|
|
207
210
|
parallel = true
|
|
@@ -225,7 +228,7 @@ exclude_lines = [
|
|
|
225
228
|
]
|
|
226
229
|
show_missing = true
|
|
227
230
|
precision = 2
|
|
228
|
-
fail_under =
|
|
231
|
+
fail_under = 67
|
|
229
232
|
skip_covered = false
|
|
230
233
|
skip_empty = false
|
|
231
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")
|