Skip to content
Other

DiffusionGemma 2: Latent Code Graph Adapters

адаптеры для работы с графами кода

2 min readupdated

Набор обученных LoRA-адаптеров (небольших надстроек над базовой моделью), входных модулей, голов считывания и базовых чекпоинтов от автора bumblebeers для модели google/diffusiongemma-26B-A4B-it. Репозиторий посвящён задаче представления и обработки графов вызовов абстрактных синтаксических деревьев (AST) размером 16x16 и непрерывных векторных представлений символов в латентном пространстве модели. На выходе система позволяет преобразовывать латентные визуальные токены в изображения разрешением 768×768 или работать с пространственными представлениями символов и кода. Материалы пригодятся исследователям архитектур диффузионных мультимодальных моделей и разработчикам, изучающим работу с графовыми структурами кода.

Ключевые особенности

  • Адаптеры для графов AST (Experiment A): веса LoRA на 150M параметров и модуль DualReadoutSoftCanvasHead (7.00M параметров), обученные на матрицах смежности графов вызовов 16x16 при замороженном визуальном энкодере SigLIP.
  • Модуль рефакторинга векторов символов (Experiment B): модификация с входным адаптером SymbolVectorInputAdapter (LayerNorm(384) + Linear(384, 2816) с RMS matching), который проецирует непрерывные векторы символов напрямую в пространство soft-токенов модели.
  • Отдельный декодер изображений: чекпоинт ImageDecoder на 34.15M параметров (архитектура ViT+Conv), восстанавливающий RGB-изображения 768×768 из непрерывных визуальных латентных токенов.
  • Дистиллированные пространственные модели-учителя: чекпоинты ContextualizedSpatialMLP и предвычисленные целевые тензоры вероятностей для оценки распределения словаря по пространственным патчам.

Что можно сделать

  • Запустить и сравнить поведение LoRA-адаптеров (сиды 42 и 1337) против контрольного замороженного чекпоинта cg_frozen_dg_ep3_slim_ckpt.pt.gz при обработке графов вызовов AST.
  • Использовать SymbolVectorInputAdapter вместе с LoRA-проекциями внимания и MLP для подачи непрерывных векторных представлений символов в google/diffusiongemma-26B-A4B-it.
  • Восстанавливать RGB-изображения разрешением 768×768 из латентных представлений с помощью автономного декодера parent_frozen/decoder.pt.
  • Проводить сравнительные эксперименты между диффузионными адаптерами и недиффузионными пространственными трансформерами (expA_nondg/ и expB_nondg/ на 26.8M параметров).

Пример

В карточке не приведён готовый сниппет инференса, но перечислены конкретные файлы чекпоинтов для загрузки в код проекта (исходники доступны в связанном GitHub-репозитории автора): например, expA_dg/cg_lora_dg_seed42_ep3_slim_ckpt.pt.gz (LoRA-адаптер на 150M параметров для графов AST 16x16), expB_dg/cg_expB_lora_dg_seed42_ep3_slim_ckpt.pt.gz (адаптер для непрерывных векторов символов) и parent_frozen/decoder.pt (декодер 768×768).

ПодробнееБазовая модель: google/diffusiongemma-26B-A4B-it (26B параметров) с замороженной башней SigLIP.
Обучение адаптеров в Experiment A и B: 3 эпохи, 4 824 шага, размерность проекций 2816 → 1152 (в Exp A) и 2816 → 384 (в Exp B).
Контрольные недиффузионные бейзлайны: 26.8M параметров с модуляцией инструкций AdaLN.
Лицензия: Apache 2.0.
Discuss Telegram 1

Will it run?

Runs in 4-bit

Full precision does not fit, a quantised version does: quality barely changes down to 8 bits, more noticeably at 4 bits.

  • BF16weights 48 GB · ready files54 GB
  • FP8 / INT8recommendedweights 24 GB27 GB
  • 4-bitweights 14 GB16 GB

Tip: go 8-bit.FP8 / INT8 is within about a percent of full precision in quality, takes half the memory and runs faster on RTX 40/50 and H100. Full precision only pays off for fine-tuning.

This is a LoRA: counted together with its base model diffusiongemma-26B-A4B-it.

Estimate: weights plus working memory. Long videos, high resolutions and long contexts need more.

Run it on Massed Compute

The script downloads the model to the rented machine. How to run it is in the model card.

  1. 1. Rent a machine with a fitting GPU

    Open Massed Compute
  2. 2. Paste the script into the machine's terminal

    Connect over SSH (the Massed Compute panel shows the command) or open a terminal on the machine's desktop.

    HF_TOKEN / CIVITAI_TOKENThe script starts with token lines: paste yours between the quotes. The Hugging Face token is for gated models, the Civitai one for Civitai models.

    # bumblebeer/dgg2-latent-code-graphs-adapters
    # ===== Tokens: paste yours between the quotes =====
    export HF_TOKEN=""        # huggingface.co/settings/tokens, for gated models
    # ==========================================
    mkdir -p ~/models
    curl -LsSf https://astral.sh/uv/install.sh | sh
    source "$HOME/.local/bin/env"
    uv tool install "huggingface_hub[cli]"
    hf download google/diffusiongemma-26B-A4B-it --local-dir ~/models/diffusiongemma-26B-A4B-it
    hf download bumblebeer/dgg2-latent-code-graphs-adapters --local-dir ~/models/dgg2-latent-code-graphs-adapters
    # The model is in ~/models. How to run it is in the model card (link above).
  3. 3. Use it

    The model is in ~/models. How to run it is in the model card (link above).

Stop the machine in the panel when you are done: it bills by the minute while it runs.

How to speed it up

Picked for this model type. Choose your hardware above to see what fits you exactly.

  • FlashAttention 44.0.0b40from November 18, 2026new release

    fastest exact attention on B200

    Kernels for Blackwell (beta). Exact attention without quantisation — fine for everything, LLMs included.

    How to enable: pip install flash-attn-4; vLLM and SGLang pick it up themselves.

    Earlier generations (2)
    • FlashAttention 3 — The Hopper (H100/H200) version with FP8.
    • FlashAttention 2 — The standard for RTX 30/40/50 and A100: exact attention without the memory cost of long contexts.
  • torch.compile2.15.0from October 28, 2026new release

    10–30% for free

    Compiles the model for your GPU. Slower first run, faster afterwards.

    How to enable: model = torch.compile(model); in ComfyUI the TorchCompileModel node.

Model family

Requires the base model

google/diffusiongemma-26B-A4B-it

This model is a LoRA / adapter. Download the base model first, then load this one on top.

New posts about versions of diffusiongemma-26B-A4B-it (quants, finetunes, LoRAs) will show up under the bell.

Quantised versions 12All on Hugging Face
Fine-tunes 12All on Hugging Face
LoRAs and adapters 8All on Hugging Face
Merges 1All on Hugging Face

About the model

bumblebeer/dgg2-latent-code-graphs-adapters
Author
bumblebeer
Category
Other
Released
Posted

On NeyroLearn

Hugging Face

01

Ask AI about this model

Answered by Gemini 4 · the chat is kept only in this tab

Comments