nnsight
nnsight copied to clipboard
Conditional Context has a GraphBasedContext entry point
Reverting to the previous API design for creating Conditional contexts, using any graph-based context.
Implementation Changes
ConditionalProtocol nodes don't have to strictly depend on Intervention Proxies anymore, as the condition input can be of any data type and will be evaluated with bool(). This means that you can have ConditionalProtocol nodes directly depend on other ConditionalProtocol nodes.
InterventionProxy is no longer a ContextManager for the moment.
Usage
with tiny_model.trace(tiny_input) as tracer:
num = 5
with tracer.cond(num > 0):
tiny_model.layer1.output[:] = 1
l1_out = tiny_model.layer1.output.save()