nnsight icon indicating copy to clipboard operation
nnsight copied to clipboard

Conditional Context has a GraphBasedContext entry point

Open AdamBelfki3 opened this issue 1 year ago • 0 comments

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()

AdamBelfki3 avatar Aug 21 '24 20:08 AdamBelfki3