Java, 257 246 210 200 195 190 188 186 181 bytes
a->{int r=9,i=512,j,e,s,k,x,z,b,c=9;for(;i-->0;r=e!=0|r<c?r:c)for(j=s=e=0;j<3;s=j++<1?x:s,e|=x-s)for(k=x=c=0;k<9;z=b>0?7:a[k],x+=k/3==j?z:0,x+=k++%3==j?30*z:0)c+=b=i>>k&1;return r;}
Saved 11 bytes thanks to ceilingcat.
Saved 46 bytes thanks to Olivier Grégoire.
Saved 19 bytes thanks to Donat.
Takes a flat array as input. This method tries all 512 (29) possibilities by using the binary representations of the integers from 0
to 511
. On each iteration, it sets the values at all indexes where i
has a set bit to 7
. Then, it checks if the current array is valid, in which case the answer is updated.