SAN FRANCISCO — The engineers of Silicon Valley are fine-tuning driverless cars, building robots designed to replicate the human brain and shaving milliseconds off internet response times.

Their trip to work, however, can be a throwback to the predigital age. The region’s commuter rail line is saddled with aging, smoke-spewing, diesel-powered locomotives.

For more than a decade, the managers of the Silicon Valley railway, known as Caltrain, have been planning to upgrade to faster and less polluting electric trains.

But those plans are now imperiled by the Trump administration’s decision in February to withhold a $647 million federal grant.