globals¶ globals ¶ Object ¶ Bases: Tensor save ¶ save(_=0) Save an object to be accessable after the trace context is exited. Examples: model = LanguageModel("gpt2", device_map='auto', dispatch=True) with model.trace("Hello World"): ... attn_0 = model.transformer.h[0].attn.output.save() print(attn_0) __getattr__ ¶ __getattr__(name: str) -> Self __getitem__ ¶ __getitem__(key: Any) -> Self __call__ ¶ __call__(*args: Any, **kwargs: Any) -> Self TracingCache ¶ TracingCache() cache instance-attribute ¶ cache = {} code_cache instance-attribute ¶ code_cache = {} get ¶ get(cache_key: Tuple) Check if the given filename and lineno is in the cache. add ¶ add(cache_key: Tuple, value: Any) Add the given value to the cache. get_code ¶ get_code(cache_key) Get a cached compiled code object. add_code ¶ add_code(cache_key, code_obj) Cache a compiled code object. clear ¶ clear() Clear all cached source, AST, and code objects. Globals ¶ stack class-attribute instance-attribute ¶ stack = 0 saves class-attribute instance-attribute ¶ saves = set() cache class-attribute instance-attribute ¶ cache = TracingCache() enter staticmethod ¶ enter() exit staticmethod ¶ exit() clear staticmethod ¶ clear() save ¶ save(object: Any)