YouZum

Uncategorized

AI, Committee, Nachrichten, Uncategorized

Meet ‘AutoAgent’: The Open-Source Library That Lets an AI Engineer and Optimize Its Own Agent Harness Overnight

There’s a particular kind of tedium that every AI engineer knows intimately: the prompt-tuning loop. You write a system prompt, run your agent against a benchmark, read the failure traces, tweak the prompt, add a tool, rerun. Repeat this a few dozen times and you might move the needle. It’s grunt work dressed up in Python files. Now, a new open-source library called AutoAgent, built by Kevin Gu at thirdlayer.inc, proposes an unsettling alternative — don’t do that work yourself. Let an AI do it. AutoAgent is an open source library for autonomously improving an agent on any domain. In a 24-hour run, it hit #1 on SpreadsheetBench with a score of 96.5%, and achieved the #1 GPT-5 score on TerminalBench with 55.1%. https://x.com/kevingu/status/2039843234760073341 What Is AutoAgent, Really? AutoAgent is described as being ‘like autoresearch but for agent engineering.’ The idea: give an AI agent a task, let it build and iterate on an agent harness autonomously overnight. It modifies the system prompt, tools, agent configuration, and orchestration, runs the benchmark, checks the score, keeps or discards the change, and repeats. To understand the analogy: Andrej Karpathy’s autoresearch does the same thing for ML training — it loops through propose-train-evaluate cycles, keeping only changes that improve validation loss. AutoAgent ports that same ratchet loop from ML training into agent engineering. Instead of optimizing a model’s weights or training hyperparameters, it optimizes the harness — the system prompt, tool definitions, routing logic, and orchestration strategy that determine how an agent behaves on a task. A harness, in this context, is the scaffolding around an LLM: what system prompt it receives, what tools it can call, how it routes between sub-agents, and how tasks are formatted as inputs. Most agent engineers hand-craft this scaffolding. AutoAgent automates the iteration on that scaffolding itself. The Architecture: Two Agents, One File, One Directive The GitHub repo has a deliberately simple structure. agent.py is the entire harness under test in a single file — it contains config, tool definitions, agent registry, routing/orchestration, and the Harbor adapter boundary. The adapter section is explicitly marked as fixed; the rest is the primary edit surface for the meta-agent. program.md contains instructions for the meta-agent plus the directive (what kind of agent to build), and this is the only file the human edits. Think of it as a separation of concerns between human and machine. The human sets the direction inside program.md. The meta-agent (a separate, higher-level AI) then reads that directive, inspects agent.py, runs the benchmark, diagnoses what failed, rewrites the relevant parts of agent.py, and repeats. The human never touches agent.py directly. A critical piece of infrastructure that keeps the loop coherent across iterations is results.tsv — an experiment log automatically created and maintained by the meta-agent. It tracks every experiment run, giving the meta-agent a history to learn from and calibrate what to try next. The full project structure also includes Dockerfile.base, an optional .agent/ directory for reusable agent workspace artifacts like prompts and skills, a tasks/ folder for benchmark payloads (added per benchmark branch), and a jobs/ directory for Harbor job outputs. The metric is total score produced by the benchmark’s task test suites. The meta-agent hill-climbs on this score. Every experiment produces a numeric score: keep if better, discard if not — the same loop as autoresearch. The Task Format and Harbor Integration Benchmarks are expressed as tasks in Harbor format. Each task lives under tasks/my-task/ and includes a task.toml for config like timeouts and metadata, an instruction.md which is the prompt sent to the agent, a tests/ directory with a test.sh entry point that writes a score to /logs/reward.txt, and a test.py for verification using either deterministic checks or LLM-as-judge. An environment/Dockerfile defines the task container, and a files/ directory holds reference files mounted into the container. Tests write a score between 0.0 and 1.0 to the verifier logs. The meta-agent hill-climbs on this. The LLM-as-judge pattern here is worth flagging: instead of only checking answers deterministically (like unit tests), the test suite can use another LLM to evaluate whether the agent’s output is ‘correct enough.’ This is common in agentic benchmarks where correct answers aren’t reducible to string matching. Key Takeaways Autonomous harness engineering works — AutoAgent proves that a meta-agent can replace the human prompt-tuning loop entirely, iterating on agent.py overnight without any human touching the harness files directly. Benchmark results validate the approach — In a 24-hour run, AutoAgent hit #1 on SpreadsheetBench (96.5%) and the top GPT-5 score on TerminalBench (55.1%), beating every other entry that was hand-engineered by humans. ‘Model empathy’ may be a real phenomenon — A Claude meta-agent optimizing a Claude task agent appeared to diagnose failures more accurately than when optimizing a GPT-based agent, suggesting same-family model pairing could matter when designing your AutoAgent loop. The human’s job shifts from engineer to director — You don’t write or edit agent.py. You write program.md — a plain Markdown directive that steers the meta-agent. The distinction mirrors the broader shift in agentic engineering from writing code to setting goals. It’s plug-and-play with any benchmark — Because tasks follow Harbor’s open format and agents run in Docker containers, AutoAgent is domain-agnostic. Any scorable task — spreadsheets, terminal commands, or your own custom domain — can become a target for autonomous self-optimization. Check out the Repo and Tweet.  Also, feel free to follow us on Twitter and don’t forget to join our 120k+ ML SubReddit and Subscribe to our Newsletter. Wait! are you on telegram? now you can join us on telegram as well. Need to partner with us for promoting your GitHub Repo OR Hugging Face Page OR Product Release OR Webinar etc.? Connect with us The post Meet ‘AutoAgent’: The Open-Source Library That Lets an AI Engineer and Optimize Its Own Agent Harness Overnight appeared first on MarkTechPost.

Meet ‘AutoAgent’: The Open-Source Library That Lets an AI Engineer and Optimize Its Own Agent Harness Overnight Beitrag lesen »

AI, Committee, Nachrichten, Uncategorized

ORBIT: Scalable and Verifiable Data Generation for Search Agents on a Tight Budget

arXiv:2604.01195v2 Announce Type: replace Abstract: Search agents, which integrate language models (LMs) with web search, are becoming crucial for answering complex user queries. Constructing training datasets for deep research tasks, involving multi-step retrieval and reasoning, remains challenging due to expensive human annotation, or cumbersome prerequisites. In this work, we introduce ORBIT, a training dataset with 20K reasoning-intensive queries with short verifiable answers, generated using a frugal framework without relying on paid API services. The modular framework relies on four stages: seed creation, question-answer pair generation, and two stages of verification: self and external. ORBIT spans 15 domains and each training pair requires 4-5 reasoning steps, with external search verification required from the complete web. We train Qwen3-4B as the base model on ORBIT using GRPO and evaluate it on Wikipedia question answering tasks. Extensive experiment results demonstrate that ORBIT-4B achieves strong performance among sub-4B LLMs as search agents, proving the utility of synthetic datasets. Our framework, code and datasets are open-sourced and available publicly.

ORBIT: Scalable and Verifiable Data Generation for Search Agents on a Tight Budget Beitrag lesen »

AI, Committee, Nachrichten, Uncategorized

Fragile Reasoning: A Mechanistic Analysis of LLM Sensitivity to Meaning-Preserving Perturbations

arXiv:2604.01639v1 Announce Type: new Abstract: Large language models demonstrate strong performance on mathematical reasoning benchmarks, yet remain surprisingly fragile to meaning-preserving surface perturbations. We systematically evaluate three open-weight LLMs, Mistral-7B, Llama-3-8B, and Qwen2.5-7B, on 677 GSM8K problems paired with semantically equivalent variants generated through name substitution and number format paraphrasing. All three models exhibit substantial answer-flip rates (28.8%-45.1%), with number paraphrasing consistently more disruptive than name swaps. To trace the mechanistic basis of these failures, we introduce the Mechanistic Perturbation Diagnostics (MPD) framework, combining logit lens analysis, activation patching, component ablation, and the Cascading Amplification Index (CAI) into a unified diagnostic pipeline. CAI, a novel metric quantifying layer-wise divergence amplification, outperforms first divergence layer as a failure predictor for two of three architectures (AUC up to 0.679). Logit lens reveals that flipped samples diverge from correct predictions at significantly earlier layers than stable samples. Activation patching reveals a stark architectural divide in failure localizability: Llama-3 failures are recoverable by patching at specific layers (43/60 samples), while Mistral and Qwen failures are broadly distributed (3/60 and 0/60). Based on these diagnostic signals, we propose a mechanistic failure taxonomy (localized, distributed, and entangled) and validate it through targeted repair experiments: steering vectors and layer fine-tuning recover 12.2% of localized failures (Llama-3) but only 7.2% of entangled (Qwen) and 5.2% of distributed (Mistral) failures.

Fragile Reasoning: A Mechanistic Analysis of LLM Sensitivity to Meaning-Preserving Perturbations Beitrag lesen »

AI, Committee, Nachrichten, Uncategorized

FourierMoE: Fourier Mixture-of-Experts Adaptation of Large Language Models

arXiv:2604.01762v1 Announce Type: cross Abstract: Parameter-efficient fine-tuning (PEFT) has emerged as a crucial paradigm for adapting large language models (LLMs) under constrained computational budgets. However, standard PEFT methods often struggle in multi-task fine-tuning settings, where diverse optimization objectives induce task interference and limited parameter budgets lead to representational deficiency. While recent approaches incorporate mixture-of-experts (MoE) to alleviate these issues, they predominantly operate in the spatial domain, which may introduce structural redundancy and parameter overhead. To overcome these limitations, we reformulate adaptation in the spectral domain. Our spectral analysis reveals that different tasks exhibit distinct frequency energy distributions, and that LLM layers display heterogeneous frequency sensitivities. Motivated by these insights, we propose FourierMoE, which integrates the MoE architecture with the inverse discrete Fourier transform (IDFT) for frequency-aware adaptation. Specifically, FourierMoE employs a frequency-adaptive router to dispatch tokens to experts specialized in distinct frequency bands. Each expert learns a set of conjugate-symmetric complex coefficients, preserving complete phase and amplitude information while theoretically guaranteeing lossless IDFT reconstruction into real-valued spatial weights. Extensive evaluations across 28 benchmarks, multiple model architectures, and scales demonstrate that FourierMoE consistently outperforms competitive baselines in both single-task and multi-task settings while using significantly fewer trainable parameters. These results highlight the promise of spectral-domain expert adaptation as an effective and parameter-efficient paradigm for LLM fine-tuning.

FourierMoE: Fourier Mixture-of-Experts Adaptation of Large Language Models Beitrag lesen »

AI, Committee, Nachrichten, Uncategorized

Grounding AI-in-Education Development in Teachers’ Voices: Findings from a National Survey in Indonesia

arXiv:2604.01630v1 Announce Type: new Abstract: Despite emerging use in Indonesian classrooms, there is limited large-scale, teacher-centred evidence on how AI is used in practice and what support teachers need, hindering the development of context-appropriate AI systems and policies. To address this gap, we conduct a nationwide survey of 349 K-12 teachers across elementary, junior high, and senior high schools. We find increasing use of AI for pedagogy, content development, and teaching media, although adoption remains uneven. Elementary teachers report more consistent use, while senior high teachers engage less; mid-career teachers assign higher importance to AI, and teachers in Eastern Indonesia perceive greater value. Across levels, teachers primarily use AI to reduce instructional preparation workload (e.g., assessment, lesson planning, and material development). However, generic outputs, infrastructure constraints, and limited contextual alignment continue to hinder effective classroom integration.

Grounding AI-in-Education Development in Teachers’ Voices: Findings from a National Survey in Indonesia Beitrag lesen »

AI, Committee, Nachrichten, Uncategorized

Netflix AI Team Just Open-Sourced VOID: an AI Model That Erases Objects From Videos — Physics and All

Video editing has always had a dirty secret: removing an object from footage is easy; making the scene look like it was never there is brutally hard. Take out a person holding a guitar, and you’re left with a floating instrument that defies gravity. Hollywood VFX teams spend weeks fixing exactly this kind of problem. A team of researchers from Netflix and INSAIT, Sofia University ‘St. Kliment Ohridski,’ released VOID (Video Object and Interaction Deletion) model that can do it automatically. VOID removes objects from videos along with all interactions they induce on the scene — not just secondary effects like shadows and reflections, but physical interactions like objects falling when a person is removed. What Problem Is VOID Actually Solving? Standard video inpainting models — the kind used in most editing workflows today — are trained to fill in the pixel region where an object was. They’re essentially very sophisticated background painters. What they don’t do is reason about causality: if I remove an actor who is holding a prop, what should happen to that prop? Existing video object removal methods excel at inpainting content ‘behind’ the object and correcting appearance-level artifacts such as shadows and reflections. However, when the removed object has more significant interactions, such as collisions with other objects, current models fail to correct them and produce implausible results. VOID is built on top of CogVideoX and fine-tuned for video inpainting with interaction-aware mask conditioning. The key innovation is in how the model understands the scene — not just ‘what pixels should I fill?’ but ‘what is physically plausible after this object disappears?’ The canonical example from the research paper: if a person holding a guitar is removed, VOID also removes the person’s effect on the guitar — causing it to fall naturally. That’s not trivial. The model has to understand that the guitar was being supported by the person, and that removing the person means gravity takes over. And unlike prior work, VOID was evaluated head-to-head against real competitors. Experiments on both synthetic and real data show that the approach better preserves consistent scene dynamics after object removal compared to prior video object removal methods including ProPainter, DiffuEraser, Runway, MiniMax-Remover, ROSE, and Gen-Omnimatte. https://arxiv.org/pdf/2604.02296 The Architecture: CogVideoX Under the Hood VOID is built on CogVideoX-Fun-V1.5-5b-InP — a model from Alibaba PAI — and fine-tuned for video inpainting with interaction-aware quadmask conditioning. CogVideoX is a 3D Transformer-based video generation model. Think of it like a video version of Stable Diffusion — a diffusion model that operates over temporal sequences of frames rather than single images. The specific base model (CogVideoX-Fun-V1.5-5b-InP) is released by Alibaba PAI on Hugging Face, which is the checkpoint engineers will need to download separately before running VOID. The fine-tuned architecture specs: a CogVideoX 3D Transformer with 5B parameters, taking video, quadmask, and a text prompt describing the scene after removal as input, operating at a default resolution of 384×672, processing a maximum of 197 frames, using the DDIM scheduler, and running in BF16 with FP8 quantization for memory efficiency. The quadmask is arguably the most interesting technical contribution here. Rather than a binary mask (remove this pixel / keep this pixel), the quadmask is a 4-value mask that encodes the primary object to remove, overlap regions, affected regions (falling objects, displaced items), and background to keep. In practice, each pixel in the mask gets one of four values: 0 (primary object being removed), 63 (overlap between primary and affected regions), 127 (interaction-affected region — things that will move or change as a result of the removal), and 255 (background, keep as-is). This gives the model a structured semantic map of what’s happening in the scene, not just where the object is. Two-Pass Inference Pipeline VOID uses two transformer checkpoints, trained sequentially. You can run inference with Pass 1 alone or chain both passes for higher temporal consistency. Pass 1 (void_pass1.safetensors) is the base inpainting model and is sufficient for most videos. Pass 2 serves a specific purpose: correcting a known failure mode. If the model detects object morphing — a known failure mode of smaller video diffusion models — an optional second pass re-runs inference using flow-warped noise derived from the first pass, stabilizing object shape along the newly synthesized trajectories. It’s worth understanding the distinction: Pass 2 isn’t just for longer clips — it’s specifically a shape-stability fix. When the diffusion model produces objects that gradually warp or deform across frames (a well-documented artifact in video diffusion), Pass 2 uses optical flow to warp the latents from Pass 1 and feeds them as initialization into a second diffusion run, anchoring the shape of synthesized objects frame-to-frame. How the Training Data Was Generated This is where things get genuinely interesting. Training a model to understand physical interactions requires paired videos — the same scene, with and without the object, where the physics plays out correctly in both. Real-world paired data at this scale doesn’t exist. So the team built it synthetically. Training used paired counterfactual videos generated from two sources: HUMOTO — human-object interactions rendered in Blender with physics simulation — and Kubric — object-only interactions using Google Scanned Objects. HUMOTO uses motion-capture data of human-object interactions. The key mechanic is a Blender re-simulation: the scene is set up with a human and objects, rendered once with the human present, then the human is removed from the simulation and physics is re-run forward from that point. The result is a physically correct counterfactual — objects that were being held or supported now fall, exactly as they should. Kubric, developed by Google Research, applies the same idea to object-object collisions. Together, they produce a dataset of paired videos where the physics is provably correct, not approximated by a human annotator. Key Takeaways VOID goes beyond pixel-filling. Unlike existing video inpainting tools that only correct visual artifacts like shadows and reflections, VOID understands physical causality — if you remove a person holding an object, the object falls naturally in the output video. The

Netflix AI Team Just Open-Sourced VOID: an AI Model That Erases Objects From Videos — Physics and All Beitrag lesen »

AI, Committee, Nachrichten, Uncategorized

Multi-lingual Multi-institutional Electronic Health Record based Predictive Model

arXiv:2604.00027v1 Announce Type: new Abstract: Large-scale EHR prediction across institutions is hindered by substantial heterogeneity in schemas and code systems. Although Common Data Models (CDMs) can standardize records for multi-institutional learning, the manual harmonization and vocabulary mapping are costly and difficult to scale. Text-based harmonization provides an alternative by converting raw EHR into a unified textual form, enabling pooled learning without explicit standardization. However, applying this paradigm to multi-national datasets introduces an additional layer of heterogeneity, which is “language” that must be addressed for truly scalable EHRs learning. In this work, we investigate multilingual multi-institutional learning for EHR prediction, aiming to enable pooled training across multinational ICU datasets without manual standardization. We compare two practical strategies for handling language barriers: (i) directly modeling multilingual records with multilingual encoders, and (ii) translating non-English records into English via LLM-based word-level translation. Across seven public ICU datasets, ten clinical tasks with multiple prediction windows, translation-based lingual alignment yields more reliable cross-dataset performance than multilingual encoders. The multi-institutional learning model consistently outperforms strong baselines that require manual feature selection and harmonization, and also surpasses single-dataset training. We further demonstrate that text-based framework with lingual alignment effectively performs transfer learning via few-shot fine-tuning, with additional gains. To our knowledge, this is the first study to aggregate multilingual multinational ICU EHR datasets into one predictive model, providing a scalable path toward language-agnostic clinical prediction and future global multi-institutional EHR research.

Multi-lingual Multi-institutional Electronic Health Record based Predictive Model Beitrag lesen »

AI, Committee, Nachrichten, Uncategorized

Truncated Step-Level Sampling with Process Rewards for Retrieval-Augmented Reasoning

arXiv:2602.23440v3 Announce Type: replace Abstract: Reinforcement learning has emerged as an effective paradigm for training large language models to interleave reasoning with search engine calls. However, existing approaches face a fundamental credit assignment problem: methods like Search-R1 assign a single outcome reward to the entire multi-step trajectory, providing no signal about which reasoning or retrieval decisions were responsible for success or failure. Process-reward methods such as StepSearch introduce step-level supervision but still sample complete trajectories independently, so advantage estimates at any given step are contaminated by the randomness of all other steps. We propose SLATE (Step-Level Advantage estimation for Truncated Exploration), which addresses both problems through two complementary ideas. First, truncated step-level sampling generates k continuations from a shared prefix, isolating all variation to a single decision point. We prove this reduces the variance of advantage estimates by up to a factor of T compared to full-trajectory sampling for T-step trajectories, the first formal variance guarantee for step-level RL in retrieval-augmented reasoning. Second, dense, decomposed process rewards separately evaluate reasoning quality, query quality, and answer correctness on a ternary scale via an LLM judge, providing richer supervision than binary outcome signals or heuristic step-level scores. Experiments on seven QA benchmarks show that SLATE consistently outperforms both sparse-reward and process-reward baselines, achieving a 7.0% relative improvement over Search-R1 on the 7B model and 30.7% on the 3B model. Gains are largest on challenging multi-hop tasks, and ablations confirm that truncated sampling and dense rewards provide complementary benefits.

Truncated Step-Level Sampling with Process Rewards for Retrieval-Augmented Reasoning Beitrag lesen »

AI, Committee, Nachrichten, Uncategorized

Hierarchical Chain-of-Thought Prompting: Enhancing LLM Reasoning Performance and Efficiency

arXiv:2604.00130v1 Announce Type: new Abstract: Chain-of-Thought (CoT) prompting has significantly improved the reasoning capabilities of large language models (LLMs). However, conventional CoT often relies on unstructured, flat reasoning chains that suffer from redundancy and suboptimal performance. In this work, we introduce Hierarchical Chain-of-Thought (Hi-CoT) prompting, a structured reasoning paradigm specifically designed to address the challenges of complex, multi-step reasoning. Hi-CoT decomposes the reasoning process into hierarchical substeps by alternating between instructional planning and step-by-step execution. This decomposition enables LLMs to better manage long reasoning horizons and maintain logical coherence. Extensive evaluations across diverse LLMs and mathematical reasoning benchmarks show that Hi-CoT consistently improves average accuracy by 6.2% (up to 61.4% on certain models and tasks) while reducing reasoning trace length by 13.9% compared to CoT prompting. We further show that accuracy and efficiency are maximized when models strictly adhere to the hierarchical structure. Our code is available at https://github.com/XingshuaiHuang/Hi-CoT.

Hierarchical Chain-of-Thought Prompting: Enhancing LLM Reasoning Performance and Efficiency Beitrag lesen »

AI, Committee, Nachrichten, Uncategorized

Step by Step Guide to Build an End-to-End Model Optimization Pipeline with NVIDIA Model Optimizer Using FastNAS Pruning and Fine-Tuning

In this tutorial, we build a complete end-to-end pipeline using NVIDIA Model Optimizer to train, prune, and fine-tune a deep learning model directly in Google Colab. We start by setting up the environment and preparing the CIFAR-10 dataset, then define a ResNet architecture and train it to establish a strong baseline. From there, we apply FastNAS pruning to systematically reduce the model’s complexity under FLOPs constraints while preserving performance. We also handle real-world compatibility issues, restore the optimized subnet, and fine-tune it to recover accuracy. By the end, we have a fully working workflow that takes a model from training to deployment-ready optimization, all within a single streamlined setup. Check out the Full Implementation Coding Notebook. Copy CodeCopiedUse a different Browser !pip -q install -U nvidia-modelopt torchvision torchprofile tqdm import math import os import random import time import numpy as np import torch import torch.nn as nn import torch.nn.functional as F import torchvision import torchvision.transforms as transforms from torch.utils.data import DataLoader, Subset from torchvision.models.resnet import BasicBlock from tqdm.auto import tqdm import modelopt.torch.opt as mto import modelopt.torch.prune as mtp SEED = 123 random.seed(SEED) np.random.seed(SEED) torch.manual_seed(SEED) if torch.cuda.is_available(): torch.cuda.manual_seed_all(SEED) FAST_MODE = True batch_size = 256 if FAST_MODE else 512 baseline_epochs = 20 if FAST_MODE else 120 finetune_epochs = 12 if FAST_MODE else 120 train_subset_size = 12000 if FAST_MODE else None val_subset_size = 2000 if FAST_MODE else None test_subset_size = 4000 if FAST_MODE else None target_flops = 60e6 We begin by installing all required dependencies and importing the necessary libraries to set up our environment. We initialize seeds to ensure reproducibility and configure the device to leverage a GPU if available. We also define key runtime parameters, such as batch size, epochs, dataset subsets, and FLOP constraints, to control the overall experiment. Copy CodeCopiedUse a different Browser def seed_worker(worker_id): worker_seed = SEED + worker_id np.random.seed(worker_seed) random.seed(worker_seed) def build_cifar10_loaders(train_batch_size=256, train_subset_size=None, val_subset_size=None, test_subset_size=None): normalize = transforms.Normalize( mean=[0.4914, 0.4822, 0.4465], std=[0.2470, 0.2435, 0.2616], ) train_transform = transforms.Compose([ transforms.ToTensor(), transforms.RandomHorizontalFlip(), transforms.RandomCrop(32, padding=4), normalize, ]) eval_transform = transforms.Compose([ transforms.ToTensor(), normalize, ]) train_full = torchvision.datasets.CIFAR10( root=”./data”, train=True, transform=train_transform, download=True ) val_full = torchvision.datasets.CIFAR10( root=”./data”, train=True, transform=eval_transform, download=True ) test_full = torchvision.datasets.CIFAR10( root=”./data”, train=False, transform=eval_transform, download=True ) n_trainval = len(train_full) ids = np.arange(n_trainval) np.random.shuffle(ids) n_train = int(n_trainval * 0.9) train_ids = ids[:n_train] val_ids = ids[n_train:] if train_subset_size is not None: train_ids = train_ids[:min(train_subset_size, len(train_ids))] if val_subset_size is not None: val_ids = val_ids[:min(val_subset_size, len(val_ids))] test_ids = np.arange(len(test_full)) if test_subset_size is not None: test_ids = test_ids[:min(test_subset_size, len(test_ids))] train_ds = Subset(train_full, train_ids.tolist()) val_ds = Subset(val_full, val_ids.tolist()) test_ds = Subset(test_full, test_ids.tolist()) num_workers = min(2, os.cpu_count() or 1) g = torch.Generator() g.manual_seed(SEED) train_loader = DataLoader( train_ds, batch_size=train_batch_size, shuffle=True, num_workers=num_workers, pin_memory=torch.cuda.is_available(), worker_init_fn=seed_worker, generator=g, ) val_loader = DataLoader( val_ds, batch_size=512, shuffle=False, num_workers=num_workers, pin_memory=torch.cuda.is_available(), worker_init_fn=seed_worker, ) test_loader = DataLoader( test_ds, batch_size=512, shuffle=False, num_workers=num_workers, pin_memory=torch.cuda.is_available(), worker_init_fn=seed_worker, ) print(f”Train: {len(train_ds)} | Val: {len(val_ds)} | Test: {len(test_ds)}”) return train_loader, val_loader, test_loader train_loader, val_loader, test_loader = build_cifar10_loaders( train_batch_size=batch_size, train_subset_size=train_subset_size, val_subset_size=val_subset_size, test_subset_size=test_subset_size, ) We construct the full data pipeline by preparing CIFAR-10 datasets with appropriate augmentations and normalization. We split the dataset to reduce its size and speed up experimentation. We then create efficient data loaders that ensure proper batching, shuffling, and reproducible data handling. Copy CodeCopiedUse a different Browser def _weights_init(m): if isinstance(m, (nn.Linear, nn.Conv2d)): nn.init.kaiming_normal_(m.weight) class LambdaLayer(nn.Module): def __init__(self, lambd): super().__init__() self.lambd = lambd def forward(self, x): return self.lambd(x) class ResNet(nn.Module): def __init__(self, num_blocks, num_classes=10): super().__init__() self.in_planes = 16 self.layers = nn.Sequential( nn.Conv2d(3, 16, kernel_size=3, stride=1, padding=1, bias=False), nn.BatchNorm2d(16), nn.ReLU(), self._make_layer(16, num_blocks, stride=1), self._make_layer(32, num_blocks, stride=2), self._make_layer(64, num_blocks, stride=2), nn.AdaptiveAvgPool2d((1, 1)), nn.Flatten(), nn.Linear(64, num_classes), ) self.apply(_weights_init) def _make_layer(self, planes, num_blocks, stride): strides = [stride] + [1] * (num_blocks – 1) layers = [] for s in strides: downsample = None if s != 1 or self.in_planes != planes: downsample = LambdaLayer( lambda x: F.pad( x[:, :, ::2, ::2], (0, 0, 0, 0, planes // 4, planes // 4), “constant”, 0, ) ) layers.append(BasicBlock(self.in_planes, planes, s, downsample)) self.in_planes = planes return nn.Sequential(*layers) def forward(self, x): return self.layers(x) def resnet20(): return ResNet(num_blocks=3).to(device) We define the ResNet20 architecture from scratch, including custom initialization and shortcut handling through lambda layers. We structure the network using convolutional blocks and residual connections to capture hierarchical features. We finally encapsulate the model creation into a reusable function that moves it directly to the selected device. Copy CodeCopiedUse a different Browser class CosineLRwithWarmup(torch.optim.lr_scheduler._LRScheduler): def __init__(self, optimizer, warmup_steps, decay_steps, warmup_lr=0.0, last_epoch=-1): self.warmup_steps = warmup_steps self.warmup_lr = warmup_lr self.decay_steps = max(decay_steps, 1) super().__init__(optimizer, last_epoch) def get_lr(self): if self.last_epoch < self.warmup_steps: return [ (base_lr – self.warmup_lr) * self.last_epoch / max(self.warmup_steps, 1) + self.warmup_lr for base_lr in self.base_lrs ] current_steps = self.last_epoch – self.warmup_steps return [ 0.5 * base_lr * (1 + math.cos(math.pi * current_steps / self.decay_steps)) for base_lr in self.base_lrs ] def get_optimizer_scheduler(model, lr, weight_decay, warmup_steps, decay_steps): optimizer = torch.optim.SGD( filter(lambda p: p.requires_grad, model.parameters()), lr=lr, momentum=0.9, weight_decay=weight_decay, ) scheduler = CosineLRwithWarmup(optimizer, warmup_steps, decay_steps) return optimizer, scheduler def loss_fn_default(model, outputs, labels): return F.cross_entropy(outputs, labels) def train_one_epoch(model, loader, optimizer, scheduler, loss_fn=loss_fn_default): model.train() running_loss = 0.0 total = 0 for images, labels in loader: images = images.to(device, non_blocking=True) labels = labels.to(device, non_blocking=True) outputs = model(images) loss = loss_fn(model, outputs, labels) optimizer.zero_grad(set_to_none=True) loss.backward() optimizer.step() scheduler.step() running_loss += loss.item() * labels.size(0) total += labels.size(0) return running_loss / max(total, 1) @torch.no_grad() def evaluate(model, loader): model.eval() correct = 0 total = 0 for images, labels in loader: images = images.to(device, non_blocking=True) labels = labels.to(device, non_blocking=True) logits = model(images) preds = logits.argmax(dim=1) correct += (preds == labels).sum().item() total += labels.size(0) return 100.0 * correct / max(total, 1) def train_model(model, train_loader, val_loader, epochs, ckpt_path, lr=None, weight_decay=1e-4, print_every=1): if lr is None: lr = 0.1 * batch_size / 128 steps_per_epoch = len(train_loader) warmup_steps = max(1, 2 * steps_per_epoch if FAST_MODE else 5 * steps_per_epoch) decay_steps = max(1, epochs * steps_per_epoch) optimizer, scheduler = get_optimizer_scheduler( model=model, lr=lr, weight_decay=weight_decay, warmup_steps=warmup_steps, decay_steps=decay_steps, ) best_val = -1.0 best_epoch = -1 print(f”Training for {epochs} epochs…”) for epoch in tqdm(range(1, epochs + 1)): train_loss = train_one_epoch(model, train_loader, optimizer, scheduler) val_acc = evaluate(model, val_loader) if val_acc >= best_val: best_val = val_acc best_epoch = epoch torch.save(model.state_dict(), ckpt_path) if epoch == 1

Step by Step Guide to Build an End-to-End Model Optimization Pipeline with NVIDIA Model Optimizer Using FastNAS Pruning and Fine-Tuning Beitrag lesen »

We use cookies to improve your experience and performance on our website. You can learn more at Datenschutzrichtlinie and manage your privacy settings by clicking Settings.

Privacy Preferences

You can choose your cookie settings by turning on/off each type of cookie as you wish, except for essential cookies.

Allow All
Manage Consent Preferences
  • Always Active

Save
de_DE