invarlock 0.3.7__tar.gz → 0.3.8__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.
Files changed (158) hide show
  1. invarlock-0.3.8/PKG-INFO +283 -0
  2. invarlock-0.3.8/README.md +176 -0
  3. {invarlock-0.3.7 → invarlock-0.3.8}/pyproject.toml +9 -9
  4. {invarlock-0.3.7 → invarlock-0.3.8}/src/invarlock/__init__.py +3 -3
  5. {invarlock-0.3.7 → invarlock-0.3.8}/src/invarlock/adapters/auto.py +2 -10
  6. {invarlock-0.3.7 → invarlock-0.3.8}/src/invarlock/adapters/hf_loading.py +7 -7
  7. {invarlock-0.3.7 → invarlock-0.3.8}/src/invarlock/adapters/hf_mixin.py +28 -5
  8. invarlock-0.3.8/src/invarlock/assurance/__init__.py +35 -0
  9. {invarlock-0.3.7 → invarlock-0.3.8}/src/invarlock/cli/adapter_auto.py +1 -5
  10. {invarlock-0.3.7 → invarlock-0.3.8}/src/invarlock/cli/app.py +57 -27
  11. {invarlock-0.3.7 → invarlock-0.3.8}/src/invarlock/cli/commands/__init__.py +2 -2
  12. {invarlock-0.3.7 → invarlock-0.3.8}/src/invarlock/cli/commands/calibrate.py +48 -4
  13. invarlock-0.3.7/src/invarlock/cli/commands/certify.py → invarlock-0.3.8/src/invarlock/cli/commands/evaluate.py +69 -46
  14. {invarlock-0.3.7 → invarlock-0.3.8}/src/invarlock/cli/commands/explain_gates.py +25 -17
  15. {invarlock-0.3.7 → invarlock-0.3.8}/src/invarlock/cli/commands/export_html.py +11 -9
  16. {invarlock-0.3.7 → invarlock-0.3.8}/src/invarlock/cli/commands/report.py +116 -46
  17. {invarlock-0.3.7 → invarlock-0.3.8}/src/invarlock/cli/commands/run.py +274 -66
  18. {invarlock-0.3.7 → invarlock-0.3.8}/src/invarlock/cli/commands/verify.py +84 -89
  19. {invarlock-0.3.7 → invarlock-0.3.8}/src/invarlock/cli/determinism.py +1 -1
  20. {invarlock-0.3.7 → invarlock-0.3.8}/src/invarlock/cli/provenance.py +3 -3
  21. {invarlock-0.3.7 → invarlock-0.3.8}/src/invarlock/core/bootstrap.py +1 -1
  22. {invarlock-0.3.7 → invarlock-0.3.8}/src/invarlock/core/retry.py +14 -14
  23. {invarlock-0.3.7 → invarlock-0.3.8}/src/invarlock/core/runner.py +1 -1
  24. {invarlock-0.3.7 → invarlock-0.3.8}/src/invarlock/edits/noop.py +2 -2
  25. {invarlock-0.3.7 → invarlock-0.3.8}/src/invarlock/edits/quant_rtn.py +2 -2
  26. {invarlock-0.3.7 → invarlock-0.3.8}/src/invarlock/eval/__init__.py +1 -1
  27. {invarlock-0.3.7 → invarlock-0.3.8}/src/invarlock/eval/bench.py +11 -7
  28. {invarlock-0.3.7 → invarlock-0.3.8}/src/invarlock/eval/primary_metric.py +1 -1
  29. {invarlock-0.3.7 → invarlock-0.3.8}/src/invarlock/guards/spectral.py +1 -1
  30. {invarlock-0.3.7 → invarlock-0.3.8}/src/invarlock/model_profile.py +16 -35
  31. {invarlock-0.3.7 → invarlock-0.3.8}/src/invarlock/plugins/hf_bnb_adapter.py +32 -21
  32. invarlock-0.3.8/src/invarlock/reporting/__init__.py +21 -0
  33. {invarlock-0.3.7 → invarlock-0.3.8}/src/invarlock/reporting/html.py +7 -7
  34. {invarlock-0.3.7 → invarlock-0.3.8}/src/invarlock/reporting/normalizer.py +2 -2
  35. {invarlock-0.3.7 → invarlock-0.3.8}/src/invarlock/reporting/policy_utils.py +1 -1
  36. {invarlock-0.3.7 → invarlock-0.3.8}/src/invarlock/reporting/primary_metric_utils.py +11 -11
  37. {invarlock-0.3.7 → invarlock-0.3.8}/src/invarlock/reporting/render.py +126 -120
  38. {invarlock-0.3.7 → invarlock-0.3.8}/src/invarlock/reporting/report.py +43 -37
  39. invarlock-0.3.7/src/invarlock/reporting/certificate.py → invarlock-0.3.8/src/invarlock/reporting/report_builder.py +98 -95
  40. invarlock-0.3.7/src/invarlock/reporting/certificate_schema.py → invarlock-0.3.8/src/invarlock/reporting/report_schema.py +22 -22
  41. invarlock-0.3.8/src/invarlock.egg-info/PKG-INFO +283 -0
  42. {invarlock-0.3.7 → invarlock-0.3.8}/src/invarlock.egg-info/SOURCES.txt +3 -3
  43. {invarlock-0.3.7 → invarlock-0.3.8}/src/invarlock.egg-info/requires.txt +7 -7
  44. invarlock-0.3.7/PKG-INFO +0 -602
  45. invarlock-0.3.7/README.md +0 -495
  46. invarlock-0.3.7/src/invarlock/assurance/__init__.py +0 -43
  47. invarlock-0.3.7/src/invarlock/reporting/__init__.py +0 -7
  48. invarlock-0.3.7/src/invarlock.egg-info/PKG-INFO +0 -602
  49. {invarlock-0.3.7 → invarlock-0.3.8}/LICENSE +0 -0
  50. {invarlock-0.3.7 → invarlock-0.3.8}/MANIFEST.in +0 -0
  51. {invarlock-0.3.7 → invarlock-0.3.8}/setup.cfg +0 -0
  52. {invarlock-0.3.7 → invarlock-0.3.8}/src/invarlock/__main__.py +0 -0
  53. {invarlock-0.3.7 → invarlock-0.3.8}/src/invarlock/_data/runtime/profiles/ci_cpu.yaml +0 -0
  54. {invarlock-0.3.7 → invarlock-0.3.8}/src/invarlock/_data/runtime/profiles/release.yaml +0 -0
  55. {invarlock-0.3.7 → invarlock-0.3.8}/src/invarlock/_data/runtime/tiers.yaml +0 -0
  56. {invarlock-0.3.7 → invarlock-0.3.8}/src/invarlock/adapters/__init__.py +0 -0
  57. {invarlock-0.3.7 → invarlock-0.3.8}/src/invarlock/adapters/_capabilities.py +0 -0
  58. {invarlock-0.3.7 → invarlock-0.3.8}/src/invarlock/adapters/base.py +0 -0
  59. {invarlock-0.3.7 → invarlock-0.3.8}/src/invarlock/adapters/base_types.py +0 -0
  60. {invarlock-0.3.7 → invarlock-0.3.8}/src/invarlock/adapters/capabilities.py +0 -0
  61. {invarlock-0.3.7 → invarlock-0.3.8}/src/invarlock/adapters/hf_causal.py +0 -0
  62. {invarlock-0.3.7 → invarlock-0.3.8}/src/invarlock/adapters/hf_causal_onnx.py +0 -0
  63. {invarlock-0.3.7 → invarlock-0.3.8}/src/invarlock/adapters/hf_mlm.py +0 -0
  64. {invarlock-0.3.7 → invarlock-0.3.8}/src/invarlock/adapters/hf_seq2seq.py +0 -0
  65. {invarlock-0.3.7 → invarlock-0.3.8}/src/invarlock/adapters/py.typed +0 -0
  66. {invarlock-0.3.7 → invarlock-0.3.8}/src/invarlock/calibration/__init__.py +0 -0
  67. {invarlock-0.3.7 → invarlock-0.3.8}/src/invarlock/calibration/spectral_null.py +0 -0
  68. {invarlock-0.3.7 → invarlock-0.3.8}/src/invarlock/calibration/variance_ve.py +0 -0
  69. {invarlock-0.3.7 → invarlock-0.3.8}/src/invarlock/cli/__init__.py +0 -0
  70. {invarlock-0.3.7 → invarlock-0.3.8}/src/invarlock/cli/__main__.py +0 -0
  71. {invarlock-0.3.7 → invarlock-0.3.8}/src/invarlock/cli/_evidence.py +0 -0
  72. {invarlock-0.3.7 → invarlock-0.3.8}/src/invarlock/cli/_json.py +0 -0
  73. {invarlock-0.3.7 → invarlock-0.3.8}/src/invarlock/cli/commands/doctor.py +0 -0
  74. {invarlock-0.3.7 → invarlock-0.3.8}/src/invarlock/cli/commands/plugins.py +0 -0
  75. {invarlock-0.3.7 → invarlock-0.3.8}/src/invarlock/cli/config.py +0 -0
  76. {invarlock-0.3.7 → invarlock-0.3.8}/src/invarlock/cli/constants.py +0 -0
  77. {invarlock-0.3.7 → invarlock-0.3.8}/src/invarlock/cli/device.py +0 -0
  78. {invarlock-0.3.7 → invarlock-0.3.8}/src/invarlock/cli/doctor_helpers.py +0 -0
  79. {invarlock-0.3.7 → invarlock-0.3.8}/src/invarlock/cli/errors.py +0 -0
  80. {invarlock-0.3.7 → invarlock-0.3.8}/src/invarlock/cli/output.py +0 -0
  81. {invarlock-0.3.7 → invarlock-0.3.8}/src/invarlock/cli/overhead_utils.py +0 -0
  82. {invarlock-0.3.7 → invarlock-0.3.8}/src/invarlock/cli/utils.py +0 -0
  83. {invarlock-0.3.7 → invarlock-0.3.8}/src/invarlock/config.py +0 -0
  84. {invarlock-0.3.7 → invarlock-0.3.8}/src/invarlock/core/__init__.py +0 -0
  85. {invarlock-0.3.7 → invarlock-0.3.8}/src/invarlock/core/abi.py +0 -0
  86. {invarlock-0.3.7 → invarlock-0.3.8}/src/invarlock/core/api.py +0 -0
  87. {invarlock-0.3.7 → invarlock-0.3.8}/src/invarlock/core/auto_tuning.py +0 -0
  88. {invarlock-0.3.7 → invarlock-0.3.8}/src/invarlock/core/checkpoint.py +0 -0
  89. {invarlock-0.3.7 → invarlock-0.3.8}/src/invarlock/core/contracts.py +0 -0
  90. {invarlock-0.3.7 → invarlock-0.3.8}/src/invarlock/core/error_utils.py +0 -0
  91. {invarlock-0.3.7 → invarlock-0.3.8}/src/invarlock/core/events.py +0 -0
  92. {invarlock-0.3.7 → invarlock-0.3.8}/src/invarlock/core/exceptions.py +0 -0
  93. {invarlock-0.3.7 → invarlock-0.3.8}/src/invarlock/core/registry.py +0 -0
  94. {invarlock-0.3.7 → invarlock-0.3.8}/src/invarlock/core/types.py +0 -0
  95. {invarlock-0.3.7 → invarlock-0.3.8}/src/invarlock/edits/__init__.py +0 -0
  96. {invarlock-0.3.7 → invarlock-0.3.8}/src/invarlock/edits/_edit_utils.py +0 -0
  97. {invarlock-0.3.7 → invarlock-0.3.8}/src/invarlock/edits/_external_utils.py +0 -0
  98. {invarlock-0.3.7 → invarlock-0.3.8}/src/invarlock/edits/py.typed +0 -0
  99. {invarlock-0.3.7 → invarlock-0.3.8}/src/invarlock/edits/registry.py +0 -0
  100. {invarlock-0.3.7 → invarlock-0.3.8}/src/invarlock/eval/bench_regression.py +0 -0
  101. {invarlock-0.3.7 → invarlock-0.3.8}/src/invarlock/eval/bootstrap.py +0 -0
  102. {invarlock-0.3.7 → invarlock-0.3.8}/src/invarlock/eval/data.py +0 -0
  103. {invarlock-0.3.7 → invarlock-0.3.8}/src/invarlock/eval/metrics.py +0 -0
  104. {invarlock-0.3.7 → invarlock-0.3.8}/src/invarlock/eval/probes/__init__.py +0 -0
  105. {invarlock-0.3.7 → invarlock-0.3.8}/src/invarlock/eval/probes/fft.py +0 -0
  106. {invarlock-0.3.7 → invarlock-0.3.8}/src/invarlock/eval/probes/mi.py +0 -0
  107. {invarlock-0.3.7 → invarlock-0.3.8}/src/invarlock/eval/probes/post_attention.py +0 -0
  108. {invarlock-0.3.7 → invarlock-0.3.8}/src/invarlock/eval/providers/base.py +0 -0
  109. {invarlock-0.3.7 → invarlock-0.3.8}/src/invarlock/eval/providers/seq2seq.py +0 -0
  110. {invarlock-0.3.7 → invarlock-0.3.8}/src/invarlock/eval/providers/text_lm.py +0 -0
  111. {invarlock-0.3.7 → invarlock-0.3.8}/src/invarlock/eval/providers/vision_text.py +0 -0
  112. {invarlock-0.3.7 → invarlock-0.3.8}/src/invarlock/eval/py.typed +0 -0
  113. {invarlock-0.3.7 → invarlock-0.3.8}/src/invarlock/eval/tail_stats.py +0 -0
  114. {invarlock-0.3.7 → invarlock-0.3.8}/src/invarlock/eval/tasks/__init__.py +0 -0
  115. {invarlock-0.3.7 → invarlock-0.3.8}/src/invarlock/eval/tasks/classification.py +0 -0
  116. {invarlock-0.3.7 → invarlock-0.3.8}/src/invarlock/eval/tasks/qa.py +0 -0
  117. {invarlock-0.3.7 → invarlock-0.3.8}/src/invarlock/eval/tasks/text_generation.py +0 -0
  118. {invarlock-0.3.7 → invarlock-0.3.8}/src/invarlock/guards/__init__.py +0 -0
  119. {invarlock-0.3.7 → invarlock-0.3.8}/src/invarlock/guards/_contracts.py +0 -0
  120. {invarlock-0.3.7 → invarlock-0.3.8}/src/invarlock/guards/_estimators.py +0 -0
  121. {invarlock-0.3.7 → invarlock-0.3.8}/src/invarlock/guards/invariants.py +0 -0
  122. {invarlock-0.3.7 → invarlock-0.3.8}/src/invarlock/guards/policies.py +0 -0
  123. {invarlock-0.3.7 → invarlock-0.3.8}/src/invarlock/guards/py.typed +0 -0
  124. {invarlock-0.3.7 → invarlock-0.3.8}/src/invarlock/guards/rmt.py +0 -0
  125. {invarlock-0.3.7 → invarlock-0.3.8}/src/invarlock/guards/tier_config.py +0 -0
  126. {invarlock-0.3.7 → invarlock-0.3.8}/src/invarlock/guards/variance.py +0 -0
  127. {invarlock-0.3.7 → invarlock-0.3.8}/src/invarlock/guards_ref/__init__.py +0 -0
  128. {invarlock-0.3.7 → invarlock-0.3.8}/src/invarlock/guards_ref/rmt_ref.py +0 -0
  129. {invarlock-0.3.7 → invarlock-0.3.8}/src/invarlock/guards_ref/spectral_ref.py +0 -0
  130. {invarlock-0.3.7 → invarlock-0.3.8}/src/invarlock/guards_ref/variance_ref.py +0 -0
  131. {invarlock-0.3.7 → invarlock-0.3.8}/src/invarlock/model_utils.py +0 -0
  132. {invarlock-0.3.7 → invarlock-0.3.8}/src/invarlock/observability/__init__.py +0 -0
  133. {invarlock-0.3.7 → invarlock-0.3.8}/src/invarlock/observability/alerting.py +0 -0
  134. {invarlock-0.3.7 → invarlock-0.3.8}/src/invarlock/observability/core.py +0 -0
  135. {invarlock-0.3.7 → invarlock-0.3.8}/src/invarlock/observability/exporters.py +0 -0
  136. {invarlock-0.3.7 → invarlock-0.3.8}/src/invarlock/observability/health.py +0 -0
  137. {invarlock-0.3.7 → invarlock-0.3.8}/src/invarlock/observability/metrics.py +0 -0
  138. {invarlock-0.3.7 → invarlock-0.3.8}/src/invarlock/observability/py.typed +0 -0
  139. {invarlock-0.3.7 → invarlock-0.3.8}/src/invarlock/observability/utils.py +0 -0
  140. {invarlock-0.3.7 → invarlock-0.3.8}/src/invarlock/plugins/__init__.py +0 -0
  141. {invarlock-0.3.7 → invarlock-0.3.8}/src/invarlock/plugins/hello_guard.py +0 -0
  142. {invarlock-0.3.7 → invarlock-0.3.8}/src/invarlock/plugins/hf_awq_adapter.py +0 -0
  143. {invarlock-0.3.7 → invarlock-0.3.8}/src/invarlock/plugins/hf_gptq_adapter.py +0 -0
  144. {invarlock-0.3.7 → invarlock-0.3.8}/src/invarlock/plugins/py.typed +0 -0
  145. {invarlock-0.3.7 → invarlock-0.3.8}/src/invarlock/py.typed +0 -0
  146. {invarlock-0.3.7 → invarlock-0.3.8}/src/invarlock/reporting/dataset_hashing.py +0 -0
  147. {invarlock-0.3.7 → invarlock-0.3.8}/src/invarlock/reporting/guards_analysis.py +0 -0
  148. {invarlock-0.3.7 → invarlock-0.3.8}/src/invarlock/reporting/report_types.py +0 -0
  149. {invarlock-0.3.7 → invarlock-0.3.8}/src/invarlock/reporting/telemetry.py +0 -0
  150. {invarlock-0.3.7 → invarlock-0.3.8}/src/invarlock/reporting/utils.py +0 -0
  151. {invarlock-0.3.7 → invarlock-0.3.8}/src/invarlock/reporting/validate.py +0 -0
  152. {invarlock-0.3.7 → invarlock-0.3.8}/src/invarlock/security.py +0 -0
  153. {invarlock-0.3.7 → invarlock-0.3.8}/src/invarlock/sparsity_utils.py +0 -0
  154. {invarlock-0.3.7 → invarlock-0.3.8}/src/invarlock/utils/__init__.py +0 -0
  155. {invarlock-0.3.7 → invarlock-0.3.8}/src/invarlock/utils/digest.py +0 -0
  156. {invarlock-0.3.7 → invarlock-0.3.8}/src/invarlock.egg-info/dependency_links.txt +0 -0
  157. {invarlock-0.3.7 → invarlock-0.3.8}/src/invarlock.egg-info/entry_points.txt +0 -0
  158. {invarlock-0.3.7 → invarlock-0.3.8}/src/invarlock.egg-info/top_level.txt +0 -0
@@ -0,0 +1,283 @@
1
+ Metadata-Version: 2.4
2
+ Name: invarlock
3
+ Version: 0.3.8
4
+ Summary: Edit‑agnostic robustness evaluation reports for weight edits (InvarLock framework)
5
+ Author-email: InvarLock Team <oss@invarlock.dev>
6
+ Maintainer-email: InvarLock Maintainers <support@invarlock.dev>
7
+ License-Expression: Apache-2.0
8
+ Project-URL: Homepage, https://github.com/invarlock/invarlock
9
+ Project-URL: Repository, https://github.com/invarlock/invarlock
10
+ Project-URL: Documentation, https://github.com/invarlock/invarlock/tree/main/docs
11
+ Project-URL: Issues, https://github.com/invarlock/invarlock/issues
12
+ Project-URL: Changelog, https://github.com/invarlock/invarlock/blob/main/CHANGELOG.md
13
+ Keywords: machine-learning,deep-learning,transformers,pytorch,llm,quantization,safety,evaluation,certification
14
+ Classifier: Development Status :: 4 - Beta
15
+ Classifier: Intended Audience :: Developers
16
+ Classifier: Intended Audience :: Science/Research
17
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
18
+ Classifier: Programming Language :: Python :: 3
19
+ Classifier: Programming Language :: Python :: 3.12
20
+ Classifier: Programming Language :: Python :: 3.13
21
+ Classifier: Operating System :: OS Independent
22
+ Classifier: Typing :: Typed
23
+ Requires-Python: >=3.12
24
+ Description-Content-Type: text/markdown
25
+ License-File: LICENSE
26
+ Requires-Dist: typer>=0.15
27
+ Requires-Dist: click>=8.1
28
+ Requires-Dist: shellingham>=1.5.0
29
+ Requires-Dist: pandas>=2.2
30
+ Requires-Dist: scikit-learn>=1.4
31
+ Requires-Dist: pydantic>=2.0
32
+ Requires-Dist: rich>=13.0
33
+ Requires-Dist: pyyaml>=6.0
34
+ Requires-Dist: markdown>=3.5
35
+ Requires-Dist: psutil>=5.9
36
+ Requires-Dist: hypothesis>=6.98
37
+ Requires-Dist: typing_extensions>=4.7
38
+ Requires-Dist: jsonschema>=4.0
39
+ Provides-Extra: adapters
40
+ Requires-Dist: torch>=2.1.0; extra == "adapters"
41
+ Requires-Dist: transformers>=5.0.0; extra == "adapters"
42
+ Provides-Extra: hf
43
+ Requires-Dist: torch>=2.1.0; extra == "hf"
44
+ Requires-Dist: transformers>=5.0.0; extra == "hf"
45
+ Requires-Dist: datasets>=3.0; extra == "hf"
46
+ Requires-Dist: numpy>=1.24; extra == "hf"
47
+ Requires-Dist: huggingface_hub>=1.0.0; extra == "hf"
48
+ Requires-Dist: aiohttp>=3.12.14; extra == "hf"
49
+ Requires-Dist: h2>=4.3.0; extra == "hf"
50
+ Requires-Dist: pillow>=11.3.0; extra == "hf"
51
+ Provides-Extra: guards
52
+ Requires-Dist: torch>=2.1.0; extra == "guards"
53
+ Requires-Dist: numpy>=1.24; extra == "guards"
54
+ Provides-Extra: edits
55
+ Requires-Dist: torch>=2.1.0; extra == "edits"
56
+ Provides-Extra: eval
57
+ Requires-Dist: torch>=2.1.0; extra == "eval"
58
+ Requires-Dist: datasets>=3.0; extra == "eval"
59
+ Provides-Extra: gptq
60
+ Requires-Dist: torch>=2.1.0; extra == "gptq"
61
+ Requires-Dist: auto-gptq>=0.7.0; platform_system == "Linux" and extra == "gptq"
62
+ Requires-Dist: triton>=2.3.0; platform_system == "Linux" and extra == "gptq"
63
+ Requires-Dist: transformers>=5.0.0; extra == "gptq"
64
+ Provides-Extra: awq
65
+ Requires-Dist: torch>=2.1.0; extra == "awq"
66
+ Requires-Dist: autoawq>=0.2.0; platform_system == "Linux" and extra == "awq"
67
+ Requires-Dist: transformers>=5.0.0; extra == "awq"
68
+ Requires-Dist: triton>=2.3.0; platform_system == "Linux" and extra == "awq"
69
+ Provides-Extra: gpu
70
+ Requires-Dist: torch>=2.1.0; extra == "gpu"
71
+ Requires-Dist: accelerate>=0.27; extra == "gpu"
72
+ Requires-Dist: bitsandbytes>=0.41; platform_system == "Linux" and extra == "gpu"
73
+ Provides-Extra: all
74
+ Requires-Dist: torch>=2.1.0; extra == "all"
75
+ Requires-Dist: transformers>=5.0.0; extra == "all"
76
+ Requires-Dist: datasets>=3.0; extra == "all"
77
+ Requires-Dist: numpy>=1.24; extra == "all"
78
+ Requires-Dist: huggingface_hub>=1.0.0; extra == "all"
79
+ Requires-Dist: accelerate>=0.27; extra == "all"
80
+ Requires-Dist: bitsandbytes>=0.41; platform_system == "Linux" and extra == "all"
81
+ Requires-Dist: auto-gptq>=0.7.0; platform_system == "Linux" and extra == "all"
82
+ Requires-Dist: autoawq>=0.2.0; platform_system == "Linux" and extra == "all"
83
+ Requires-Dist: triton>=2.3.0; platform_system == "Linux" and extra == "all"
84
+ Requires-Dist: aiohttp>=3.12.14; extra == "all"
85
+ Requires-Dist: h2>=4.3.0; extra == "all"
86
+ Requires-Dist: pillow>=11.3.0; extra == "all"
87
+ Provides-Extra: onnx
88
+ Requires-Dist: optimum>=1.17.0; extra == "onnx"
89
+ Requires-Dist: onnxruntime>=1.17.0; extra == "onnx"
90
+ Provides-Extra: dev
91
+ Requires-Dist: pytest>=7.0; extra == "dev"
92
+ Requires-Dist: pytest-cov>=4.0; extra == "dev"
93
+ Requires-Dist: ruff>=0.1.0; extra == "dev"
94
+ Requires-Dist: black>=23.0; extra == "dev"
95
+ Requires-Dist: mypy>=1.0; extra == "dev"
96
+ Requires-Dist: hypothesis>=6.98; extra == "dev"
97
+ Requires-Dist: pre-commit>=3.0; extra == "dev"
98
+ Requires-Dist: mkdocs>=1.5; extra == "dev"
99
+ Requires-Dist: mkdocs-material>=9.5; extra == "dev"
100
+ Requires-Dist: mkdocs-mermaid2-plugin>=1.1; extra == "dev"
101
+ Requires-Dist: sphinx>=7.0; extra == "dev"
102
+ Requires-Dist: matplotlib>=3.7; extra == "dev"
103
+ Requires-Dist: bitsandbytes>=0.41; extra == "dev"
104
+ Requires-Dist: build>=0.10.0; extra == "dev"
105
+ Requires-Dist: twine>=4.0.0; extra == "dev"
106
+ Dynamic: license-file
107
+
108
+ <p align="center">
109
+ <img
110
+ src="docs/assets/invarlock-logo.svg"
111
+ alt="InvarLock"
112
+ width="420"
113
+ />
114
+ </p>
115
+
116
+ # InvarLock — Edit‑agnostic robustness reports for weight edits
117
+
118
+ [![CI](https://img.shields.io/github/actions/workflow/status/invarlock/invarlock/ci.yml?branch=main&logo=github&label=CI)](https://github.com/invarlock/invarlock/actions/workflows/ci.yml)
119
+ [![PyPI](https://badge.fury.io/py/invarlock.svg)](https://pypi.org/project/invarlock/)
120
+ [![Docs](https://img.shields.io/badge/docs-quickstart-blue.svg)](https://github.com/invarlock/invarlock/blob/main/docs/user-guide/quickstart.md)
121
+ [![License: Apache-2.0](https://img.shields.io/badge/License-Apache_2.0-blue.svg)](LICENSE)
122
+ [![Python 3.12+](https://img.shields.io/badge/python-3.12+-blue.svg)](https://www.python.org/downloads/release/python-3120/)
123
+
124
+ Quantizing, pruning, or otherwise editing a model’s weights can silently degrade quality.
125
+ InvarLock compares an edited **subject** checkpoint against a fixed **baseline** with paired
126
+ evaluation windows, enforces a guard pipeline (invariants → spectral → RMT → variance), and
127
+ produces a machine‑readable Evaluation Report you can gate in CI.
128
+
129
+ > Status: pre‑1.0. Until 1.0, minor releases may be breaking. See `CHANGELOG.md`.
130
+
131
+ For guidance on where to ask questions, how to report bugs, and what to expect in terms of response times, see
132
+ [SUPPORT.md](https://github.com/invarlock/invarlock/blob/main/SUPPORT.md).
133
+
134
+ ## Why InvarLock?
135
+
136
+ - **Quality gates for weight edits**: catch regressions before deployment.
137
+ - **Statistical guarantees**: paired primary metrics with confidence intervals.
138
+ - **Auditable evidence**: deterministic pairing metadata + policy digests in `evaluation.report.json`.
139
+ - **CI/CD-friendly**: stable exit codes, `--json` outputs, and portable “proof packs”.
140
+ - **Offline-first**: network is disabled by default; enable downloads per command.
141
+
142
+ ## Who is this for?
143
+
144
+ - ML engineers shipping quantized/pruned checkpoints.
145
+ - MLOps teams building CI quality gates and reviewable artifacts.
146
+ - Researchers validating compression/edit methods with reproducible, paired eval.
147
+
148
+ ## How it works
149
+
150
+ ```text
151
+ ┌───────────────────────┐ ┌────────────────────────────────────────────┐
152
+ │ Baseline (checkpoint) │────►│ │
153
+ └───────────────────────┘ │ invarlock evaluate │
154
+ │ ├─► Paired windows (deterministic) │
155
+ ┌───────────────────────┐ │ ├─► GuardChain pipeline │
156
+ │ Subject (checkpoint) │────►│ │ └─► invariants → spectral → RMT → VE │
157
+ └───────────────────────┘ │ └─► Emit: evaluation.report.json │
158
+ │ │
159
+ └────────────────────────────────────────────┘
160
+
161
+ ┌───────────────┴───────────────┐
162
+ ▼ ▼
163
+ ✅ PASS ❌ FAIL
164
+ (ship) (rollback)
165
+
166
+ ```
167
+
168
+ ## Quick start
169
+
170
+ Colab (CPU-friendly):
171
+ [![Open in Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/invarlock/invarlock/blob/main/notebooks/invarlock_quickstart_cpu.ipynb)
172
+
173
+ ```bash
174
+ # HF adapter stack (torch/transformers)
175
+ pip install "invarlock[hf]"
176
+
177
+ # Version + report schema (when available)
178
+ invarlock --version
179
+
180
+ # Compare baseline vs subject (downloads require explicit network enable)
181
+ INVARLOCK_ALLOW_NETWORK=1 invarlock evaluate \
182
+ --baseline gpt2 \
183
+ --subject gpt2 \
184
+ --adapter auto \
185
+ --profile dev \
186
+ --quiet
187
+
188
+ # Validate the evaluation report
189
+ invarlock verify reports/eval/evaluation.report.json
190
+
191
+ # Render HTML for sharing
192
+ invarlock report html -i reports/eval/evaluation.report.json -o reports/eval/evaluation.html
193
+ ```
194
+
195
+ Example output (abridged; counts vary by profile/config):
196
+
197
+ ```text
198
+ INVARLOCK v<version> · EVALUATE
199
+ Baseline: gpt2 -> Subject: gpt2 · Profile: dev
200
+ Status: PASS · Gates: <passed>/<total> passed
201
+ Primary metric ratio: <ratio>
202
+ Output: reports/eval/evaluation.report.json
203
+ ```
204
+
205
+ ## Proof packs (portable evidence bundles)
206
+
207
+ Proof packs bundle reports + verification metadata into a distributable artifact.
208
+
209
+ - Guide: <https://github.com/invarlock/invarlock/blob/main/docs/user-guide/proof-packs.md>
210
+ - Verify: `scripts/proof_packs/verify_pack.sh --pack <dir> --strict` (or `PACK_STRICT_MODE=1 ...`)
211
+
212
+ Note: `configs/` and `scripts/` are repo resources and are not shipped in wheels; clone the repo to use
213
+ presets and proof-pack helpers.
214
+
215
+ ## Installation
216
+
217
+ ```bash
218
+ # Minimal CLI (no torch/transformers)
219
+ pip install invarlock
220
+
221
+ # HF workflows (torch/transformers)
222
+ pip install "invarlock[hf]"
223
+ ```
224
+
225
+ Optional extras: `invarlock[gpu]`, `invarlock[awq,gptq]`. Full setup: <https://github.com/invarlock/invarlock/blob/main/docs/user-guide/getting-started.md>.
226
+
227
+ ## Documentation
228
+
229
+ - Quickstart: <https://github.com/invarlock/invarlock/blob/main/docs/user-guide/quickstart.md>
230
+ - Compare & evaluate (BYOE): <https://github.com/invarlock/invarlock/blob/main/docs/user-guide/compare-and-evaluate.md>
231
+ - Reading a report: <https://github.com/invarlock/invarlock/blob/main/docs/user-guide/reading-report.md>
232
+ - CLI reference: <https://github.com/invarlock/invarlock/blob/main/docs/reference/cli.md>
233
+ - Assurance case: <https://github.com/invarlock/invarlock/blob/main/docs/assurance/00-safety-case.md>
234
+ - Threat model: <https://github.com/invarlock/invarlock/blob/main/docs/security/threat-model.md>
235
+
236
+ ## Community
237
+
238
+ - Questions/ideas: <https://github.com/invarlock/invarlock/discussions>
239
+ - Bug reports: <https://github.com/invarlock/invarlock/issues>
240
+ - Contact: <mailto:support@invarlock.dev>
241
+
242
+ ## Citation
243
+
244
+ If you use InvarLock in scientific work, please cite it (canonical metadata is in `CITATION.cff`):
245
+
246
+ ```bibtex
247
+ @software{invarlock,
248
+ title = {InvarLock: Edit-agnostic robustness evaluation reports for weight edits},
249
+ author = {{InvarLock Maintainers}},
250
+ url = {https://github.com/invarlock/invarlock},
251
+ }
252
+ ```
253
+
254
+ ## Limitations
255
+
256
+ - InvarLock evaluates an edited model relative to a baseline under a specific configuration; results are not “global” guarantees.
257
+ - Not a content-safety/alignment tool.
258
+ - Native Windows is not supported (use WSL2 or Linux).
259
+
260
+ ## Support matrix
261
+
262
+ <!-- markdownlint-disable MD060 -->
263
+ | Platform | Status | Notes |
264
+ | ---------------------- | --------------- | ----------------------------------------- |
265
+ | Python 3.12+ | ✅ Required | |
266
+ | Linux | ✅ Full | Primary dev target |
267
+ | macOS (Intel/M-series) | ✅ Full | MPS supported (default on Apple Silicon) |
268
+ | Windows | ❌ Not supported | Use WSL2 or a Linux container if required |
269
+ | CUDA | ✅ Recommended | For larger models |
270
+ | CPU | ✅ Fallback | Slower but functional |
271
+ <!-- markdownlint-enable MD060 -->
272
+
273
+ ## Contributing
274
+
275
+ - Contributing guide: <https://github.com/invarlock/invarlock/blob/main/CONTRIBUTING.md>
276
+ - Fast local checks (repo clone):
277
+ - `make dev-install`
278
+ - `make test`
279
+ - `make lint`
280
+
281
+ ## License
282
+
283
+ Apache-2.0 — see `LICENSE`.
@@ -0,0 +1,176 @@
1
+ <p align="center">
2
+ <img
3
+ src="docs/assets/invarlock-logo.svg"
4
+ alt="InvarLock"
5
+ width="420"
6
+ />
7
+ </p>
8
+
9
+ # InvarLock — Edit‑agnostic robustness reports for weight edits
10
+
11
+ [![CI](https://img.shields.io/github/actions/workflow/status/invarlock/invarlock/ci.yml?branch=main&logo=github&label=CI)](https://github.com/invarlock/invarlock/actions/workflows/ci.yml)
12
+ [![PyPI](https://badge.fury.io/py/invarlock.svg)](https://pypi.org/project/invarlock/)
13
+ [![Docs](https://img.shields.io/badge/docs-quickstart-blue.svg)](https://github.com/invarlock/invarlock/blob/main/docs/user-guide/quickstart.md)
14
+ [![License: Apache-2.0](https://img.shields.io/badge/License-Apache_2.0-blue.svg)](LICENSE)
15
+ [![Python 3.12+](https://img.shields.io/badge/python-3.12+-blue.svg)](https://www.python.org/downloads/release/python-3120/)
16
+
17
+ Quantizing, pruning, or otherwise editing a model’s weights can silently degrade quality.
18
+ InvarLock compares an edited **subject** checkpoint against a fixed **baseline** with paired
19
+ evaluation windows, enforces a guard pipeline (invariants → spectral → RMT → variance), and
20
+ produces a machine‑readable Evaluation Report you can gate in CI.
21
+
22
+ > Status: pre‑1.0. Until 1.0, minor releases may be breaking. See `CHANGELOG.md`.
23
+
24
+ For guidance on where to ask questions, how to report bugs, and what to expect in terms of response times, see
25
+ [SUPPORT.md](https://github.com/invarlock/invarlock/blob/main/SUPPORT.md).
26
+
27
+ ## Why InvarLock?
28
+
29
+ - **Quality gates for weight edits**: catch regressions before deployment.
30
+ - **Statistical guarantees**: paired primary metrics with confidence intervals.
31
+ - **Auditable evidence**: deterministic pairing metadata + policy digests in `evaluation.report.json`.
32
+ - **CI/CD-friendly**: stable exit codes, `--json` outputs, and portable “proof packs”.
33
+ - **Offline-first**: network is disabled by default; enable downloads per command.
34
+
35
+ ## Who is this for?
36
+
37
+ - ML engineers shipping quantized/pruned checkpoints.
38
+ - MLOps teams building CI quality gates and reviewable artifacts.
39
+ - Researchers validating compression/edit methods with reproducible, paired eval.
40
+
41
+ ## How it works
42
+
43
+ ```text
44
+ ┌───────────────────────┐ ┌────────────────────────────────────────────┐
45
+ │ Baseline (checkpoint) │────►│ │
46
+ └───────────────────────┘ │ invarlock evaluate │
47
+ │ ├─► Paired windows (deterministic) │
48
+ ┌───────────────────────┐ │ ├─► GuardChain pipeline │
49
+ │ Subject (checkpoint) │────►│ │ └─► invariants → spectral → RMT → VE │
50
+ └───────────────────────┘ │ └─► Emit: evaluation.report.json │
51
+ │ │
52
+ └────────────────────────────────────────────┘
53
+
54
+ ┌───────────────┴───────────────┐
55
+ ▼ ▼
56
+ ✅ PASS ❌ FAIL
57
+ (ship) (rollback)
58
+
59
+ ```
60
+
61
+ ## Quick start
62
+
63
+ Colab (CPU-friendly):
64
+ [![Open in Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/invarlock/invarlock/blob/main/notebooks/invarlock_quickstart_cpu.ipynb)
65
+
66
+ ```bash
67
+ # HF adapter stack (torch/transformers)
68
+ pip install "invarlock[hf]"
69
+
70
+ # Version + report schema (when available)
71
+ invarlock --version
72
+
73
+ # Compare baseline vs subject (downloads require explicit network enable)
74
+ INVARLOCK_ALLOW_NETWORK=1 invarlock evaluate \
75
+ --baseline gpt2 \
76
+ --subject gpt2 \
77
+ --adapter auto \
78
+ --profile dev \
79
+ --quiet
80
+
81
+ # Validate the evaluation report
82
+ invarlock verify reports/eval/evaluation.report.json
83
+
84
+ # Render HTML for sharing
85
+ invarlock report html -i reports/eval/evaluation.report.json -o reports/eval/evaluation.html
86
+ ```
87
+
88
+ Example output (abridged; counts vary by profile/config):
89
+
90
+ ```text
91
+ INVARLOCK v<version> · EVALUATE
92
+ Baseline: gpt2 -> Subject: gpt2 · Profile: dev
93
+ Status: PASS · Gates: <passed>/<total> passed
94
+ Primary metric ratio: <ratio>
95
+ Output: reports/eval/evaluation.report.json
96
+ ```
97
+
98
+ ## Proof packs (portable evidence bundles)
99
+
100
+ Proof packs bundle reports + verification metadata into a distributable artifact.
101
+
102
+ - Guide: <https://github.com/invarlock/invarlock/blob/main/docs/user-guide/proof-packs.md>
103
+ - Verify: `scripts/proof_packs/verify_pack.sh --pack <dir> --strict` (or `PACK_STRICT_MODE=1 ...`)
104
+
105
+ Note: `configs/` and `scripts/` are repo resources and are not shipped in wheels; clone the repo to use
106
+ presets and proof-pack helpers.
107
+
108
+ ## Installation
109
+
110
+ ```bash
111
+ # Minimal CLI (no torch/transformers)
112
+ pip install invarlock
113
+
114
+ # HF workflows (torch/transformers)
115
+ pip install "invarlock[hf]"
116
+ ```
117
+
118
+ Optional extras: `invarlock[gpu]`, `invarlock[awq,gptq]`. Full setup: <https://github.com/invarlock/invarlock/blob/main/docs/user-guide/getting-started.md>.
119
+
120
+ ## Documentation
121
+
122
+ - Quickstart: <https://github.com/invarlock/invarlock/blob/main/docs/user-guide/quickstart.md>
123
+ - Compare & evaluate (BYOE): <https://github.com/invarlock/invarlock/blob/main/docs/user-guide/compare-and-evaluate.md>
124
+ - Reading a report: <https://github.com/invarlock/invarlock/blob/main/docs/user-guide/reading-report.md>
125
+ - CLI reference: <https://github.com/invarlock/invarlock/blob/main/docs/reference/cli.md>
126
+ - Assurance case: <https://github.com/invarlock/invarlock/blob/main/docs/assurance/00-safety-case.md>
127
+ - Threat model: <https://github.com/invarlock/invarlock/blob/main/docs/security/threat-model.md>
128
+
129
+ ## Community
130
+
131
+ - Questions/ideas: <https://github.com/invarlock/invarlock/discussions>
132
+ - Bug reports: <https://github.com/invarlock/invarlock/issues>
133
+ - Contact: <mailto:support@invarlock.dev>
134
+
135
+ ## Citation
136
+
137
+ If you use InvarLock in scientific work, please cite it (canonical metadata is in `CITATION.cff`):
138
+
139
+ ```bibtex
140
+ @software{invarlock,
141
+ title = {InvarLock: Edit-agnostic robustness evaluation reports for weight edits},
142
+ author = {{InvarLock Maintainers}},
143
+ url = {https://github.com/invarlock/invarlock},
144
+ }
145
+ ```
146
+
147
+ ## Limitations
148
+
149
+ - InvarLock evaluates an edited model relative to a baseline under a specific configuration; results are not “global” guarantees.
150
+ - Not a content-safety/alignment tool.
151
+ - Native Windows is not supported (use WSL2 or Linux).
152
+
153
+ ## Support matrix
154
+
155
+ <!-- markdownlint-disable MD060 -->
156
+ | Platform | Status | Notes |
157
+ | ---------------------- | --------------- | ----------------------------------------- |
158
+ | Python 3.12+ | ✅ Required | |
159
+ | Linux | ✅ Full | Primary dev target |
160
+ | macOS (Intel/M-series) | ✅ Full | MPS supported (default on Apple Silicon) |
161
+ | Windows | ❌ Not supported | Use WSL2 or a Linux container if required |
162
+ | CUDA | ✅ Recommended | For larger models |
163
+ | CPU | ✅ Fallback | Slower but functional |
164
+ <!-- markdownlint-enable MD060 -->
165
+
166
+ ## Contributing
167
+
168
+ - Contributing guide: <https://github.com/invarlock/invarlock/blob/main/CONTRIBUTING.md>
169
+ - Fast local checks (repo clone):
170
+ - `make dev-install`
171
+ - `make test`
172
+ - `make lint`
173
+
174
+ ## License
175
+
176
+ Apache-2.0 — see `LICENSE`.
@@ -4,8 +4,8 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "invarlock"
7
- version = "0.3.7"
8
- description = "Edit‑agnostic robustness certificates for weight edits (InvarLock framework)"
7
+ version = "0.3.8"
8
+ description = "Edit‑agnostic robustness evaluation reports for weight edits (InvarLock framework)"
9
9
  authors = [{ name = "InvarLock Team", email = "oss@invarlock.dev" }]
10
10
  maintainers = [{ name = "InvarLock Maintainers", email = "support@invarlock.dev" }]
11
11
  license = "Apache-2.0"
@@ -52,16 +52,16 @@ Changelog = "https://github.com/invarlock/invarlock/blob/main/CHANGELOG.md"
52
52
  # Core torch dependencies for adapters
53
53
  adapters = [
54
54
  "torch>=2.1.0",
55
- "transformers>=4.53.0",
55
+ "transformers>=5.0.0",
56
56
  ]
57
57
 
58
58
  # Hugging Face workflow (adapters + evaluation stack)
59
59
  hf = [
60
60
  "torch>=2.1.0",
61
- "transformers>=4.53.0",
61
+ "transformers>=5.0.0",
62
62
  "datasets>=3.0",
63
63
  "numpy>=1.24",
64
- "huggingface_hub>=0.23",
64
+ "huggingface_hub>=1.0.0",
65
65
  "aiohttp>=3.12.14",
66
66
  "h2>=4.3.0",
67
67
  "pillow>=11.3.0",
@@ -89,14 +89,14 @@ gptq = [
89
89
  "torch>=2.1.0",
90
90
  "auto-gptq>=0.7.0; platform_system == \"Linux\"",
91
91
  "triton>=2.3.0; platform_system == \"Linux\"",
92
- "transformers>=4.53.0",
92
+ "transformers>=5.0.0",
93
93
  ]
94
94
 
95
95
 
96
96
  awq = [
97
97
  "torch>=2.1.0",
98
98
  "autoawq>=0.2.0; platform_system == \"Linux\"",
99
- "transformers>=4.53.0",
99
+ "transformers>=5.0.0",
100
100
  "triton>=2.3.0; platform_system == \"Linux\"",
101
101
  ]
102
102
 
@@ -111,10 +111,10 @@ gpu = [
111
111
  # Complete installation with all features
112
112
  all = [
113
113
  "torch>=2.1.0",
114
- "transformers>=4.53.0",
114
+ "transformers>=5.0.0",
115
115
  "datasets>=3.0",
116
116
  "numpy>=1.24",
117
- "huggingface_hub>=0.23",
117
+ "huggingface_hub>=1.0.0",
118
118
  "accelerate>=0.27",
119
119
  "bitsandbytes>=0.41; platform_system == \"Linux\"",
120
120
  "auto-gptq>=0.7.0; platform_system == \"Linux\"",
@@ -1,5 +1,5 @@
1
1
  """
2
- InvarLock: Edit‑agnostic robustness certificates for weight edits
2
+ InvarLock: Edit‑agnostic evaluation reports for weight edits
3
3
  =============================================================
4
4
 
5
5
  Core runtime package — torch-independent utilities, configuration, and interfaces.
@@ -9,10 +9,10 @@ For torch-dependent functionality, see subpackages under `invarlock.*`:
9
9
  - `invarlock.adapters`: Model adapters (HF causal/MLM/seq2seq + auto)
10
10
  - `invarlock.guards`: Safety mechanisms (invariants, spectral, RMT, variance)
11
11
  - `invarlock.edits`: Built-in quantization and edit interfaces
12
- - `invarlock.eval`: Metrics, guard-overhead checks, and certification
12
+ - `invarlock.eval`: Metrics, guard-overhead checks, and evaluation reporting
13
13
  """
14
14
 
15
- __version__ = "0.3.7"
15
+ __version__ = "0.3.8"
16
16
 
17
17
  # Core exports - torch-independent
18
18
  from .config import CFG, Defaults, get_default_config
@@ -38,11 +38,7 @@ def _detect_quantization_from_path(model_id: str) -> str | None:
38
38
  return "hf_awq"
39
39
  elif quant_method == "gptq":
40
40
  return "hf_gptq"
41
- elif (
42
- quant_method == "bitsandbytes"
43
- or quant_cfg.get("load_in_8bit")
44
- or quant_cfg.get("load_in_4bit")
45
- ):
41
+ elif "bitsandbytes" in quant_method or "bnb" in quant_method:
46
42
  return "hf_bnb"
47
43
 
48
44
  except Exception:
@@ -78,11 +74,7 @@ def _detect_quantization_from_model(model: Any) -> str | None:
78
74
  return "hf_awq"
79
75
  elif quant_method == "gptq":
80
76
  return "hf_gptq"
81
- elif (
82
- quant_method == "bitsandbytes"
83
- or quant_cfg.get("load_in_8bit")
84
- or quant_cfg.get("load_in_4bit")
85
- ):
77
+ elif "bitsandbytes" in quant_method or "bnb" in quant_method:
86
78
  return "hf_bnb"
87
79
  else:
88
80
  # Object-style config
@@ -50,7 +50,7 @@ def resolve_trust_remote_code(
50
50
  return default
51
51
 
52
52
 
53
- def default_torch_dtype() -> torch.dtype:
53
+ def default_dtype() -> torch.dtype:
54
54
  """Pick a safe default dtype for HF loads based on hardware."""
55
55
  if torch.cuda.is_available():
56
56
  try:
@@ -69,10 +69,10 @@ def default_torch_dtype() -> torch.dtype:
69
69
  return torch.float32
70
70
 
71
71
 
72
- def resolve_torch_dtype(kwargs: dict[str, Any] | None = None) -> torch.dtype | str:
73
- """Resolve torch_dtype from kwargs or choose a hardware-aware default."""
74
- if kwargs and "torch_dtype" in kwargs:
75
- val = kwargs.get("torch_dtype")
72
+ def resolve_dtype(kwargs: dict[str, Any] | None = None) -> torch.dtype | str:
73
+ """Resolve dtype from kwargs or choose a hardware-aware default."""
74
+ if kwargs and "dtype" in kwargs:
75
+ val = kwargs.get("dtype")
76
76
  if isinstance(val, torch.dtype):
77
77
  return val
78
78
  if isinstance(val, str):
@@ -91,7 +91,7 @@ def resolve_torch_dtype(kwargs: dict[str, Any] | None = None) -> torch.dtype | s
91
91
  if s in mapping:
92
92
  return mapping[s]
93
93
 
94
- return default_torch_dtype()
94
+ return default_dtype()
95
95
 
96
96
 
97
- __all__ = ["resolve_trust_remote_code", "default_torch_dtype", "resolve_torch_dtype"]
97
+ __all__ = ["resolve_trust_remote_code", "default_dtype", "resolve_dtype"]
@@ -583,22 +583,45 @@ class HFAdapterMixin:
583
583
  def _serialize_config(self, config: Any) -> dict[str, Any]:
584
584
  """Serialize HuggingFace config fields into simple Python types."""
585
585
 
586
+ def _collect(data: dict[str, Any]) -> dict[str, Any]:
587
+ out: dict[str, Any] = {}
588
+ for key, value in data.items():
589
+ if key.startswith("_") or key in {"method_calls"}:
590
+ continue
591
+ if value is None or isinstance(value, SCALAR_TYPES):
592
+ out[key] = value
593
+ elif isinstance(value, list | dict):
594
+ out[key] = value
595
+ return out
596
+
597
+ to_dict = getattr(config, "to_dict", None)
598
+ if callable(to_dict):
599
+ try:
600
+ data = to_dict()
601
+ except Exception:
602
+ data = None
603
+ if isinstance(data, dict):
604
+ return _collect(data)
605
+
606
+ try:
607
+ data = vars(config)
608
+ except TypeError:
609
+ data = None
610
+ if isinstance(data, dict):
611
+ return _collect(data)
612
+
586
613
  result: dict[str, Any] = {}
587
614
  for key in dir(config):
588
- if key.startswith("_"):
615
+ if key.startswith("_") or key in {"torch_dtype"}:
589
616
  continue
590
-
591
617
  try:
592
618
  value = getattr(config, key)
593
619
  except AttributeError:
594
620
  continue
595
-
596
621
  if callable(value):
597
622
  continue
598
-
599
623
  if value is None or isinstance(value, SCALAR_TYPES):
600
624
  result[key] = value
601
625
  elif isinstance(value, list | dict):
602
626
  result[key] = value
603
-
604
627
  return result