Download validate_local_reference.py from gatilin/fastframes-s-refiner-pixel-decoder: direct link, hf CLI and curl.
- Browser
- Download file 2.38 kB
-
https://huggingface.co/gatilin/fastframes-s-refiner-pixel-decoder/resolve/main/validate_local_reference.py
- Command line
-
hf download hf://gatilin/fastframes-s-refiner-pixel-decoder/validate_local_reference.py
-
curl -L -o validate_local_reference.py https://huggingface.co/gatilin/fastframes-s-refiner-pixel-decoder/resolve/main/validate_local_reference.py
2.38 kB
| """CPU smoke tests of the separate FastFrames-S decoder and KV refiner.""" | |
| import hashlib,json,sys,time | |
| from pathlib import Path | |
| import torch | |
| from safetensors.torch import load_file | |
| from fastframes.models.pixel_decoder import PixelDecoder | |
| from fastframes.models.kv_refinement import KVRefinementNetwork | |
| root=Path(__file__).resolve().parent;torch.manual_seed(11);torch.set_num_threads(4);torch.set_grad_enabled(False);start=time.monotonic();results={} | |
| for name,cls in [('pixel_decoder',PixelDecoder),('kv_refiner',KVRefinementNetwork)]: | |
| path=root/'fastframes-s'/f'{name}.safetensors' | |
| with torch.device('meta'):m=cls() | |
| state=load_file(str(path),device='cpu');n=len(state);m.load_state_dict(state,strict=True,assign=True);m=m.float().eval().requires_grad_(False);print('STRICT LOAD',name,n,flush=True) | |
| with torch.inference_mode(): | |
| if name=='pixel_decoder': | |
| x=torch.randn(1,4,1536);e=torch.randn(1,1,1,1536);grid=torch.tensor([[1,2,2]]);o=m(x,e,grid);assert o.shape==(1,4,3,32,32) and torch.isfinite(o).all();results[name]={'strict_load':True,'tensor_count':n,'input_shape':list(x.shape),'output_shape':list(o.shape),'output_std':float(o.std())} | |
| else: | |
| e=m.embed_timestep(500,1,'cpu',torch.float32);phi=m.compute_phi(torch.randn(1,4,1536),e);nk=torch.randn(30,4,1536);nv=torch.randn(30,4,1536);k,v=m.repair_all(nk,nv,phi,e);assert k.shape==v.shape==nk.shape and torch.isfinite(k).all() and torch.isfinite(v).all();results[name]={'strict_load':True,'tensor_count':n,'phi_shape':list(phi.shape),'key_value_shape':list(k.shape),'mean_key_change':float((k-nk).abs().mean()),'mean_value_change':float((v-nv).abs().mean())} | |
| del state,m | |
| h=hashlib.sha256() | |
| with path.open('rb') as f: | |
| for b in iter(lambda:f.read(8*1024*1024),b''):h.update(b) | |
| results[name]['sha256']=h.hexdigest();print('PASSED',name,flush=True) | |
| result={'passed':True,'device':'CPU float32','source_repo':'apple/FastFrames-S','source_revision':'aa099efcedf1b65447106bf9004cde75821f7387','model_code_revision':'a65c59240e01cf1de86197fa771ca09b38cf592a','components':results,'limitations':'Small synthetic features, tiny token grid and synthetic KV cache. The frozen Causal Forcing++ generator, Wan text encoder and full video generation were not tested.','seconds':round(time.monotonic()-start,1)};(root/'validation.json').write_text(json.dumps(result,indent=2)+'\n');print('VALIDATION PASSED',flush=True) | |