Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

engram

Personal research utilities for differentiable rendering (Mitsuba 3 / Dr.Jit), NN training and vision science. Engram in this context is more a "memory trace" that I upload here. It will be updated as I go, and may not be fully functional at any given time. The goal however is to provide a stable package at post-alpha time with a clean API making it easier for vision/neuro researchers to use Mitsuba 3 and Dr.Jit in their experiments.

Moves with the experiments I am running. The API is still unstable. Consider this pre-alpha.

uv add engram            # core: numpy, torch, matplotlib, mitsuba, drjit, mitsuba-scene-description
uv add "engram[all]"     # + scipy, wandb/pandas, flip-evaluator, moviepy, gpytoolbox, transformers/accelerate

Python >= 3.12. import engram is side-effect free: no Mitsuba variant is selected, nothing heavy is imported until you touch the module that needs it.

Module tour

Module What's inside
engram.color Correct piecewise sRGB encode/decode (linear_to_srgb, srgb_to_linear), reinhard/hable_filmic tonemaps, linear_to_srgb_ldr display transform. Backend-generic: numpy, torch, and Dr.Jit tensors.
engram.io save_image/load_image (one writer for numpy/torch/Mitsuba images), ensure_dir, renumber_frames + frames_to_video (ffmpeg).
engram.imagenet Offline ImageNet-1k idx2label/label2idx and ImageNet/CLIP normalization constants.
engram.losses smooth_minimum, the controversiality score family (Golan et al. 2020: classification, regression, undirected, confidence-weighted, hard), diagonal-Gaussian W2/symmetric-KL distances. Pure torch.
engram.metrics Torch-native pearsonr/spearmanr (tie-aware)/r2_score/cohens_d, RDM + RSA helpers, FLIP wrapper, colormapped pixel_error_map.
engram.stats JZS Bayes factors (directional + rank-based) and vectorized permutation tests for paired condition scores.
engram.plot Loss curves, image grids, side-by-side comparisons, RDM/RSA figures, sampled and analytic (GGX) polar BSDF-lobe plots.
engram.track StepLogger (per-run CSV + PNG persistence, wandb-free), lazy init_wandb_run, wandb_image_grid, flatten_params/flatten_history for readable log keys.
engram.mi set_variant() (explicit, env-var aware, autodetecting), Variant enum, wrap_torch/wrap_drjit autodiff bridges, Fibonacci-lattice cameras + sensor builders, envmap emitter, pixel/param/dual-buffer losses in correct sRGB, Large Steps registration, SigmoidReparam box constraints, spp-batched gradient accumulation, forward-gradient visualization, SceneDescription.
engram.train seed_everything + deterministic render_seed pairs, EarlyStopping (snapshots torch and Dr.Jit optimizer state) + PixelChangeCriterion, torch helpers (device probe, FSDP-aware checkpointing, DDP mean-reduce), and the training framework below.

Training framework

engram.train ships an HF-Trainer-shaped framework that covers inverse rendering and NN training with one interface: OptimizationConfig mirrors TrainingArguments (output dir, evaluation/save strategies, gradient accumulation, logging frequency), and Optimization subclasses implement the step/loop methods. With use_accelerator=True the run goes through Hugging Face accelerate (device placement, DDP, mixed precision — engram[hf]).

import mitsuba as mi
from engram.mi import set_variant

set_variant()  # cuda_ad_rgb -> llvm_ad_rgb -> scalar_rgb, or $ENGRAM_MI_VARIANT

from engram.mi.scene import SceneDescription
from engram.train import DROptimization, OptimizationConfig
from engram.train.render import RenderPipeline
from engram.train.optimization import GroundTruth

scene = SceneDescription.from_dict(mi.cornell_box())      # dicts or msd.Plugin objects
target_render = scene.render()
scene["red.reflectance.value"] = mi.Color3f(0.5, 0.5, 0.5)

optim = DROptimization(
    config=OptimizationConfig(output_dir="albedo-recovery", epochs=15, learning_rate=0.05),
    pipeline=RenderPipeline(spp=16),
    scene=scene,
)

report = optim.fit(GroundTruth(image=target_render))
report.plot_losses()

Scene dictionaries can be authored with mitsuba-scene-description (typed dataclasses per Mitsuba plugin); SceneDescription.from_dict accepts anything exposing to_dict().

Install groups (just pick what you need)

Extra Enables Pulls in
stats engram.stats, exotic RDM metrics scipy
track StepLogger CSV output, wandb helpers pandas, wandb
flip engram.metrics.flip_error flip-evaluator
video moviepy fallback for video assembly moviepy
geometry remeshing workflows gpytoolbox
hf use_accelerator=True runs transformers, accelerate
all everything above

Development

uv sync --group dev
uv run pytest          # mitsuba tests use llvm_ad_rgb/scalar_rgb and skip when unavailable
uv run ruff check src tests

# package up for PyPI
uv build

Metadata

Release files for engram 0.1.0a1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for engram 0.1.0a1
File Size Uploaded Provenance
engram-0.1.0a1.tar.gz 148.5 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for engram 0.1.0a1
File Interpreter ABI Platform
engram-0.1.0a1-py3-none-any.whl Python 3 none any Details

Total release size: 217.2 kB

Release files / engram-0.1.0a1.tar.gz

Download URL engram-0.1.0a1.tar.gz
Size 148.5 kB
Tags Source
SHA-256 checksum
How to use checksums
fd613a71211e35f3462648125a0dd22f2326342f26b9f87c8ab490390a3ec26a
BLAKE2b-256 checksum
How to use checksums
724c86154f2053385ec5944fd6ba338f76ac9fad139599f1a235d0ff1c3a87e4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.9.9 {"installer":{"name":"uv","version":"0.9.9"},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release files / engram-0.1.0a1-py3-none-any.whl

Download URL engram-0.1.0a1-py3-none-any.whl
Size 68.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
85600b0b78afbe1b2f7aaeae74b1ac053de575bddd5b98f7edaad8660c22993c
BLAKE2b-256 checksum
How to use checksums
6a9b56b02eff4abf2d43c45665b1db65f485e11dc1f9e7c21ec96660258c5cc2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.9.9 {"installer":{"name":"uv","version":"0.9.9"},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Security for engram 0.1.0a1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

Release history Release notifications | RSS feed

This release
Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page