Run this model with HF Jobs

Run XiangnanW/CGVM-R2.6-Qwen3VL-8B-step600 on Hugging Face's managed compute, monitor its progress, and retrieve the results when it's done.

Paste one of these prompts into your coding agent:

Fine-tune on my dataset

Use HF Jobs to fine-tune https://huggingface.co/XiangnanW/CGVM-R2.6-Qwen3VL-8B-step600. Ask me which dataset to train on, then push the fine-tuned model to a new model repo. Run `hf jobs --help` first to learn the CLI.

Run batch inference

Use HF Jobs to run batch inference with https://huggingface.co/XiangnanW/CGVM-R2.6-Qwen3VL-8B-step600 on the inputs in a mounted HF Bucket. Ask me which Bucket to use, then write the outputs back to it and keep each input ID. Run `hf jobs --help` first to learn the CLI.
XiangnanW's picture
Upload CGVM R2.6 step-000600 checkpoint, R2.6 source bundle (cgvm-r26-src-v1.tar.gz), and 4-round audit report
4ad9219 verified
Raw History Blame Contribute Delete
6.48 kB
"""由同一冻结因果缓存构造原键/变化键输入;保留来源、代际与带符号差分。"""
import math
import torch
import torch.nn.functional as F
def features(cache, chunk, variant, query_time, writer_features=None, max_tokens=256, device='cpu'):
if variant not in ('R1','R2'):
raise ValueError('只有显式R1/R2检索接口')
if chunk['terminal_flush'] or chunk['committed_at']>query_time+1e-6:
raise ValueError('未闭合尾窗或未来chunk不能进入检索')
global_key=chunk['global_key'].float()
entity_keys=chunk['entity_keys'].float()
if entity_keys.numel()==0:entity_keys=global_key.new_zeros((0,global_key.numel()))
refs=[]
if variant=='R1':
# R1容量相同,输入仅来自原全局/实体键;没有变化文字或时间特征。
primary=torch.cat([global_key.unsqueeze(0),entity_keys],dim=0)
secondary=global_key.unsqueeze(0).expand_as(primary).clone()
geometry=primary.new_zeros((len(primary),10));geometry[0,0]=1
if len(primary)>1:geometry[1:,1]=1
geometry[:,2]=primary.norm(dim=-1)
geometry[:,3]=F.cosine_similarity(primary,secondary,dim=-1)
geometry[:,4]=primary.mean(dim=-1);geometry[:,5]=primary.std(dim=-1)
geometry[:,6]=secondary.mean(dim=-1);geometry[:,7]=secondary.std(dim=-1)
geometry[:,8]=primary.abs().mean(dim=-1);geometry[:,9]=secondary.abs().mean(dim=-1)
context=primary.new_tensor([float(global_key.norm()),len(entity_keys)/32,
float(primary.mean()),float(primary.std()),float(primary.abs().mean()),
float(geometry[:,3].mean()),float(geometry[:,3].min()),float(geometry[:,3].max())])
else:
if '_frame_lookup' not in cache:
cache['_frame_lookup']={frame['native_index']:frame for frame in cache['frames']}
lookup=cache['_frame_lookup']
rows=[];previous={};start=min(lookup[i]['timestamp'] for i in chunk['frame_ids'])
for index in chunk['frame_ids']:
frame=lookup[index]
if frame['timestamp']>query_time+1e-6:
raise ValueError('视觉变化输入包含未来帧')
objects=[dict(track_id='scene',generation=-1,bbox=dict(x1=0.,y1=0.,x2=1.,y2=1.),
local_feature=frame['global_feature'])]+frame['objects']
visible_entities=set()
for obj in objects:
key=(obj['generation'],obj['track_id']);f=obj['local_feature'].float()
visible_entities.add(key)
box=obj['bbox'];position=f.new_tensor([box[k] for k in ('x1','y1','x2','y2')])
last=previous.get(key)
if last is None:
delta=torch.zeros_like(f);dpos=position.new_zeros(4);dt=0.
else:
last_f,last_box,last_time=last
delta=f-last_f
current_center=(position[:2]+position[2:])/2;old_center=(last_box[:2]+last_box[2:])/2
scale=position[2:]-position[:2];old_scale=last_box[2:]-last_box[:2]
dpos=torch.cat([current_center-old_center,scale-old_scale])
dt=frame['timestamp']-last_time
previous[key]=(f,position,frame['timestamp'])
geometry=torch.cat([position,dpos,position.new_tensor([math.log1p(dt),1.])])
rows.append((f,delta,geometry))
refs.append(dict(frame_id=frame['frame_id'],timestamp=frame['timestamp'],generation=obj['generation'],
entity_id=obj['track_id'],camera_motion='unknown_not_assumed_physical_motion'))
for key,(last_f,last_box,last_time) in previous.items():
if key in visible_entities:continue
# 检测缺失/遮挡保持显式visibility=0,不以零向量差分伪造一次移动。
geometry=torch.cat([last_box,last_box.new_zeros(4),
last_box.new_tensor([math.log1p(frame['timestamp']-last_time),0.])])
rows.append((torch.zeros_like(last_f),torch.zeros_like(last_f),geometry))
refs.append(dict(frame_id=frame['frame_id'],timestamp=frame['timestamp'],generation=key[0],entity_id=key[1],
visibility=False,last_seen_at=last_time,motion='unknown_due_to_missing_observation'))
if writer_features:
for name in ('state_key','change_key'):
value=writer_features.get(name)
if value is not None:
rows.append((value.float(),torch.zeros_like(value.float()),global_key.new_zeros(10)))
refs.append(dict(text_key=name,writer_committed_at=chunk['committed_at']))
if not rows:
raise ValueError('变化输入无真实可见来源')
primary=torch.stack([r[0] for r in rows]);secondary=torch.stack([r[1] for r in rows]);geometry=torch.stack([r[2] for r in rows])
end=max(lookup[i]['timestamp'] for i in chunk['frame_ids']);denominator=max(query_time,1.)
context=primary.new_tensor([start/denominator,end/denominator,math.log1p(end-start),
math.log1p(max(0.,query_time-end)),float(geometry[:,-1].mean()),
float(secondary.norm(dim=-1).max()),len(entity_keys)/32,float(bool(writer_features))])
if len(primary)>max_tokens:
# 原序列仍完整保存在缓存;排序头只取固定预算子序列,不对相反差分求平均。
# 一半均匀时序、一半按变化幅度;确定性并集保持原顺序,不依赖QA答案或GT时间。
uniform=torch.linspace(0,len(primary)-1,max_tokens//2).long().tolist()
ranked=torch.argsort(secondary.norm(dim=-1),descending=True,stable=True).tolist()
indices=set(uniform)
if refs:indices.update(i for i,ref in enumerate(refs) if 'text_key' in ref)
for index in ranked:
indices.add(index)
if len(indices)>=max_tokens:break
indices=sorted(indices)
primary=primary[indices];secondary=secondary[indices];geometry=geometry[indices]
if refs:refs=[refs[i] for i in indices]
result=dict(primary=primary.unsqueeze(0).to(device),secondary=secondary.unsqueeze(0).to(device),
geometry=geometry.unsqueeze(0).to(device),context=context.unsqueeze(0).to(device),
visible_mask=torch.ones((1,len(primary)),dtype=torch.bool,device=device))
return result,refs