nnsight 0.5.0.dev10__tar.gz → 0.5.0.dev11__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.5.0.dev10 → nnsight-0.5.0.dev11}/PKG-INFO +1 -1
- {nnsight-0.5.0.dev10 → nnsight-0.5.0.dev11}/src/nnsight/intervention/envoy.py +4 -1
- {nnsight-0.5.0.dev10 → nnsight-0.5.0.dev11}/src/nnsight/intervention/interleaver.py +49 -36
- {nnsight-0.5.0.dev10 → nnsight-0.5.0.dev11}/src/nnsight.egg-info/PKG-INFO +1 -1
- {nnsight-0.5.0.dev10 → nnsight-0.5.0.dev11}/tests/test_lm.py +6 -6
- {nnsight-0.5.0.dev10 → nnsight-0.5.0.dev11}/.github/workflows/publish.yml +0 -0
- {nnsight-0.5.0.dev10 → nnsight-0.5.0.dev11}/.github/workflows/python-app.yml +0 -0
- {nnsight-0.5.0.dev10 → nnsight-0.5.0.dev11}/.gitignore +0 -0
- {nnsight-0.5.0.dev10 → nnsight-0.5.0.dev11}/CHANGELOG.md +0 -0
- {nnsight-0.5.0.dev10 → nnsight-0.5.0.dev11}/CODE_OF_CONDUCT.md +0 -0
- {nnsight-0.5.0.dev10 → nnsight-0.5.0.dev11}/LICENSE +0 -0
- {nnsight-0.5.0.dev10 → nnsight-0.5.0.dev11}/NNsight_Walkthrough.ipynb +0 -0
- {nnsight-0.5.0.dev10 → nnsight-0.5.0.dev11}/NNsight_v0_3_guide.ipynb +0 -0
- {nnsight-0.5.0.dev10 → nnsight-0.5.0.dev11}/NNsight_v0_4_guide.ipynb +0 -0
- {nnsight-0.5.0.dev10 → nnsight-0.5.0.dev11}/README.md +0 -0
- {nnsight-0.5.0.dev10 → nnsight-0.5.0.dev11}/conftest.py +0 -0
- {nnsight-0.5.0.dev10 → nnsight-0.5.0.dev11}/pyproject.toml +0 -0
- {nnsight-0.5.0.dev10 → nnsight-0.5.0.dev11}/pytest.ini +0 -0
- {nnsight-0.5.0.dev10 → nnsight-0.5.0.dev11}/setup.cfg +0 -0
- {nnsight-0.5.0.dev10 → nnsight-0.5.0.dev11}/setup.py +0 -0
- {nnsight-0.5.0.dev10 → nnsight-0.5.0.dev11}/src/nnsight/__init__.py +0 -0
- {nnsight-0.5.0.dev10 → nnsight-0.5.0.dev11}/src/nnsight/_c/__init__.py +0 -0
- {nnsight-0.5.0.dev10 → nnsight-0.5.0.dev11}/src/nnsight/_c/py_mount.c +0 -0
- {nnsight-0.5.0.dev10 → nnsight-0.5.0.dev11}/src/nnsight/config.yaml +0 -0
- {nnsight-0.5.0.dev10 → nnsight-0.5.0.dev11}/src/nnsight/intervention/__init__.py +0 -0
- {nnsight-0.5.0.dev10 → nnsight-0.5.0.dev11}/src/nnsight/intervention/backends/__init__.py +0 -0
- {nnsight-0.5.0.dev10 → nnsight-0.5.0.dev11}/src/nnsight/intervention/backends/base.py +0 -0
- {nnsight-0.5.0.dev10 → nnsight-0.5.0.dev11}/src/nnsight/intervention/backends/editing.py +0 -0
- {nnsight-0.5.0.dev10 → nnsight-0.5.0.dev11}/src/nnsight/intervention/backends/execution.py +0 -0
- {nnsight-0.5.0.dev10 → nnsight-0.5.0.dev11}/src/nnsight/intervention/backends/remote.py +0 -0
- {nnsight-0.5.0.dev10 → nnsight-0.5.0.dev11}/src/nnsight/intervention/batching.py +0 -0
- {nnsight-0.5.0.dev10 → nnsight-0.5.0.dev11}/src/nnsight/intervention/inject.py +0 -0
- {nnsight-0.5.0.dev10 → nnsight-0.5.0.dev11}/src/nnsight/intervention/serialization.py +0 -0
- {nnsight-0.5.0.dev10 → nnsight-0.5.0.dev11}/src/nnsight/intervention/tracing/__init__.py +0 -0
- {nnsight-0.5.0.dev10 → nnsight-0.5.0.dev11}/src/nnsight/intervention/tracing/backwards.py +0 -0
- {nnsight-0.5.0.dev10 → nnsight-0.5.0.dev11}/src/nnsight/intervention/tracing/base.py +0 -0
- {nnsight-0.5.0.dev10 → nnsight-0.5.0.dev11}/src/nnsight/intervention/tracing/editing.py +0 -0
- {nnsight-0.5.0.dev10 → nnsight-0.5.0.dev11}/src/nnsight/intervention/tracing/globals.py +0 -0
- {nnsight-0.5.0.dev10 → nnsight-0.5.0.dev11}/src/nnsight/intervention/tracing/invoker.py +0 -0
- {nnsight-0.5.0.dev10 → nnsight-0.5.0.dev11}/src/nnsight/intervention/tracing/iterator.py +0 -0
- {nnsight-0.5.0.dev10 → nnsight-0.5.0.dev11}/src/nnsight/intervention/tracing/tracer.py +0 -0
- {nnsight-0.5.0.dev10 → nnsight-0.5.0.dev11}/src/nnsight/intervention/tracing/util.py +0 -0
- {nnsight-0.5.0.dev10 → nnsight-0.5.0.dev11}/src/nnsight/log.py +0 -0
- {nnsight-0.5.0.dev10 → nnsight-0.5.0.dev11}/src/nnsight/modeling/__init__.py +0 -0
- {nnsight-0.5.0.dev10 → nnsight-0.5.0.dev11}/src/nnsight/modeling/base.py +0 -0
- {nnsight-0.5.0.dev10 → nnsight-0.5.0.dev11}/src/nnsight/modeling/diffusion.py +0 -0
- {nnsight-0.5.0.dev10 → nnsight-0.5.0.dev11}/src/nnsight/modeling/language.py +0 -0
- {nnsight-0.5.0.dev10 → nnsight-0.5.0.dev11}/src/nnsight/modeling/mixins/__init__.py +0 -0
- {nnsight-0.5.0.dev10 → nnsight-0.5.0.dev11}/src/nnsight/modeling/mixins/loadable.py +0 -0
- {nnsight-0.5.0.dev10 → nnsight-0.5.0.dev11}/src/nnsight/modeling/mixins/meta.py +0 -0
- {nnsight-0.5.0.dev10 → nnsight-0.5.0.dev11}/src/nnsight/modeling/mixins/remoteable.py +0 -0
- {nnsight-0.5.0.dev10 → nnsight-0.5.0.dev11}/src/nnsight/modeling/vllm/__init__.py +0 -0
- {nnsight-0.5.0.dev10 → nnsight-0.5.0.dev11}/src/nnsight/modeling/vllm/model_runners/GPUModelRunner copy.py +0 -0
- {nnsight-0.5.0.dev10 → nnsight-0.5.0.dev11}/src/nnsight/modeling/vllm/model_runners/GPUModelRunner.py +0 -0
- {nnsight-0.5.0.dev10 → nnsight-0.5.0.dev11}/src/nnsight/modeling/vllm/model_runners/__init__.py +0 -0
- {nnsight-0.5.0.dev10 → nnsight-0.5.0.dev11}/src/nnsight/modeling/vllm/sampling copy.py +0 -0
- {nnsight-0.5.0.dev10 → nnsight-0.5.0.dev11}/src/nnsight/modeling/vllm/sampling.py +0 -0
- {nnsight-0.5.0.dev10 → nnsight-0.5.0.dev11}/src/nnsight/modeling/vllm/vllm.py +0 -0
- {nnsight-0.5.0.dev10 → nnsight-0.5.0.dev11}/src/nnsight/modeling/vllm/workers/GPUWorker.py +0 -0
- {nnsight-0.5.0.dev10 → nnsight-0.5.0.dev11}/src/nnsight/modeling/vllm/workers/__init__.py +0 -0
- {nnsight-0.5.0.dev10 → nnsight-0.5.0.dev11}/src/nnsight/modeling/vllm/workers/gpu_input_batch.py +0 -0
- {nnsight-0.5.0.dev10 → nnsight-0.5.0.dev11}/src/nnsight/schema/__init__.py +0 -0
- {nnsight-0.5.0.dev10 → nnsight-0.5.0.dev11}/src/nnsight/schema/config.py +0 -0
- {nnsight-0.5.0.dev10 → nnsight-0.5.0.dev11}/src/nnsight/schema/request.py +0 -0
- {nnsight-0.5.0.dev10 → nnsight-0.5.0.dev11}/src/nnsight/schema/response.py +0 -0
- {nnsight-0.5.0.dev10 → nnsight-0.5.0.dev11}/src/nnsight/util.py +0 -0
- {nnsight-0.5.0.dev10 → nnsight-0.5.0.dev11}/src/nnsight.egg-info/SOURCES.txt +0 -0
- {nnsight-0.5.0.dev10 → nnsight-0.5.0.dev11}/src/nnsight.egg-info/dependency_links.txt +0 -0
- {nnsight-0.5.0.dev10 → nnsight-0.5.0.dev11}/src/nnsight.egg-info/requires.txt +0 -0
- {nnsight-0.5.0.dev10 → nnsight-0.5.0.dev11}/src/nnsight.egg-info/top_level.txt +0 -0
- {nnsight-0.5.0.dev10 → nnsight-0.5.0.dev11}/tests/__init__.py +0 -0
- {nnsight-0.5.0.dev10 → nnsight-0.5.0.dev11}/tests/test_diffusion.py +0 -0
- {nnsight-0.5.0.dev10 → nnsight-0.5.0.dev11}/tests/test_tiny.py +0 -0
- {nnsight-0.5.0.dev10 → nnsight-0.5.0.dev11}/tests/test_vllm.py +0 -0
|
@@ -720,8 +720,11 @@ class Envoy(Batchable):
|
|
|
720
720
|
try:
|
|
721
721
|
with self._interleaver:
|
|
722
722
|
fn(*args, **kwargs)
|
|
723
|
-
|
|
723
|
+
|
|
724
724
|
self._interleaver.check_cache_full()
|
|
725
|
+
self._interleaver.check_dangling_mediators()
|
|
726
|
+
|
|
727
|
+
finally:
|
|
725
728
|
self._interleaver.cancel()
|
|
726
729
|
|
|
727
730
|
#### Private methods ####
|
|
@@ -49,6 +49,14 @@ class EarlyStopException(Exception):
|
|
|
49
49
|
pass
|
|
50
50
|
|
|
51
51
|
|
|
52
|
+
class UnboundIteratorException(Exception):
|
|
53
|
+
"""
|
|
54
|
+
An .iterator was used with no ties to any module.
|
|
55
|
+
"""
|
|
56
|
+
|
|
57
|
+
pass
|
|
58
|
+
|
|
59
|
+
|
|
52
60
|
class SkipException(Exception):
|
|
53
61
|
"""
|
|
54
62
|
Exception raised to skip the execution of the model.
|
|
@@ -97,20 +105,15 @@ class Interleaver:
|
|
|
97
105
|
|
|
98
106
|
def cancel(self):
|
|
99
107
|
"""Cancel all intervention threads."""
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
self.check_dangling_mediators()
|
|
104
|
-
finally:
|
|
105
|
-
|
|
106
|
-
for mediator in list(self.mediators.values()):
|
|
107
|
-
mediator.cancel()
|
|
108
|
+
|
|
109
|
+
for mediator in list(self.mediators.values()):
|
|
110
|
+
mediator.cancel()
|
|
108
111
|
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
112
|
+
self.mediators = None
|
|
113
|
+
self.tracer = None
|
|
114
|
+
self.batcher = None
|
|
115
|
+
self.user_cache = None
|
|
116
|
+
self.invokers = None
|
|
114
117
|
|
|
115
118
|
|
|
116
119
|
def iterate(self, provider: str):
|
|
@@ -494,32 +497,12 @@ class Mediator:
|
|
|
494
497
|
The original or modified value
|
|
495
498
|
"""
|
|
496
499
|
|
|
497
|
-
if self.child is not None:
|
|
498
|
-
|
|
499
|
-
self.child.handle(provider)
|
|
500
|
-
|
|
501
|
-
# If the child was canceled
|
|
502
|
-
if self.child.thread is None:
|
|
503
|
-
|
|
504
|
-
# Tell the parent (current mediator) to continue
|
|
505
|
-
self.response_queue.put(None)
|
|
506
|
-
|
|
507
|
-
# Then wipe the child
|
|
508
|
-
self.child = None
|
|
509
|
-
|
|
510
|
-
# Wait until the parent has an event
|
|
511
|
-
self.wait()
|
|
512
|
-
|
|
513
|
-
# Continue to handle parent event
|
|
514
|
-
else:
|
|
515
|
-
return
|
|
516
|
-
|
|
517
500
|
process = not self.event_queue.empty()
|
|
518
501
|
|
|
519
502
|
event = None
|
|
520
|
-
|
|
503
|
+
|
|
521
504
|
while process:
|
|
522
|
-
|
|
505
|
+
|
|
523
506
|
value = self.interleaver.batcher.current_value
|
|
524
507
|
|
|
525
508
|
event, data = self.event_queue.get()
|
|
@@ -542,6 +525,9 @@ class Mediator:
|
|
|
542
525
|
process = False
|
|
543
526
|
elif event == Events.CONTINUE:
|
|
544
527
|
process = False
|
|
528
|
+
# Putting it down here gives the child a chance to handle after the parent has already had one for this provider.
|
|
529
|
+
if self.handle_child(provider):
|
|
530
|
+
return
|
|
545
531
|
|
|
546
532
|
if event == Events.END:
|
|
547
533
|
self.handle_end_event()
|
|
@@ -556,6 +542,30 @@ class Mediator:
|
|
|
556
542
|
self.batch_group, self.interleaver.batcher.current_value
|
|
557
543
|
),
|
|
558
544
|
)
|
|
545
|
+
|
|
546
|
+
def handle_child(self, provider: Any) -> bool:
|
|
547
|
+
|
|
548
|
+
if self.child is not None:
|
|
549
|
+
|
|
550
|
+
self.child.handle(provider)
|
|
551
|
+
|
|
552
|
+
# If the child was canceled
|
|
553
|
+
if self.child.thread is None:
|
|
554
|
+
|
|
555
|
+
# Tell the parent (current mediator) to continue
|
|
556
|
+
self.response_queue.put(None)
|
|
557
|
+
|
|
558
|
+
# Then wipe the child
|
|
559
|
+
self.child = None
|
|
560
|
+
|
|
561
|
+
# Wait until the parent has an event
|
|
562
|
+
self.wait()
|
|
563
|
+
|
|
564
|
+
# Give the parent a chance to handle the provider afer the child is done.
|
|
565
|
+
self.handle(provider)
|
|
566
|
+
|
|
567
|
+
return True
|
|
568
|
+
|
|
559
569
|
|
|
560
570
|
def handle_end_event(self):
|
|
561
571
|
"""
|
|
@@ -795,6 +805,9 @@ class Mediator:
|
|
|
795
805
|
mediator.args = list([mediator.iteration])
|
|
796
806
|
self.child = mediator
|
|
797
807
|
mediator.start(self.interleaver)
|
|
808
|
+
|
|
809
|
+
if not self.child.alive:
|
|
810
|
+
raise UnboundIteratorException("`.iter` encountered with no dependence on any module.\n`.iter` only makes sense in the context of iteration over mu;ltiple module exeecutions." )
|
|
798
811
|
|
|
799
812
|
self.event_queue.put((Events.CONTINUE, None))
|
|
800
813
|
|
|
@@ -809,7 +822,7 @@ class Mediator:
|
|
|
809
822
|
while True:
|
|
810
823
|
|
|
811
824
|
do_iteration(i)
|
|
812
|
-
|
|
825
|
+
|
|
813
826
|
if self.interleaver.default_all is not None and stop is None:
|
|
814
827
|
stop = self.interleaver.default_all
|
|
815
828
|
|
|
@@ -832,17 +832,17 @@ def test_batched_iter(gpt2: nnsight.LanguageModel, MSG_prompt: str):
|
|
|
832
832
|
assert gpt2.tokenizer.batch_decode(logits_1) == [" York", " City"]
|
|
833
833
|
assert gpt2.tokenizer.batch_decode(logits_2) == [" New", " York", " City"]
|
|
834
834
|
|
|
835
|
-
|
|
835
|
+
from nnsight.intervention.interleaver import UnboundIteratorException
|
|
836
836
|
@torch.no_grad()
|
|
837
837
|
@pytest.mark.iter
|
|
838
838
|
def test_one_iter(gpt2: nnsight.LanguageModel):
|
|
839
|
-
with
|
|
840
|
-
|
|
839
|
+
with pytest.raises(UnboundIteratorException):
|
|
840
|
+
with gpt2.generate("_", max_new_tokens=1) as tracer:
|
|
841
|
+
arr_gen = list().save()
|
|
841
842
|
|
|
842
|
-
|
|
843
|
-
|
|
843
|
+
with tracer.all():
|
|
844
|
+
arr_gen.append(1)
|
|
844
845
|
|
|
845
|
-
assert len(arr_gen) == 1
|
|
846
846
|
|
|
847
847
|
|
|
848
848
|
@torch.no_grad()
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{nnsight-0.5.0.dev10 → nnsight-0.5.0.dev11}/src/nnsight/modeling/vllm/model_runners/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{nnsight-0.5.0.dev10 → nnsight-0.5.0.dev11}/src/nnsight/modeling/vllm/workers/gpu_input_batch.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|