Portable Colab/Kaggle diffusion lm-eval with SliceGPT and task workers
Browse files- README.md +8 -0
- bundle_manifest.json +1 -1
- portable_eval.zip +2 -2
- portable_lm_eval.ipynb +51 -19
- runner.py +29 -12
README.md
CHANGED
|
@@ -39,3 +39,11 @@ and both families, including Dream's pinned HF generation code. It checks reload
|
|
| 39 |
logits, actual harness likelihood/generation, CPU/disk dispatch, and CUDA FP16
|
| 40 |
with CPU offload when a local GPU is available. These checks do not replace a
|
| 41 |
full 7B/8B benchmark run on the target platform.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 39 |
logits, actual harness likelihood/generation, CPU/disk dispatch, and CUDA FP16
|
| 40 |
with CPU offload when a local GPU is available. These checks do not replace a
|
| 41 |
full 7B/8B benchmark run on the target platform.
|
| 42 |
+
|
| 43 |
+
|
| 44 |
+
The notebook displays its effective config and exact adapter parameters before
|
| 45 |
+
loading weights. To see the same preview from a terminal, add --show-config to
|
| 46 |
+
your evaluation command. Denoising steps come from llada_steps/dream_steps
|
| 47 |
+
(256); llada_generation_* fields are standalone helper defaults. Change
|
| 48 |
+
MC_BATCH_SIZE, DTYPE, or RUN_PPL in the notebook settings cell to control its
|
| 49 |
+
explicit overrides. RUN_PPL=True includes the shared perplexity settings.
|
bundle_manifest.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
| 1 |
{
|
| 2 |
"run_id": "run-9fc515e82f313fab",
|
| 3 |
-
"zip_sha256": "
|
| 4 |
"available_checkpoints": 27,
|
| 5 |
"shared_config": "Pruning-LLMs/diffusion_eval_and_vis/config.py",
|
| 6 |
"smoke_tests": "All three methods on tiny LLaDA/Dream: likelihood, generation, CPU/disk and CUDA fp16 offload, reload agreement; task sharding and merging"
|
|
|
|
| 1 |
{
|
| 2 |
"run_id": "run-9fc515e82f313fab",
|
| 3 |
+
"zip_sha256": "e0860d29f84d16a6f75a934b3ff8e1f1b0185645b3ff677a550907177c3fc5d2",
|
| 4 |
"available_checkpoints": 27,
|
| 5 |
"shared_config": "Pruning-LLMs/diffusion_eval_and_vis/config.py",
|
| 6 |
"smoke_tests": "All three methods on tiny LLaDA/Dream: likelihood, generation, CPU/disk and CUDA fp16 offload, reload agreement; task sharding and merging"
|
portable_eval.zip
CHANGED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
-
size
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:e0860d29f84d16a6f75a934b3ff8e1f1b0185645b3ff677a550907177c3fc5d2
|
| 3 |
+
size 38470
|
portable_lm_eval.ipynb
CHANGED
|
@@ -51,40 +51,65 @@
|
|
| 51 |
},
|
| 52 |
{
|
| 53 |
"cell_type": "code",
|
| 54 |
-
"execution_count": null,
|
| 55 |
"metadata": {},
|
| 56 |
-
"outputs": [],
|
| 57 |
"source": [
|
| 58 |
"REPO = 'vanshnawander/structured-llada-8b-instruct-sparsegpt-20-9fc515e82f313fab'\n",
|
| 59 |
-
"# Choose a different checkpoint in each session, or split tasks with these settings.\n",
|
| 60 |
"WORKER_INDEX = 0\n",
|
| 61 |
"NUM_WORKERS = 1\n",
|
| 62 |
-
"
|
| 63 |
-
"#
|
|
|
|
|
|
|
|
|
|
|
|
|
| 64 |
"COMMON = [sys.executable, str(EVAL_ROOT / 'runner.py'), '--repo', REPO,\n",
|
| 65 |
-
" '--batch-size',
|
| 66 |
" '--gpu-memory-ratio', '0.65', '--output', 'results']\n",
|
| 67 |
-
"
|
|
|
|
|
|
|
|
|
|
|
|
|
| 68 |
],
|
|
|
|
|
|
|
| 69 |
"id": "cell-4"
|
| 70 |
},
|
| 71 |
{
|
| 72 |
"cell_type": "markdown",
|
| 73 |
"metadata": {},
|
| 74 |
"source": [
|
| 75 |
-
"
|
| 76 |
],
|
| 77 |
"id": "cell-5"
|
| 78 |
},
|
| 79 |
{
|
| 80 |
"cell_type": "code",
|
|
|
|
|
|
|
|
|
|
|
|
|
| 81 |
"execution_count": null,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 82 |
"metadata": {},
|
|
|
|
|
|
|
|
|
|
|
|
|
| 83 |
"outputs": [],
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 84 |
"source": [
|
| 85 |
-
"
|
| 86 |
],
|
| 87 |
-
"id": "cell-
|
| 88 |
},
|
| 89 |
{
|
| 90 |
"cell_type": "code",
|
|
@@ -92,20 +117,27 @@
|
|
| 92 |
"metadata": {},
|
| 93 |
"outputs": [],
|
| 94 |
"source": [
|
| 95 |
-
"
|
| 96 |
-
"FULL[FULL.index('--output') + 1] = 'full_results'\n",
|
| 97 |
-
"subprocess.run(FULL + ['--skip-ppl', '--worker-index', str(WORKER_INDEX),\n",
|
| 98 |
-
" '--num-workers', str(NUM_WORKERS)], check=True)\n"
|
| 99 |
],
|
| 100 |
-
"id": "cell-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 101 |
},
|
| 102 |
{
|
| 103 |
"cell_type": "markdown",
|
| 104 |
"metadata": {},
|
| 105 |
"source": [
|
| 106 |
-
"The full run uses all seven configured tasks unless you provide --tasks. GSM8K keeps the harness's built-in five shots; other tasks use zero shots.
|
| 107 |
],
|
| 108 |
-
"id": "cell-
|
| 109 |
},
|
| 110 |
{
|
| 111 |
"cell_type": "code",
|
|
@@ -121,7 +153,7 @@
|
|
| 121 |
"except ImportError:\n",
|
| 122 |
" print('Download evaluation_results.zip from the notebook output/files panel.')\n"
|
| 123 |
],
|
| 124 |
-
"id": "cell-
|
| 125 |
},
|
| 126 |
{
|
| 127 |
"cell_type": "markdown",
|
|
@@ -129,7 +161,7 @@
|
|
| 129 |
"source": [
|
| 130 |
"Keep the result ZIP before the session expires. Extract ZIPs from multiple workers into one results directory, then run runner.py --merge that_directory --output merged_results.json. It groups results by checkpoint revision and evaluation settings and rejects conflicting duplicate task scores."
|
| 131 |
],
|
| 132 |
-
"id": "cell-
|
| 133 |
}
|
| 134 |
],
|
| 135 |
"metadata": {
|
|
|
|
| 51 |
},
|
| 52 |
{
|
| 53 |
"cell_type": "code",
|
|
|
|
| 54 |
"metadata": {},
|
|
|
|
| 55 |
"source": [
|
| 56 |
"REPO = 'vanshnawander/structured-llada-8b-instruct-sparsegpt-20-9fc515e82f313fab'\n",
|
|
|
|
| 57 |
"WORKER_INDEX = 0\n",
|
| 58 |
"NUM_WORKERS = 1\n",
|
| 59 |
+
"\n",
|
| 60 |
+
"# Only these platform choices override the shared evaluation config.\n",
|
| 61 |
+
"MC_BATCH_SIZE = 1 # Shared default is 32; mc_num stays 128.\n",
|
| 62 |
+
"DTYPE = 'auto' # Shared default is bfloat16; auto supports FP16-only GPUs.\n",
|
| 63 |
+
"RUN_PPL = False # Set True to include the configured WikiText-2/C4 perplexities.\n",
|
| 64 |
+
"\n",
|
| 65 |
"COMMON = [sys.executable, str(EVAL_ROOT / 'runner.py'), '--repo', REPO,\n",
|
| 66 |
+
" '--batch-size', str(MC_BATCH_SIZE), '--dtype', DTYPE, '--device-map', 'auto',\n",
|
| 67 |
" '--gpu-memory-ratio', '0.65', '--output', 'results']\n",
|
| 68 |
+
"FULL = COMMON.copy()\n",
|
| 69 |
+
"FULL[FULL.index('--output') + 1] = 'full_results'\n",
|
| 70 |
+
"FULL += ['--worker-index', str(WORKER_INDEX), '--num-workers', str(NUM_WORKERS)]\n",
|
| 71 |
+
"if not RUN_PPL:\n",
|
| 72 |
+
" FULL.append('--skip-ppl')\n"
|
| 73 |
],
|
| 74 |
+
"execution_count": null,
|
| 75 |
+
"outputs": [],
|
| 76 |
"id": "cell-4"
|
| 77 |
},
|
| 78 |
{
|
| 79 |
"cell_type": "markdown",
|
| 80 |
"metadata": {},
|
| 81 |
"source": [
|
| 82 |
+
"Review the full benchmark settings before loading a checkpoint. This prints every effective config value and the exact parameters passed to the chosen adapter. Both families use 256 generation steps by default; LLaDA uses generation/block length 1024 and Dream generation length 256. MC likelihood scoring uses mc_num=128. The separate llada_generation_* helper defaults do not control the benchmark.\n"
|
| 83 |
],
|
| 84 |
"id": "cell-5"
|
| 85 |
},
|
| 86 |
{
|
| 87 |
"cell_type": "code",
|
| 88 |
+
"metadata": {},
|
| 89 |
+
"source": [
|
| 90 |
+
"subprocess.run(FULL + ['--show-config'], check=True)\n"
|
| 91 |
+
],
|
| 92 |
"execution_count": null,
|
| 93 |
+
"outputs": [],
|
| 94 |
+
"id": "cell-6"
|
| 95 |
+
},
|
| 96 |
+
{
|
| 97 |
+
"cell_type": "code",
|
| 98 |
"metadata": {},
|
| 99 |
+
"source": [
|
| 100 |
+
"subprocess.run(COMMON + ['--smoke'], check=True)\n"
|
| 101 |
+
],
|
| 102 |
+
"execution_count": null,
|
| 103 |
"outputs": [],
|
| 104 |
+
"id": "cell-7"
|
| 105 |
+
},
|
| 106 |
+
{
|
| 107 |
+
"cell_type": "markdown",
|
| 108 |
+
"metadata": {},
|
| 109 |
"source": [
|
| 110 |
+
"Run a short harness check first. This result is a smoke test, not the full benchmark. Re-running skips matching completed tasks. Full benchmark output uses a separate directory."
|
| 111 |
],
|
| 112 |
+
"id": "cell-8"
|
| 113 |
},
|
| 114 |
{
|
| 115 |
"cell_type": "code",
|
|
|
|
| 117 |
"metadata": {},
|
| 118 |
"outputs": [],
|
| 119 |
"source": [
|
| 120 |
+
"subprocess.run(COMMON + ['--tasks', 'piqa', '--limit', '2', '--skip-ppl'], check=True)\n"
|
|
|
|
|
|
|
|
|
|
| 121 |
],
|
| 122 |
+
"id": "cell-9"
|
| 123 |
+
},
|
| 124 |
+
{
|
| 125 |
+
"cell_type": "code",
|
| 126 |
+
"metadata": {},
|
| 127 |
+
"source": [
|
| 128 |
+
"subprocess.run(FULL, check=True)\n"
|
| 129 |
+
],
|
| 130 |
+
"execution_count": null,
|
| 131 |
+
"outputs": [],
|
| 132 |
+
"id": "cell-10"
|
| 133 |
},
|
| 134 |
{
|
| 135 |
"cell_type": "markdown",
|
| 136 |
"metadata": {},
|
| 137 |
"source": [
|
| 138 |
+
"The full run uses all seven configured tasks unless you provide --tasks. GSM8K keeps the harness's built-in five shots; other tasks use zero shots. Set RUN_PPL=True in the settings cell to compute configured WikiText-2/C4 perplexities too, then rerun the preview. For parallel task evaluation, use NUM_WORKERS=2 with WORKER_INDEX=0 in one session and 1 in the other, using the same checkpoint and settings.\n"
|
| 139 |
],
|
| 140 |
+
"id": "cell-11"
|
| 141 |
},
|
| 142 |
{
|
| 143 |
"cell_type": "code",
|
|
|
|
| 153 |
"except ImportError:\n",
|
| 154 |
" print('Download evaluation_results.zip from the notebook output/files panel.')\n"
|
| 155 |
],
|
| 156 |
+
"id": "cell-12"
|
| 157 |
},
|
| 158 |
{
|
| 159 |
"cell_type": "markdown",
|
|
|
|
| 161 |
"source": [
|
| 162 |
"Keep the result ZIP before the session expires. Extract ZIPs from multiple workers into one results directory, then run runner.py --merge that_directory --output merged_results.json. It groups results by checkpoint revision and evaluation settings and rejects conflicting duplicate task scores."
|
| 163 |
],
|
| 164 |
+
"id": "cell-13"
|
| 165 |
}
|
| 166 |
],
|
| 167 |
"metadata": {
|
runner.py
CHANGED
|
@@ -196,22 +196,29 @@ def load_checkpoint(path, cfg, device_map="auto", gpu_memory_ratio=0.65, cpu_gib
|
|
| 196 |
return model, tokenizer
|
| 197 |
|
| 198 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 199 |
def make_adapter(model, tokenizer, cfg, family, checkpoint=""):
|
|
|
|
| 200 |
if family == "dream":
|
| 201 |
from diffusion_eval_and_vis.eval_dream import DreamLM
|
| 202 |
-
return DreamLM(model, tokenizer,
|
| 203 |
-
device=cfg.device, add_bos_token=cfg.add_bos_token and not cfg.no_add_bos_token,
|
| 204 |
-
max_length=cfg.max_length, nll_type=cfg.nll_type, log_type=cfg.log_type,
|
| 205 |
-
sampling_eps=cfg.sampling_eps, classifier_free_guidance=cfg.dream_cfg,
|
| 206 |
-
diffusion_steps=cfg.dream_steps, gen_length=cfg.dream_gen_length,
|
| 207 |
-
gen_alg=cfg.dream_gen_alg, gen_temperature=cfg.dream_gen_temperature)
|
| 208 |
from diffusion_eval_and_vis.eval_diffusion import LLaDiffusionLM
|
| 209 |
return LLaDiffusionLM(model_path=checkpoint, model_instance=model, tokenizer_instance=tokenizer,
|
| 210 |
-
|
| 211 |
-
batch_size=cfg.batch_size, mc_num=cfg.mc_num,
|
| 212 |
-
is_check_greedy=cfg.is_check_greedy, cfg=cfg.llada_cfg,
|
| 213 |
-
steps=cfg.llada_steps, gen_length=cfg.llada_gen_length,
|
| 214 |
-
block_length=cfg.llada_block_length, remasking=cfg.llada_remasking)
|
| 215 |
|
| 216 |
|
| 217 |
def merge_results(root, destination):
|
|
@@ -241,6 +248,7 @@ def main():
|
|
| 241 |
parser.add_argument("--checkpoint", help="Already downloaded local checkpoint")
|
| 242 |
parser.add_argument("--family", choices=["llada", "dream"])
|
| 243 |
parser.add_argument("--list", action="store_true")
|
|
|
|
| 244 |
parser.add_argument("--owner", default=DEFAULT_OWNER)
|
| 245 |
parser.add_argument("--run", default=DEFAULT_RUN)
|
| 246 |
parser.add_argument("--tasks", nargs="+")
|
|
@@ -267,7 +275,7 @@ def main():
|
|
| 267 |
if args.merge:
|
| 268 |
print({"merged_evaluations": merge_results(args.merge, args.output)})
|
| 269 |
return
|
| 270 |
-
if not args.repo and not args.checkpoint:
|
| 271 |
parser.error("Supply --repo or --checkpoint")
|
| 272 |
import torch
|
| 273 |
from huggingface_hub import HfApi, snapshot_download
|
|
@@ -286,6 +294,15 @@ def main():
|
|
| 286 |
raise RuntimeError("Enable a GPU runtime or pass --device cpu")
|
| 287 |
if cfg.dtype == "bfloat16" and cfg.device.startswith("cuda") and not torch.cuda.is_bf16_supported():
|
| 288 |
raise RuntimeError("This GPU needs --dtype auto or --dtype float16; the override is recorded in results")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 289 |
token = os.environ.get("HF_TOKEN", False)
|
| 290 |
if args.checkpoint:
|
| 291 |
checkpoint, revision = args.checkpoint, args.revision or "local"
|
|
|
|
| 196 |
return model, tokenizer
|
| 197 |
|
| 198 |
|
| 199 |
+
def adapter_parameters(cfg, family):
|
| 200 |
+
"""The exact config values passed to the benchmark adapter."""
|
| 201 |
+
common = {"batch_size": cfg.batch_size, "mc_num": cfg.mc_num, "device": cfg.device}
|
| 202 |
+
if family == "dream":
|
| 203 |
+
return {**common, "add_bos_token": cfg.add_bos_token and not cfg.no_add_bos_token,
|
| 204 |
+
"max_length": cfg.max_length, "nll_type": cfg.nll_type, "log_type": cfg.log_type,
|
| 205 |
+
"sampling_eps": cfg.sampling_eps, "classifier_free_guidance": cfg.dream_cfg,
|
| 206 |
+
"diffusion_steps": cfg.dream_steps, "gen_length": cfg.dream_gen_length,
|
| 207 |
+
"gen_alg": cfg.dream_gen_alg, "gen_temperature": cfg.dream_gen_temperature}
|
| 208 |
+
return {**common, "mask_id": cfg.llada_mask_id, "dtype": cfg.dtype,
|
| 209 |
+
"is_check_greedy": cfg.is_check_greedy, "cfg": cfg.llada_cfg,
|
| 210 |
+
"steps": cfg.llada_steps, "gen_length": cfg.llada_gen_length,
|
| 211 |
+
"block_length": cfg.llada_block_length, "remasking": cfg.llada_remasking}
|
| 212 |
+
|
| 213 |
+
|
| 214 |
def make_adapter(model, tokenizer, cfg, family, checkpoint=""):
|
| 215 |
+
parameters = adapter_parameters(cfg, family)
|
| 216 |
if family == "dream":
|
| 217 |
from diffusion_eval_and_vis.eval_dream import DreamLM
|
| 218 |
+
return DreamLM(model, tokenizer, **parameters)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 219 |
from diffusion_eval_and_vis.eval_diffusion import LLaDiffusionLM
|
| 220 |
return LLaDiffusionLM(model_path=checkpoint, model_instance=model, tokenizer_instance=tokenizer,
|
| 221 |
+
**parameters)
|
|
|
|
|
|
|
|
|
|
|
|
|
| 222 |
|
| 223 |
|
| 224 |
def merge_results(root, destination):
|
|
|
|
| 248 |
parser.add_argument("--checkpoint", help="Already downloaded local checkpoint")
|
| 249 |
parser.add_argument("--family", choices=["llada", "dream"])
|
| 250 |
parser.add_argument("--list", action="store_true")
|
| 251 |
+
parser.add_argument("--show-config", action="store_true", help="Print effective config and adapter parameters without loading weights")
|
| 252 |
parser.add_argument("--owner", default=DEFAULT_OWNER)
|
| 253 |
parser.add_argument("--run", default=DEFAULT_RUN)
|
| 254 |
parser.add_argument("--tasks", nargs="+")
|
|
|
|
| 275 |
if args.merge:
|
| 276 |
print({"merged_evaluations": merge_results(args.merge, args.output)})
|
| 277 |
return
|
| 278 |
+
if not args.repo and not args.checkpoint and not args.show_config:
|
| 279 |
parser.error("Supply --repo or --checkpoint")
|
| 280 |
import torch
|
| 281 |
from huggingface_hub import HfApi, snapshot_download
|
|
|
|
| 294 |
raise RuntimeError("Enable a GPU runtime or pass --device cpu")
|
| 295 |
if cfg.dtype == "bfloat16" and cfg.device.startswith("cuda") and not torch.cuda.is_bf16_supported():
|
| 296 |
raise RuntimeError("This GPU needs --dtype auto or --dtype float16; the override is recorded in results")
|
| 297 |
+
if args.show_config:
|
| 298 |
+
family = args.family or ("dream" if "structured-dream-" in (args.repo or "") else "llada")
|
| 299 |
+
tasks = args.tasks or (cfg.dream_tasks or cfg.llada_tasks if family == "dream" else cfg.llada_tasks)
|
| 300 |
+
print(json.dumps({"family": family, "eval_config": asdict(cfg),
|
| 301 |
+
"adapter_parameters": adapter_parameters(cfg, family),
|
| 302 |
+
"worker_tasks": split_tasks(tasks, args.worker_index, args.num_workers),
|
| 303 |
+
"perplexity_enabled": not cfg.skip_ppl,
|
| 304 |
+
"note": "llada_generation_* are separate helper defaults; the benchmark uses llada_steps/llada_gen_length/llada_block_length."}, indent=2))
|
| 305 |
+
return
|
| 306 |
token = os.environ.get("HF_TOKEN", False)
|
| 307 |
if args.checkpoint:
|
| 308 |
checkpoint, revision = args.checkpoint, args.revision or "local"
|