How early could we detect an asteroid the size of the one that caused the extinction of the dinosaurs? Would we know months, years ahead? How sophisticated is our technology's ability to detect it at 100% accuracy?
It could be as little notice as a few days.
There is a large variation in the amount of warning we would have before an asteroid strike similar in energy to Chicxulub.  Let’s examine the case in which we would have the least warning.
The lower bound to the estimated energy released by the Chicxulub collision is 1.3e24 joules https://en.wikipedia.org/wiki/Chicxulub_crater#Impact_specifics.
We know the object ‘Oumoamoa was moving at about 50km/s at 1 au from the sun https://en.wikipedia.org/wiki/%CA%BBOumuamua , which is the distance of the earth from the sun.  The earth itself is moving at about 30 km/s with respect to the sun, so if they struck in opposition,  the difference in velocity could be 80 km/s.
For kinetic energy impact, we know $e=1/2*mv^2$, or energy = 0.5*mass times the square of the velocity.  So $m=2e/v^2$, so m is approximately 4e14kg.  If we assume an asteroid a bit denser than iron at 1e4 kg/m^3, then the volume of the asteroid is 4e10m^3.  If we assume the asteroid is a sphere, then since the volume of a sphere is $V=4/3\pi r^3$, then the radius is $r^3 = (3/4*V/\pi)$ or $r$= 2.121km.
Let’s assume the asteroid is matte black so it hardy reflects any light, give it an albedo of 0.02.  Then the absolute magnitude of the asteroid of this size and albedo at 1 AU from an observer is 17, using the tables here https://cneos.jpl.nasa.gov/tools/ast_size_est.html.  Let’s suppose that we spot the asteroid when it is much much brighter than at one AU (or 1.5e8 km), with the same apparent magnitude as Pluto (magnitude 14).  Since magnitude is a log scale, that is $2.5^3 = 16$ times as bright.
Brightness varies as square of distance, so the asteroid will be at $1.5e8/4$, or 3.75e7 km away from earth when it’s spotted.  At 80 km/s relative velocity, the time from seeing it to impact is 4.6875e5 seconds, or about 5.4 days.
Notes:

The above outlined scenario is almost impossibly unlikely. A much more likely scenario is that an asteroid from our known asteroid belt strikes earth, in which case we would probably know it was going to collide years before the strike.

The object Oumoamoa was classified as an asteroid rather than a comet due to its lack of corona, but now it has an ‘I’ designation for the first Interstellar object which is neither a comet nor an asteroid.  One could argue that I shouldn’t use it as an example given that the question asks about asteroids, but I think it is perfectly reasonable.

We don’t ever know a collision with 100% accuracy.  There is always error in our orbit estimations.  We can’t even tell if satellites are going to collide in earth orbit, it’s just probabilities.

I don't have a good idea of how long a new object of a certain apparent magnitude will be in the night sky before it's discovered by someone.  If someone thinks we would notice this object sooner due to transits or some other reason, I may amend this answer.