Skip to content

_c

_c

Low-level, process-wide helpers nnsight installs at import.

  • py_mount — a small C extension that writes a method into object's type dict (bypassing its read-only mappingproxy), so it appears on all objects. nnsight uses it to add .save() universally. Optional: if it didn't build, mount/unmount are None and callers fall back to nnsight.save(value).
  • backtrace — neutralizes glibc backtrace() so a torch C++ error raised inside an interleaving greenlet surfaces as a normal Python exception instead of segfaulting the process (see backtrace.install).

__all__ module-attribute

__all__ = ['mount', 'unmount', 'install_backtrace_guard']

install_backtrace_guard

install_backtrace_guard() -> bool

Neutralize glibc backtrace() so a c10 error on a greenlet can't crash.

Returns True if the guard is in place (including on a repeat call), and False if it was skipped -- unsupported platform, no glibc backtrace, or a page could not be made writable. Idempotent and never raises.

mount builtin

mount()

Mount a function to all objects

unmount builtin

unmount()

Unmount a function from all objects

Submodules