nnsight 0.3.6__tar.gz → 0.4.0.dev0__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.
- {nnsight-0.3.6 → nnsight-0.4.0.dev0}/.gitignore +1 -2
- {nnsight-0.3.6 → nnsight-0.4.0.dev0}/PKG-INFO +12 -2
- {nnsight-0.3.6 → nnsight-0.4.0.dev0}/conftest.py +19 -1
- {nnsight-0.3.6 → nnsight-0.4.0.dev0}/docs/source/conf.py +7 -7
- {nnsight-0.3.6 → nnsight-0.4.0.dev0}/pyproject.toml +22 -5
- nnsight-0.4.0.dev0/pytest.ini +3 -0
- nnsight-0.4.0.dev0/src/nnsight/__init__.py +115 -0
- nnsight-0.4.0.dev0/src/nnsight/config.yaml +13 -0
- nnsight-0.4.0.dev0/src/nnsight/intervention/__init__.py +7 -0
- nnsight-0.4.0.dev0/src/nnsight/intervention/backends/__init__.py +3 -0
- nnsight-0.4.0.dev0/src/nnsight/intervention/backends/editing.py +18 -0
- nnsight-0.4.0.dev0/src/nnsight/intervention/backends/noop.py +9 -0
- nnsight-0.4.0.dev0/src/nnsight/intervention/backends/remote.py +367 -0
- nnsight-0.4.0.dev0/src/nnsight/intervention/base.py +478 -0
- nnsight-0.4.0.dev0/src/nnsight/intervention/contexts/__init__.py +7 -0
- nnsight-0.4.0.dev0/src/nnsight/intervention/contexts/editing.py +28 -0
- nnsight-0.4.0.dev0/src/nnsight/intervention/contexts/globals.py +59 -0
- nnsight-0.4.0.dev0/src/nnsight/intervention/contexts/interleaving.py +163 -0
- nnsight-0.3.6/src/nnsight/contexts/Invoker.py → nnsight-0.4.0.dev0/src/nnsight/intervention/contexts/invoker.py +43 -36
- nnsight-0.4.0.dev0/src/nnsight/intervention/contexts/local.py +115 -0
- nnsight-0.4.0.dev0/src/nnsight/intervention/contexts/session.py +37 -0
- nnsight-0.4.0.dev0/src/nnsight/intervention/contexts/tracer.py +61 -0
- {nnsight-0.3.6/src/nnsight → nnsight-0.4.0.dev0/src/nnsight/intervention}/envoy.py +364 -215
- nnsight-0.4.0.dev0/src/nnsight/intervention/graph/__init__.py +3 -0
- nnsight-0.4.0.dev0/src/nnsight/intervention/graph/graph.py +432 -0
- nnsight-0.4.0.dev0/src/nnsight/intervention/graph/node.py +159 -0
- nnsight-0.4.0.dev0/src/nnsight/intervention/graph/proxy.py +142 -0
- nnsight-0.4.0.dev0/src/nnsight/intervention/interleaver.py +128 -0
- nnsight-0.4.0.dev0/src/nnsight/intervention/protocols/__init__.py +6 -0
- nnsight-0.4.0.dev0/src/nnsight/intervention/protocols/entrypoint.py +18 -0
- nnsight-0.4.0.dev0/src/nnsight/intervention/protocols/grad.py +73 -0
- nnsight-0.4.0.dev0/src/nnsight/intervention/protocols/intervention.py +215 -0
- nnsight-0.4.0.dev0/src/nnsight/intervention/protocols/module.py +106 -0
- nnsight-0.4.0.dev0/src/nnsight/intervention/protocols/noop.py +14 -0
- nnsight-0.4.0.dev0/src/nnsight/intervention/protocols/swap.py +36 -0
- {nnsight-0.3.6/src/nnsight/contexts/session → nnsight-0.4.0.dev0/src/nnsight/modeling}/__init__.py +0 -0
- nnsight-0.3.6/src/nnsight/models/DiffusionModel.py → nnsight-0.4.0.dev0/src/nnsight/modeling/diffusion.py +35 -26
- nnsight-0.4.0.dev0/src/nnsight/modeling/language.py +336 -0
- nnsight-0.4.0.dev0/src/nnsight/modeling/mixins/__init__.py +3 -0
- nnsight-0.4.0.dev0/src/nnsight/modeling/mixins/loadable.py +22 -0
- nnsight-0.4.0.dev0/src/nnsight/modeling/mixins/meta.py +47 -0
- nnsight-0.4.0.dev0/src/nnsight/modeling/mixins/remoteable.py +86 -0
- nnsight-0.4.0.dev0/src/nnsight/modeling/vllm/__init__.py +1 -0
- nnsight-0.4.0.dev0/src/nnsight/modeling/vllm/executors/GPUExecutor.py +9 -0
- nnsight-0.4.0.dev0/src/nnsight/modeling/vllm/executors/RayGPUExecutor.py +6 -0
- {nnsight-0.3.6/src/nnsight/schema → nnsight-0.4.0.dev0/src/nnsight/modeling/vllm/executors}/__init__.py +0 -0
- nnsight-0.4.0.dev0/src/nnsight/modeling/vllm/model_runners/GPUModelRunner.py +418 -0
- {nnsight-0.3.6/src/nnsight/toolbox → nnsight-0.4.0.dev0/src/nnsight/modeling/vllm/model_runners}/__init__.py +0 -0
- nnsight-0.4.0.dev0/src/nnsight/modeling/vllm/sampling.py +158 -0
- nnsight-0.4.0.dev0/src/nnsight/modeling/vllm/vllm.py +272 -0
- nnsight-0.4.0.dev0/src/nnsight/modeling/vllm/workers/GPUWorker.py +10 -0
- {nnsight-0.3.6/src/nnsight/toolbox/interventions → nnsight-0.4.0.dev0/src/nnsight/modeling/vllm/workers}/__init__.py +0 -0
- nnsight-0.4.0.dev0/src/nnsight/nnsight.log +7 -0
- nnsight-0.3.6/src/nnsight/schema/Config.py → nnsight-0.4.0.dev0/src/nnsight/schema/config.py +11 -2
- {nnsight-0.3.6 → nnsight-0.4.0.dev0}/src/nnsight/schema/format/functions.py +42 -6
- nnsight-0.4.0.dev0/src/nnsight/schema/format/types.py +447 -0
- nnsight-0.4.0.dev0/src/nnsight/schema/request.py +161 -0
- nnsight-0.4.0.dev0/src/nnsight/schema/response.py +80 -0
- nnsight-0.4.0.dev0/src/nnsight/schema/result.py +26 -0
- nnsight-0.4.0.dev0/src/nnsight/test.py +40 -0
- nnsight-0.4.0.dev0/src/nnsight/tracing/__init__.py +7 -0
- nnsight-0.4.0.dev0/src/nnsight/tracing/backends/__init__.py +1 -0
- nnsight-0.4.0.dev0/src/nnsight/tracing/backends/base.py +59 -0
- nnsight-0.4.0.dev0/src/nnsight/tracing/contexts/__init__.py +5 -0
- nnsight-0.4.0.dev0/src/nnsight/tracing/contexts/base.py +96 -0
- nnsight-0.4.0.dev0/src/nnsight/tracing/contexts/conditional.py +69 -0
- nnsight-0.4.0.dev0/src/nnsight/tracing/contexts/globals.py +175 -0
- nnsight-0.4.0.dev0/src/nnsight/tracing/contexts/iterator.py +76 -0
- nnsight-0.4.0.dev0/src/nnsight/tracing/contexts/tracer.py +51 -0
- nnsight-0.4.0.dev0/src/nnsight/tracing/graph/__init__.py +4 -0
- nnsight-0.4.0.dev0/src/nnsight/tracing/graph/graph.py +342 -0
- nnsight-0.4.0.dev0/src/nnsight/tracing/graph/node.py +419 -0
- nnsight-0.4.0.dev0/src/nnsight/tracing/graph/proxy.py +305 -0
- nnsight-0.4.0.dev0/src/nnsight/tracing/graph/viz.py +222 -0
- nnsight-0.4.0.dev0/src/nnsight/tracing/hacks/__init__.py +23 -0
- nnsight-0.4.0.dev0/src/nnsight/tracing/hacks/comprehension.py +67 -0
- nnsight-0.4.0.dev0/src/nnsight/tracing/hacks/conditional.py +74 -0
- nnsight-0.4.0.dev0/src/nnsight/tracing/hacks/iterator.py +106 -0
- nnsight-0.4.0.dev0/src/nnsight/tracing/hacks/util.py +95 -0
- nnsight-0.4.0.dev0/src/nnsight/tracing/protocols/__init__.py +4 -0
- nnsight-0.4.0.dev0/src/nnsight/tracing/protocols/base.py +45 -0
- nnsight-0.4.0.dev0/src/nnsight/tracing/protocols/lock.py +31 -0
- nnsight-0.4.0.dev0/src/nnsight/tracing/protocols/stop.py +33 -0
- nnsight-0.4.0.dev0/src/nnsight/tracing/protocols/variable.py +34 -0
- {nnsight-0.3.6 → nnsight-0.4.0.dev0}/src/nnsight/util.py +89 -42
- {nnsight-0.3.6 → nnsight-0.4.0.dev0}/src/nnsight.egg-info/PKG-INFO +12 -2
- {nnsight-0.3.6 → nnsight-0.4.0.dev0}/src/nnsight.egg-info/SOURCES.txt +75 -53
- {nnsight-0.3.6 → nnsight-0.4.0.dev0}/src/nnsight.egg-info/requires.txt +7 -1
- {nnsight-0.3.6 → nnsight-0.4.0.dev0}/tests/test_lm.py +63 -40
- {nnsight-0.3.6 → nnsight-0.4.0.dev0}/tests/test_tiny.py +65 -68
- nnsight-0.4.0.dev0/tests/test_vllm.py +213 -0
- nnsight-0.3.6/src/nnsight/__init__.py +0 -550
- nnsight-0.3.6/src/nnsight/config.yaml +0 -8
- nnsight-0.3.6/src/nnsight/contexts/Conditional.py +0 -111
- nnsight-0.3.6/src/nnsight/contexts/GraphBasedContext.py +0 -464
- nnsight-0.3.6/src/nnsight/contexts/Tracer.py +0 -192
- nnsight-0.3.6/src/nnsight/contexts/__init__.py +0 -91
- nnsight-0.3.6/src/nnsight/contexts/backends/BridgeBackend.py +0 -38
- nnsight-0.3.6/src/nnsight/contexts/backends/EditBackend.py +0 -27
- nnsight-0.3.6/src/nnsight/contexts/backends/LocalBackend.py +0 -27
- nnsight-0.3.6/src/nnsight/contexts/backends/NoopBackend.py +0 -10
- nnsight-0.3.6/src/nnsight/contexts/backends/RemoteBackend.py +0 -318
- nnsight-0.3.6/src/nnsight/contexts/backends/__init__.py +0 -21
- nnsight-0.3.6/src/nnsight/contexts/session/Iterator.py +0 -110
- nnsight-0.3.6/src/nnsight/contexts/session/Session.py +0 -154
- nnsight-0.3.6/src/nnsight/intervention.py +0 -617
- nnsight-0.3.6/src/nnsight/models/LanguageModel.py +0 -362
- nnsight-0.3.6/src/nnsight/models/Mamba.py +0 -344
- nnsight-0.3.6/src/nnsight/models/NNsightModel.py +0 -643
- nnsight-0.3.6/src/nnsight/models/UnifiedTransformer.py +0 -119
- nnsight-0.3.6/src/nnsight/models/__init__.py +0 -70
- nnsight-0.3.6/src/nnsight/models/mixins/Generation.py +0 -46
- nnsight-0.3.6/src/nnsight/models/mixins/Remoteable.py +0 -28
- nnsight-0.3.6/src/nnsight/models/mixins/__init__.py +0 -2
- nnsight-0.3.6/src/nnsight/module.py +0 -24
- nnsight-0.3.6/src/nnsight/patching.py +0 -71
- nnsight-0.3.6/src/nnsight/schema/Request.py +0 -50
- nnsight-0.3.6/src/nnsight/schema/Response.py +0 -56
- nnsight-0.3.6/src/nnsight/schema/format/types.py +0 -458
- nnsight-0.3.6/src/nnsight/toolbox/.ipynb_checkpoints/__init__-checkpoint.py +0 -0
- nnsight-0.3.6/src/nnsight/toolbox/.ipynb_checkpoints/logit_lens-checkpoint.ipynb +0 -1144
- nnsight-0.3.6/src/nnsight/toolbox/das.ipynb +0 -1768
- nnsight-0.3.6/src/nnsight/toolbox/interventions/.ipynb_checkpoints/transformations-checkpoint.py +0 -18
- nnsight-0.3.6/src/nnsight/toolbox/interventions/interventions.py +0 -96
- nnsight-0.3.6/src/nnsight/toolbox/interventions/interventions_utils.py +0 -6
- nnsight-0.3.6/src/nnsight/toolbox/interventions/transformations.py +0 -18
- nnsight-0.3.6/src/nnsight/toolbox/lens/__init__.txt +0 -0
- nnsight-0.3.6/src/nnsight/toolbox/lens/lens.py +0 -63
- nnsight-0.3.6/src/nnsight/toolbox/lens/utils.py +0 -34
- nnsight-0.3.6/src/nnsight/toolbox/logit_lens.ipynb +0 -1144
- nnsight-0.3.6/src/nnsight/toolbox/optim/__init__.py +0 -15
- nnsight-0.3.6/src/nnsight/toolbox/optim/lora.py +0 -23
- nnsight-0.3.6/src/nnsight/toolbox/optim/softprompt.py +0 -21
- nnsight-0.3.6/src/nnsight/tracing/Bridge.py +0 -99
- nnsight-0.3.6/src/nnsight/tracing/Graph.py +0 -278
- nnsight-0.3.6/src/nnsight/tracing/Node.py +0 -570
- nnsight-0.3.6/src/nnsight/tracing/Proxy.py +0 -319
- nnsight-0.3.6/src/nnsight/tracing/__init__.py +0 -8
- nnsight-0.3.6/src/nnsight/tracing/protocols.py +0 -965
- nnsight-0.3.6/src/nnsight/tracing/util.py +0 -27
- {nnsight-0.3.6 → nnsight-0.4.0.dev0}/.github/workflows/publish.yml +0 -0
- {nnsight-0.3.6 → nnsight-0.4.0.dev0}/.github/workflows/python-app.yml +0 -0
- {nnsight-0.3.6 → nnsight-0.4.0.dev0}/CHANGELOG.md +0 -0
- {nnsight-0.3.6 → nnsight-0.4.0.dev0}/CODE_OF_CONDUCT.md +0 -0
- {nnsight-0.3.6 → nnsight-0.4.0.dev0}/LICENSE +0 -0
- {nnsight-0.3.6 → nnsight-0.4.0.dev0}/NNsight_Walkthrough.ipynb +0 -0
- {nnsight-0.3.6 → nnsight-0.4.0.dev0}/NNsight_v0_3_guide.ipynb +0 -0
- {nnsight-0.3.6 → nnsight-0.4.0.dev0}/README.md +0 -0
- {nnsight-0.3.6 → nnsight-0.4.0.dev0}/docs/.DS_Store +0 -0
- {nnsight-0.3.6 → nnsight-0.4.0.dev0}/docs/Makefile +0 -0
- {nnsight-0.3.6 → nnsight-0.4.0.dev0}/docs/contributing.md +0 -0
- {nnsight-0.3.6 → nnsight-0.4.0.dev0}/docs/make.bat +0 -0
- {nnsight-0.3.6 → nnsight-0.4.0.dev0}/docs/requirements.txt +0 -0
- {nnsight-0.3.6 → nnsight-0.4.0.dev0}/docs/source/.DS_Store +0 -0
- {nnsight-0.3.6 → nnsight-0.4.0.dev0}/docs/source/_static/.DS_Store +0 -0
- {nnsight-0.3.6 → nnsight-0.4.0.dev0}/docs/source/_static/css/custom.css +0 -0
- {nnsight-0.3.6 → nnsight-0.4.0.dev0}/docs/source/_static/css/home.css +0 -0
- {nnsight-0.3.6 → nnsight-0.4.0.dev0}/docs/source/_static/css/pygments.css +0 -0
- {nnsight-0.3.6 → nnsight-0.4.0.dev0}/docs/source/_static/css/status.css +0 -0
- {nnsight-0.3.6 → nnsight-0.4.0.dev0}/docs/source/_static/images/.DS_Store +0 -0
- {nnsight-0.3.6 → nnsight-0.4.0.dev0}/docs/source/_static/images/execution.png +0 -0
- {nnsight-0.3.6 → nnsight-0.4.0.dev0}/docs/source/_static/images/icon.ico +0 -0
- {nnsight-0.3.6 → nnsight-0.4.0.dev0}/docs/source/_static/images/interleaved.png +0 -0
- {nnsight-0.3.6 → nnsight-0.4.0.dev0}/docs/source/_static/images/ioi.png +0 -0
- {nnsight-0.3.6 → nnsight-0.4.0.dev0}/docs/source/_static/images/nnsight_logo.svg +0 -0
- {nnsight-0.3.6 → nnsight-0.4.0.dev0}/docs/source/_static/images/tutorials/.DS_Store +0 -0
- {nnsight-0.3.6 → nnsight-0.4.0.dev0}/docs/source/_static/images/tutorials/activation_patching.webp +0 -0
- {nnsight-0.3.6 → nnsight-0.4.0.dev0}/docs/source/_static/images/tutorials/attribution_patching.webp +0 -0
- {nnsight-0.3.6 → nnsight-0.4.0.dev0}/docs/source/_static/images/tutorials/dictionary_learning.webp +0 -0
- {nnsight-0.3.6 → nnsight-0.4.0.dev0}/docs/source/_static/images/tutorials/function_vectors.webp +0 -0
- {nnsight-0.3.6 → nnsight-0.4.0.dev0}/docs/source/_static/images/tutorials/future_lens.webp +0 -0
- {nnsight-0.3.6 → nnsight-0.4.0.dev0}/docs/source/_static/images/tutorials/logit_lens.webp +0 -0
- {nnsight-0.3.6 → nnsight-0.4.0.dev0}/docs/source/_static/images/tutorials/walkthrough.webp +0 -0
- {nnsight-0.3.6 → nnsight-0.4.0.dev0}/docs/source/_static/js/.DS_Store +0 -0
- {nnsight-0.3.6 → nnsight-0.4.0.dev0}/docs/source/_static/js/code.js +0 -0
- {nnsight-0.3.6 → nnsight-0.4.0.dev0}/docs/source/_static/js/custom.js +0 -0
- {nnsight-0.3.6 → nnsight-0.4.0.dev0}/docs/source/_templates/layout.html +0 -0
- {nnsight-0.3.6 → nnsight-0.4.0.dev0}/docs/source/_templates/ndif_status.html +0 -0
- {nnsight-0.3.6 → nnsight-0.4.0.dev0}/docs/source/about.rst +0 -0
- {nnsight-0.3.6 → nnsight-0.4.0.dev0}/docs/source/documentation/contexts.rst +0 -0
- {nnsight-0.3.6 → nnsight-0.4.0.dev0}/docs/source/documentation/envoy.rst +0 -0
- {nnsight-0.3.6 → nnsight-0.4.0.dev0}/docs/source/documentation/intervention.rst +0 -0
- {nnsight-0.3.6 → nnsight-0.4.0.dev0}/docs/source/documentation/models.rst +0 -0
- {nnsight-0.3.6 → nnsight-0.4.0.dev0}/docs/source/documentation/patching.rst +0 -0
- {nnsight-0.3.6 → nnsight-0.4.0.dev0}/docs/source/documentation/schema.rst +0 -0
- {nnsight-0.3.6 → nnsight-0.4.0.dev0}/docs/source/documentation/tracing.rst +0 -0
- {nnsight-0.3.6 → nnsight-0.4.0.dev0}/docs/source/documentation/util.rst +0 -0
- {nnsight-0.3.6 → nnsight-0.4.0.dev0}/docs/source/documentation.rst +0 -0
- {nnsight-0.3.6 → nnsight-0.4.0.dev0}/docs/source/features.rst +0 -0
- {nnsight-0.3.6 → nnsight-0.4.0.dev0}/docs/source/index.rst +0 -0
- {nnsight-0.3.6 → nnsight-0.4.0.dev0}/docs/source/notebooks/features/conditionals.ipynb +0 -0
- {nnsight-0.3.6 → nnsight-0.4.0.dev0}/docs/source/notebooks/features/cross_prompt.ipynb +0 -0
- {nnsight-0.3.6 → nnsight-0.4.0.dev0}/docs/source/notebooks/features/custom_functions.ipynb +0 -0
- {nnsight-0.3.6 → nnsight-0.4.0.dev0}/docs/source/notebooks/features/early_stopping.ipynb +0 -0
- {nnsight-0.3.6 → nnsight-0.4.0.dev0}/docs/source/notebooks/features/getting.ipynb +0 -0
- {nnsight-0.3.6 → nnsight-0.4.0.dev0}/docs/source/notebooks/features/gradients.ipynb +0 -0
- {nnsight-0.3.6 → nnsight-0.4.0.dev0}/docs/source/notebooks/features/iterator.ipynb +0 -0
- {nnsight-0.3.6 → nnsight-0.4.0.dev0}/docs/source/notebooks/features/lora_training.ipynb +0 -0
- {nnsight-0.3.6 → nnsight-0.4.0.dev0}/docs/source/notebooks/features/model_editing.ipynb +0 -0
- {nnsight-0.3.6 → nnsight-0.4.0.dev0}/docs/source/notebooks/features/modules.ipynb +0 -0
- {nnsight-0.3.6 → nnsight-0.4.0.dev0}/docs/source/notebooks/features/multiple_token.ipynb +0 -0
- {nnsight-0.3.6 → nnsight-0.4.0.dev0}/docs/source/notebooks/features/operations.ipynb +0 -0
- {nnsight-0.3.6 → nnsight-0.4.0.dev0}/docs/source/notebooks/features/remote_execution.ipynb +0 -0
- {nnsight-0.3.6 → nnsight-0.4.0.dev0}/docs/source/notebooks/features/scan_validate.ipynb +0 -0
- {nnsight-0.3.6 → nnsight-0.4.0.dev0}/docs/source/notebooks/features/sessions.ipynb +0 -0
- {nnsight-0.3.6 → nnsight-0.4.0.dev0}/docs/source/notebooks/features/setting.ipynb +0 -0
- {nnsight-0.3.6 → nnsight-0.4.0.dev0}/docs/source/notebooks/tutorials/activation_patching.ipynb +0 -0
- {nnsight-0.3.6 → nnsight-0.4.0.dev0}/docs/source/notebooks/tutorials/attribution_patching.ipynb +0 -0
- {nnsight-0.3.6 → nnsight-0.4.0.dev0}/docs/source/notebooks/tutorials/boundless_DAS.ipynb +0 -0
- {nnsight-0.3.6 → nnsight-0.4.0.dev0}/docs/source/notebooks/tutorials/dict_learning.ipynb +0 -0
- {nnsight-0.3.6 → nnsight-0.4.0.dev0}/docs/source/notebooks/tutorials/logit_lens.ipynb +0 -0
- {nnsight-0.3.6 → nnsight-0.4.0.dev0}/docs/source/notebooks/tutorials/tutorial_price_tagging_utils.py +0 -0
- {nnsight-0.3.6 → nnsight-0.4.0.dev0}/docs/source/notebooks/tutorials/walkthrough.ipynb +0 -0
- {nnsight-0.3.6 → nnsight-0.4.0.dev0}/docs/source/pages/home.html +0 -0
- {nnsight-0.3.6 → nnsight-0.4.0.dev0}/docs/source/start.rst +0 -0
- {nnsight-0.3.6 → nnsight-0.4.0.dev0}/docs/source/status.rst +0 -0
- {nnsight-0.3.6 → nnsight-0.4.0.dev0}/docs/source/tutorials.rst +0 -0
- {nnsight-0.3.6 → nnsight-0.4.0.dev0}/docs/sourcelatex/conf.py +0 -0
- {nnsight-0.3.6 → nnsight-0.4.0.dev0}/docs/sourcelatex/documentation/contexts.rst +0 -0
- {nnsight-0.3.6 → nnsight-0.4.0.dev0}/docs/sourcelatex/documentation/intervention.rst +0 -0
- {nnsight-0.3.6 → nnsight-0.4.0.dev0}/docs/sourcelatex/documentation/models.rst +0 -0
- {nnsight-0.3.6 → nnsight-0.4.0.dev0}/docs/sourcelatex/documentation/module.rst +0 -0
- {nnsight-0.3.6 → nnsight-0.4.0.dev0}/docs/sourcelatex/documentation/patching.rst +0 -0
- {nnsight-0.3.6 → nnsight-0.4.0.dev0}/docs/sourcelatex/documentation/tracing.rst +0 -0
- {nnsight-0.3.6 → nnsight-0.4.0.dev0}/docs/sourcelatex/documentation/util.rst +0 -0
- {nnsight-0.3.6 → nnsight-0.4.0.dev0}/docs/sourcelatex/index.rst +0 -0
- {nnsight-0.3.6 → nnsight-0.4.0.dev0}/setup.cfg +0 -0
- {nnsight-0.3.6 → nnsight-0.4.0.dev0}/src/nnsight/logger.py +0 -0
- {nnsight-0.3.6/tests → nnsight-0.4.0.dev0/src/nnsight/schema}/__init__.py +0 -0
- {nnsight-0.3.6 → nnsight-0.4.0.dev0}/src/nnsight/schema/format/__init__.py +0 -0
- {nnsight-0.3.6 → nnsight-0.4.0.dev0}/src/nnsight.egg-info/dependency_links.txt +0 -0
- {nnsight-0.3.6 → nnsight-0.4.0.dev0}/src/nnsight.egg-info/top_level.txt +0 -0
- /nnsight-0.3.6/src/nnsight/nnsight.log → /nnsight-0.4.0.dev0/tests/__init__.py +0 -0
|
@@ -1,9 +1,14 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: nnsight
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.4.0.dev0
|
|
4
4
|
Summary: Package for interpreting and manipulating the internals of deep learning models.
|
|
5
5
|
Author-email: Jaden Fiotto-Kaufman <jadenfk@outlook.com>
|
|
6
|
+
License: MIT License
|
|
6
7
|
Project-URL: Homepage, https://github.com/ndif-team/nnsight
|
|
8
|
+
Project-URL: Website, https://nnsight.net/
|
|
9
|
+
Project-URL: Documentation, https://nnsight.net/documentation/
|
|
10
|
+
Project-URL: Changelog, https://github.com/ndif-team/nnsight/CHANGELOG.md
|
|
11
|
+
Project-URL: Releases, https://github.com/ndif-team/nnsight/releases
|
|
7
12
|
Classifier: Programming Language :: Python :: 3
|
|
8
13
|
Classifier: License :: OSI Approved :: MIT License
|
|
9
14
|
Classifier: Operating System :: OS Independent
|
|
@@ -14,13 +19,18 @@ Requires-Dist: transformers
|
|
|
14
19
|
Requires-Dist: protobuf
|
|
15
20
|
Requires-Dist: python-socketio[client]
|
|
16
21
|
Requires-Dist: tokenizers>=0.13.0
|
|
17
|
-
Requires-Dist: pydantic>=2.
|
|
22
|
+
Requires-Dist: pydantic>=2.9.0
|
|
18
23
|
Requires-Dist: torch>=2.4.0
|
|
19
24
|
Requires-Dist: sentencepiece
|
|
20
25
|
Requires-Dist: torchvision
|
|
21
26
|
Requires-Dist: accelerate
|
|
22
27
|
Requires-Dist: diffusers
|
|
23
28
|
Requires-Dist: einops
|
|
29
|
+
Requires-Dist: msgspec
|
|
30
|
+
Requires-Dist: toml
|
|
31
|
+
Provides-Extra: test
|
|
32
|
+
Requires-Dist: pytest; extra == "test"
|
|
33
|
+
Requires-Dist: toml; extra == "test"
|
|
24
34
|
|
|
25
35
|
<img src="./docs/source/_static/images/nnsight_logo.svg" alt="drawing" style="width:200px;float:left"/>
|
|
26
36
|
|
|
@@ -1,6 +1,15 @@
|
|
|
1
|
+
import pytest
|
|
2
|
+
import toml
|
|
3
|
+
|
|
1
4
|
def pytest_addoption(parser):
|
|
2
5
|
parser.addoption("--device", action="store", default="cuda:0")
|
|
3
|
-
|
|
6
|
+
parser.addoption(
|
|
7
|
+
"--tp",
|
|
8
|
+
action="store",
|
|
9
|
+
type=int,
|
|
10
|
+
default="1",
|
|
11
|
+
help="An argument for specifying the number of gpus to be used by VLLM"
|
|
12
|
+
)
|
|
4
13
|
|
|
5
14
|
def pytest_generate_tests(metafunc):
|
|
6
15
|
# This is called for every test. Only get/set command line arguments
|
|
@@ -9,5 +18,14 @@ def pytest_generate_tests(metafunc):
|
|
|
9
18
|
if "device" in metafunc.fixturenames and option_value is not None:
|
|
10
19
|
metafunc.parametrize("device", [option_value], scope="module")
|
|
11
20
|
|
|
21
|
+
@pytest.fixture(scope="session")
|
|
22
|
+
def load_pyproject_toml():
|
|
23
|
+
"""Fixture to load and parse the pyproject.toml file."""
|
|
24
|
+
try:
|
|
25
|
+
with open("pyproject.toml", "r") as f:
|
|
26
|
+
data = toml.load(f)
|
|
27
|
+
return data
|
|
28
|
+
except toml.TomlDecodeError as e:
|
|
29
|
+
pytest.fail(f"Failed to load pyproject.toml: {e}")
|
|
12
30
|
|
|
13
31
|
collect_ignore = ["examples/test_server.py", "examples/test_server_llama.py"]
|
|
@@ -43,15 +43,9 @@ html_context = {
|
|
|
43
43
|
|
|
44
44
|
html_theme_options = {
|
|
45
45
|
"show_nav_level": 2,
|
|
46
|
-
"navbar_end": ["
|
|
46
|
+
"navbar_end": ["theme-switcher","navbar-icon-links", "ndif_status"],
|
|
47
47
|
"navbar_align": "left",
|
|
48
48
|
"icon_links": [
|
|
49
|
-
{
|
|
50
|
-
"name": "Status: Unknown",
|
|
51
|
-
"url": "/status",
|
|
52
|
-
"icon": "fa-solid fa-circle-check",
|
|
53
|
-
"attributes": {"class": "ndif"},
|
|
54
|
-
},
|
|
55
49
|
{
|
|
56
50
|
"name": "GitHub",
|
|
57
51
|
"url": "https://github.com/ndif-team/nnsight",
|
|
@@ -62,6 +56,12 @@ html_theme_options = {
|
|
|
62
56
|
"url": "https://forms.gle/1Y6myaXYzSh3oHf56",
|
|
63
57
|
"icon": "fa-brands fa-discord",
|
|
64
58
|
},
|
|
59
|
+
{
|
|
60
|
+
"name": "Status: Unknown",
|
|
61
|
+
"url": "/status",
|
|
62
|
+
"icon": "fa-solid fa-circle-check",
|
|
63
|
+
"attributes": {"class": "ndif"},
|
|
64
|
+
},
|
|
65
65
|
],
|
|
66
66
|
"show_prev_next": False,
|
|
67
67
|
"pygment_dark_style": "monokai",
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
[build-system]
|
|
2
2
|
requires = ["setuptools>=45", "setuptools_scm[toml]>=6.2"]
|
|
3
3
|
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
4
5
|
[tool.setuptools_scm]
|
|
5
6
|
|
|
6
7
|
[project]
|
|
@@ -12,30 +13,46 @@ authors = [
|
|
|
12
13
|
description = "Package for interpreting and manipulating the internals of deep learning models."
|
|
13
14
|
readme = "README.md"
|
|
14
15
|
requires-python = ">=3.7"
|
|
16
|
+
license = { text = "MIT License" }
|
|
17
|
+
|
|
15
18
|
classifiers = [
|
|
16
19
|
"Programming Language :: Python :: 3",
|
|
17
20
|
"License :: OSI Approved :: MIT License",
|
|
18
21
|
"Operating System :: OS Independent",
|
|
19
22
|
]
|
|
23
|
+
|
|
20
24
|
dependencies = [
|
|
21
25
|
"transformers",
|
|
22
|
-
"protobuf",
|
|
26
|
+
"protobuf",
|
|
23
27
|
"python-socketio[client]",
|
|
24
28
|
"tokenizers>=0.13.0",
|
|
25
|
-
"pydantic>=2.
|
|
29
|
+
"pydantic>=2.9.0",
|
|
26
30
|
"torch>=2.4.0",
|
|
27
31
|
"sentencepiece",
|
|
28
32
|
"torchvision",
|
|
29
33
|
"accelerate",
|
|
30
34
|
"diffusers",
|
|
31
|
-
"einops"
|
|
35
|
+
"einops",
|
|
36
|
+
"msgspec",
|
|
37
|
+
"toml"
|
|
32
38
|
]
|
|
39
|
+
|
|
40
|
+
[project.optional-dependencies]
|
|
41
|
+
test = [
|
|
42
|
+
"pytest",
|
|
43
|
+
"toml"
|
|
44
|
+
]
|
|
45
|
+
|
|
33
46
|
[project.urls]
|
|
34
47
|
"Homepage" = "https://github.com/ndif-team/nnsight"
|
|
48
|
+
"Website" = "https://nnsight.net/"
|
|
49
|
+
"Documentation" = "https://nnsight.net/documentation/"
|
|
50
|
+
"Changelog" = "https://github.com/ndif-team/nnsight/CHANGELOG.md"
|
|
51
|
+
"Releases" = "https://github.com/ndif-team/nnsight/releases"
|
|
35
52
|
|
|
36
53
|
[tool.setuptools]
|
|
37
54
|
include-package-data = true
|
|
55
|
+
license-files = ["LICENSE"]
|
|
56
|
+
|
|
38
57
|
[tool.setuptools.package-data]
|
|
39
58
|
nnsight = ["config.yaml", "nnsight.log"]
|
|
40
|
-
|
|
41
|
-
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
|
|
2
|
+
# _____ ___ _____ ___ ________ __ _______ __ __ ___________ ______ ___ ___ #
|
|
3
|
+
# (\" \|" \ (\" \|" \ /" )|" \ /" _ "| /" | | "\(" _ ") / " \ (: "||_ | #
|
|
4
|
+
# |.\\ \ ||.\\ \ |(: \___/ || | (: ( \___) (: (__) :))__/ \\__/ // ____ \ | (__) :| #
|
|
5
|
+
# |: \. \\ ||: \. \\ | \___ \ |: | \/ \ \/ \/ \\_ / / / ) :) \____ || #
|
|
6
|
+
# |. \ \. ||. \ \. | __/ \\ |. | // \ ___ // __ \\ |. | (: (____/ //_____ _\ '| #
|
|
7
|
+
# | \ \ || \ \ | /" \ :) /\ |\(: _( _|(: ( ) :) \: | \ /))_ ")/" \_|\ #
|
|
8
|
+
# \___|\____\) \___|\____\)(_______/ (__\_|_)\_______) \__| |__/ \__| \"_____/(_____((_______) #
|
|
9
|
+
# #
|
|
10
|
+
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
|
|
11
|
+
import os
|
|
12
|
+
from functools import wraps
|
|
13
|
+
|
|
14
|
+
from importlib.metadata import PackageNotFoundError, version
|
|
15
|
+
from typing import Any, Callable, Dict, Union
|
|
16
|
+
|
|
17
|
+
try:
|
|
18
|
+
__version__ = version("nnsight")
|
|
19
|
+
except PackageNotFoundError:
|
|
20
|
+
__version__ = "unknown version"
|
|
21
|
+
|
|
22
|
+
import torch
|
|
23
|
+
import yaml
|
|
24
|
+
|
|
25
|
+
from .schema.config import ConfigModel
|
|
26
|
+
from .util import Patch, Patcher
|
|
27
|
+
|
|
28
|
+
PATH = os.path.dirname(os.path.abspath(__file__))
|
|
29
|
+
with open(os.path.join(PATH, "config.yaml"), "r") as file:
|
|
30
|
+
CONFIG = ConfigModel(**yaml.safe_load(file))
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
from .logger import logger, remote_logger
|
|
34
|
+
from .intervention import Envoy, NNsight
|
|
35
|
+
from .modeling.language import LanguageModel
|
|
36
|
+
|
|
37
|
+
logger.disabled = not CONFIG.APP.LOGGING
|
|
38
|
+
remote_logger.disabled = not CONFIG.APP.REMOTE_LOGGING
|
|
39
|
+
|
|
40
|
+
# Below do default patching:
|
|
41
|
+
DEFAULT_PATCHER = Patcher()
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
# Tensor creation operations
|
|
45
|
+
from torch._subclasses.fake_tensor import FakeTensor
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
def fake_bool(self):
|
|
49
|
+
return True
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
DEFAULT_PATCHER.add(Patch(FakeTensor, fake_bool, "__bool__"))
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
def fake_tensor_new_wrapper(fn):
|
|
56
|
+
|
|
57
|
+
@wraps(fn)
|
|
58
|
+
def inner(cls, fake_mode, elem, device, constant=None):
|
|
59
|
+
|
|
60
|
+
if isinstance(elem, FakeTensor):
|
|
61
|
+
|
|
62
|
+
return elem
|
|
63
|
+
|
|
64
|
+
else:
|
|
65
|
+
|
|
66
|
+
return fn(cls, fake_mode, elem, device, constant=constant)
|
|
67
|
+
|
|
68
|
+
return inner
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
DEFAULT_PATCHER.add(
|
|
72
|
+
Patch(FakeTensor, fake_tensor_new_wrapper(FakeTensor.__new__), "__new__")
|
|
73
|
+
)
|
|
74
|
+
|
|
75
|
+
DEFAULT_PATCHER.__enter__()
|
|
76
|
+
|
|
77
|
+
from .intervention.contexts import GlobalInterventionTracingContext
|
|
78
|
+
|
|
79
|
+
apply = GlobalInterventionTracingContext.GLOBAL_TRACING_CONTEXT.apply
|
|
80
|
+
log = GlobalInterventionTracingContext.GLOBAL_TRACING_CONTEXT.log
|
|
81
|
+
local = GlobalInterventionTracingContext.GLOBAL_TRACING_CONTEXT.local
|
|
82
|
+
cond = GlobalInterventionTracingContext.GLOBAL_TRACING_CONTEXT.cond
|
|
83
|
+
iter = GlobalInterventionTracingContext.GLOBAL_TRACING_CONTEXT.iter
|
|
84
|
+
stop = GlobalInterventionTracingContext.GLOBAL_TRACING_CONTEXT.stop
|
|
85
|
+
|
|
86
|
+
def trace(fn):
|
|
87
|
+
"""Helper decorator to add a function to the intervention graph via `.apply(...)`.
|
|
88
|
+
This is opposed to entering the function during tracing and tracing all inner operations.
|
|
89
|
+
|
|
90
|
+
Args:
|
|
91
|
+
fn (Callable): Function to apply.
|
|
92
|
+
|
|
93
|
+
Returns:
|
|
94
|
+
Callable: Traceable function.
|
|
95
|
+
"""
|
|
96
|
+
|
|
97
|
+
@wraps(fn)
|
|
98
|
+
def inner(*args, **kwargs):
|
|
99
|
+
|
|
100
|
+
return apply(fn, *args, **kwargs)
|
|
101
|
+
|
|
102
|
+
return inner
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
bool = trace(bool)
|
|
106
|
+
bytes = trace(bytes)
|
|
107
|
+
int = trace(int)
|
|
108
|
+
float = trace(float)
|
|
109
|
+
str = trace(str)
|
|
110
|
+
complex = trace(complex)
|
|
111
|
+
bytearray = trace(bytearray)
|
|
112
|
+
tuple = trace(tuple)
|
|
113
|
+
list = trace(list)
|
|
114
|
+
set = trace(set)
|
|
115
|
+
dict = trace(dict)
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
|
|
2
|
+
"""
|
|
3
|
+
The `intervention` module extends the `tracing` module to add PyTorch specific interventions to a given computation graph.
|
|
4
|
+
It defines its own: protocols, contexts, backends and graph primitives to achieve this.
|
|
5
|
+
"""
|
|
6
|
+
from .base import NNsight
|
|
7
|
+
from .envoy import Envoy
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
from typing import TYPE_CHECKING
|
|
2
|
+
from ...tracing.backends import Backend
|
|
3
|
+
|
|
4
|
+
from ...tracing.graph import Graph
|
|
5
|
+
if TYPE_CHECKING:
|
|
6
|
+
from .. import NNsight
|
|
7
|
+
|
|
8
|
+
class EditingBackend(Backend):
|
|
9
|
+
"""Backend to set the default graph to the current InterventionGraph. Assumes the final Node is an InterleavingTracer.
|
|
10
|
+
"""
|
|
11
|
+
|
|
12
|
+
def __init__(self, model: "NNsight") -> None:
|
|
13
|
+
|
|
14
|
+
self.model = model
|
|
15
|
+
|
|
16
|
+
def __call__(self, graph: Graph) -> None:
|
|
17
|
+
|
|
18
|
+
self.model._default_graph = graph.nodes[-1].args[0]
|